@temporary-name/server 1.9.3-alpha.021f5c8fe9793dff332b025dce560e804c45a7b1 → 1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36
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 +3 -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 +3 -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 +3 -2
- package/dist/adapters/standard/index.d.mts +14 -30
- package/dist/adapters/standard/index.d.ts +14 -30
- package/dist/adapters/standard/index.mjs +3 -2
- package/dist/index.d.mts +14 -957
- package/dist/index.d.ts +14 -957
- package/dist/index.mjs +51 -1676
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.CMTfy2UB.mjs → server.BVxcyR6X.mjs} +76 -82
- package/dist/shared/{server.CQyYNJ1H.d.ts → server.Bk5r0-2R.d.ts} +1 -2
- package/dist/shared/{server.BeuTpcmO.d.mts → server.Bs6ka_UE.d.mts} +2 -2
- package/dist/shared/{server.BKSOrA6h.d.mts → server.CZNLCQBm.d.mts} +2 -2
- package/dist/shared/{server.BKSOrA6h.d.ts → server.CZNLCQBm.d.ts} +2 -2
- package/dist/shared/{server.C1fnTLq0.d.mts → server.CbLTWfgn.d.mts} +1 -2
- package/dist/shared/{server.SLLuK6_v.d.ts → server.D2UFMrxf.d.ts} +2 -2
- package/dist/shared/{server.BZtKt8i8.mjs → server.DcfsPloY.mjs} +10 -9
- package/package.json +10 -9
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, E as ProcedureClientInterceptorOptions } from '../shared/server.
|
|
4
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CbLTWfgn.mjs';
|
|
5
|
+
import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.CZNLCQBm.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, E as ProcedureClientInterceptorOptions } from '../shared/server.
|
|
4
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.Bk5r0-2R.js';
|
|
5
|
+
import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.CZNLCQBm.js';
|
|
6
6
|
import { Meta } from '@temporary-name/contract';
|
|
7
7
|
|
|
8
8
|
interface BatchHandlerOptions<T extends Context> {
|
|
@@ -1,67 +1,64 @@
|
|
|
1
1
|
import { isObject, stringifyJSON, isORPCErrorStatus, tryDecodeURIComponent, value, toHttpPath, toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, ORPCError, toORPCError } from '@temporary-name/shared';
|
|
2
2
|
import { flattenHeader } from '@temporary-name/standard-server';
|
|
3
|
-
import { c as createProcedureClient } from './server.
|
|
3
|
+
import { c as createProcedureClient } from './server.DcfsPloY.mjs';
|
|
4
4
|
import { fallbackContractConfig } from '@temporary-name/contract';
|
|
5
5
|
import { d as deserialize, s as serialize, a as standardizeHTTPPath } from './server.BEHw7Eyx.mjs';
|
|
6
6
|
import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@temporary-name/server';
|
|
7
7
|
import { createRouter, addRoute, findRoute } from 'rou3';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
const data = request.method === "GET" ? deserialize(request.url.searchParams) : deserialize(await request.body());
|
|
19
|
-
if (data === void 0) {
|
|
20
|
-
return params;
|
|
21
|
-
}
|
|
22
|
-
if (isObject(data)) {
|
|
23
|
-
return {
|
|
24
|
-
...params,
|
|
25
|
-
...data
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
return data;
|
|
9
|
+
async function decode(request, params, procedure) {
|
|
10
|
+
const inputStructure = fallbackContractConfig(
|
|
11
|
+
"defaultInputStructure",
|
|
12
|
+
procedure["~orpc"].route.inputStructure
|
|
13
|
+
);
|
|
14
|
+
if (inputStructure === "compact") {
|
|
15
|
+
const data = request.method === "GET" ? deserialize(request.url.searchParams) : deserialize(await request.body());
|
|
16
|
+
if (data === void 0) {
|
|
17
|
+
return params;
|
|
29
18
|
}
|
|
30
|
-
|
|
31
|
-
return deserialize(request.url.searchParams);
|
|
32
|
-
};
|
|
33
|
-
return {
|
|
34
|
-
params,
|
|
35
|
-
get query() {
|
|
36
|
-
const value = deserializeSearchParams();
|
|
37
|
-
Object.defineProperty(this, "query", { value, writable: true });
|
|
38
|
-
return value;
|
|
39
|
-
},
|
|
40
|
-
set query(value) {
|
|
41
|
-
Object.defineProperty(this, "query", { value, writable: true });
|
|
42
|
-
},
|
|
43
|
-
headers: request.headers,
|
|
44
|
-
body: deserialize(await request.body())
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
encode(output, procedure) {
|
|
48
|
-
const successStatus = fallbackContractConfig(
|
|
49
|
-
"defaultSuccessStatus",
|
|
50
|
-
procedure["~orpc"].route.successStatus
|
|
51
|
-
);
|
|
52
|
-
const outputStructure = fallbackContractConfig(
|
|
53
|
-
"defaultOutputStructure",
|
|
54
|
-
procedure["~orpc"].route.outputStructure
|
|
55
|
-
);
|
|
56
|
-
if (outputStructure === "compact") {
|
|
19
|
+
if (isObject(data)) {
|
|
57
20
|
return {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
body: serialize(output)
|
|
21
|
+
...params,
|
|
22
|
+
...data
|
|
61
23
|
};
|
|
62
24
|
}
|
|
63
|
-
|
|
64
|
-
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
const deserializeSearchParams = () => {
|
|
28
|
+
return deserialize(request.url.searchParams);
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
params,
|
|
32
|
+
get query() {
|
|
33
|
+
const value = deserializeSearchParams();
|
|
34
|
+
Object.defineProperty(this, "query", { value, writable: true });
|
|
35
|
+
return value;
|
|
36
|
+
},
|
|
37
|
+
set query(value) {
|
|
38
|
+
Object.defineProperty(this, "query", { value, writable: true });
|
|
39
|
+
},
|
|
40
|
+
headers: request.headers,
|
|
41
|
+
body: deserialize(await request.body())
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function encode(output, procedure) {
|
|
45
|
+
const successStatus = fallbackContractConfig(
|
|
46
|
+
"defaultSuccessStatus",
|
|
47
|
+
procedure["~orpc"].route.successStatus
|
|
48
|
+
);
|
|
49
|
+
const outputStructure = fallbackContractConfig(
|
|
50
|
+
"defaultOutputStructure",
|
|
51
|
+
procedure["~orpc"].route.outputStructure
|
|
52
|
+
);
|
|
53
|
+
if (outputStructure === "compact") {
|
|
54
|
+
return {
|
|
55
|
+
status: successStatus,
|
|
56
|
+
headers: {},
|
|
57
|
+
body: serialize(output)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (!isDetailedOutput(output)) {
|
|
61
|
+
throw new Error(`
|
|
65
62
|
Invalid "detailed" output structure:
|
|
66
63
|
\u2022 Expected an object with optional properties:
|
|
67
64
|
- status (number 200-399)
|
|
@@ -72,32 +69,31 @@ class StandardOpenAPICodec {
|
|
|
72
69
|
Actual value:
|
|
73
70
|
${stringifyJSON(output)}
|
|
74
71
|
`);
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
status: output.status ?? successStatus,
|
|
78
|
-
headers: output.headers ?? {},
|
|
79
|
-
body: serialize(output.body)
|
|
80
|
-
};
|
|
81
72
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
73
|
+
return {
|
|
74
|
+
status: output.status ?? successStatus,
|
|
75
|
+
headers: output.headers ?? {},
|
|
76
|
+
body: serialize(output.body)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function encodeError(error) {
|
|
80
|
+
return {
|
|
81
|
+
status: error.status,
|
|
82
|
+
headers: {},
|
|
83
|
+
body: serialize(error.toJSON(), { outputFormat: "plain" })
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function isDetailedOutput(output) {
|
|
87
|
+
if (!isObject(output)) {
|
|
88
|
+
return false;
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isORPCErrorStatus(output.status))) {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
return true;
|
|
90
|
+
if (output.headers && !isObject(output.headers)) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isORPCErrorStatus(output.status))) {
|
|
94
|
+
return false;
|
|
100
95
|
}
|
|
96
|
+
return true;
|
|
101
97
|
}
|
|
102
98
|
|
|
103
99
|
function resolveFriendlyStandardHandleOptions(options) {
|
|
@@ -204,10 +200,8 @@ class StandardHandler {
|
|
|
204
200
|
clientInterceptors;
|
|
205
201
|
rootInterceptors;
|
|
206
202
|
matcher;
|
|
207
|
-
codec;
|
|
208
203
|
constructor(router, options) {
|
|
209
204
|
this.matcher = new StandardOpenAPIMatcher();
|
|
210
|
-
this.codec = new StandardOpenAPICodec();
|
|
211
205
|
const plugins = new CompositeStandardHandlerPlugin(options.plugins);
|
|
212
206
|
plugins.init(options, router);
|
|
213
207
|
this.interceptors = toArray(options.interceptors);
|
|
@@ -244,7 +238,7 @@ class StandardHandler {
|
|
|
244
238
|
step = "decode_input";
|
|
245
239
|
let input = await runWithSpan(
|
|
246
240
|
{ name: "decode_input" },
|
|
247
|
-
() =>
|
|
241
|
+
() => decode(request2, match.params, match.procedure)
|
|
248
242
|
);
|
|
249
243
|
step = void 0;
|
|
250
244
|
if (isAsyncIteratorObject(input)) {
|
|
@@ -264,7 +258,7 @@ class StandardHandler {
|
|
|
264
258
|
lastEventId: flattenHeader(request2.headers["last-event-id"])
|
|
265
259
|
});
|
|
266
260
|
step = void 0;
|
|
267
|
-
const response =
|
|
261
|
+
const response = encode(output, match.procedure);
|
|
268
262
|
return {
|
|
269
263
|
matched: true,
|
|
270
264
|
response
|
|
@@ -279,7 +273,7 @@ class StandardHandler {
|
|
|
279
273
|
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
280
274
|
cause: e
|
|
281
275
|
}) : toORPCError(e);
|
|
282
|
-
const response =
|
|
276
|
+
const response = encodeError(error);
|
|
283
277
|
return {
|
|
284
278
|
matched: true,
|
|
285
279
|
response
|
|
@@ -290,4 +284,4 @@ class StandardHandler {
|
|
|
290
284
|
}
|
|
291
285
|
}
|
|
292
286
|
|
|
293
|
-
export { CompositeStandardHandlerPlugin as C, StandardHandler as S,
|
|
287
|
+
export { CompositeStandardHandlerPlugin as C, StandardHandler as S, encodeError as a, StandardOpenAPIMatcher as b, decodeParams as c, decode as d, encode as e, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as 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, E as ProcedureClientInterceptorOptions } from './server.
|
|
4
|
+
import { C as Context, R as Router, E as ProcedureClientInterceptorOptions } from './server.CZNLCQBm.js';
|
|
5
5
|
|
|
6
6
|
interface StandardHandlerPlugin<T extends Context> {
|
|
7
7
|
order?: number;
|
|
@@ -48,7 +48,6 @@ declare class StandardHandler<T extends Context> {
|
|
|
48
48
|
private readonly clientInterceptors;
|
|
49
49
|
private readonly rootInterceptors;
|
|
50
50
|
private readonly matcher;
|
|
51
|
-
private readonly codec;
|
|
52
51
|
constructor(router: Router<any, T>, options: NoInfer<StandardHandlerOptions<T>>);
|
|
53
52
|
handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
|
|
54
53
|
}
|
|
@@ -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.CZNLCQBm.mjs';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.CbLTWfgn.mjs';
|
|
4
4
|
|
|
5
5
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
6
6
|
context?: T;
|
|
@@ -71,7 +71,7 @@ declare class Procedure<TInitialContext extends Context, TCurrentContext extends
|
|
|
71
71
|
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
72
72
|
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
73
73
|
}
|
|
74
|
-
type AnyProcedure = Procedure<any, any,
|
|
74
|
+
type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
|
|
75
75
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
|
76
76
|
|
|
77
77
|
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
|
@@ -189,4 +189,4 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
|
|
|
189
189
|
};
|
|
190
190
|
|
|
191
191
|
export { isProcedure as D, createProcedureClient as F, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, middlewareOutputFn as y };
|
|
192
|
-
export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L,
|
|
192
|
+
export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, MergedInitialContext as M, ORPCErrorConstructorMap as O, Router as R, CreateProcedureClientOptions as a, ProcedureClient as b, AnyRouter as c, Lazy as d, AnyProcedure as e, Middleware as f, MergedCurrentContext as g, ProcedureHandler as h, MapInputMiddleware as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
|
|
@@ -71,7 +71,7 @@ declare class Procedure<TInitialContext extends Context, TCurrentContext extends
|
|
|
71
71
|
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
72
72
|
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
73
73
|
}
|
|
74
|
-
type AnyProcedure = Procedure<any, any,
|
|
74
|
+
type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
|
|
75
75
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
|
76
76
|
|
|
77
77
|
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
|
@@ -189,4 +189,4 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
|
|
|
189
189
|
};
|
|
190
190
|
|
|
191
191
|
export { isProcedure as D, createProcedureClient as F, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, middlewareOutputFn as y };
|
|
192
|
-
export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L,
|
|
192
|
+
export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, MergedInitialContext as M, ORPCErrorConstructorMap as O, Router as R, CreateProcedureClientOptions as a, ProcedureClient as b, AnyRouter as c, Lazy as d, AnyProcedure as e, Middleware as f, MergedCurrentContext as g, ProcedureHandler as h, MapInputMiddleware as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Meta } from '@temporary-name/contract';
|
|
2
2
|
import { HTTPPath, Interceptor } from '@temporary-name/shared';
|
|
3
3
|
import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
|
|
4
|
-
import { C as Context, R as Router, E as ProcedureClientInterceptorOptions } from './server.
|
|
4
|
+
import { C as Context, R as Router, E as ProcedureClientInterceptorOptions } from './server.CZNLCQBm.mjs';
|
|
5
5
|
|
|
6
6
|
interface StandardHandlerPlugin<T extends Context> {
|
|
7
7
|
order?: number;
|
|
@@ -48,7 +48,6 @@ declare class StandardHandler<T extends Context> {
|
|
|
48
48
|
private readonly clientInterceptors;
|
|
49
49
|
private readonly rootInterceptors;
|
|
50
50
|
private readonly matcher;
|
|
51
|
-
private readonly codec;
|
|
52
51
|
constructor(router: Router<any, T>, options: NoInfer<StandardHandlerOptions<T>>);
|
|
53
52
|
handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
|
|
54
53
|
}
|
|
@@ -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.CZNLCQBm.js';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.Bk5r0-2R.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,7 @@
|
|
|
1
1
|
import { validateORPCError, ValidationError } from '@temporary-name/contract';
|
|
2
2
|
import { resolveMaybeOptionalOptions, ORPCError, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, overlayProxy, asyncIteratorWithSpan } from '@temporary-name/shared';
|
|
3
3
|
import { HibernationEventIterator, mapEventIterator } from '@temporary-name/standard-server';
|
|
4
|
+
import { safeParseAsync } from '@temporary-name/zod';
|
|
4
5
|
|
|
5
6
|
const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
|
|
6
7
|
function lazy(loader, meta = {}) {
|
|
@@ -114,21 +115,21 @@ async function validateInput(procedure, input) {
|
|
|
114
115
|
return input;
|
|
115
116
|
}
|
|
116
117
|
return runWithSpan({ name: "validate_input" }, async () => {
|
|
117
|
-
const result = await schema
|
|
118
|
-
if (result.
|
|
118
|
+
const result = await safeParseAsync(schema, input);
|
|
119
|
+
if (!result.success) {
|
|
119
120
|
throw new ORPCError("BAD_REQUEST", {
|
|
120
121
|
message: "Input validation failed",
|
|
121
122
|
data: {
|
|
122
|
-
issues: result.issues
|
|
123
|
+
issues: result.error.issues
|
|
123
124
|
},
|
|
124
125
|
cause: new ValidationError({
|
|
125
126
|
message: "Input validation failed",
|
|
126
|
-
issues: result.issues,
|
|
127
|
+
issues: result.error.issues,
|
|
127
128
|
data: input
|
|
128
129
|
})
|
|
129
130
|
});
|
|
130
131
|
}
|
|
131
|
-
return result.
|
|
132
|
+
return result.data;
|
|
132
133
|
});
|
|
133
134
|
}
|
|
134
135
|
async function validateOutput(procedure, output) {
|
|
@@ -137,18 +138,18 @@ async function validateOutput(procedure, output) {
|
|
|
137
138
|
return output;
|
|
138
139
|
}
|
|
139
140
|
return runWithSpan({ name: "validate_output" }, async () => {
|
|
140
|
-
const result = await schema
|
|
141
|
-
if (result.
|
|
141
|
+
const result = await safeParseAsync(schema, output);
|
|
142
|
+
if (!result.success) {
|
|
142
143
|
throw new ORPCError("INTERNAL_SERVER_ERROR", {
|
|
143
144
|
message: "Output validation failed",
|
|
144
145
|
cause: new ValidationError({
|
|
145
146
|
message: "Output validation failed",
|
|
146
|
-
issues: result.issues,
|
|
147
|
+
issues: result.error.issues,
|
|
147
148
|
data: output
|
|
148
149
|
})
|
|
149
150
|
});
|
|
150
151
|
}
|
|
151
|
-
return result.
|
|
152
|
+
return result.data;
|
|
152
153
|
});
|
|
153
154
|
}
|
|
154
155
|
async function executeProcedureInternal(procedure, options) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporary-name/server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.3-alpha.
|
|
4
|
+
"version": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -71,16 +71,17 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"cookie": "^1.0.2",
|
|
74
|
-
"@standard-schema/spec": "^1.0.0",
|
|
75
74
|
"rou3": "^0.7.7",
|
|
76
75
|
"zod": "^4.1.12",
|
|
77
|
-
"@temporary-name/contract": "1.9.3-alpha.
|
|
78
|
-
"@temporary-name/
|
|
79
|
-
"@temporary-name/interop": "1.9.3-alpha.
|
|
80
|
-
"@temporary-name/standard-server": "1.9.3-alpha.
|
|
81
|
-
"@temporary-name/standard-server-
|
|
82
|
-
"@temporary-name/
|
|
83
|
-
"@temporary-name/standard-server-
|
|
76
|
+
"@temporary-name/contract": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
|
|
77
|
+
"@temporary-name/json-schema": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
|
|
78
|
+
"@temporary-name/interop": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
|
|
79
|
+
"@temporary-name/standard-server": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
|
|
80
|
+
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
|
|
81
|
+
"@temporary-name/shared": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
|
|
82
|
+
"@temporary-name/standard-server-fetch": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
|
|
83
|
+
"@temporary-name/standard-server-node": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
|
|
84
|
+
"@temporary-name/zod": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36"
|
|
84
85
|
},
|
|
85
86
|
"devDependencies": {
|
|
86
87
|
"@types/supertest": "^6.0.3",
|