@temporary-name/server 1.9.3-alpha.5537ef74244620c125352bc9356d8c0ae804f10d → 1.9.3-alpha.5c041722542bb790586629fc98d4c72d9f6ee65e
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 -3
- 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 -3
- 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 -3
- 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 -3
- package/dist/index.d.mts +46 -139
- package/dist/index.d.ts +46 -139
- package/dist/index.mjs +51 -295
- package/dist/openapi/index.mjs +30 -64
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.Bzrdopnd.d.ts → server.B5czSQQh.d.mts} +114 -71
- package/dist/shared/{server.Bzrdopnd.d.mts → server.B5czSQQh.d.ts} +114 -71
- package/dist/shared/{server.DcfsPloY.mjs → server.BdGbIyq8.mjs} +211 -17
- package/dist/shared/{server.Cp__uvkw.d.mts → server.Bk8Hmx7Z.d.mts} +2 -2
- package/dist/shared/{server.B9i6p26R.d.ts → server.C4l2ZA3m.d.ts} +1 -2
- package/dist/shared/{server.CYRDznXq.d.ts → server.D7UjcuIv.d.ts} +2 -2
- package/dist/shared/{server.BEHw7Eyx.mjs → server.Kxw442A9.mjs} +1 -1
- package/dist/shared/{server.B9VxPdeK.mjs → server.SmOM3Fae.mjs} +58 -89
- package/dist/shared/{server.C-j2WKJz.d.mts → server.TgmlNh8r.d.mts} +1 -2
- package/package.json +10 -10
|
@@ -1,25 +1,46 @@
|
|
|
1
|
-
import { validateORPCError, ValidationError } from '@temporary-name/contract';
|
|
1
|
+
import { isContractProcedure, mergePrefix, mergeErrorMap, enhanceRoute, 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
4
|
import { safeParseAsync } from '@temporary-name/zod';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
function isStartWithMiddlewares(middlewares, compare) {
|
|
7
|
+
if (compare.length > middlewares.length) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
for (let i = 0; i < middlewares.length; i++) {
|
|
11
|
+
if (compare[i] === void 0) {
|
|
12
|
+
return true;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
if (middlewares[i] !== compare[i]) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
14
19
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
20
|
+
function mergeMiddlewares(first, second, options) {
|
|
21
|
+
if (options.dedupeLeading && isStartWithMiddlewares(second, first)) {
|
|
22
|
+
return second;
|
|
23
|
+
}
|
|
24
|
+
return [...first, ...second];
|
|
17
25
|
}
|
|
18
|
-
function
|
|
19
|
-
return
|
|
26
|
+
function addMiddleware(middlewares, addition) {
|
|
27
|
+
return [...middlewares, addition];
|
|
20
28
|
}
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
|
|
30
|
+
class Procedure {
|
|
31
|
+
/**
|
|
32
|
+
* This property holds the defined options.
|
|
33
|
+
*/
|
|
34
|
+
"~orpc";
|
|
35
|
+
constructor(def) {
|
|
36
|
+
this["~orpc"] = def;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function isProcedure(item) {
|
|
40
|
+
if (item instanceof Procedure) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return isContractProcedure(item) && "middlewares" in item["~orpc"] && "handler" in item["~orpc"];
|
|
23
44
|
}
|
|
24
45
|
|
|
25
46
|
function mergeCurrentContext(context, other) {
|
|
@@ -49,6 +70,179 @@ function createORPCErrorConstructorMap(errors) {
|
|
|
49
70
|
return proxy;
|
|
50
71
|
}
|
|
51
72
|
|
|
73
|
+
const HIDDEN_ROUTER_CONTRACT_SYMBOL = Symbol("ORPC_HIDDEN_ROUTER_CONTRACT");
|
|
74
|
+
function setHiddenRouterContract(router, contract) {
|
|
75
|
+
return new Proxy(router, {
|
|
76
|
+
get(target, key) {
|
|
77
|
+
if (key === HIDDEN_ROUTER_CONTRACT_SYMBOL) {
|
|
78
|
+
return contract;
|
|
79
|
+
}
|
|
80
|
+
return Reflect.get(target, key);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function getHiddenRouterContract(router) {
|
|
85
|
+
return router[HIDDEN_ROUTER_CONTRACT_SYMBOL];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function getRouter(router, path) {
|
|
89
|
+
let current = router;
|
|
90
|
+
for (let i = 0; i < path.length; i++) {
|
|
91
|
+
const segment = path[i];
|
|
92
|
+
if (!current) {
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
if (isProcedure(current)) {
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
if (!isLazy(current)) {
|
|
99
|
+
current = current[segment];
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const lazied = current;
|
|
103
|
+
const rest = path.slice(i);
|
|
104
|
+
return lazyInternal(async () => {
|
|
105
|
+
const unwrapped = await unlazy(lazied);
|
|
106
|
+
const next = getRouter(unwrapped.default, rest);
|
|
107
|
+
return unlazy(next);
|
|
108
|
+
}, getLazyMeta(lazied));
|
|
109
|
+
}
|
|
110
|
+
return current;
|
|
111
|
+
}
|
|
112
|
+
function createAccessibleLazyRouter(lazied) {
|
|
113
|
+
const recursive = new Proxy(lazied, {
|
|
114
|
+
get(target, key) {
|
|
115
|
+
if (typeof key !== "string") {
|
|
116
|
+
return Reflect.get(target, key);
|
|
117
|
+
}
|
|
118
|
+
const next = getRouter(lazied, [key]);
|
|
119
|
+
return createAccessibleLazyRouter(next);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return recursive;
|
|
123
|
+
}
|
|
124
|
+
function enhanceRouter(router, options) {
|
|
125
|
+
if (isLazy(router)) {
|
|
126
|
+
const laziedMeta = getLazyMeta(router);
|
|
127
|
+
const enhancedPrefix = laziedMeta?.prefix ? mergePrefix(options.prefix, laziedMeta?.prefix) : options.prefix;
|
|
128
|
+
const enhanced2 = lazyInternal(
|
|
129
|
+
async () => {
|
|
130
|
+
const { default: unlaziedRouter } = await unlazy(router);
|
|
131
|
+
const enhanced3 = enhanceRouter(unlaziedRouter, options);
|
|
132
|
+
return unlazy(enhanced3);
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
...laziedMeta,
|
|
136
|
+
prefix: enhancedPrefix
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
const accessible = createAccessibleLazyRouter(enhanced2);
|
|
140
|
+
return accessible;
|
|
141
|
+
}
|
|
142
|
+
if (isProcedure(router)) {
|
|
143
|
+
const newMiddlewares = mergeMiddlewares(options.middlewares, router["~orpc"].middlewares, {
|
|
144
|
+
dedupeLeading: options.dedupeLeadingMiddlewares
|
|
145
|
+
});
|
|
146
|
+
const newMiddlewareAdded = newMiddlewares.length - router["~orpc"].middlewares.length;
|
|
147
|
+
const enhanced2 = new Procedure({
|
|
148
|
+
...router["~orpc"],
|
|
149
|
+
route: enhanceRoute(router["~orpc"].route, options),
|
|
150
|
+
errorMap: mergeErrorMap(options.errorMap, router["~orpc"].errorMap),
|
|
151
|
+
middlewares: newMiddlewares,
|
|
152
|
+
inputValidationIndex: router["~orpc"].inputValidationIndex + newMiddlewareAdded,
|
|
153
|
+
outputValidationIndex: router["~orpc"].outputValidationIndex + newMiddlewareAdded
|
|
154
|
+
});
|
|
155
|
+
return enhanced2;
|
|
156
|
+
}
|
|
157
|
+
const enhanced = {};
|
|
158
|
+
for (const key in router) {
|
|
159
|
+
enhanced[key] = enhanceRouter(router[key], options);
|
|
160
|
+
}
|
|
161
|
+
return enhanced;
|
|
162
|
+
}
|
|
163
|
+
function traverseContractProcedures(options, callback, lazyOptions = []) {
|
|
164
|
+
let currentRouter = options.router;
|
|
165
|
+
const hiddenContract = getHiddenRouterContract(options.router);
|
|
166
|
+
if (hiddenContract !== void 0) {
|
|
167
|
+
currentRouter = hiddenContract;
|
|
168
|
+
}
|
|
169
|
+
if (isLazy(currentRouter)) {
|
|
170
|
+
lazyOptions.push({
|
|
171
|
+
router: currentRouter,
|
|
172
|
+
path: options.path
|
|
173
|
+
});
|
|
174
|
+
} else if (isContractProcedure(currentRouter)) {
|
|
175
|
+
callback({
|
|
176
|
+
contract: currentRouter,
|
|
177
|
+
path: options.path
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
for (const key in currentRouter) {
|
|
181
|
+
traverseContractProcedures(
|
|
182
|
+
{
|
|
183
|
+
router: currentRouter[key],
|
|
184
|
+
path: [...options.path, key]
|
|
185
|
+
},
|
|
186
|
+
callback,
|
|
187
|
+
lazyOptions
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return lazyOptions;
|
|
192
|
+
}
|
|
193
|
+
async function resolveContractProcedures(options, callback) {
|
|
194
|
+
const pending = [options];
|
|
195
|
+
for (const options2 of pending) {
|
|
196
|
+
const lazyOptions = traverseContractProcedures(options2, callback);
|
|
197
|
+
for (const options3 of lazyOptions) {
|
|
198
|
+
const { default: router } = await unlazy(options3.router);
|
|
199
|
+
pending.push({
|
|
200
|
+
router,
|
|
201
|
+
path: options3.path
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async function unlazyRouter(router) {
|
|
207
|
+
if (isProcedure(router)) {
|
|
208
|
+
return router;
|
|
209
|
+
}
|
|
210
|
+
const unlazied = {};
|
|
211
|
+
for (const key in router) {
|
|
212
|
+
const item = router[key];
|
|
213
|
+
const { default: unlaziedRouter } = await unlazy(item);
|
|
214
|
+
unlazied[key] = await unlazyRouter(unlaziedRouter);
|
|
215
|
+
}
|
|
216
|
+
return unlazied;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
|
|
220
|
+
function lazyInternal(loader, meta = {}) {
|
|
221
|
+
return {
|
|
222
|
+
[LAZY_SYMBOL]: {
|
|
223
|
+
loader,
|
|
224
|
+
meta
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function lazy(prefix, loader) {
|
|
229
|
+
return enhanceRouter(lazyInternal(loader), {
|
|
230
|
+
middlewares: [],
|
|
231
|
+
errorMap: {},
|
|
232
|
+
dedupeLeadingMiddlewares: true,
|
|
233
|
+
prefix
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function isLazy(item) {
|
|
237
|
+
return (typeof item === "object" || typeof item === "function") && item !== null && LAZY_SYMBOL in item;
|
|
238
|
+
}
|
|
239
|
+
function getLazyMeta(lazied) {
|
|
240
|
+
return lazied[LAZY_SYMBOL].meta;
|
|
241
|
+
}
|
|
242
|
+
function unlazy(lazied) {
|
|
243
|
+
return isLazy(lazied) ? lazied[LAZY_SYMBOL].loader() : Promise.resolve({ default: lazied });
|
|
244
|
+
}
|
|
245
|
+
|
|
52
246
|
function middlewareOutputFn(output) {
|
|
53
247
|
return { output, context: {} };
|
|
54
248
|
}
|
|
@@ -110,7 +304,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
110
304
|
};
|
|
111
305
|
}
|
|
112
306
|
async function validateInput(procedure, input) {
|
|
113
|
-
const schema = procedure["~orpc"].inputSchema;
|
|
307
|
+
const schema = procedure["~orpc"].schemas.inputSchema;
|
|
114
308
|
if (!schema) {
|
|
115
309
|
return input;
|
|
116
310
|
}
|
|
@@ -133,7 +327,7 @@ async function validateInput(procedure, input) {
|
|
|
133
327
|
});
|
|
134
328
|
}
|
|
135
329
|
async function validateOutput(procedure, output) {
|
|
136
|
-
const schema = procedure["~orpc"].outputSchema;
|
|
330
|
+
const schema = procedure["~orpc"].schemas.outputSchema;
|
|
137
331
|
if (!schema) {
|
|
138
332
|
return output;
|
|
139
333
|
}
|
|
@@ -199,4 +393,4 @@ async function executeProcedureInternal(procedure, options) {
|
|
|
199
393
|
return next(0, options.context, options.input);
|
|
200
394
|
}
|
|
201
395
|
|
|
202
|
-
export { LAZY_SYMBOL as L,
|
|
396
|
+
export { LAZY_SYMBOL as L, Procedure as P, addMiddleware as a, isLazy as b, createProcedureClient as c, getRouter as d, enhanceRouter as e, createORPCErrorConstructorMap as f, getLazyMeta as g, lazy as h, isProcedure as i, middlewareOutputFn as j, isStartWithMiddlewares as k, lazyInternal as l, mergeCurrentContext as m, mergeMiddlewares as n, getHiddenRouterContract as o, createAccessibleLazyRouter as p, unlazyRouter as q, resolveContractProcedures as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u };
|
|
@@ -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.B5czSQQh.mjs';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.TgmlNh8r.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,
|
|
4
|
+
import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.B5czSQQh.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.B5czSQQh.js';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.C4l2ZA3m.js';
|
|
4
4
|
|
|
5
5
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
6
6
|
context?: T;
|
|
@@ -244,4 +244,4 @@ function getDynamicParams(path) {
|
|
|
244
244
|
})) : void 0;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
export { standardizeHTTPPath as a, deserialize as d, getDynamicParams as g, jsonSerialize as j, serialize as s };
|
|
247
|
+
export { standardizeHTTPPath as a, bracketNotationDeserialize as b, deserialize as d, getDynamicParams as g, jsonSerialize as j, serialize as s };
|
|
@@ -1,67 +1,45 @@
|
|
|
1
|
-
import { isObject, stringifyJSON, isORPCErrorStatus, tryDecodeURIComponent,
|
|
1
|
+
import { isObject, stringifyJSON, isORPCErrorStatus, tryDecodeURIComponent, 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.BdGbIyq8.mjs';
|
|
4
4
|
import { fallbackContractConfig } from '@temporary-name/contract';
|
|
5
|
-
import { d as deserialize, s as serialize, a as standardizeHTTPPath } from './server.
|
|
5
|
+
import { d as deserialize, s as serialize, b as bracketNotationDeserialize, a as standardizeHTTPPath } from './server.Kxw442A9.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
|
-
|
|
9
|
+
async function decode(request, pathParams) {
|
|
10
|
+
const deserializeSearchParams = () => {
|
|
11
|
+
return bracketNotationDeserialize(Array.from(request.url.searchParams.entries()));
|
|
12
|
+
};
|
|
13
|
+
const data = request.method === "GET" ? deserializeSearchParams() : deserialize(await request.body());
|
|
14
|
+
if (data === void 0) {
|
|
15
|
+
return pathParams;
|
|
11
16
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
17
|
-
if (inputStructure === "compact") {
|
|
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;
|
|
29
|
-
}
|
|
30
|
-
const deserializeSearchParams = () => {
|
|
31
|
-
return deserialize(request.url.searchParams);
|
|
17
|
+
if (isObject(data)) {
|
|
18
|
+
return {
|
|
19
|
+
...pathParams,
|
|
20
|
+
...data
|
|
32
21
|
};
|
|
22
|
+
}
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
function encode(output, procedure) {
|
|
26
|
+
const successStatus = fallbackContractConfig(
|
|
27
|
+
"defaultSuccessStatus",
|
|
28
|
+
procedure["~orpc"].route.successStatus
|
|
29
|
+
);
|
|
30
|
+
const outputStructure = fallbackContractConfig(
|
|
31
|
+
"defaultOutputStructure",
|
|
32
|
+
procedure["~orpc"].route.outputStructure
|
|
33
|
+
);
|
|
34
|
+
if (outputStructure === "compact") {
|
|
33
35
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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())
|
|
36
|
+
status: successStatus,
|
|
37
|
+
headers: {},
|
|
38
|
+
body: serialize(output)
|
|
45
39
|
};
|
|
46
40
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"defaultSuccessStatus",
|
|
50
|
-
procedure["~orpc"].route.successStatus
|
|
51
|
-
);
|
|
52
|
-
const outputStructure = fallbackContractConfig(
|
|
53
|
-
"defaultOutputStructure",
|
|
54
|
-
procedure["~orpc"].route.outputStructure
|
|
55
|
-
);
|
|
56
|
-
if (outputStructure === "compact") {
|
|
57
|
-
return {
|
|
58
|
-
status: successStatus,
|
|
59
|
-
headers: {},
|
|
60
|
-
body: serialize(output)
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
if (!this.#isDetailedOutput(output)) {
|
|
64
|
-
throw new Error(`
|
|
41
|
+
if (!isDetailedOutput(output)) {
|
|
42
|
+
throw new Error(`
|
|
65
43
|
Invalid "detailed" output structure:
|
|
66
44
|
\u2022 Expected an object with optional properties:
|
|
67
45
|
- status (number 200-399)
|
|
@@ -72,32 +50,31 @@ class StandardOpenAPICodec {
|
|
|
72
50
|
Actual value:
|
|
73
51
|
${stringifyJSON(output)}
|
|
74
52
|
`);
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
status: output.status ?? successStatus,
|
|
78
|
-
headers: output.headers ?? {},
|
|
79
|
-
body: serialize(output.body)
|
|
80
|
-
};
|
|
81
53
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
54
|
+
return {
|
|
55
|
+
status: output.status ?? successStatus,
|
|
56
|
+
headers: output.headers ?? {},
|
|
57
|
+
body: serialize(output.body)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function encodeError(error) {
|
|
61
|
+
return {
|
|
62
|
+
status: error.status,
|
|
63
|
+
headers: {},
|
|
64
|
+
body: serialize(error.toJSON(), { outputFormat: "plain" })
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function isDetailedOutput(output) {
|
|
68
|
+
if (!isObject(output)) {
|
|
69
|
+
return false;
|
|
88
70
|
}
|
|
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;
|
|
71
|
+
if (output.headers && !isObject(output.headers)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isORPCErrorStatus(output.status))) {
|
|
75
|
+
return false;
|
|
100
76
|
}
|
|
77
|
+
return true;
|
|
101
78
|
}
|
|
102
79
|
|
|
103
80
|
function resolveFriendlyStandardHandleOptions(options) {
|
|
@@ -121,9 +98,6 @@ class StandardOpenAPIMatcher {
|
|
|
121
98
|
pendingRouters = [];
|
|
122
99
|
init(router, path = []) {
|
|
123
100
|
const laziedOptions = traverseContractProcedures({ router, path }, (traverseOptions) => {
|
|
124
|
-
if (!value(true, traverseOptions)) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
101
|
const { path: path2, contract } = traverseOptions;
|
|
128
102
|
const method = fallbackContractConfig("defaultMethod", contract["~orpc"].route.method);
|
|
129
103
|
const httpPath = toRou3Pattern(contract["~orpc"].route.path ?? toHttpPath(path2));
|
|
@@ -204,10 +178,8 @@ class StandardHandler {
|
|
|
204
178
|
clientInterceptors;
|
|
205
179
|
rootInterceptors;
|
|
206
180
|
matcher;
|
|
207
|
-
codec;
|
|
208
181
|
constructor(router, options) {
|
|
209
182
|
this.matcher = new StandardOpenAPIMatcher();
|
|
210
|
-
this.codec = new StandardOpenAPICodec();
|
|
211
183
|
const plugins = new CompositeStandardHandlerPlugin(options.plugins);
|
|
212
184
|
plugins.init(options, router);
|
|
213
185
|
this.interceptors = toArray(options.interceptors);
|
|
@@ -242,10 +214,7 @@ class StandardHandler {
|
|
|
242
214
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
243
215
|
span?.setAttribute("rpc.method", match.path.join("."));
|
|
244
216
|
step = "decode_input";
|
|
245
|
-
let input = await runWithSpan(
|
|
246
|
-
{ name: "decode_input" },
|
|
247
|
-
() => this.codec.decode(request2, match.params, match.procedure)
|
|
248
|
-
);
|
|
217
|
+
let input = await runWithSpan({ name: "decode_input" }, () => decode(request2, match.params));
|
|
249
218
|
step = void 0;
|
|
250
219
|
if (isAsyncIteratorObject(input)) {
|
|
251
220
|
input = asyncIteratorWithSpan(
|
|
@@ -264,7 +233,7 @@ class StandardHandler {
|
|
|
264
233
|
lastEventId: flattenHeader(request2.headers["last-event-id"])
|
|
265
234
|
});
|
|
266
235
|
step = void 0;
|
|
267
|
-
const response =
|
|
236
|
+
const response = encode(output, match.procedure);
|
|
268
237
|
return {
|
|
269
238
|
matched: true,
|
|
270
239
|
response
|
|
@@ -279,7 +248,7 @@ class StandardHandler {
|
|
|
279
248
|
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
280
249
|
cause: e
|
|
281
250
|
}) : toORPCError(e);
|
|
282
|
-
const response =
|
|
251
|
+
const response = encodeError(error);
|
|
283
252
|
return {
|
|
284
253
|
matched: true,
|
|
285
254
|
response
|
|
@@ -290,4 +259,4 @@ class StandardHandler {
|
|
|
290
259
|
}
|
|
291
260
|
}
|
|
292
261
|
|
|
293
|
-
export { CompositeStandardHandlerPlugin as C, StandardHandler as S,
|
|
262
|
+
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,
|
|
4
|
+
import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.B5czSQQh.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
|
}
|
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.5c041722542bb790586629fc98d4c72d9f6ee65e",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -73,15 +73,15 @@
|
|
|
73
73
|
"cookie": "^1.0.2",
|
|
74
74
|
"rou3": "^0.7.7",
|
|
75
75
|
"zod": "^4.1.12",
|
|
76
|
-
"@temporary-name/
|
|
77
|
-
"@temporary-name/
|
|
78
|
-
"@temporary-name/shared": "1.9.3-alpha.
|
|
79
|
-
"@temporary-name/standard-server": "1.9.3-alpha.
|
|
80
|
-
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.
|
|
81
|
-
"@temporary-name/
|
|
82
|
-
"@temporary-name/standard-server-
|
|
83
|
-
"@temporary-name/
|
|
84
|
-
"@temporary-name/zod": "1.9.3-alpha.
|
|
76
|
+
"@temporary-name/interop": "1.9.3-alpha.5c041722542bb790586629fc98d4c72d9f6ee65e",
|
|
77
|
+
"@temporary-name/json-schema": "1.9.3-alpha.5c041722542bb790586629fc98d4c72d9f6ee65e",
|
|
78
|
+
"@temporary-name/shared": "1.9.3-alpha.5c041722542bb790586629fc98d4c72d9f6ee65e",
|
|
79
|
+
"@temporary-name/standard-server": "1.9.3-alpha.5c041722542bb790586629fc98d4c72d9f6ee65e",
|
|
80
|
+
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.5c041722542bb790586629fc98d4c72d9f6ee65e",
|
|
81
|
+
"@temporary-name/contract": "1.9.3-alpha.5c041722542bb790586629fc98d4c72d9f6ee65e",
|
|
82
|
+
"@temporary-name/standard-server-fetch": "1.9.3-alpha.5c041722542bb790586629fc98d4c72d9f6ee65e",
|
|
83
|
+
"@temporary-name/standard-server-node": "1.9.3-alpha.5c041722542bb790586629fc98d4c72d9f6ee65e",
|
|
84
|
+
"@temporary-name/zod": "1.9.3-alpha.5c041722542bb790586629fc98d4c72d9f6ee65e"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@types/supertest": "^6.0.3",
|