@temporary-name/server 1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3 → 1.9.3-alpha.2d4311b66d2b675b022398c62ddc6fde97c93a6f

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 (30) 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 +10 -5
  11. package/dist/adapters/standard/index.d.ts +10 -5
  12. package/dist/adapters/standard/index.mjs +3 -3
  13. package/dist/index.d.mts +52 -44
  14. package/dist/index.d.ts +52 -44
  15. package/dist/index.mjs +39 -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 +2 -2
  20. package/dist/plugins/index.d.ts +2 -2
  21. package/dist/shared/{server.BlJrjUA9.d.mts → server.BCcLYvdF.d.mts} +1 -1
  22. package/dist/shared/{server.CjkiSCui.mjs → server.CHV9AQHl.mjs} +33 -17
  23. package/dist/shared/{server.C-tNYmY_.d.ts → server.CdeqmULw.d.ts} +1 -1
  24. package/dist/shared/{server.DdHBdcen.mjs → server.Cn7WsRHl.mjs} +13 -21
  25. package/dist/shared/{server.BYnDyuDL.d.mts → server.DHezmW6C.d.mts} +2 -2
  26. package/dist/shared/{server.JI4dqTgD.d.ts → server.Da-qLzdU.d.ts} +2 -2
  27. package/dist/shared/{server.WsFQIubj.d.mts → server.DecvGKtb.d.mts} +29 -22
  28. package/dist/shared/{server.WsFQIubj.d.ts → server.DecvGKtb.d.ts} +29 -22
  29. package/dist/shared/{server.Kxw442A9.mjs → server.JtIZ8YG7.mjs} +1 -11
  30. package/package.json +10 -10
package/dist/index.d.ts CHANGED
@@ -1,42 +1,48 @@
1
- import { AnySchema, ErrorMap, Meta, ContractProcedure, MergedErrorMap, Route, InferSchemaOutput, InferSchemaInput, ContractRouter, ContractProcedureDef, Schema, AnyContractRouter, InferContractRouterErrorMap, InferContractRouterMeta, AnyContractProcedure, ErrorFromErrorMap } from '@temporary-name/contract';
1
+ import { Schemas, ErrorMap, Meta, ContractProcedure, MergedErrorMap, AnyShape, MergedSchemas, WrapShape, UnionToIntersection, AnySchema, Route, InferHandlerInputs, InferSchemaInput, ContractRouter, ContractProcedureDef, InitialSchemas, AnyContractRouter, InferContractRouterErrorMap, InferContractRouterMeta, AnyContractProcedure, InferProcedureClientInputs, InferSchemaOutput, ErrorFromErrorMap, Schema } from '@temporary-name/contract';
2
2
  export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, validateORPCError } from '@temporary-name/contract';
3
- import { ClientContext, MaybeOptionalOptions, IntersectPick, HTTPPath, ClientOptions, ClientPromiseResult } from '@temporary-name/shared';
3
+ import { ClientContext, MaybeOptionalOptions, HTTPEndpoint, IntersectPick, HTTPPath, ClientOptions, ClientPromiseResult } from '@temporary-name/shared';
4
4
  export { AsyncIteratorClass, ClientContext, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, HTTPMethod, HTTPPath, IntersectPick, ORPCError, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, isDefinedError, onError, onFinish, onStart, onSuccess, safe, streamToAsyncIteratorClass as streamToEventIterator } from '@temporary-name/shared';
