@temporary-name/server 1.9.3-alpha.4275e976ddda4d8be107c2cfde9899bdea9a337d → 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 +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 +23 -13
- package/dist/adapters/standard/index.d.ts +23 -13
- package/dist/adapters/standard/index.mjs +8 -100
- package/dist/index.d.mts +44 -368
- package/dist/index.d.ts +44 -368
- 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.BEHw7Eyx.mjs +247 -0
- package/dist/shared/server.BVxcyR6X.mjs +287 -0
- package/dist/shared/{server.Btxrgkj5.d.ts → server.Bk5r0-2R.d.ts} +7 -24
- package/dist/shared/server.Bs6ka_UE.d.mts +23 -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.Bo94xDTv.d.mts → server.CbLTWfgn.d.mts} +7 -24
- package/dist/shared/server.D2UFMrxf.d.ts +23 -0
- package/dist/shared/{server.BEQrAa3A.mjs → server.DcfsPloY.mjs} +16 -21
- package/package.json +19 -13
- package/dist/shared/server.D6K9uoPI.mjs +0 -35
- package/dist/shared/server.DZ5BIITo.mjs +0 -9
- package/dist/shared/server.X0YaZxSJ.mjs +0 -13
|
@@ -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,13 @@ 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
|
+
constructor(router: Router<any, T>, options: NoInfer<StandardHandlerOptions<T>>);
|
|
69
52
|
handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
|
|
70
53
|
}
|
|
71
54
|
|
|
72
|
-
export { CompositeStandardHandlerPlugin as C, StandardHandler as
|
|
73
|
-
export type {
|
|
55
|
+
export { CompositeStandardHandlerPlugin as C, StandardHandler as e };
|
|
56
|
+
export type { StandardHandlerInterceptorOptions as S, StandardHandlerPlugin as a, StandardHandlerOptions as b, StandardHandleOptions as c, StandardHandleResult as d };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HTTPPath } from '@temporary-name/shared';
|
|
2
|
+
import { C as Context } from './server.CZNLCQBm.js';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.Bk5r0-2R.js';
|
|
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
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/stainless-api/krusty.git",
|
|
10
10
|
"directory": "packages/server"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
@@ -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,21 +71,22 @@
|
|
|
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
|
|
76
|
-
"@temporary-name/
|
|
77
|
-
"@temporary-name/standard-server-
|
|
78
|
-
"@temporary-name/
|
|
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"
|
|
79
85
|
},
|
|
80
86
|
"devDependencies": {
|
|
87
|
+
"@types/supertest": "^6.0.3",
|
|
81
88
|
"@types/ws": "^8.18.1",
|
|
82
|
-
"supertest": "^7.1.4"
|
|
83
|
-
"type-fest": "^5.0.1"
|
|
89
|
+
"supertest": "^7.1.4"
|
|
84
90
|
},
|
|
85
91
|
"scripts": {
|
|
86
92
|
"build": "unbuild",
|
|
@@ -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 };
|