@temporary-name/server 1.9.3-alpha.37dfe6603933b8e445661fe453c4fbdb30ccb524 → 1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e
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 -5
- 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 -5
- 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 -5
- 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 -5
- package/dist/index.d.mts +44 -266
- package/dist/index.d.ts +44 -266
- package/dist/index.mjs +108 -151
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.DLsti1Pv.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.BKh8I1Ny.mjs → server.DcfsPloY.mjs} +17 -54
- package/package.json +10 -9
|
@@ -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,39 +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 {
|
|
5
|
-
import 'zod';
|
|
6
|
-
import * as z4 from 'zod/v4/core';
|
|
7
|
-
|
|
8
|
-
const gatingContext = new AsyncLocalStorage();
|
|
9
|
-
function withoutGatedFields(data, schema, isGateEnabled) {
|
|
10
|
-
const filtered = { ...data };
|
|
11
|
-
const gatedFields = getGatedFields(schema);
|
|
12
|
-
for (const [fieldName, gate] of gatedFields) {
|
|
13
|
-
if (!isGateEnabled(gate)) {
|
|
14
|
-
delete filtered[fieldName];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return filtered;
|
|
18
|
-
}
|
|
19
|
-
function getGatedFields(schema) {
|
|
20
|
-
if (!schema || schema["~standard"].vendor !== "zod") {
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
const gatedFields = [];
|
|
24
|
-
const zodDef = schema._zod.def;
|
|
25
|
-
if (zodDef.type === "object") {
|
|
26
|
-
const shape = zodDef.shape;
|
|
27
|
-
for (const fieldName in shape) {
|
|
28
|
-
const fieldSchema = shape[fieldName];
|
|
29
|
-
const gate = z4.globalRegistry.get(fieldSchema)?.gate;
|
|
30
|
-
if (gate) {
|
|
31
|
-
gatedFields.push([fieldName, gate]);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return gatedFields;
|
|
36
|
-
}
|
|
4
|
+
import { safeParseAsync } from '@temporary-name/zod';
|
|
37
5
|
|
|
38
6
|
const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
|
|
39
7
|
function lazy(loader, meta = {}) {
|
|
@@ -147,37 +115,41 @@ async function validateInput(procedure, input) {
|
|
|
147
115
|
return input;
|
|
148
116
|
}
|
|
149
117
|
return runWithSpan({ name: "validate_input" }, async () => {
|
|
150
|
-
const result = await schema
|
|
151
|
-
if (result.
|
|
118
|
+
const result = await safeParseAsync(schema, input);
|
|
119
|
+
if (!result.success) {
|
|
152
120
|
throw new ORPCError("BAD_REQUEST", {
|
|
153
121
|
message: "Input validation failed",
|
|
154
122
|
data: {
|
|
155
|
-
issues: result.issues
|
|
123
|
+
issues: result.error.issues
|
|
156
124
|
},
|
|
157
125
|
cause: new ValidationError({
|
|
158
126
|
message: "Input validation failed",
|
|
159
|
-
issues: result.issues,
|
|
127
|
+
issues: result.error.issues,
|
|
160
128
|
data: input
|
|
161
129
|
})
|
|
162
130
|
});
|
|
163
131
|
}
|
|
164
|
-
return result.
|
|
132
|
+
return result.data;
|
|
165
133
|
});
|
|
166
134
|
}
|
|
167
|
-
async function validateOutput(
|
|
135
|
+
async function validateOutput(procedure, output) {
|
|
136
|
+
const schema = procedure["~orpc"].outputSchema;
|
|
137
|
+
if (!schema) {
|
|
138
|
+
return output;
|
|
139
|
+
}
|
|
168
140
|
return runWithSpan({ name: "validate_output" }, async () => {
|
|
169
|
-
const result = await schema
|
|
170
|
-
if (result.
|
|
141
|
+
const result = await safeParseAsync(schema, output);
|
|
142
|
+
if (!result.success) {
|
|
171
143
|
throw new ORPCError("INTERNAL_SERVER_ERROR", {
|
|
172
144
|
message: "Output validation failed",
|
|
173
145
|
cause: new ValidationError({
|
|
174
146
|
message: "Output validation failed",
|
|
175
|
-
issues: result.issues,
|
|
147
|
+
issues: result.error.issues,
|
|
176
148
|
data: output
|
|
177
149
|
})
|
|
178
150
|
});
|
|
179
151
|
}
|
|
180
|
-
return result.
|
|
152
|
+
return result.data;
|
|
181
153
|
});
|
|
182
154
|
}
|
|
183
155
|
async function executeProcedureInternal(procedure, options) {
|
|
@@ -220,20 +192,11 @@ async function executeProcedureInternal(procedure, options) {
|
|
|
220
192
|
() => procedure["~orpc"].handler({ ...options, context, input: currentInput })
|
|
221
193
|
);
|
|
222
194
|
if (index === outputValidationIndex) {
|
|
223
|
-
|
|
224
|
-
if (!schema) {
|
|
225
|
-
return output;
|
|
226
|
-
}
|
|
227
|
-
const validated = await validateOutput(schema, output);
|
|
228
|
-
const isGateEnabled = gatingContext.getStore();
|
|
229
|
-
if (!validated || !isGateEnabled) {
|
|
230
|
-
return validated;
|
|
231
|
-
}
|
|
232
|
-
return withoutGatedFields(validated, schema, isGateEnabled);
|
|
195
|
+
return await validateOutput(procedure, output);
|
|
233
196
|
}
|
|
234
197
|
return output;
|
|
235
198
|
};
|
|
236
199
|
return next(0, options.context, options.input);
|
|
237
200
|
}
|
|
238
201
|
|
|
239
|
-
export { LAZY_SYMBOL as L,
|
|
202
|
+
export { LAZY_SYMBOL as L, createORPCErrorConstructorMap as a, middlewareOutputFn as b, createProcedureClient as c, getLazyMeta as g, isLazy as i, lazy as l, mergeCurrentContext as m, unlazy as u };
|
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.50b729ba628b987e14f5bd1004e5a04590fd4b4e",
|
|
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/interop": "1.9.3-alpha.
|
|
79
|
-
"@temporary-name/
|
|
80
|
-
"@temporary-name/
|
|
81
|
-
"@temporary-name/standard-server
|
|
82
|
-
"@temporary-name/standard-server-
|
|
83
|
-
"@temporary-name/standard-server-
|
|
76
|
+
"@temporary-name/contract": "1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e",
|
|
77
|
+
"@temporary-name/interop": "1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e",
|
|
78
|
+
"@temporary-name/json-schema": "1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e",
|
|
79
|
+
"@temporary-name/shared": "1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e",
|
|
80
|
+
"@temporary-name/standard-server": "1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e",
|
|
81
|
+
"@temporary-name/standard-server-fetch": "1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e",
|
|
82
|
+
"@temporary-name/standard-server-node": "1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e",
|
|
83
|
+
"@temporary-name/zod": "1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e",
|
|
84
|
+
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e"
|
|
84
85
|
},
|
|
85
86
|
"devDependencies": {
|
|
86
87
|
"@types/supertest": "^6.0.3",
|