5
- import { SchemaClass } from '@temporary-name/zod';
6
- import { C as Context, P as Procedure, a as CreateProcedureClientOptions, b as ProcedureClient, M as Middleware, O as ORPCErrorConstructorMap, c as MergedInitialContext, d as MergedCurrentContext, e as ProcedureHandler, E as EnhanceRouterOptions, R as Router, f as EnhancedRouter, g as MapInputMiddleware, A as AnyMiddleware, L as Lazy, h as AnyProcedure, i as Lazyable, j as AnyRouter, I as InferRouterInitialContext } from './shared/server.WsFQIubj.js';
7
- export { U as AccessibleLazyRouter, Z as ContractProcedureCallbackOptions, N as InferRouterCurrentContexts, K as InferRouterInitialContexts, Q as InferRouterInputs, S as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, _ as LazyTraverseContractProceduresOptions, x as MiddlewareNextFn, w as MiddlewareNextFnOptions, z as MiddlewareOptions, y as MiddlewareOutputFn, v as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, H as ProcedureClientInterceptorOptions, F as ProcedureDef, D as ProcedureHandlerOptions, Y as TraverseContractProcedureCallbackOptions, X as TraverseContractProceduresOptions, a1 as UnlaziedRouter, V as createAccessibleLazyRouter, n as createORPCErrorConstructorMap, J as createProcedureClient, W as enhanceRouter, t as getLazyMeta, T as getRouter, s as isLazy, G as isProcedure, r as lazy, q as lazyInternal, m as mergeCurrentContext, B as middlewareOutputFn, a0 as resolveContractProcedures, $ as traverseContractProcedures, u as unlazy, a2 as unlazyRouter } from './shared/server.WsFQIubj.js';
5
+ import { SchemaClass, core } from '@temporary-name/zod';
6
+ import { C as Context, P as Procedure, a as CreateProcedureClientOptions, b as ProcedureClient, M as Middleware, O as ORPCErrorConstructorMap, c as MergedInitialContext, d as MergedCurrentContext, e as ProcedureHandler, E as EnhanceRouterOptions, R as Router, f as EnhancedRouter, g as MapInputMiddleware, A as AnyMiddleware, L as Lazy, h as AnyProcedure, i as Lazyable, j as AnyRouter, I as InferRouterInitialContext } from './shared/server.DecvGKtb.js';
7
+ export { U as AccessibleLazyRouter, Z as ContractProcedureCallbackOptions, N as InferRouterCurrentContexts, K as InferRouterInitialContexts, Q as InferRouterInputs, S as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, _ as LazyTraverseContractProceduresOptions, x as MiddlewareNextFn, w as MiddlewareNextFnOptions, z as MiddlewareOptions, y as MiddlewareOutputFn, v as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, H as ProcedureClientInterceptorOptions, F as ProcedureDef, D as ProcedureHandlerOptions, Y as TraverseContractProcedureCallbackOptions, X as TraverseContractProceduresOptions, a1 as UnlaziedRouter, V as createAccessibleLazyRouter, n as createORPCErrorConstructorMap, J as createProcedureClient, W as enhanceRouter, t as getLazyMeta, T as getRouter, s as isLazy, G as isProcedure, r as lazy, q as lazyInternal, m as mergeCurrentContext, B as middlewareOutputFn, a0 as resolveContractProcedures, $ as traverseContractProcedures, u as unlazy, a2 as unlazyRouter } from './shared/server.DecvGKtb.js';
8
8
  export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
9
9
 
10
- declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
10
+ declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> {
11
11
  /**
12
12
  * Make this procedure callable (works like a function while still being a procedure).
13
13
  *
14
14
  * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
15
15
  */
16
- callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
16
+ callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> & ProcedureClient<TClientContext, TSchemas, TErrorMap>;
17
17
  }
18
18
 
19
- declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
20
- z: SchemaClass;
19
+ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ContractProcedure<TSchemas, TErrorMap, TMeta> {
20
+ z: SchemaClass<TGateName>;
21
21
  /**
22
22
  * This property holds the defined options.
23
23
  */
24
- '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
25
- constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
24
+ '~orpc': BuilderDef<TSchemas, TErrorMap, TMeta>;
25
+ constructor(def: BuilderDef<TSchemas, TErrorMap, TMeta>);
26
26
  /**
27
27
  * Adds type-safe custom errors to the contract.
28
28
  * The provided errors are spared-merged with any existing errors in the contract.
29
29
  *
30
30
  * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
31
31
  */
32
- errors<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
32
+ errors<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
33
33
  /**
34
34
  * Sets or updates the metadata for the contract.
35
35
  * The provided metadata is spared-merged with any existing metadata in the contract.
36
36
  *
37
37
  * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
38
38
  */
39
- meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
39
+ meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
40
+ endpoint<U extends AnyShape[]>(strings: TemplateStringsArray, ...values: [...U]): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
41
+ pathSchema: WrapShape<UnionToIntersection<U>>;
42
+ }>, TErrorMap, TMeta, TGateName>;
43
+ endpoint<U extends AnySchema | AnyShape = core.$ZodType<Record<string, never>, Record<string, never>>>(endpoint: HTTPEndpoint, schema?: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
44
+ pathSchema: WrapShape<U>;
45
+ }>, TErrorMap, TMeta, TGateName>;
40
46
  /**
41
47
  * Sets or updates the route definition for the contract.
42
48
  * The provided route is spared-merged with any existing route in the contract.
@@ -45,19 +51,21 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
45
51
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
46
52
  * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
47
53
  */
