@temporary-name/server 1.9.3-alpha.6ef4729e23affbe6454d37025d1dfc4d998b0649 → 1.9.3-alpha.76a5d8c6a7525b4b17df3f9565304645f0922ab3
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 +12 -6
- package/dist/adapters/aws-lambda/index.d.ts +12 -6
- package/dist/adapters/aws-lambda/index.mjs +12 -4
- package/dist/adapters/fetch/index.d.mts +12 -6
- package/dist/adapters/fetch/index.d.ts +12 -6
- package/dist/adapters/fetch/index.mjs +12 -11
- package/dist/adapters/node/index.d.mts +12 -6
- package/dist/adapters/node/index.d.ts +12 -6
- package/dist/adapters/node/index.mjs +12 -11
- package/dist/adapters/standard/index.d.mts +39 -13
- package/dist/adapters/standard/index.d.ts +39 -13
- package/dist/adapters/standard/index.mjs +8 -100
- package/dist/index.d.mts +44 -319
- package/dist/index.d.ts +44 -319
- package/dist/index.mjs +108 -152
- package/dist/openapi/index.d.mts +220 -0
- package/dist/openapi/index.d.ts +220 -0
- package/dist/openapi/index.mjs +776 -0
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/server.8gkXYsTZ.d.ts +23 -0
- package/dist/shared/{server.Btxrgkj5.d.ts → server.B15EEOr0.d.ts} +8 -24
- package/dist/shared/server.B9VxPdeK.mjs +293 -0
- package/dist/shared/server.BEHw7Eyx.mjs +247 -0
- package/dist/shared/{server.C1YnHvvf.d.ts → server.CZNLCQBm.d.mts} +3 -3
- package/dist/shared/{server.C1YnHvvf.d.mts → server.CZNLCQBm.d.ts} +3 -3
- package/dist/shared/server.ChraIVaQ.d.mts +23 -0
- package/dist/shared/{server.BEQrAa3A.mjs → server.DcfsPloY.mjs} +16 -21
- package/dist/shared/{server.Bo94xDTv.d.mts → server.YXplw8TW.d.mts} +8 -24
- package/package.json +17 -10
- package/dist/shared/server.D6K9uoPI.mjs +0 -35
- package/dist/shared/server.DZ5BIITo.mjs +0 -9
- package/dist/shared/server.X0YaZxSJ.mjs +0 -13
|
@@ -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<{
|
|
@@ -188,5 +188,5 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
|
|
|
188
188
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
189
189
|
};
|
|
190
190
|
|
|
191
|
-
export { isProcedure as
|
|
192
|
-
export type {
|
|
191
|
+
export { isProcedure as D, createProcedureClient as F, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, middlewareOutputFn as y };
|
|
192
|
+
export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, MergedInitialContext as M, ORPCErrorConstructorMap as O, Router as R, CreateProcedureClientOptions as a, ProcedureClient as b, AnyRouter as c, Lazy as d, AnyProcedure as e, Middleware as f, MergedCurrentContext as g, ProcedureHandler as h, MapInputMiddleware as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HTTPPath } from '@temporary-name/shared';
|
|
2
|
+
import { C as Context } from './server.CZNLCQBm.mjs';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.YXplw8TW.mjs';
|
|
4
|
+
|
|
5
|
+
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
6
|
+
context?: T;
|
|
7
|
+
} : {
|
|
8
|
+
context: T;
|
|
9
|
+
});
|
|
10
|
+
declare function resolveFriendlyStandardHandleOptions<T extends Context>(options: FriendlyStandardHandleOptions<T>): StandardHandleOptions<T>;
|
|
11
|
+
/**
|
|
12
|
+
* {@link https://github.com/unjs/rou3}
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
declare function toRou3Pattern(path: HTTPPath): string;
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
declare function decodeParams(params: Record<string, string>): Record<string, string>;
|
|
21
|
+
|
|
22
|
+
export { decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
|
|
23
|
+
export type { FriendlyStandardHandleOptions as F };
|
|
@@ -1,7 +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 {
|
|
4
|
+
import { safeParseAsync } from '@temporary-name/zod';
|
|
5
5
|
|
|
6
6
|
const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
|
|
7
7
|
function lazy(loader, meta = {}) {
|
|
@@ -115,37 +115,41 @@ async function validateInput(procedure, input) {
|
|
|
115
115
|
return input;
|
|
116
116
|
}
|
|
117
117
|
return runWithSpan({ name: "validate_input" }, async () => {
|
|
118
|
-
const result = await schema
|
|
119
|
-
if (result.
|
|
118
|
+
const result = await safeParseAsync(schema, input);
|
|
119
|
+
if (!result.success) {
|
|
120
120
|
throw new ORPCError("BAD_REQUEST", {
|
|
121
121
|
message: "Input validation failed",
|
|
122
122
|
data: {
|
|
123
|
-
issues: result.issues
|
|
123
|
+
issues: result.error.issues
|
|
124
124
|
},
|
|
125
125
|
cause: new ValidationError({
|
|
126
126
|
message: "Input validation failed",
|
|
127
|
-
issues: result.issues,
|
|
127
|
+
issues: result.error.issues,
|
|
128
128
|
data: input
|
|
129
129
|
})
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
|
-
return result.
|
|
132
|
+
return result.data;
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
|
-
async function validateOutput(
|
|
135
|
+
async function validateOutput(procedure, output) {
|
|
136
|
+
const schema = procedure["~orpc"].outputSchema;
|
|
137
|
+
if (!schema) {
|
|
138
|
+
return output;
|
|
139
|
+
}
|
|
136
140
|
return runWithSpan({ name: "validate_output" }, async () => {
|
|
137
|
-
const result = await schema
|
|
138
|
-
if (result.
|
|
141
|
+
const result = await safeParseAsync(schema, output);
|
|
142
|
+
if (!result.success) {
|
|
139
143
|
throw new ORPCError("INTERNAL_SERVER_ERROR", {
|
|
140
144
|
message: "Output validation failed",
|
|
141
145
|
cause: new ValidationError({
|
|
142
146
|
message: "Output validation failed",
|
|
143
|
-
issues: result.issues,
|
|
147
|
+
issues: result.error.issues,
|
|
144
148
|
data: output
|
|
145
149
|
})
|
|
146
150
|
});
|
|
147
151
|
}
|
|
148
|
-
return result.
|
|
152
|
+
return result.data;
|
|
149
153
|
});
|
|
150
154
|
}
|
|
151
155
|
async function executeProcedureInternal(procedure, options) {
|
|
@@ -188,16 +192,7 @@ async function executeProcedureInternal(procedure, options) {
|
|
|
188
192
|
() => procedure["~orpc"].handler({ ...options, context, input: currentInput })
|
|
189
193
|
);
|
|
190
194
|
if (index === outputValidationIndex) {
|
|
191
|
-
|
|
192
|
-
if (!schema) {
|
|
193
|
-
return output;
|
|
194
|
-
}
|
|
195
|
-
const validated = await validateOutput(schema, output);
|
|
196
|
-
const isGateEnabled = gatingContext.getStore();
|
|
197
|
-
if (!validated || !isGateEnabled) {
|
|
198
|
-
return validated;
|
|
199
|
-
}
|
|
200
|
-
return withoutGatedFields(validated, schema, isGateEnabled);
|
|
195
|
+
return await validateOutput(procedure, output);
|
|
201
196
|
}
|
|
202
197
|
return output;
|
|
203
198
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Meta } from '@temporary-name/contract';
|
|
2
|
-
import { HTTPPath,
|
|
3
|
-
import {
|
|
4
|
-
import { C as Context, R as Router,
|
|
2
|
+
import { HTTPPath, Interceptor } from '@temporary-name/shared';
|
|
3
|
+
import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-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;
|
|
@@ -13,22 +13,6 @@ declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends
|
|
|
13
13
|
init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
type StandardParams = Record<string, string>;
|
|
17
|
-
type StandardMatchResult = {
|
|
18
|
-
path: readonly string[];
|
|
19
|
-
procedure: AnyProcedure;
|
|
20
|
-
params?: StandardParams;
|
|
21
|
-
} | undefined;
|
|
22
|
-
interface StandardMatcher {
|
|
23
|
-
init(router: AnyRouter): void;
|
|
24
|
-
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
25
|
-
}
|
|
26
|
-
interface StandardCodec {
|
|
27
|
-
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
|
28
|
-
encodeError(error: ORPCError<any, any>): StandardResponse;
|
|
29
|
-
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
16
|
interface StandardHandleOptions<T extends Context> {
|
|
33
17
|
prefix?: HTTPPath;
|
|
34
18
|
context: T;
|
|
@@ -60,14 +44,14 @@ interface StandardHandlerOptions<TContext extends Context> {
|
|
|
60
44
|
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
|
|
61
45
|
}
|
|
62
46
|
declare class StandardHandler<T extends Context> {
|
|
63
|
-
private readonly matcher;
|
|
64
|
-
private readonly codec;
|
|
65
47
|
private readonly interceptors;
|
|
66
48
|
private readonly clientInterceptors;
|
|
67
49
|
private readonly rootInterceptors;
|
|
68
|
-
|
|
50
|
+
private readonly matcher;
|
|
51
|
+
private readonly codec;
|
|
52
|
+
constructor(router: Router<any, T>, options: NoInfer<StandardHandlerOptions<T>>);
|
|
69
53
|
handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
|
|
70
54
|
}
|
|
71
55
|
|
|
72
|
-
export { CompositeStandardHandlerPlugin as C, StandardHandler as
|
|
73
|
-
export type {
|
|
56
|
+
export { CompositeStandardHandlerPlugin as C, StandardHandler as e };
|
|
57
|
+
export type { StandardHandlerInterceptorOptions as S, StandardHandlerPlugin as a, StandardHandlerOptions as b, StandardHandleOptions as c, StandardHandleResult as d };
|
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.76a5d8c6a7525b4b17df3f9565304645f0922ab3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -47,6 +47,11 @@
|
|
|
47
47
|
"types": "./dist/adapters/aws-lambda/index.d.mts",
|
|
48
48
|
"import": "./dist/adapters/aws-lambda/index.mjs",
|
|
49
49
|
"default": "./dist/adapters/aws-lambda/index.mjs"
|
|
50
|
+
},
|
|
51
|
+
"./openapi": {
|
|
52
|
+
"types": "./dist/openapi/index.d.mts",
|
|
53
|
+
"import": "./dist/openapi/index.mjs",
|
|
54
|
+
"default": "./dist/openapi/index.mjs"
|
|
50
55
|
}
|
|
51
56
|
},
|
|
52
57
|
"files": [
|
|
@@ -66,18 +71,20 @@
|
|
|
66
71
|
},
|
|
67
72
|
"dependencies": {
|
|
68
73
|
"cookie": "^1.0.2",
|
|
69
|
-
"
|
|
74
|
+
"rou3": "^0.7.7",
|
|
70
75
|
"zod": "^4.1.12",
|
|
71
|
-
"@temporary-name/contract": "1.9.3-alpha.
|
|
72
|
-
"@temporary-name/interop": "1.9.3-alpha.
|
|
73
|
-
"@temporary-name/
|
|
74
|
-
"@temporary-name/
|
|
75
|
-
"@temporary-name/standard-server-fetch": "1.9.3-alpha.
|
|
76
|
-
"@temporary-name/standard-server-
|
|
77
|
-
"@temporary-name/
|
|
78
|
-
"@temporary-name/standard-server-
|
|
76
|
+
"@temporary-name/contract": "1.9.3-alpha.76a5d8c6a7525b4b17df3f9565304645f0922ab3",
|
|
77
|
+
"@temporary-name/interop": "1.9.3-alpha.76a5d8c6a7525b4b17df3f9565304645f0922ab3",
|
|
78
|
+
"@temporary-name/json-schema": "1.9.3-alpha.76a5d8c6a7525b4b17df3f9565304645f0922ab3",
|
|
79
|
+
"@temporary-name/shared": "1.9.3-alpha.76a5d8c6a7525b4b17df3f9565304645f0922ab3",
|
|
80
|
+
"@temporary-name/standard-server-fetch": "1.9.3-alpha.76a5d8c6a7525b4b17df3f9565304645f0922ab3",
|
|
81
|
+
"@temporary-name/standard-server-node": "1.9.3-alpha.76a5d8c6a7525b4b17df3f9565304645f0922ab3",
|
|
82
|
+
"@temporary-name/zod": "1.9.3-alpha.76a5d8c6a7525b4b17df3f9565304645f0922ab3",
|
|
83
|
+
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.76a5d8c6a7525b4b17df3f9565304645f0922ab3",
|
|
84
|
+
"@temporary-name/standard-server": "1.9.3-alpha.76a5d8c6a7525b4b17df3f9565304645f0922ab3"
|
|
79
85
|
},
|
|
80
86
|
"devDependencies": {
|
|
87
|
+
"@types/supertest": "^6.0.3",
|
|
81
88
|
"@types/ws": "^8.18.1",
|
|
82
89
|
"supertest": "^7.1.4"
|
|
83
90
|
},
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
import 'zod';
|
|
3
|
-
import * as z4 from 'zod/v4/core';
|
|
4
|
-
|
|
5
|
-
const gatingContext = new AsyncLocalStorage();
|
|
6
|
-
function withoutGatedFields(data, schema, isGateEnabled) {
|
|
7
|
-
const filtered = { ...data };
|
|
8
|
-
const gatedFields = getGatedFields(schema);
|
|
9
|
-
for (const [fieldName, gate] of gatedFields) {
|
|
10
|
-
if (!isGateEnabled(gate)) {
|
|
11
|
-
delete filtered[fieldName];
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return filtered;
|
|
15
|
-
}
|
|
16
|
-
function getGatedFields(schema) {
|
|
17
|
-
if (!schema || schema["~standard"].vendor !== "zod") {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
const gatedFields = [];
|
|
21
|
-
const zodDef = schema._zod.def;
|
|
22
|
-
if (zodDef.type === "object") {
|
|
23
|
-
const shape = zodDef.shape;
|
|
24
|
-
for (const fieldName in shape) {
|
|
25
|
-
const fieldSchema = shape[fieldName];
|
|
26
|
-
const gate = z4.globalRegistry.get(fieldSchema)?.gate;
|
|
27
|
-
if (gate) {
|
|
28
|
-
gatedFields.push([fieldName, gate]);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return gatedFields;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { gatingContext as g, withoutGatedFields as w };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
class CompositeStandardHandlerPlugin {
|
|
2
|
-
plugins;
|
|
3
|
-
constructor(plugins = []) {
|
|
4
|
-
this.plugins = [...plugins].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
5
|
-
}
|
|
6
|
-
init(options, router) {
|
|
7
|
-
for (const plugin of this.plugins) {
|
|
8
|
-
plugin.init?.(options, router);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { CompositeStandardHandlerPlugin as C };
|