@temporary-name/server 1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3 → 1.9.3-alpha.32780b2c7ad58cf8dcbc93a40f13494185223e6e
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.
- package/dist/adapters/aws-lambda/index.d.mts +3 -3
- package/dist/adapters/aws-lambda/index.d.ts +3 -3
- package/dist/adapters/aws-lambda/index.mjs +2 -2
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/node/index.d.mts +3 -3
- package/dist/adapters/node/index.d.ts +3 -3
- package/dist/adapters/node/index.mjs +2 -2
- package/dist/adapters/standard/index.d.mts +10 -5
- package/dist/adapters/standard/index.d.ts +10 -5
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/index.d.mts +47 -42
- package/dist/index.d.ts +47 -42
- package/dist/index.mjs +34 -12
- package/dist/openapi/index.d.mts +1 -1
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.mjs +50 -33
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.BlJrjUA9.d.mts → server.BRCH88Sb.d.mts} +1 -1
- package/dist/shared/{server.JI4dqTgD.d.ts → server.Bb9Wxubg.d.ts} +2 -2
- package/dist/shared/{server.BYnDyuDL.d.mts → server.BbfNcgas.d.mts} +2 -2
- package/dist/shared/{server.C-tNYmY_.d.ts → server.D24uJlXJ.d.ts} +1 -1
- package/dist/shared/{server.CjkiSCui.mjs → server.DlRH_uit.mjs} +24 -11
- package/dist/shared/{server.WsFQIubj.d.mts → server.XpnxYU3D.d.mts} +32 -20
- package/dist/shared/{server.WsFQIubj.d.ts → server.XpnxYU3D.d.ts} +32 -20
- package/dist/shared/{server.DdHBdcen.mjs → server.u-02Z0mj.mjs} +12 -20
- package/package.json +10 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Schemas, ErrorMap, Meta, ContractProcedure, MergedErrorMap, Route, AnySchema, MergedSchemas, 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
3
|
import { ClientContext, MaybeOptionalOptions, 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
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.
|
|
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.
|
|
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.XpnxYU3D.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.XpnxYU3D.js';
|
|
8
8
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
9
9
|
|
|
10
|
-
declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context,
|
|
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,
|
|
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,
|
|
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<
|
|
25
|
-
constructor(def: BuilderDef<
|
|
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,
|
|
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,
|
|
39
|
+
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
|
|
40
40
|
/**
|
|
41
41
|
* Sets or updates the route definition for the contract.
|
|
42
42
|
* The provided route is spared-merged with any existing route in the contract.
|
|
@@ -45,19 +45,24 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
|
|
|
45
45
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
46
46
|
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
47
47
|
*/
|
|
48
|
-
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
|
|
49
|
+
path<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
50
|
+
pathSchema: USchema;
|
|
51
|
+
}>, TErrorMap, TMeta, TGateName>;
|
|
52
|
+
query<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
53
|
+
querySchema: USchema;
|
|
54
|
+
}>, TErrorMap, TMeta, TGateName>;
|
|
55
|
+
body<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
56
|
+
bodySchema: USchema;
|
|
57
|
+
}>, TErrorMap, TMeta, TGateName>;
|
|
55
58
|
/**
|
|
56
59
|
* Defines the output validation schema.
|
|
57
60
|
*
|
|
58
61
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
59
62
|
*/
|
|
60
|
-
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext,
|
|
63
|
+
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
64
|
+
outputSchema: USchema;
|
|
65
|
+
}>, TErrorMap, TMeta, TGateName>;
|
|
61
66
|
/**
|
|
62
67
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
63
68
|
*
|
|
@@ -65,18 +70,18 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
|
|
|
65
70
|
* @note The current context must be satisfy middleware dependent-context
|
|
66
71
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
67
72
|
*/
|
|
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>,
|
|
73
|
+
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
74
|
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
70
75
|
isGateEnabled: typeof isGateEnabled;
|
|
71
|
-
}>,
|
|
76
|
+
}>, TSchemas, TErrorMap, TMeta, TInferredGateName>;
|
|
72
77
|
/**
|
|
73
78
|
* Defines the handler of the procedure.
|
|
74
79
|
*
|
|
75
80
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
76
81
|
*/
|
|
77
|
-
handler(handler: ProcedureHandler<TCurrentContext,
|
|
82
|
+
handler(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
|
|
78
83
|
}
|
|
79
|
-
declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context,
|
|
84
|
+
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
85
|
/**
|
|
81
86
|
* Prefixes all procedures in the router.
|
|
82
87
|
* The provided prefix is post-appended to any existing router prefix.
|
|
@@ -85,7 +90,7 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
|
|
|
85
90
|
*
|
|
86
91
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
87
92
|
*/
|
|
88
|
-
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext,
|
|
93
|
+
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
|
|
89
94
|
/**
|
|
90
95
|
* Adds tags to all procedures in the router.
|
|
91
96
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
@@ -100,7 +105,7 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
|
|
|
100
105
|
*/
|
|
101
106
|
router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
|
102
107
|
}
|
|
103
|
-
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any,
|
|
108
|
+
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
109
|
/**
|
|
105
110
|
* This property holds the defined options.
|
|
106
111
|
*/
|
|
@@ -129,18 +134,18 @@ interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Co
|
|
|
129
134
|
}
|
|
130
135
|
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
136
|
|
|
132
|
-
interface BuilderDef<
|
|
137
|
+
interface BuilderDef<TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
|
|
133
138
|
middlewares: readonly AnyMiddleware[];
|
|
134
139
|
inputValidationIndex: number;
|
|
135
140
|
outputValidationIndex: number;
|
|
136
141
|
}
|
|
137
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context,
|
|
142
|
+
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
143
|
/**
|
|
139
144
|
* Set or override the initial context.
|
|
140
145
|
*
|
|
141
146
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
142
147
|
*/
|
|
143
|
-
$context<U extends Context>(): Builder<U, U,
|
|
148
|
+
$context<U extends Context>(): Builder<U, U, TSchemas, TErrorMap, TMeta, TGateName>;
|
|
144
149
|
/**
|
|
145
150
|
* Creates a middleware.
|
|
146
151
|
*
|
|
@@ -149,7 +154,7 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
|
149
154
|
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
155
|
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, TMeta>;
|
|
151
156
|
}
|
|
152
|
-
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>,
|
|
157
|
+
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, InitialSchemas, Record<never, never>, TMeta, never>;
|
|
153
158
|
interface ApiBuilderOpts<TMeta extends Meta> {
|
|
154
159
|
meta?: TMeta;
|
|
155
160
|
}
|
|
@@ -159,7 +164,7 @@ declare const os: ApiBuilder<Record<never, never>>;
|
|
|
159
164
|
/**
|
|
160
165
|
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
|
161
166
|
*/
|
|
162
|
-
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context,
|
|
167
|
+
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
168
|
/**
|
|
164
169
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
165
170
|
*
|
|
@@ -168,7 +173,7 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
|
|
|
168
173
|
* @note The current context must be satisfy middleware dependent-context
|
|
169
174
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
170
175
|
*/
|
|
171
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext,
|
|
176
|
+
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
177
|
/**
|
|
173
178
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
174
179
|
*
|
|
@@ -177,19 +182,19 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
|
|
|
177
182
|
* @note The current context must be satisfy middleware dependent-context
|
|
178
183
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
179
184
|
*/
|
|
180
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<
|
|
185
|
+
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
186
|
/**
|
|
182
187
|
* Make this procedure callable (works like a function while still being a procedure).
|
|
183
188
|
*
|
|
184
189
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
185
190
|
*/
|
|
186
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext,
|
|
191
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> & ProcedureClient<TClientContext, TSchemas, TErrorMap>;
|
|
187
192
|
}
|
|
188
193
|
/**
|
|
189
194
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
|
190
195
|
*/
|
|
191
|
-
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context,
|
|
192
|
-
'~orpc': BuilderDef<
|
|
196
|
+
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
197
|
+
'~orpc': BuilderDef<TSchemas, TErrorMap, TMeta>;
|
|
193
198
|
/**
|
|
194
199
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
195
200
|
*
|
|
@@ -198,7 +203,7 @@ interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext
|
|
|
198
203
|
* @note The current context must be satisfy middleware dependent-context
|
|
199
204
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
200
205
|
*/
|
|
201
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext,
|
|
206
|
+
'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
207
|
/**
|
|
203
208
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
204
209
|
*
|
|
@@ -207,13 +212,13 @@ interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext
|
|
|
207
212
|
* @note The current context must be satisfy middleware dependent-context
|
|
208
213
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
209
214
|
*/
|
|
210
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<
|
|
215
|
+
'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
216
|
/**
|
|
212
217
|
* Defines the handler of the procedure.
|
|
213
218
|
*
|
|
214
219
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
215
220
|
*/
|
|
216
|
-
'handler'(handler: ProcedureHandler<TCurrentContext,
|
|
221
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
|
|
217
222
|
}
|
|
218
223
|
|
|
219
224
|
interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
|
@@ -233,7 +238,7 @@ interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitial
|
|
|
233
238
|
*/
|
|
234
239
|
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
235
240
|
}
|
|
236
|
-
type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer
|
|
241
|
+
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
242
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
238
243
|
};
|
|
239
244
|
|
|
@@ -271,7 +276,7 @@ interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends
|
|
|
271
276
|
default: U;
|
|
272
277
|
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
273
278
|
}
|
|
274
|
-
type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer
|
|
279
|
+
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
280
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
276
281
|
};
|
|
277
282
|
declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
|
|
@@ -306,9 +311,9 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
|
|
|
306
311
|
* ```
|
|
307
312
|
*
|
|
308
313
|
*/
|
|
309
|
-
declare function call<TInitialContext extends Context,
|
|
314
|
+
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
315
|
|
|
311
|
-
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer
|
|
316
|
+
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
317
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
|
313
318
|
};
|
|
314
319
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { mergePrefix, mergeTags, ContractProcedure, mergeErrorMap, mergeMeta, 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
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.
|
|
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.
|
|
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.DlRH_uit.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.DlRH_uit.mjs';
|
|
8
8
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
9
9
|
|
|
10
10
|
class DecoratedProcedure extends Procedure {
|
|
@@ -71,15 +71,33 @@ class ProcedureBuilder extends ContractProcedure {
|
|
|
71
71
|
route: mergeRoute(this["~orpc"].route, prefix ? prefixRoute(route, prefix) : route)
|
|
72
72
|
});
|
|
73
73
|
}
|
|
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) {
|
|
74
|
+
path(schema) {
|
|
80
75
|
return new ProcedureBuilder({
|
|
81
76
|
...this["~orpc"],
|
|
82
|
-
|
|
77
|
+
schemas: {
|
|
78
|
+
...this["~orpc"].schemas,
|
|
79
|
+
pathSchema: schema
|
|
80
|
+
},
|
|
81
|
+
inputValidationIndex: this["~orpc"].middlewares.length
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
query(schema) {
|
|
85
|
+
return new ProcedureBuilder({
|
|
86
|
+
...this["~orpc"],
|
|
87
|
+
schemas: {
|
|
88
|
+
...this["~orpc"].schemas,
|
|
89
|
+
querySchema: schema
|
|
90
|
+
},
|
|
91
|
+
inputValidationIndex: this["~orpc"].middlewares.length
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
body(schema) {
|
|
95
|
+
return new ProcedureBuilder({
|
|
96
|
+
...this["~orpc"],
|
|
97
|
+
schemas: {
|
|
98
|
+
...this["~orpc"].schemas,
|
|
99
|
+
bodySchema: schema
|
|
100
|
+
},
|
|
83
101
|
inputValidationIndex: this["~orpc"].middlewares.length
|
|
84
102
|
});
|
|
85
103
|
}
|
|
@@ -91,7 +109,10 @@ class ProcedureBuilder extends ContractProcedure {
|
|
|
91
109
|
output(schema) {
|
|
92
110
|
return new ProcedureBuilder({
|
|
93
111
|
...this["~orpc"],
|
|
94
|
-
|
|
112
|
+
schemas: {
|
|
113
|
+
...this["~orpc"].schemas,
|
|
114
|
+
outputSchema: schema
|
|
115
|
+
},
|
|
95
116
|
outputValidationIndex: this["~orpc"].middlewares.length
|
|
96
117
|
});
|
|
97
118
|
}
|
|
@@ -231,6 +252,7 @@ function createApiBuilder(opts = {}) {
|
|
|
231
252
|
console.dir(error, { depth: null });
|
|
232
253
|
})
|
|
233
254
|
],
|
|
255
|
+
schemas: initialSchemas,
|
|
234
256
|
// 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
257
|
// the best solution). For now I've removed the interface to configure it externally.
|
|
236
258
|
dedupeLeadingMiddlewares: true
|
package/dist/openapi/index.d.mts
CHANGED
|
@@ -55,7 +55,7 @@ interface SchemaConvertOptions {
|
|
|
55
55
|
minStructureDepthForRef?: number;
|
|
56
56
|
}
|
|
57
57
|
interface SchemaConverter {
|
|
58
|
-
convert(
|
|
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>;
|
package/dist/openapi/index.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ interface SchemaConvertOptions {
|
|
|
55
55
|
minStructureDepthForRef?: number;
|
|
56
56
|
}
|
|
57
57
|
interface SchemaConverter {
|
|
58
|
-
convert(
|
|
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>;
|
package/dist/openapi/index.mjs
CHANGED
|
@@ -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
|
-
|
|
534
|
+
const [_pathRequired, pathSchema] = await this.converter.convert(def.schemas.pathSchema, {
|
|
546
535
|
...baseSchemaConvertOptions,
|
|
547
536
|
strategy: "input",
|
|
548
|
-
minStructureDepthForRef:
|
|
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(
|
|
544
|
+
if (!isObjectSchema(pathSchema)) {
|
|
558
545
|
throw error;
|
|
559
546
|
}
|
|
560
|
-
|
|
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(
|
|
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
|
-
|
|
570
|
-
|
|
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
|
-
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
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);
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -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.
|
|
5
|
-
import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.
|
|
4
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.BRCH88Sb.mjs';
|
|
5
|
+
import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.XpnxYU3D.mjs';
|
|
6
6
|
import { Meta } from '@temporary-name/contract';
|
|
7
7
|
|
|
8
8
|
interface BatchHandlerOptions<T extends Context> {
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -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.
|
|
5
|
-
import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.
|
|
4
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.D24uJlXJ.js';
|
|
5
|
+
import { C as Context, H as ProcedureClientInterceptorOptions } from '../shared/server.XpnxYU3D.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.
|
|
4
|
+
import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.XpnxYU3D.mjs';
|
|
5
5
|
|
|
6
6
|
interface StandardHandlerPlugin<T extends Context> {
|
|
7
7
|
order?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTTPPath } from '@temporary-name/shared';
|
|
2
|
-
import { C as Context } from './server.
|
|
3
|
-
import { c as StandardHandleOptions } from './server.
|
|
2
|
+
import { C as Context } from './server.XpnxYU3D.js';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.D24uJlXJ.js';
|
|
4
4
|
|
|
5
5
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
6
6
|
context?: T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTTPPath } from '@temporary-name/shared';
|
|
2
|
-
import { C as Context } from './server.
|
|
3
|
-
import { c as StandardHandleOptions } from './server.
|
|
2
|
+
import { C as Context } from './server.XpnxYU3D.mjs';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.BRCH88Sb.mjs';
|
|
4
4
|
|
|
5
5
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
6
6
|
context?: T;
|
|
@@ -1,7 +1,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.
|
|
4
|
+
import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.XpnxYU3D.js';
|
|
5
5
|
|
|
6
6
|
interface StandardHandlerPlugin<T extends Context> {
|
|
7
7
|
order?: number;
|
|
@@ -269,7 +269,6 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
269
269
|
{
|
|
270
270
|
context,
|
|
271
271
|
input,
|
|
272
|
-
// input only optional when it undefinable so we can safely cast it
|
|
273
272
|
errors,
|
|
274
273
|
path,
|
|
275
274
|
procedure,
|
|
@@ -304,30 +303,44 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
304
303
|
};
|
|
305
304
|
}
|
|
306
305
|
async function validateInput(procedure, input) {
|
|
307
|
-
const
|
|
308
|
-
if (!schema) {
|
|
309
|
-
return input;
|
|
310
|
-
}
|
|
306
|
+
const schemas = procedure["~orpc"].schemas;
|
|
311
307
|
return runWithSpan({ name: "validate_input" }, async () => {
|
|
312
|
-
const
|
|
313
|
-
|
|
308
|
+
const resultBody = await safeParseAsync(schemas.bodySchema, input.body);
|
|
309
|
+
const resultPath = await safeParseAsync(schemas.pathSchema, input.path);
|
|
310
|
+
const resultQuery = await safeParseAsync(schemas.querySchema, input.query);
|
|
311
|
+
const issues = [];
|
|
312
|
+
if (!resultBody.success) {
|
|
313
|
+
issues.push(...resultBody.error.issues.map((i) => ({ ...i, path: ["body", ...i.path] })));
|
|
314
|
+
}
|
|
315
|
+
if (!resultPath.success) {
|
|
316
|
+
issues.push(...resultPath.error.issues.map((i) => ({ ...i, path: ["path", ...i.path] })));
|
|
317
|
+
}
|
|
318
|
+
if (!resultQuery.success) {
|
|
319
|
+
issues.push(...resultQuery.error.issues.map((i) => ({ ...i, path: ["query", ...i.path] })));
|
|
320
|
+
}
|
|
321
|
+
if (issues.length > 0) {
|
|
314
322
|
throw new ORPCError("BAD_REQUEST", {
|
|
315
323
|
message: "Input validation failed",
|
|
316
324
|
data: {
|
|
317
|
-
issues
|
|
325
|
+
issues
|
|
318
326
|
},
|
|
319
327
|
cause: new ValidationError({
|
|
320
328
|
message: "Input validation failed",
|
|
321
|
-
issues
|
|
329
|
+
issues,
|
|
322
330
|
data: input
|
|
323
331
|
})
|
|
324
332
|
});
|
|
325
333
|
}
|
|
326
|
-
|
|
334
|
+
const results = {
|
|
335
|
+
body: resultBody.data,
|
|
336
|
+
path: resultPath.data,
|
|
337
|
+
query: resultQuery.data
|
|
338
|
+
};
|
|
339
|
+
return results;
|
|
327
340
|
});
|
|
328
341
|
}
|
|
329
342
|
async function validateOutput(procedure, output) {
|
|
330
|
-
const schema = procedure["~orpc"].outputSchema;
|
|
343
|
+
const schema = procedure["~orpc"].schemas.outputSchema;
|
|
331
344
|
if (!schema) {
|
|
332
345
|
return output;
|
|
333
346
|
}
|