@orpc/server 0.0.0-next.b825e0c → 0.0.0-next.bc9d3dd
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/{chunk-IWQZNJGN.js → chunk-4IQKTPXM.js} +35 -26
- package/dist/{chunk-PYUF3JOC.js → chunk-SD2T3J2Z.js} +28 -17
- package/dist/{chunk-OEPDHGQ4.js → chunk-SV6DBVXJ.js} +11 -12
- package/dist/{chunk-Q2XV45Q4.js → chunk-XFBAK67J.js} +6 -1
- package/dist/fetch.js +4 -6
- package/dist/hono.js +5 -7
- package/dist/index.js +1 -1
- package/dist/next.js +4 -6
- package/dist/node.js +27 -32
- package/dist/plugins.js +1 -1
- package/dist/src/adapters/fetch/utils.d.ts +0 -1
- package/dist/src/adapters/standard/handler.d.ts +5 -1
- package/dist/src/adapters/standard/rpc-serializer.d.ts +1 -1
- package/dist/src/plugins/base.d.ts +3 -1
- package/dist/src/router-client.d.ts +2 -1
- package/dist/standard.js +3 -3
- package/package.json +4 -4
@@ -2,11 +2,11 @@ import {
|
|
2
2
|
RPCCodec,
|
3
3
|
RPCMatcher,
|
4
4
|
StandardHandler
|
5
|
-
} from "./chunk-
|
5
|
+
} from "./chunk-SD2T3J2Z.js";
|
6
6
|
|
7
7
|
// src/adapters/fetch/utils.ts
|
8
8
|
import { once } from "@orpc/shared";
|
9
|
-
import
|
9
|
+
import { contentDisposition, parse as parseContentDisposition } from "@tinyhttp/content-disposition";
|
10
10
|
function fetchHeadersToStandardHeaders(headers) {
|
11
11
|
const standardHeaders = {};
|
12
12
|
for (const [key, value] of headers) {
|
@@ -24,13 +24,15 @@ async function fetchReToStandardBody(re) {
|
|
24
24
|
if (!re.body) {
|
25
25
|
return void 0;
|
26
26
|
}
|
27
|
-
const
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
const contentDisposition2 = re.headers.get("content-disposition");
|
28
|
+
if (contentDisposition2) {
|
29
|
+
const fileName = parseContentDisposition(contentDisposition2).parameters.filename;
|
30
|
+
if (typeof fileName === "string") {
|
31
|
+
const blob2 = await re.blob();
|
32
|
+
return new File([blob2], fileName, {
|
33
|
+
type: blob2.type
|
34
|
+
});
|
35
|
+
}
|
34
36
|
}
|
35
37
|
const contentType = re.headers.get("content-type");
|
36
38
|
if (!contentType || contentType.startsWith("application/json")) {
|
@@ -85,24 +87,32 @@ function standardResponseToFetchHeaders(response) {
|
|
85
87
|
fetchHeaders.append(key, value);
|
86
88
|
}
|
87
89
|
}
|
88
|
-
if (response.body instanceof Blob && !fetchHeaders.has("content-disposition")) {
|
89
|
-
fetchHeaders.set("content-disposition", cd(response.body instanceof File ? response.body.name : "blob"));
|
90
|
-
} else if (!(response.body instanceof Blob) && !(response.body instanceof URLSearchParams) && !(response.body instanceof FormData) && response.body !== void 0 && !fetchHeaders.has("content-type")) {
|
91
|
-
fetchHeaders.set("content-type", "application/json");
|
92
|
-
}
|
93
90
|
return fetchHeaders;
|
94
91
|
}
|
95
|
-
function standardBodyToFetchBody(body) {
|
96
|
-
if (body instanceof Blob || body instanceof FormData || body instanceof URLSearchParams) {
|
97
|
-
return body;
|
98
|
-
}
|
99
|
-
return JSON.stringify(body);
|
100
|
-
}
|
101
92
|
function standardResponseToFetchResponse(response) {
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
93
|
+
const resHeaders = standardResponseToFetchHeaders(response);
|
94
|
+
resHeaders.delete("content-type");
|
95
|
+
resHeaders.delete("content-disposition");
|
96
|
+
if (response.body === void 0) {
|
97
|
+
return new Response(void 0, { headers: resHeaders, status: response.status });
|
98
|
+
}
|
99
|
+
if (response.body instanceof Blob) {
|
100
|
+
resHeaders.set("content-type", response.body.type);
|
101
|
+
resHeaders.set("content-length", response.body.size.toString());
|
102
|
+
resHeaders.set(
|
103
|
+
"content-disposition",
|
104
|
+
contentDisposition(response.body instanceof File ? response.body.name : "blob", { type: "inline" })
|
105
|
+
);
|
106
|
+
return new Response(response.body, { headers: resHeaders, status: response.status });
|
107
|
+
}
|
108
|
+
if (response.body instanceof FormData) {
|
109
|
+
return new Response(response.body, { headers: resHeaders, status: response.status });
|
110
|
+
}
|
111
|
+
if (response.body instanceof URLSearchParams) {
|
112
|
+
return new Response(response.body, { headers: resHeaders, status: response.status });
|
113
|
+
}
|
114
|
+
resHeaders.set("content-type", "application/json");
|
115
|
+
return new Response(JSON.stringify(response.body), { headers: resHeaders, status: response.status });
|
106
116
|
}
|
107
117
|
|
108
118
|
// src/adapters/fetch/rpc-handler.ts
|
@@ -129,8 +139,7 @@ var RPCHandler = class {
|
|
129
139
|
export {
|
130
140
|
fetchReToStandardBody,
|
131
141
|
fetchRequestToStandardRequest,
|
132
|
-
standardBodyToFetchBody,
|
133
142
|
standardResponseToFetchResponse,
|
134
143
|
RPCHandler
|
135
144
|
};
|
136
|
-
//# sourceMappingURL=chunk-
|
145
|
+
//# sourceMappingURL=chunk-4IQKTPXM.js.map
|
@@ -6,10 +6,10 @@ import {
|
|
6
6
|
getRouterChild,
|
7
7
|
isProcedure,
|
8
8
|
unlazy
|
9
|
-
} from "./chunk-
|
9
|
+
} from "./chunk-SV6DBVXJ.js";
|
10
10
|
import {
|
11
11
|
CompositePlugin
|
12
|
-
} from "./chunk-
|
12
|
+
} from "./chunk-XFBAK67J.js";
|
13
13
|
|
14
14
|
// src/adapters/standard/handler.ts
|
15
15
|
import { toORPCError } from "@orpc/contract";
|
@@ -25,30 +25,35 @@ var StandardHandler = class {
|
|
25
25
|
}
|
26
26
|
plugin;
|
27
27
|
handle(request, ...[options]) {
|
28
|
-
const handleOptions = options ?? {};
|
29
|
-
handleOptions.context ??= {};
|
30
28
|
return intercept(
|
31
29
|
this.options.interceptorsRoot ?? [],
|
32
|
-
{
|
33
|
-
|
30
|
+
{
|
31
|
+
request,
|
32
|
+
...options,
|
33
|
+
context: options?.context ?? {}
|
34
|
+
// context is optional only when all fields are optional so we can safely force it to have a context
|
35
|
+
},
|
36
|
+
async (interceptorOptions) => {
|
34
37
|
try {
|
35
38
|
return await intercept(
|
36
39
|
this.options.interceptors ?? [],
|
37
|
-
|
38
|
-
async (
|
39
|
-
const method =
|
40
|
-
const url =
|
41
|
-
const pathname = `/${trim(url.pathname.replace(
|
40
|
+
interceptorOptions,
|
41
|
+
async (interceptorOptions2) => {
|
42
|
+
const method = interceptorOptions2.request.method;
|
43
|
+
const url = interceptorOptions2.request.url;
|
44
|
+
const pathname = `/${trim(url.pathname.replace(interceptorOptions2.prefix ?? "", ""), "/")}`;
|
42
45
|
const match = await this.matcher.match(method, pathname);
|
43
46
|
if (!match) {
|
44
47
|
return { matched: false, response: void 0 };
|
45
48
|
}
|
46
|
-
const
|
47
|
-
context,
|
49
|
+
const clientOptions = {
|
50
|
+
context: interceptorOptions2.context,
|
48
51
|
path: match.path
|
49
|
-
}
|
50
|
-
|
51
|
-
const
|
52
|
+
};
|
53
|
+
this.plugin.beforeCreateProcedureClient(clientOptions, interceptorOptions2);
|
54
|
+
const client = createProcedureClient(match.procedure, clientOptions);
|
55
|
+
const input = await this.codec.decode(request, match.params, match.procedure);
|
56
|
+
const output = await client(input, { signal: request.signal });
|
52
57
|
const response = this.codec.encode(output, match.procedure);
|
53
58
|
return {
|
54
59
|
matched: true,
|
@@ -73,6 +78,9 @@ var StandardHandler = class {
|
|
73
78
|
import { findDeepMatches, isPlainObject, set } from "@orpc/shared";
|
74
79
|
var RPCSerializer = class {
|
75
80
|
serialize(data) {
|
81
|
+
if (data === void 0) {
|
82
|
+
return void 0;
|
83
|
+
}
|
76
84
|
if (data instanceof Blob) {
|
77
85
|
return data;
|
78
86
|
}
|
@@ -90,6 +98,9 @@ var RPCSerializer = class {
|
|
90
98
|
return form;
|
91
99
|
}
|
92
100
|
deserialize(serialized) {
|
101
|
+
if (serialized === void 0) {
|
102
|
+
return void 0;
|
103
|
+
}
|
93
104
|
if (serialized instanceof Blob) {
|
94
105
|
return serialized;
|
95
106
|
}
|
@@ -305,4 +316,4 @@ export {
|
|
305
316
|
RPCCodec,
|
306
317
|
RPCMatcher
|
307
318
|
};
|
308
|
-
//# sourceMappingURL=chunk-
|
319
|
+
//# sourceMappingURL=chunk-SD2T3J2Z.js.map
|
@@ -70,20 +70,19 @@ function createProcedureClient(lazyableProcedure, ...[options]) {
|
|
70
70
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
71
71
|
const context = await value(options?.context ?? {}, callerOptions?.context);
|
72
72
|
const errors = createORPCErrorConstructorMap(procedure["~orpc"].errorMap);
|
73
|
-
const interceptorOptions = {
|
74
|
-
context,
|
75
|
-
input,
|
76
|
-
// input only optional when it undefinable so we can safely cast it
|
77
|
-
errors,
|
78
|
-
path,
|
79
|
-
procedure,
|
80
|
-
signal: callerOptions?.signal
|
81
|
-
};
|
82
73
|
try {
|
83
74
|
return await intercept(
|
84
75
|
options?.interceptors ?? [],
|
85
|
-
|
86
|
-
|
76
|
+
{
|
77
|
+
context,
|
78
|
+
input,
|
79
|
+
// input only optional when it undefinable so we can safely cast it
|
80
|
+
errors,
|
81
|
+
path,
|
82
|
+
procedure,
|
83
|
+
signal: callerOptions?.signal
|
84
|
+
},
|
85
|
+
(interceptorOptions) => executeProcedureInternal(interceptorOptions.procedure, interceptorOptions)
|
87
86
|
);
|
88
87
|
} catch (e) {
|
89
88
|
if (!(e instanceof ORPCError)) {
|
@@ -375,4 +374,4 @@ export {
|
|
375
374
|
convertPathToHttpPath,
|
376
375
|
createContractedProcedure
|
377
376
|
};
|
378
|
-
//# sourceMappingURL=chunk-
|
377
|
+
//# sourceMappingURL=chunk-SV6DBVXJ.js.map
|
@@ -8,6 +8,11 @@ var CompositePlugin = class {
|
|
8
8
|
plugin.init?.(options);
|
9
9
|
}
|
10
10
|
}
|
11
|
+
beforeCreateProcedureClient(clientOptions, interceptorOptions) {
|
12
|
+
for (const plugin of this.plugins) {
|
13
|
+
plugin.beforeCreateProcedureClient?.(clientOptions, interceptorOptions);
|
14
|
+
}
|
15
|
+
}
|
11
16
|
};
|
12
17
|
|
13
18
|
// src/plugins/cors.ts
|
@@ -120,4 +125,4 @@ export {
|
|
120
125
|
CORSPlugin,
|
121
126
|
ResponseHeadersPlugin
|
122
127
|
};
|
123
|
-
//# sourceMappingURL=chunk-
|
128
|
+
//# sourceMappingURL=chunk-XFBAK67J.js.map
|
package/dist/fetch.js
CHANGED
@@ -2,17 +2,15 @@ import {
|
|
2
2
|
RPCHandler,
|
3
3
|
fetchReToStandardBody,
|
4
4
|
fetchRequestToStandardRequest,
|
5
|
-
standardBodyToFetchBody,
|
6
5
|
standardResponseToFetchResponse
|
7
|
-
} from "./chunk-
|
8
|
-
import "./chunk-
|
9
|
-
import "./chunk-
|
10
|
-
import "./chunk-
|
6
|
+
} from "./chunk-4IQKTPXM.js";
|
7
|
+
import "./chunk-SD2T3J2Z.js";
|
8
|
+
import "./chunk-SV6DBVXJ.js";
|
9
|
+
import "./chunk-XFBAK67J.js";
|
11
10
|
export {
|
12
11
|
RPCHandler,
|
13
12
|
fetchReToStandardBody,
|
14
13
|
fetchRequestToStandardRequest,
|
15
|
-
standardBodyToFetchBody,
|
16
14
|
standardResponseToFetchResponse
|
17
15
|
};
|
18
16
|
//# sourceMappingURL=fetch.js.map
|
package/dist/hono.js
CHANGED
@@ -2,12 +2,11 @@ import {
|
|
2
2
|
RPCHandler,
|
3
3
|
fetchReToStandardBody,
|
4
4
|
fetchRequestToStandardRequest,
|
5
|
-
standardBodyToFetchBody,
|
6
5
|
standardResponseToFetchResponse
|
7
|
-
} from "./chunk-
|
8
|
-
import "./chunk-
|
9
|
-
import "./chunk-
|
10
|
-
import "./chunk-
|
6
|
+
} from "./chunk-4IQKTPXM.js";
|
7
|
+
import "./chunk-SD2T3J2Z.js";
|
8
|
+
import "./chunk-SV6DBVXJ.js";
|
9
|
+
import "./chunk-XFBAK67J.js";
|
11
10
|
|
12
11
|
// src/adapters/hono/middleware.ts
|
13
12
|
import { value } from "@orpc/shared";
|
@@ -26,7 +25,7 @@ function createMiddleware(handler, ...[options]) {
|
|
26
25
|
const context = await value(options?.context ?? {}, c);
|
27
26
|
const { matched, response } = await handler.handle(request, { ...options, context });
|
28
27
|
if (matched) {
|
29
|
-
return c.
|
28
|
+
return c.newResponse(response.body, response);
|
30
29
|
}
|
31
30
|
await next();
|
32
31
|
};
|
@@ -36,7 +35,6 @@ export {
|
|
36
35
|
createMiddleware,
|
37
36
|
fetchReToStandardBody,
|
38
37
|
fetchRequestToStandardRequest,
|
39
|
-
standardBodyToFetchBody,
|
40
38
|
standardResponseToFetchResponse
|
41
39
|
};
|
42
40
|
//# sourceMappingURL=hono.js.map
|
package/dist/index.js
CHANGED
@@ -21,7 +21,7 @@ import {
|
|
21
21
|
middlewareOutputFn,
|
22
22
|
setRouterContract,
|
23
23
|
unlazy
|
24
|
-
} from "./chunk-
|
24
|
+
} from "./chunk-SV6DBVXJ.js";
|
25
25
|
|
26
26
|
// src/builder.ts
|
27
27
|
import { mergeErrorMap as mergeErrorMap2, mergeMeta as mergeMeta2, mergePrefix, mergeRoute as mergeRoute2, mergeTags } from "@orpc/contract";
|
package/dist/next.js
CHANGED
@@ -2,12 +2,11 @@ import {
|
|
2
2
|
RPCHandler,
|
3
3
|
fetchReToStandardBody,
|
4
4
|
fetchRequestToStandardRequest,
|
5
|
-
standardBodyToFetchBody,
|
6
5
|
standardResponseToFetchResponse
|
7
|
-
} from "./chunk-
|
8
|
-
import "./chunk-
|
9
|
-
import "./chunk-
|
10
|
-
import "./chunk-
|
6
|
+
} from "./chunk-4IQKTPXM.js";
|
7
|
+
import "./chunk-SD2T3J2Z.js";
|
8
|
+
import "./chunk-SV6DBVXJ.js";
|
9
|
+
import "./chunk-XFBAK67J.js";
|
11
10
|
|
12
11
|
// src/adapters/next/serve.ts
|
13
12
|
import { value } from "@orpc/shared";
|
@@ -33,7 +32,6 @@ export {
|
|
33
32
|
fetchReToStandardBody,
|
34
33
|
fetchRequestToStandardRequest,
|
35
34
|
serve,
|
36
|
-
standardBodyToFetchBody,
|
37
35
|
standardResponseToFetchResponse
|
38
36
|
};
|
39
37
|
//# sourceMappingURL=next.js.map
|
package/dist/node.js
CHANGED
@@ -2,15 +2,15 @@ import {
|
|
2
2
|
RPCCodec,
|
3
3
|
RPCMatcher,
|
4
4
|
StandardHandler
|
5
|
-
} from "./chunk-
|
6
|
-
import "./chunk-
|
7
|
-
import "./chunk-
|
5
|
+
} from "./chunk-SD2T3J2Z.js";
|
6
|
+
import "./chunk-SV6DBVXJ.js";
|
7
|
+
import "./chunk-XFBAK67J.js";
|
8
8
|
|
9
9
|
// src/adapters/node/utils.ts
|
10
10
|
import { Buffer, File } from "node:buffer";
|
11
11
|
import { Readable } from "node:stream";
|
12
12
|
import { once } from "@orpc/shared";
|
13
|
-
import
|
13
|
+
import { contentDisposition, parse as parseContentDisposition } from "@tinyhttp/content-disposition";
|
14
14
|
function nodeHttpToStandardRequest(req, res) {
|
15
15
|
const method = req.method ?? "GET";
|
16
16
|
const protocol = "encrypted" in req.socket && req.socket.encrypted ? "https:" : "http:";
|
@@ -38,20 +38,21 @@ function nodeHttpResponseSendStandardResponse(res, standardResponse) {
|
|
38
38
|
return new Promise((resolve, reject) => {
|
39
39
|
res.on("error", reject);
|
40
40
|
res.on("finish", resolve);
|
41
|
+
const resHeaders = standardResponse.headers;
|
42
|
+
delete resHeaders["content-type"];
|
43
|
+
delete resHeaders["content-disposition"];
|
41
44
|
if (standardResponse.body === void 0) {
|
42
45
|
res.writeHead(standardResponse.status, standardResponse.headers);
|
43
46
|
res.end();
|
44
47
|
return;
|
45
48
|
}
|
46
49
|
if (standardResponse.body instanceof Blob) {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
resHeaders["content-disposition"] = cd(standardResponse.body instanceof File ? standardResponse.body.name : "blob");
|
54
|
-
}
|
50
|
+
resHeaders["content-type"] = standardResponse.body.type;
|
51
|
+
resHeaders["content-length"] = standardResponse.body.size.toString();
|
52
|
+
resHeaders["content-disposition"] = contentDisposition(
|
53
|
+
standardResponse.body instanceof File ? standardResponse.body.name : "blob",
|
54
|
+
{ type: "inline" }
|
55
|
+
);
|
55
56
|
res.writeHead(standardResponse.status, resHeaders);
|
56
57
|
Readable.fromWeb(
|
57
58
|
standardResponse.body.stream()
|
@@ -61,10 +62,8 @@ function nodeHttpResponseSendStandardResponse(res, standardResponse) {
|
|
61
62
|
}
|
62
63
|
if (standardResponse.body instanceof FormData) {
|
63
64
|
const response = new Response(standardResponse.body);
|
64
|
-
|
65
|
-
|
66
|
-
"content-type": response.headers.get("content-type")
|
67
|
-
});
|
65
|
+
resHeaders["content-type"] = response.headers.get("content-type");
|
66
|
+
res.writeHead(standardResponse.status, resHeaders);
|
68
67
|
Readable.fromWeb(
|
69
68
|
response.body
|
70
69
|
// Conflict between types=node and lib=dom so we need to cast it
|
@@ -72,20 +71,14 @@ function nodeHttpResponseSendStandardResponse(res, standardResponse) {
|
|
72
71
|
return;
|
73
72
|
}
|
74
73
|
if (standardResponse.body instanceof URLSearchParams) {
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
});
|
79
|
-
const string2 = standardResponse.body.toString();
|
80
|
-
res.end(string2);
|
74
|
+
resHeaders["content-type"] = "application/x-www-form-urlencoded";
|
75
|
+
res.writeHead(standardResponse.status, resHeaders);
|
76
|
+
res.end(standardResponse.body.toString());
|
81
77
|
return;
|
82
78
|
}
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
});
|
87
|
-
const string = JSON.stringify(standardResponse.body);
|
88
|
-
res.end(string);
|
79
|
+
resHeaders["content-type"] = "application/json";
|
80
|
+
res.writeHead(standardResponse.status, resHeaders);
|
81
|
+
res.end(JSON.stringify(standardResponse.body));
|
89
82
|
});
|
90
83
|
}
|
91
84
|
async function nodeHttpRequestToStandardBody(req) {
|
@@ -93,11 +86,13 @@ async function nodeHttpRequestToStandardBody(req) {
|
|
93
86
|
if (method === "GET" || method === "HEAD") {
|
94
87
|
return void 0;
|
95
88
|
}
|
96
|
-
const
|
97
|
-
const fileName = contentDisposition ? cd.parse(contentDisposition).parameters.filename : void 0;
|
89
|
+
const contentDisposition2 = req.headers["content-disposition"];
|
98
90
|
const contentType = req.headers["content-type"];
|
99
|
-
if (
|
100
|
-
|
91
|
+
if (contentDisposition2) {
|
92
|
+
const fileName = parseContentDisposition(contentDisposition2).parameters.filename;
|
93
|
+
if (typeof fileName === "string") {
|
94
|
+
return await streamToFile(req, fileName, contentType || "application/octet-stream");
|
95
|
+
}
|
101
96
|
}
|
102
97
|
if (!contentType || contentType.startsWith("application/json")) {
|
103
98
|
const text = await streamToString(req);
|
package/dist/plugins.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import type { StandardBody, StandardRequest, StandardResponse } from '../standard';
|
2
2
|
export declare function fetchReToStandardBody(re: Request | Response): Promise<StandardBody>;
|
3
3
|
export declare function fetchRequestToStandardRequest(request: Request): StandardRequest;
|
4
|
-
export declare function standardBodyToFetchBody(body: StandardBody): Blob | FormData | URLSearchParams | string | undefined;
|
5
4
|
export declare function standardResponseToFetchResponse(response: StandardResponse): Response;
|
6
5
|
//# sourceMappingURL=utils.d.ts.map
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import type { HTTPPath } from '@orpc/contract';
|
1
|
+
import type { ErrorMap, HTTPPath, Meta, Schema } from '@orpc/contract';
|
2
2
|
import type { Interceptor } from '@orpc/shared';
|
3
3
|
import type { Context } from '../../context';
|
4
4
|
import type { Plugin } from '../../plugins';
|
5
|
+
import type { CreateProcedureClientOptions } from '../../procedure-client';
|
5
6
|
import type { Router } from '../../router';
|
6
7
|
import type { StandardCodec, StandardMatcher, StandardRequest, StandardResponse } from './types';
|
7
8
|
export type StandardHandleOptions<T extends Context> = {
|
@@ -25,6 +26,9 @@ export type StandardHandleResult = {
|
|
25
26
|
export type StandardHandlerInterceptorOptions<TContext extends Context> = WellStandardHandleOptions<TContext> & {
|
26
27
|
request: StandardRequest;
|
27
28
|
};
|
29
|
+
export type WellCreateProcedureClientOptions<TContext extends Context> = CreateProcedureClientOptions<TContext, Schema, Schema, unknown, ErrorMap, Meta, unknown> & {
|
30
|
+
context: TContext;
|
31
|
+
};
|
28
32
|
export interface StandardHandlerOptions<TContext extends Context> {
|
29
33
|
plugins?: Plugin<TContext>[];
|
30
34
|
/**
|
@@ -3,7 +3,7 @@ export type RPCSerializedJsonMeta = ['bigint' | 'date' | 'nan' | 'undefined' | '
|
|
3
3
|
export type RPCSerialized = {
|
4
4
|
json: unknown;
|
5
5
|
meta: RPCSerializedJsonMeta;
|
6
|
-
} | FormData | Blob;
|
6
|
+
} | FormData | Blob | undefined;
|
7
7
|
export type RPCSerializedFormDataMaps = Segment[][];
|
8
8
|
export declare class RPCSerializer {
|
9
9
|
serialize(data: unknown): RPCSerialized;
|
@@ -1,11 +1,13 @@
|
|
1
|
-
import type { StandardHandlerOptions } from '../adapters/standard';
|
1
|
+
import type { StandardHandlerInterceptorOptions, StandardHandlerOptions, WellCreateProcedureClientOptions } from '../adapters/standard';
|
2
2
|
import type { Context } from '../context';
|
3
3
|
export interface Plugin<TContext extends Context> {
|
4
4
|
init?(options: StandardHandlerOptions<TContext>): void;
|
5
|
+
beforeCreateProcedureClient?(clientOptions: WellCreateProcedureClientOptions<TContext>, interceptorOptions: StandardHandlerInterceptorOptions<TContext>): void;
|
5
6
|
}
|
6
7
|
export declare class CompositePlugin<TContext extends Context> implements Plugin<TContext> {
|
7
8
|
private readonly plugins;
|
8
9
|
constructor(plugins?: Plugin<TContext>[]);
|
9
10
|
init(options: StandardHandlerOptions<TContext>): void;
|
11
|
+
beforeCreateProcedureClient(clientOptions: WellCreateProcedureClientOptions<TContext>, interceptorOptions: StandardHandlerInterceptorOptions<TContext>): void;
|
10
12
|
}
|
11
13
|
//# sourceMappingURL=base.d.ts.map
|
@@ -6,5 +6,6 @@ import type { AnyRouter, Router } from './router';
|
|
6
6
|
export type RouterClient<TRouter extends AnyRouter, TClientContext> = TRouter extends Lazy<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UFuncOutput, UErrorMap> : {
|
7
7
|
[K in keyof TRouter]: TRouter[K] extends AnyRouter ? RouterClient<TRouter[K], TClientContext> : never;
|
8
8
|
};
|
9
|
-
export
|
9
|
+
export type CreateRouterClientRest<TRouter extends AnyRouter, TClientContext> = CreateProcedureClientRest<TRouter extends Router<infer UContext, any> ? UContext : never, undefined, undefined, unknown, ErrorMap, Meta, TClientContext>;
|
10
|
+
export declare function createRouterClient<TRouter extends AnyRouter, TClientContext>(router: TRouter | Lazy<undefined>, ...rest: CreateRouterClientRest<TRouter, TClientContext>): RouterClient<TRouter, TClientContext>;
|
10
11
|
//# sourceMappingURL=router-client.d.ts.map
|
package/dist/standard.js
CHANGED
@@ -4,9 +4,9 @@ import {
|
|
4
4
|
RPCSerializer,
|
5
5
|
StandardHandler,
|
6
6
|
serializeRPCJson
|
7
|
-
} from "./chunk-
|
8
|
-
import "./chunk-
|
9
|
-
import "./chunk-
|
7
|
+
} from "./chunk-SD2T3J2Z.js";
|
8
|
+
import "./chunk-SV6DBVXJ.js";
|
9
|
+
import "./chunk-XFBAK67J.js";
|
10
10
|
export {
|
11
11
|
RPCCodec,
|
12
12
|
RPCMatcher,
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.bc9d3dd",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -63,9 +63,9 @@
|
|
63
63
|
"next": ">=14.0.0"
|
64
64
|
},
|
65
65
|
"dependencies": {
|
66
|
-
"content-disposition": "^
|
67
|
-
"@orpc/contract": "0.0.0-next.
|
68
|
-
"@orpc/shared": "0.0.0-next.
|
66
|
+
"@tinyhttp/content-disposition": "^2.2.2",
|
67
|
+
"@orpc/contract": "0.0.0-next.bc9d3dd",
|
68
|
+
"@orpc/shared": "0.0.0-next.bc9d3dd"
|
69
69
|
},
|
70
70
|
"devDependencies": {
|
71
71
|
"light-my-request": "^6.5.1"
|