48
- route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
49
- /**
50
- * Defines the input validation schema.
51
- *
52
- * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
53
- */
54
- input<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
54
+ endpointOpts(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
55
+ query<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
56
+ querySchema: WrapShape<U>;
57
+ }>, TErrorMap, TMeta, TGateName>;
58
+ body<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
59
+ bodySchema: WrapShape<U>;
60
+ }>, TErrorMap, TMeta, TGateName>;
55
61
  /**
56
62
  * Defines the output validation schema.
57
63
  *
58
64
  * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
59
65
  */
60
- output<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta, TGateName>;
66
+ output<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
67
+ outputSchema: WrapShape<U>;
68
+ }>, TErrorMap, TMeta, TGateName>;
61
69
  /**
62
70
  * Uses a middleware to modify the context or improve the pipeline.
63
71
  *
@@ -65,18 +73,18 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
65
73
  * @note The current context must be satisfy middleware dependent-context
66
74
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
67
75
  */
68
- use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
76
+ use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta, TGateName>;
69
77
  useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
70
78
  isGateEnabled: typeof isGateEnabled;
71
- }>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TInferredGateName>;
79
+ }>, TSchemas, TErrorMap, TMeta, TInferredGateName>;
72
80
  /**
73
81
  * Defines the handler of the procedure.
74
82
  *
75
83
  * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
76
84
  */
