@temporary-name/server 1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36 → 1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f
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 -4
- package/dist/adapters/aws-lambda/index.d.ts +3 -4
- package/dist/adapters/aws-lambda/index.mjs +3 -3
- package/dist/adapters/fetch/index.d.mts +3 -4
- package/dist/adapters/fetch/index.d.ts +3 -4
- package/dist/adapters/fetch/index.mjs +3 -3
- package/dist/adapters/node/index.d.mts +3 -4
- package/dist/adapters/node/index.d.ts +3 -4
- package/dist/adapters/node/index.mjs +3 -3
- package/dist/adapters/standard/index.d.mts +10 -6
- package/dist/adapters/standard/index.d.ts +10 -6
- package/dist/adapters/standard/index.mjs +4 -4
- package/dist/helpers/index.mjs +3 -29
- package/dist/index.d.mts +73 -126
- package/dist/index.d.ts +73 -126
- package/dist/index.mjs +125 -234
- package/dist/openapi/index.d.mts +4 -4
- package/dist/openapi/index.d.ts +4 -4
- package/dist/openapi/index.mjs +61 -128
- package/dist/plugins/index.d.mts +5 -83
- package/dist/plugins/index.d.ts +5 -83
- package/dist/plugins/index.mjs +17 -189
- package/dist/shared/{server.Bk5r0-2R.d.ts → server.25yUS-xw.d.mts} +3 -4
- package/dist/shared/{server.Bs6ka_UE.d.mts → server.BKwU5-Ea.d.mts} +2 -2
- package/dist/shared/server.C1RJffw4.mjs +30 -0
- package/dist/shared/{server.CbLTWfgn.d.mts → server.Co-zpS8Y.d.ts} +3 -4
- package/dist/shared/{server.BVxcyR6X.mjs → server.DRYRuXpK.mjs} +17 -50
- package/dist/shared/{server.D2UFMrxf.d.ts → server.DV_PWBS2.d.ts} +2 -2
- package/dist/shared/server.DWEp52Gx.mjs +379 -0
- package/dist/shared/{server.BEHw7Eyx.mjs → server.JtIZ8YG7.mjs} +1 -11
- package/dist/shared/server.VtI8pLxV.d.mts +242 -0
- package/dist/shared/server.VtI8pLxV.d.ts +242 -0
- package/package.json +10 -22
- package/dist/shared/server.CZNLCQBm.d.mts +0 -192
- package/dist/shared/server.CZNLCQBm.d.ts +0 -192
- package/dist/shared/server.DcfsPloY.mjs +0 -202
package/dist/plugins/index.mjs
CHANGED
|
@@ -1,119 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { parseBatchRequest, toBatchResponse } from '@temporary-name/standard-server/batch';
|
|
4
|
-
import { toFetchHeaders } from '@temporary-name/standard-server-fetch';
|
|
5
|
-
|
|
6
|
-
class BatchHandlerPlugin {
|
|
7
|
-
maxSize;
|
|
8
|
-
mapRequestItem;
|
|
9
|
-
successStatus;
|
|
10
|
-
headers;
|
|
11
|
-
order = 5e6;
|
|
12
|
-
constructor(options = {}) {
|
|
13
|
-
this.maxSize = options.maxSize ?? 10;
|
|
14
|
-
this.mapRequestItem = options.mapRequestItem ?? ((request, { request: batchRequest }) => ({
|
|
15
|
-
...request,
|
|
16
|
-
headers: {
|
|
17
|
-
...batchRequest.headers,
|
|
18
|
-
...request.headers
|
|
19
|
-
}
|
|
20
|
-
}));
|
|
21
|
-
this.successStatus = options.successStatus ?? 207;
|
|
22
|
-
this.headers = options.headers ?? {};
|
|
23
|
-
}
|
|
24
|
-
init(options) {
|
|
25
|
-
options.rootInterceptors ??= [];
|
|
26
|
-
options.rootInterceptors.unshift(async (options2) => {
|
|
27
|
-
const xHeader = flattenHeader(options2.request.headers["x-orpc-batch"]);
|
|
28
|
-
if (xHeader === void 0) {
|
|
29
|
-
return options2.next();
|
|
30
|
-
}
|
|
31
|
-
let isParsing = false;
|
|
32
|
-
try {
|
|
33
|
-
return await runWithSpan({ name: "handle_batch_request" }, async (span) => {
|
|
34
|
-
const mode = xHeader === "buffered" ? "buffered" : "streaming";
|
|
35
|
-
isParsing = true;
|
|
36
|
-
const parsed = parseBatchRequest({ ...options2.request, body: await options2.request.body() });
|
|
37
|
-
isParsing = false;
|
|
38
|
-
span?.setAttribute("batch.mode", mode);
|
|
39
|
-
span?.setAttribute("batch.size", parsed.length);
|
|
40
|
-
const maxSize = await value(this.maxSize, options2);
|
|
41
|
-
if (parsed.length > maxSize) {
|
|
42
|
-
const message = "Batch request size exceeds the maximum allowed size";
|
|
43
|
-
setSpanError(span, message);
|
|
44
|
-
return {
|
|
45
|
-
matched: true,
|
|
46
|
-
response: {
|
|
47
|
-
status: 413,
|
|
48
|
-
headers: {},
|
|
49
|
-
body: message
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
const responses = parsed.map((request, index) => {
|
|
54
|
-
const mapped = this.mapRequestItem(request, options2);
|
|
55
|
-
return options2.next({ ...options2, request: { ...mapped, body: () => Promise.resolve(mapped.body) } }).then(({ response: response2, matched }) => {
|
|
56
|
-
span?.addEvent(`response.${index}.${matched ? "success" : "not_matched"}`);
|
|
57
|
-
if (matched) {
|
|
58
|
-
if (response2.body instanceof Blob || response2.body instanceof FormData || isAsyncIteratorObject(response2.body)) {
|
|
59
|
-
return {
|
|
60
|
-
index,
|
|
61
|
-
status: 500,
|
|
62
|
-
headers: {},
|
|
63
|
-
body: "Batch responses do not support file/blob, or event-iterator. Please call this procedure separately outside of the batch request."
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
return { ...response2, index };
|
|
67
|
-
}
|
|
68
|
-
return { index, status: 404, headers: {}, body: "No procedure matched" };
|
|
69
|
-
}).catch((err) => {
|
|
70
|
-
Promise.reject(err);
|
|
71
|
-
return { index, status: 500, headers: {}, body: "Internal server error" };
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
await Promise.race(responses);
|
|
75
|
-
const status = await value(this.successStatus, responses, options2);
|
|
76
|
-
const headers = await value(this.headers, responses, options2);
|
|
77
|
-
const promises = [...responses];
|
|
78
|
-
const response = await toBatchResponse({
|
|
79
|
-
status,
|
|
80
|
-
headers,
|
|
81
|
-
mode,
|
|
82
|
-
body: new AsyncIteratorClass(
|
|
83
|
-
async () => {
|
|
84
|
-
const handling = promises.filter((p) => p !== void 0);
|
|
85
|
-
if (handling.length <= 0) {
|
|
86
|
-
return { done: true, value: void 0 };
|
|
87
|
-
}
|
|
88
|
-
const value2 = await Promise.race(handling);
|
|
89
|
-
promises[value2.index] = void 0;
|
|
90
|
-
return { done: false, value: value2 };
|
|
91
|
-
},
|
|
92
|
-
async () => {
|
|
93
|
-
}
|
|
94
|
-
)
|
|
95
|
-
});
|
|
96
|
-
return {
|
|
97
|
-
matched: true,
|
|
98
|
-
response
|
|
99
|
-
};
|
|
100
|
-
});
|
|
101
|
-
} catch (cause) {
|
|
102
|
-
if (isParsing) {
|
|
103
|
-
return {
|
|
104
|
-
matched: true,
|
|
105
|
-
response: {
|
|
106
|
-
status: 400,
|
|
107
|
-
headers: {},
|
|
108
|
-
body: "Invalid batch request, this could be caused by a malformed request body or a missing header"
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
throw cause;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
1
|
+
import { value, ORPCError } from '@temporary-name/shared';
|
|
2
|
+
import { maybeSetHeader } from '@temporary-name/standard-server';
|
|
117
3
|
|
|
118
4
|
class CORSPlugin {
|
|
119
5
|
options;
|
|
@@ -132,17 +18,13 @@ class CORSPlugin {
|
|
|
132
18
|
options.rootInterceptors ??= [];
|
|
133
19
|
options.rootInterceptors.unshift(async (interceptorOptions) => {
|
|
134
20
|
if (interceptorOptions.request.method === "OPTIONS") {
|
|
135
|
-
const resHeaders =
|
|
21
|
+
const resHeaders = new Headers();
|
|
136
22
|
if (this.options.maxAge !== void 0) {
|
|
137
|
-
resHeaders
|
|
138
|
-
}
|
|
139
|
-
if (this.options.allowMethods?.length) {
|
|
140
|
-
resHeaders["access-control-allow-methods"] = flattenHeader(this.options.allowMethods);
|
|
141
|
-
}
|
|
142
|
-
const allowHeaders = this.options.allowHeaders ?? interceptorOptions.request.headers["access-control-request-headers"];
|
|
143
|
-
if (typeof allowHeaders === "string" || allowHeaders?.length) {
|
|
144
|
-
resHeaders["access-control-allow-headers"] = flattenHeader(allowHeaders);
|
|
23
|
+
resHeaders.set("access-control-max-age", this.options.maxAge.toString());
|
|
145
24
|
}
|
|
25
|
+
maybeSetHeader(resHeaders, "access-control-allow-methods", this.options.allowMethods);
|
|
26
|
+
const allowHeaders = this.options.allowHeaders ?? interceptorOptions.request.headers.get("access-control-request-headers");
|
|
27
|
+
maybeSetHeader(resHeaders, "access-control-allow-headers", allowHeaders);
|
|
146
28
|
return {
|
|
147
29
|
matched: true,
|
|
148
30
|
response: {
|
|
@@ -159,87 +41,33 @@ class CORSPlugin {
|
|
|
159
41
|
if (!result.matched) {
|
|
160
42
|
return result;
|
|
161
43
|
}
|
|
162
|
-
const origin =
|
|
44
|
+
const origin = interceptorOptions.request.headers.get("origin") ?? "";
|
|
163
45
|
const allowedOrigin = await value(this.options.origin, origin, interceptorOptions);
|
|
164
46
|
const allowedOriginArr = Array.isArray(allowedOrigin) ? allowedOrigin : [allowedOrigin];
|
|
165
47
|
if (allowedOriginArr.includes("*")) {
|
|
166
|
-
result.response.headers
|
|
48
|
+
result.response.headers.set("access-control-allow-origin", "*");
|
|
167
49
|
} else {
|
|
168
50
|
if (allowedOriginArr.includes(origin)) {
|
|
169
|
-
result.response.headers
|
|
51
|
+
result.response.headers.set("access-control-allow-origin", origin);
|
|
170
52
|
}
|
|
171
|
-
result.response.headers.vary
|
|
53
|
+
result.response.headers.set("vary", interceptorOptions.request.headers.get("vary") ?? "origin");
|
|
172
54
|
}
|
|
173
55
|
const allowedTimingOrigin = await value(this.options.timingOrigin, origin, interceptorOptions);
|
|
174
56
|
const allowedTimingOriginArr = Array.isArray(allowedTimingOrigin) ? allowedTimingOrigin : [allowedTimingOrigin];
|
|
175
57
|
if (allowedTimingOriginArr.includes("*")) {
|
|
176
|
-
result.response.headers
|
|
58
|
+
result.response.headers.set("timing-allow-origin", "*");
|
|
177
59
|
} else if (allowedTimingOriginArr.includes(origin)) {
|
|
178
|
-
result.response.headers
|
|
60
|
+
result.response.headers.set("timing-allow-origin", origin);
|
|
179
61
|
}
|
|
180
62
|
if (this.options.credentials) {
|
|
181
|
-
result.response.headers
|
|
182
|
-
}
|
|
183
|
-
if (this.options.exposeHeaders?.length) {
|
|
184
|
-
result.response.headers["access-control-expose-headers"] = flattenHeader(this.options.exposeHeaders);
|
|
63
|
+
result.response.headers.set("access-control-allow-credentials", "true");
|
|
185
64
|
}
|
|
65
|
+
maybeSetHeader(result.response.headers, "access-control-expose-headers", this.options.exposeHeaders);
|
|
186
66
|
return result;
|
|
187
67
|
});
|
|
188
68
|
}
|
|
189
69
|
}
|
|
190
70
|
|
|
191
|
-
class RequestHeadersPlugin {
|
|
192
|
-
init(options) {
|
|
193
|
-
options.rootInterceptors ??= [];
|
|
194
|
-
options.rootInterceptors.push((interceptorOptions) => {
|
|
195
|
-
const reqHeaders = interceptorOptions.context.reqHeaders ?? toFetchHeaders(interceptorOptions.request.headers);
|
|
196
|
-
return interceptorOptions.next({
|
|
197
|
-
...interceptorOptions,
|
|
198
|
-
context: {
|
|
199
|
-
...interceptorOptions.context,
|
|
200
|
-
reqHeaders
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
class ResponseHeadersPlugin {
|
|
208
|
-
init(options) {
|
|
209
|
-
options.rootInterceptors ??= [];
|
|
210
|
-
options.rootInterceptors.push(async (interceptorOptions) => {
|
|
211
|
-
const resHeaders = interceptorOptions.context.resHeaders ?? new Headers();
|
|
212
|
-
const result = await interceptorOptions.next({
|
|
213
|
-
...interceptorOptions,
|
|
214
|
-
context: {
|
|
215
|
-
...interceptorOptions.context,
|
|
216
|
-
resHeaders
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
if (!result.matched) {
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
const responseHeaders = clone(result.response.headers);
|
|
223
|
-
for (const [key, value] of resHeaders) {
|
|
224
|
-
if (Array.isArray(responseHeaders[key])) {
|
|
225
|
-
responseHeaders[key].push(value);
|
|
226
|
-
} else if (responseHeaders[key] !== void 0) {
|
|
227
|
-
responseHeaders[key] = [responseHeaders[key], value];
|
|
228
|
-
} else {
|
|
229
|
-
responseHeaders[key] = value;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return {
|
|
233
|
-
...result,
|
|
234
|
-
response: {
|
|
235
|
-
...result.response,
|
|
236
|
-
headers: responseHeaders
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
71
|
const SIMPLE_CSRF_PROTECTION_CONTEXT_SYMBOL = Symbol("SIMPLE_CSRF_PROTECTION_CONTEXT");
|
|
244
72
|
class SimpleCsrfProtectionHandlerPlugin {
|
|
245
73
|
headerName;
|
|
@@ -266,7 +94,7 @@ class SimpleCsrfProtectionHandlerPlugin {
|
|
|
266
94
|
...options2,
|
|
267
95
|
context: {
|
|
268
96
|
...options2.context,
|
|
269
|
-
[SIMPLE_CSRF_PROTECTION_CONTEXT_SYMBOL]: options2.request.headers
|
|
97
|
+
[SIMPLE_CSRF_PROTECTION_CONTEXT_SYMBOL]: options2.request.headers.get(headerName) === headerValue
|
|
270
98
|
}
|
|
271
99
|
});
|
|
272
100
|
});
|
|
@@ -285,4 +113,4 @@ class SimpleCsrfProtectionHandlerPlugin {
|
|
|
285
113
|
}
|
|
286
114
|
}
|
|
287
115
|
|
|
288
|
-
export {
|
|
116
|
+
export { CORSPlugin, SimpleCsrfProtectionHandlerPlugin };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Meta } from '@temporary-name/contract';
|
|
2
|
-
import { HTTPPath, Interceptor } from '@temporary-name/shared';
|
|
3
|
-
import {
|
|
4
|
-
import { C as Context, R as Router, E as ProcedureClientInterceptorOptions } from './server.CZNLCQBm.js';
|
|
2
|
+
import { HTTPPath, StandardLazyRequest, Interceptor, StandardResponse } from '@temporary-name/shared';
|
|
3
|
+
import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.VtI8pLxV.mjs';
|
|
5
4
|
|
|
6
5
|
interface StandardHandlerPlugin<T extends Context> {
|
|
7
6
|
order?: number;
|
|
@@ -41,7 +40,7 @@ interface StandardHandlerOptions<TContext extends Context> {
|
|
|
41
40
|
*
|
|
42
41
|
* Interceptors for procedure client.
|
|
43
42
|
*/
|
|
44
|
-
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext,
|
|
43
|
+
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Meta>, Promise<unknown>>[];
|
|
45
44
|
}
|
|
46
45
|
declare class StandardHandler<T extends Context> {
|
|
47
46
|
private readonly interceptors;
|
|
@@ -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.VtI8pLxV.mjs';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.25yUS-xw.mjs';
|
|
4
4
|
|
|
5
5
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
6
6
|
context?: T;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { parse, serialize } from 'cookie';
|
|
2
|
+
|
|
3
|
+
function setCookie(headers, name, value, options = {}) {
|
|
4
|
+
if (headers === void 0) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const cookieString = serialize(name, value, {
|
|
8
|
+
path: "/",
|
|
9
|
+
...options
|
|
10
|
+
});
|
|
11
|
+
headers.append("Set-Cookie", cookieString);
|
|
12
|
+
}
|
|
13
|
+
function getCookie(headers, name, options = {}) {
|
|
14
|
+
if (headers === void 0) {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
const cookieHeader = headers.get("cookie");
|
|
18
|
+
if (cookieHeader === null) {
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
return parse(cookieHeader, options)[name];
|
|
22
|
+
}
|
|
23
|
+
function deleteCookie(headers, name, options = {}) {
|
|
24
|
+
return setCookie(headers, name, "", {
|
|
25
|
+
...options,
|
|
26
|
+
maxAge: 0
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { deleteCookie as d, getCookie as g, setCookie as s };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Meta } from '@temporary-name/contract';
|
|
2
|
-
import { HTTPPath, Interceptor } from '@temporary-name/shared';
|
|
3
|
-
import {
|
|
4
|
-
import { C as Context, R as Router, E as ProcedureClientInterceptorOptions } from './server.CZNLCQBm.mjs';
|
|
2
|
+
import { HTTPPath, StandardLazyRequest, Interceptor, StandardResponse } from '@temporary-name/shared';
|
|
3
|
+
import { C as Context, R as Router, H as ProcedureClientInterceptorOptions } from './server.VtI8pLxV.js';
|
|
5
4
|
|
|
6
5
|
interface StandardHandlerPlugin<T extends Context> {
|
|
7
6
|
order?: number;
|
|
@@ -41,7 +40,7 @@ interface StandardHandlerOptions<TContext extends Context> {
|
|
|
41
40
|
*
|
|
42
41
|
* Interceptors for procedure client.
|
|
43
42
|
*/
|
|
44
|
-
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext,
|
|
43
|
+
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Meta>, Promise<unknown>>[];
|
|
45
44
|
}
|
|
46
45
|
declare class StandardHandler<T extends Context> {
|
|
47
46
|
private readonly interceptors;
|
|
@@ -1,44 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { d as deserialize, s as serialize, a as standardizeHTTPPath } from './server.BEHw7Eyx.mjs';
|
|
1
|
+
import { stringifyJSON, isObject, isORPCErrorStatus, tryDecodeURIComponent, toHttpPath, toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, ORPCError, toORPCError } from '@temporary-name/shared';
|
|
2
|
+
import { c as createProcedureClient } from './server.DWEp52Gx.mjs';
|
|
3
|
+
import { fallbackContractConfig, standardizeHTTPPath } from '@temporary-name/contract';
|
|
4
|
+
import { d as deserialize, b as bracketNotationDeserialize, s as serialize } from './server.JtIZ8YG7.mjs';
|
|
6
5
|
import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@temporary-name/server';
|
|
7
6
|
import { createRouter, addRoute, findRoute } from 'rou3';
|
|
8
7
|
|
|
9
|
-
async function decode(request,
|
|
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;
|
|
18
|
-
}
|
|
19
|
-
if (isObject(data)) {
|
|
20
|
-
return {
|
|
21
|
-
...params,
|
|
22
|
-
...data
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
const deserializeSearchParams = () => {
|
|
28
|
-
return deserialize(request.url.searchParams);
|
|
29
|
-
};
|
|
8
|
+
async function decode(request, pathParams) {
|
|
30
9
|
return {
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
},
|
|
10
|
+
path: pathParams ?? {},
|
|
11
|
+
query: bracketNotationDeserialize(Array.from(request.url.searchParams.entries())),
|
|
40
12
|
headers: request.headers,
|
|
41
|
-
body: deserialize(await request.body())
|
|
13
|
+
body: deserialize(await request.body()) ?? {}
|
|
42
14
|
};
|
|
43
15
|
}
|
|
44
16
|
function encode(output, procedure) {
|
|
@@ -53,7 +25,7 @@ function encode(output, procedure) {
|
|
|
53
25
|
if (outputStructure === "compact") {
|
|
54
26
|
return {
|
|
55
27
|
status: successStatus,
|
|
56
|
-
headers:
|
|
28
|
+
headers: new Headers(),
|
|
57
29
|
body: serialize(output)
|
|
58
30
|
};
|
|
59
31
|
}
|
|
@@ -72,14 +44,14 @@ function encode(output, procedure) {
|
|
|
72
44
|
}
|
|
73
45
|
return {
|
|
74
46
|
status: output.status ?? successStatus,
|
|
75
|
-
headers: output.headers ??
|
|
47
|
+
headers: output.headers ?? new Headers(),
|
|
76
48
|
body: serialize(output.body)
|
|
77
49
|
};
|
|
78
50
|
}
|
|
79
51
|
function encodeError(error) {
|
|
80
52
|
return {
|
|
81
53
|
status: error.status,
|
|
82
|
-
headers:
|
|
54
|
+
headers: new Headers(),
|
|
83
55
|
body: serialize(error.toJSON(), { outputFormat: "plain" })
|
|
84
56
|
};
|
|
85
57
|
}
|
|
@@ -117,9 +89,6 @@ class StandardOpenAPIMatcher {
|
|
|
117
89
|
pendingRouters = [];
|
|
118
90
|
init(router, path = []) {
|
|
119
91
|
const laziedOptions = traverseContractProcedures({ router, path }, (traverseOptions) => {
|
|
120
|
-
if (!value(true, traverseOptions)) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
92
|
const { path: path2, contract } = traverseOptions;
|
|
124
93
|
const method = fallbackContractConfig("defaultMethod", contract["~orpc"].route.method);
|
|
125
94
|
const httpPath = toRou3Pattern(contract["~orpc"].route.path ?? toHttpPath(path2));
|
|
@@ -236,15 +205,12 @@ class StandardHandler {
|
|
|
236
205
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
237
206
|
span?.setAttribute("rpc.method", match.path.join("."));
|
|
238
207
|
step = "decode_input";
|
|
239
|
-
|
|
240
|
-
{ name: "decode_input" },
|
|
241
|
-
() => decode(request2, match.params, match.procedure)
|
|
242
|
-
);
|
|
208
|
+
const input = await runWithSpan({ name: "decode_input" }, () => decode(request2, match.params));
|
|
243
209
|
step = void 0;
|
|
244
|
-
if (isAsyncIteratorObject(input)) {
|
|
245
|
-
input = asyncIteratorWithSpan(
|
|
210
|
+
if (isAsyncIteratorObject(input.body)) {
|
|
211
|
+
input.body = asyncIteratorWithSpan(
|
|
246
212
|
{ name: "consume_event_iterator_input", signal: request2.signal },
|
|
247
|
-
input
|
|
213
|
+
input.body
|
|
248
214
|
);
|
|
249
215
|
}
|
|
250
216
|
const client = createProcedureClient(match.procedure, {
|
|
@@ -254,8 +220,9 @@ class StandardHandler {
|
|
|
254
220
|
});
|
|
255
221
|
step = "call_procedure";
|
|
256
222
|
const output = await client(input, {
|
|
223
|
+
request: request2,
|
|
257
224
|
signal: request2.signal,
|
|
258
|
-
lastEventId:
|
|
225
|
+
lastEventId: request2.headers.get("last-event-id") ?? void 0
|
|
259
226
|
});
|
|
260
227
|
step = void 0;
|
|
261
228
|
const response = encode(output, match.procedure);
|
|
@@ -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.VtI8pLxV.js';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.Co-zpS8Y.js';
|
|
4
4
|
|
|
5
5
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
6
6
|
context?: T;
|