77
- handler(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
85
+ handler(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
78
86
  }
79
- declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName> {
87
+ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName> {
80
88
  /**
81
89
  * Prefixes all procedures in the router.
82
90
  * The provided prefix is post-appended to any existing router prefix.
@@ -85,7 +93,7 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
85
93
  *
86
94
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
87
95
  */
88
- prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
96
+ prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
89
97
  /**
90
98
  * Adds tags to all procedures in the router.
91
99
  * This helpful when you want to group procedures together in the OpenAPI specification.
@@ -100,7 +108,7 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
100
108
  */
101
109
  router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
102
110
  }
103
- interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any, any, TErrorMap, TMeta, any>, 'prefix' | 'tag' | 'router'> {
111
+ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any, TErrorMap, TMeta, any>, 'prefix' | 'tag' | 'router'> {
104
112
  /**
105
113
  * This property holds the defined options.
106
114
  */
@@ -129,18 +137,18 @@ interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Co
129
137
  }
130
138
  declare function decorateMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta>(middleware: Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>;
131
139
 
132
- interface BuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
140
+ interface BuilderDef<TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
133
141
  middlewares: readonly AnyMiddleware[];
134
142
  inputValidationIndex: number;
135
143
  outputValidationIndex: number;
136
144
  }
137
- declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName> {
145
+ declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName> {
138
146
  /**
139
147
  * Set or override the initial context.
140
148
  *
141
149
  * @see {@link https://orpc.unnoq.com/docs/context Context Docs}
142
150
  */
143
- $context<U extends Context>(): Builder<U, U, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
151
+ $context<U extends Context>(): Builder<U, U, TSchemas, TErrorMap, TMeta, TGateName>;
144
152
  /**
145
153
  * Creates a middleware.
146
154
  *
@@ -149,7 +157,7 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
149
157
  middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
150
158
  middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, TMeta>;
151
159
  }
152
- type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, TMeta, never>;
160
+ type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, InitialSchemas, Record<never, never>, TMeta, never>;
153
161
  interface ApiBuilderOpts<TMeta extends Meta> {
154
162
  meta?: TMeta;
155
163
  }
@@ -159,7 +167,7 @@ declare const os: ApiBuilder<Record<never, never>>;
159
167
  /**
160
168
  * Like `DecoratedProcedure`, but removed all method that can change the contract.
161
169
  */
162
- interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
170
+ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> {
163
171
  /**
164
172
  * Uses a middleware to modify the context or improve the pipeline.
165
173
  *
@@ -168,7 +176,7 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
168
176
  * @note The current context must be satisfy middleware dependent-context
169
177
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
170
178
  */
171
- use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
179
+ use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
172
180
  /**
173
181
  * Uses a middleware to modify the context or improve the pipeline.
174
182
  *
@@ -177,19 +185,19 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
177
185
  * @note The current context must be satisfy middleware dependent-context
178
186
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
179
187
  */
180
- use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
188
+ use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferHandlerInputs<TSchemas>, UInput>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
181
189
  /**
182
190
  * Make this procedure callable (works like a function while still being a procedure).
183
191
  *
184
192
  * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
185
193
  */
186
- callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
194
+ callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> & ProcedureClient<TClientContext, TSchemas, TErrorMap>;
187
195
  }
188
196
  /**
189
197
  * Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
190
198
  */
191
- interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
192
- '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
199
+ interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> {
200
+ '~orpc': BuilderDef<TSchemas, TErrorMap, TMeta>;
193
201
  /**
194
202
  * Uses a middleware to modify the context or improve the pipeline.
195
203
  *
@@ -198,7 +206,7 @@ interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext
198
206
  * @note The current context must be satisfy middleware dependent-context
199
207
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
200
208
  */
201
- 'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
209
+ 'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
202
210
  /**
203
211
  * Uses a middleware to modify the context or improve the pipeline.
204
212
  *
@@ -207,13 +215,13 @@ interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext
207
215
  * @note The current context must be satisfy middleware dependent-context
208
216
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
209
217
  */
210
- 'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
218
+ 'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferHandlerInputs<TSchemas>, UInput>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
211
219
  /**
212
220
  * Defines the handler of the procedure.
213
221
  *
214
222
  * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
215
223
  */
216
- 'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
224
+ 'handler'(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
217
225
  }
218
226
 
219
227
  interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
@@ -233,7 +241,7 @@ interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitial
233
241
  */
234
242
  router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
235
243
  }
236
- type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementerWithMiddlewares<TContract, TInitialContext, TCurrentContext> & {
244
+ type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, USchemas, UErrorMap, UMeta> : RouterImplementerWithMiddlewares<TContract, TInitialContext, TCurrentContext> & {
237
245
  [K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
238
246
  };
239
247
 
@@ -271,7 +279,7 @@ interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends
271
279
  default: U;
272
280
  }>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
273
281
  }
274
- type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementer<TContract, TInitialContext, TCurrentContext> & {
282
+ type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, USchemas, UErrorMap, UMeta> : RouterImplementer<TContract, TInitialContext, TCurrentContext> & {
275
283
  [K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
276
284
  };
277
285
  declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
@@ -306,9 +314,9 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
306
314
  * ```
307
315
  *
308
316
  */
309
- declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, input: InferSchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, Record<never, never>> & Omit<ClientOptions<Record<never, never>>, 'context'>>): ClientPromiseResult<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
317
+ declare function call<TInitialContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TSchemas, TErrorMap, TMeta>>, input: InferProcedureClientInputs<TSchemas>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, Record<never, never>> & Omit<ClientOptions<Record<never, never>>, 'context'>>): ClientPromiseResult<InferSchemaOutput<TSchemas['outputSchema']>, ErrorFromErrorMap<TErrorMap>>;
310
318
 
311
- type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
319
+ type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer USchemas, infer UErrorMap, any> ? ProcedureClient<TClientContext, USchemas, UErrorMap> : {
312
320
  [K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
313
321
  };
314
322
  /**
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
+ import { mergePrefix, mergeTags, ContractProcedure, mergeErrorMap, mergeMeta, parseEndpointDefinition, mergeRoute, prefixRoute, initialSchemas, isContractProcedure, getContractRouter } from '@temporary-name/contract';
2
+ export { ValidationError, eventIterator, validateORPCError } from '@temporary-name/contract';
1
3
  import { onError, resolveMaybeOptionalOptions } from '@temporary-name/shared';
2
4
  export { AsyncIteratorClass, EventPublisher, ORPCError, asyncIteratorToStream as eventIteratorToStream, isDefinedError, onError, onFinish, onStart, onSuccess, safe, streamToAsyncIteratorClass as streamToEventIterator } from '@temporary-name/shared';
3
- import { mergePrefix, mergeTags, ContractProcedure, mergeErrorMap, mergeMeta, mergeRoute, prefixRoute, isContractProcedure, getContractRouter } from '@temporary-name/contract';
4
- export { ValidationError, eventIterator, validateORPCError } from '@temporary-name/contract';
5
- import { SchemaClass, gatingContext } from '@temporary-name/zod';
6
- import { P as Procedure, c as createProcedureClient, e as enhanceRouter, a as addMiddleware, s as setHiddenRouterContract, l as lazyInternal, g as getLazyMeta, u as unlazy, i as isProcedure, b as isLazy, d as getRouter } from './shared/server.CjkiSCui.mjs';
7
- export { L as LAZY_SYMBOL, p as createAccessibleLazyRouter, f as createORPCErrorConstructorMap, o as getHiddenRouterContract, k as isStartWithMiddlewares, h as lazy, m as mergeCurrentContext, n as mergeMiddlewares, j as middlewareOutputFn, r as resolveContractProcedures, t as traverseContractProcedures, q as unlazyRouter } from './shared/server.CjkiSCui.mjs';
5
+ import { SchemaClass, object, core, gatingContext } from '@temporary-name/zod';
6
+ import { P as Procedure, c as createProcedureClient, e as enhanceRouter, a as addMiddleware, s as setHiddenRouterContract, l as lazyInternal, g as getLazyMeta, u as unlazy, i as isProcedure, b as isLazy, d as getRouter } from './shared/server.CHV9AQHl.mjs';
7
+ export { L as LAZY_SYMBOL, p as createAccessibleLazyRouter, f as createORPCErrorConstructorMap, o as getHiddenRouterContract, k as isStartWithMiddlewares, h as lazy, m as mergeCurrentContext, n as mergeMiddlewares, j as middlewareOutputFn, r as resolveContractProcedures, t as traverseContractProcedures, q as unlazyRouter } from './shared/server.CHV9AQHl.mjs';
8
8
  export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
9
9
 
10
10
  class DecoratedProcedure extends Procedure {
@@ -56,6 +56,19 @@ class ProcedureBuilder extends ContractProcedure {
56
56
  meta: mergeMeta(this["~orpc"].meta, meta)
57
57
  });
58
58
  }
59
+ endpoint(stringsOrEndpoint, ...values) {
60
+ const { method, path, pathSchema } = parseEndpointDefinition(stringsOrEndpoint, values);
61
+ const { prefix } = this["~orpc"];
62
+ const route = { method, path };
63
+ return new ProcedureBuilder({
64
+ ...this["~orpc"],
65
+ route: mergeRoute(this["~orpc"].route, prefix ? prefixRoute(route, prefix) : route),
66
+ schemas: {
67
+ ...this["~orpc"].schemas,
68
+ pathSchema
69
+ }
70
+ });
71
+ }
59
72
  /**
60
73
  * Sets or updates the route definition for the contract.
61
74
  * The provided route is spared-merged with any existing route in the contract.
@@ -64,22 +77,30 @@ class ProcedureBuilder extends ContractProcedure {
64
77
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
65
78
  * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
66
79
  */
67
- route(route) {
80
+ endpointOpts(route) {
68
81
  const { prefix } = this["~orpc"];
69
82
  return new ProcedureBuilder({
70
83
  ...this["~orpc"],
71
84
  route: mergeRoute(this["~orpc"].route, prefix ? prefixRoute(route, prefix) : route)
72
85
  });
73
86
  }
74
- /**
75
- * Defines the input validation schema.
76
- *
77
- * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
78
- */
79
- input(schema) {
87
+ query(schema) {
80
88
  return new ProcedureBuilder({
81
89
  ...this["~orpc"],
82
- inputSchema: schema,
90
+ schemas: {
91
+ ...this["~orpc"].schemas,
92
+ querySchema: schema instanceof core.$ZodType ? schema : object(schema)
93
+ },
94
+ inputValidationIndex: this["~orpc"].middlewares.length
95
+ });
96
+ }
97
+ body(schema) {
98
+ return new ProcedureBuilder({
99
+ ...this["~orpc"],
100
+ schemas: {
101
+ ...this["~orpc"].schemas,
102
+ bodySchema: schema instanceof core.$ZodType ? schema : object(schema)
103
+ },
83
104
  inputValidationIndex: this["~orpc"].middlewares.length
84
105
  });
85
106
  }
@@ -91,7 +112,10 @@ class ProcedureBuilder extends ContractProcedure {
91
112
  output(schema) {
92
113
  return new ProcedureBuilder({
93
114
  ...this["~orpc"],
94
- outputSchema: schema,
115
+ schemas: {
116
+ ...this["~orpc"].schemas,
117
+ outputSchema: schema instanceof core.$ZodType ? schema : object(schema)
118
+ },
95
119
  outputValidationIndex: this["~orpc"].middlewares.length
96
120
  });
97
121
  }
@@ -231,6 +255,7 @@ function createApiBuilder(opts = {}) {
231
255
  console.dir(error, { depth: null });
232
256
  })
233
257
  ],
258
+ schemas: initialSchemas,
234
259
  // NB: this is a relic from orpc -- I'm not convinced there's a need for this (or if there is, that it's
235
260
  // the best solution). For now I've removed the interface to configure it externally.
236
261
  dedupeLeadingMiddlewares: true
@@ -55,7 +55,7 @@ interface SchemaConvertOptions {
55
55
  minStructureDepthForRef?: number;
56
56
  }
57
57
  interface SchemaConverter {
58
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
58
+ convert(schemas: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
59
59
  }
60
60
  interface ConditionalSchemaConverter extends SchemaConverter {
61
61
  condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
@@ -55,7 +55,7 @@ interface SchemaConvertOptions {
55
55
  minStructureDepthForRef?: number;
56
56
  }
57
57
  interface SchemaConverter {
58
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
58
+ convert(schemas: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
59
59
  }
60
60
  interface ConditionalSchemaConverter extends SchemaConverter {
61
61
  condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
@@ -1,7 +1,7 @@
1
1
  import { isProcedure, resolveContractProcedures, ORPCError, createRouterClient } from '@temporary-name/server';
2
- import { fallbackContractConfig, getEventIteratorSchemaDetails } from '@temporary-name/contract';
2
+ import { standardizeHTTPPath, fallbackContractConfig, getDynamicParams, getEventIteratorSchemaDetails } from '@temporary-name/contract';
3
3
  import { isObject, stringifyJSON, findDeepMatches, toArray, clone, value, toHttpPath, isORPCErrorStatus, fallbackORPCErrorStatus, fallbackORPCErrorMessage, resolveMaybeOptionalOptions, createORPCErrorFromJson } from '@temporary-name/shared';
4
- import { a as standardizeHTTPPath, j as jsonSerialize, g as getDynamicParams, d as deserialize, s as serialize } from '../shared/server.Kxw442A9.mjs';
4
+ import { j as jsonSerialize, d as deserialize, s as serialize } from '../shared/server.JtIZ8YG7.mjs';
5
5
  import '@temporary-name/standard-server';
6
6
  import { TypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
7
7
  export { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
@@ -530,60 +530,77 @@ ${errors.join("\n\n")}`
530
530
  }
531
531
  async #request(doc, ref, def, baseSchemaConvertOptions) {
532
532
  const method = fallbackContractConfig("defaultMethod", def.route.method);
533
- const details = getEventIteratorSchemaDetails(def.inputSchema);
534
- if (details) {
535
- ref.requestBody = {
536
- required: true,
537
- content: toOpenAPIEventIteratorContent(
538
- await this.converter.convert(details.yields, { ...baseSchemaConvertOptions, strategy: "input" }),
539
- await this.converter.convert(details.returns, { ...baseSchemaConvertOptions, strategy: "input" })
540
- )
541
- };
542
- return;
543
- }
544
533
  const dynamicParams = getDynamicParams(def.route.path)?.map((v) => v.name);
545
- let [required, schema] = await this.converter.convert(def.inputSchema, {
534
+ const [_pathRequired, pathSchema] = await this.converter.convert(def.schemas.pathSchema, {
546
535
  ...baseSchemaConvertOptions,
547
536
  strategy: "input",
548
- minStructureDepthForRef: dynamicParams?.length ? 1 : 0
537
+ minStructureDepthForRef: 1
549
538
  });
550
- if (isAnySchema(schema) && !dynamicParams?.length) {
551
- return;
552
- }
553
539
  if (dynamicParams?.length) {
554
540
  const error = new OpenAPIGeneratorError(
541
+ // TODO: fix this error
555
542
  'When input structure is "compact", and path has dynamic params, input schema must be an object with all dynamic params as required.'
556
543
  );
557
- if (!isObjectSchema(schema)) {
544
+ if (!isObjectSchema(pathSchema)) {
558
545
  throw error;
559
546
  }
560
- const [paramsSchema, rest] = separateObjectSchema(schema, dynamicParams);
561
- schema = rest;
562
- required = rest.required ? rest.required.length !== 0 : false;
563
- if (!checkParamsSchema(paramsSchema, dynamicParams)) {
547
+ if (!checkParamsSchema(pathSchema, dynamicParams)) {
564
548
  throw error;
565
549
  }
566
550
  ref.parameters ??= [];
567
- ref.parameters.push(...toOpenAPIParameters(paramsSchema, "path"));
551
+ ref.parameters.push(...toOpenAPIParameters(pathSchema, "path"));
552
+ } else {
553
+ const error = new OpenAPIGeneratorError("Params set via path do not match those on the route");
554
+ if (!isObjectSchema(pathSchema)) {
555
+ console.log("FOO", pathSchema);
556
+ throw error;
557
+ }
558
+ if (!checkParamsSchema(pathSchema, [])) {
559
+ console.log("BAR", pathSchema);
560
+ throw error;
561
+ }
568
562
  }
569
- if (method === "GET") {
570
- const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, schema);
563
+ const [_queryRequired, querySchema] = await this.converter.convert(def.schemas.querySchema, {
564
+ ...baseSchemaConvertOptions,
565
+ strategy: "input",
566
+ minStructureDepthForRef: 0
567
+ });
568
+ if (!isAnySchema(querySchema)) {
569
+ const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, querySchema);
571
570
  if (!isObjectSchema(resolvedSchema)) {
572
- throw new OpenAPIGeneratorError(
573
- 'When method is "GET", input schema must satisfy: object | any | unknown'
574
- );
571
+ throw new OpenAPIGeneratorError("Query param schema must satisfy: object | any | unknown");
575
572
  }
576
573
  ref.parameters ??= [];
577
574
  ref.parameters.push(...toOpenAPIParameters(resolvedSchema, "query"));
578
- } else {
579
- ref.requestBody = {
580
- required,
581
- content: toOpenAPIContent(schema)
582
- };
575
+ }
576
+ if (method !== "GET") {
577
+ const details = getEventIteratorSchemaDetails(def.schemas.bodySchema);
578
+ if (details) {
579
+ ref.requestBody = {
580
+ required: true,
581
+ content: toOpenAPIEventIteratorContent(
582
+ await this.converter.convert(details.yields, { ...baseSchemaConvertOptions, strategy: "input" }),
583
+ await this.converter.convert(details.returns, { ...baseSchemaConvertOptions, strategy: "input" })
584
+ )
585
+ };
586
+ } else {
587
+ const [bodyRequired, bodySchema] = await this.converter.convert(def.schemas.bodySchema, {
588
+ ...baseSchemaConvertOptions,
589
+ strategy: "input",
590
+ minStructureDepthForRef: 0
591
+ });
592
+ if (isAnySchema(bodySchema)) {
593
+ return;
594
+ }
595
+ ref.requestBody = {
596
+ required: bodyRequired,
597
+ content: toOpenAPIContent(bodySchema)
598
+ };
599
+ }
583
600
  }
584
601
  }
585
602
  async #successResponse(doc, ref, def, baseSchemaConvertOptions) {
586
- const outputSchema = def.outputSchema;
603
+ const outputSchema = def.schemas.outputSchema;
587
604
  const status = fallbackContractConfig("defaultSuccessStatus", def.route.successStatus);
588
605
  const description = fallbackContractConfig("defaultSuccessDescription", def.route?.successDescription);
589
606
  const eventIteratorSchemaDetails = getEventIteratorSchemaDetails(outputSchema);
@@ -1,8 +1,8 @@
1
1
  import { Value, Promisable, ORPCError } from '@temporary-name/shared';
2
2
  import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
3
3
  import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
4
- import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.BlJrjUA9.mjs';
5
- import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.WsFQIubj.mjs';
4
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.BCcLYvdF.mjs';
5
+ import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.DecvGKtb.mjs';
6
6
  import { Meta } from '@temporary-name/contract';
7
7
 
8
8
  interface BatchHandlerOptions<T extends Context> {
@@ -1,8 +1,8 @@
1
1
  import { Value, Promisable, ORPCError } from '@temporary-name/shared';
2
2
  import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
3
3
  import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
4
- import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.C-tNYmY_.js';
5
- import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.WsFQIubj.js';
4
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CdeqmULw.js';
5
+ import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.DecvGKtb.js';
6
6
  import { Meta } from '@temporary-name/contract';
7
7
 
8
8
  interface BatchHandlerOptions<T extends Context> {
@@ -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, H as ProcedureClientInterceptorOptions } from './server.WsFQIubj.mjs';
4
+ import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.DecvGKtb.mjs';
5
5
 
6
6
  interface StandardHandlerPlugin<T extends Context> {
7
7
  order?: number;