@orpc/server 0.0.0-next.b4e6d3a → 0.0.0-next.b825e0c
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-WJ2G7572.js → chunk-IWQZNJGN.js} +26 -35
- package/dist/{chunk-XP6YRLY2.js → chunk-OEPDHGQ4.js} +13 -13
- package/dist/{chunk-GIXDBJGV.js → chunk-PYUF3JOC.js} +19 -30
- package/dist/{chunk-XFBAK67J.js → chunk-Q2XV45Q4.js} +1 -6
- package/dist/fetch.js +6 -4
- package/dist/hono.js +7 -5
- package/dist/index.js +1 -1
- package/dist/next.js +6 -4
- package/dist/node.js +32 -27
- package/dist/plugins.js +1 -1
- package/dist/src/adapters/fetch/rpc-handler.d.ts +2 -3
- package/dist/src/adapters/fetch/types.d.ts +2 -3
- package/dist/src/adapters/fetch/utils.d.ts +1 -0
- package/dist/src/adapters/hono/middleware.d.ts +3 -2
- package/dist/src/adapters/next/serve.d.ts +3 -2
- package/dist/src/adapters/node/rpc-handler.d.ts +2 -3
- package/dist/src/adapters/node/types.d.ts +2 -3
- package/dist/src/adapters/standard/handler.d.ts +6 -9
- package/dist/src/adapters/standard/rpc-serializer.d.ts +1 -1
- package/dist/src/adapters/standard/types.d.ts +1 -1
- package/dist/src/implementer-procedure.d.ts +4 -5
- package/dist/src/middleware.d.ts +4 -3
- package/dist/src/plugins/base.d.ts +1 -3
- package/dist/src/procedure-client.d.ts +6 -5
- package/dist/src/procedure-decorated.d.ts +4 -5
- package/dist/src/procedure-utils.d.ts +2 -3
- package/dist/src/procedure.d.ts +1 -1
- package/dist/src/router-client.d.ts +5 -6
- package/dist/src/router.d.ts +0 -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-PYUF3JOC.js";
|
6
6
|
|
7
7
|
// src/adapters/fetch/utils.ts
|
8
8
|
import { once } from "@orpc/shared";
|
9
|
-
import
|
9
|
+
import cd from "content-disposition";
|
10
10
|
function fetchHeadersToStandardHeaders(headers) {
|
11
11
|
const standardHeaders = {};
|
12
12
|
for (const [key, value] of headers) {
|
@@ -24,15 +24,13 @@ async function fetchReToStandardBody(re) {
|
|
24
24
|
if (!re.body) {
|
25
25
|
return void 0;
|
26
26
|
}
|
27
|
-
const
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
});
|
35
|
-
}
|
27
|
+
const contentDisposition = re.headers.get("content-disposition");
|
28
|
+
const fileName = contentDisposition ? cd.parse(contentDisposition).parameters.filename : void 0;
|
29
|
+
if (fileName) {
|
30
|
+
const blob2 = await re.blob();
|
31
|
+
return new File([blob2], fileName, {
|
32
|
+
type: blob2.type
|
33
|
+
});
|
36
34
|
}
|
37
35
|
const contentType = re.headers.get("content-type");
|
38
36
|
if (!contentType || contentType.startsWith("application/json")) {
|
@@ -87,32 +85,24 @@ function standardResponseToFetchHeaders(response) {
|
|
87
85
|
fetchHeaders.append(key, value);
|
88
86
|
}
|
89
87
|
}
|
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
|
+
}
|
90
93
|
return fetchHeaders;
|
91
94
|
}
|
92
|
-
function
|
93
|
-
|
94
|
-
|
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 });
|
95
|
+
function standardBodyToFetchBody(body) {
|
96
|
+
if (body instanceof Blob || body instanceof FormData || body instanceof URLSearchParams) {
|
97
|
+
return body;
|
110
98
|
}
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
99
|
+
return JSON.stringify(body);
|
100
|
+
}
|
101
|
+
function standardResponseToFetchResponse(response) {
|
102
|
+
return new Response(standardBodyToFetchBody(response.body), {
|
103
|
+
headers: standardResponseToFetchHeaders(response),
|
104
|
+
status: response.status
|
105
|
+
});
|
116
106
|
}
|
117
107
|
|
118
108
|
// src/adapters/fetch/rpc-handler.ts
|
@@ -139,7 +129,8 @@ var RPCHandler = class {
|
|
139
129
|
export {
|
140
130
|
fetchReToStandardBody,
|
141
131
|
fetchRequestToStandardRequest,
|
132
|
+
standardBodyToFetchBody,
|
142
133
|
standardResponseToFetchResponse,
|
143
134
|
RPCHandler
|
144
135
|
};
|
145
|
-
//# sourceMappingURL=chunk-
|
136
|
+
//# sourceMappingURL=chunk-IWQZNJGN.js.map
|
@@ -68,22 +68,22 @@ function createProcedureClient(lazyableProcedure, ...[options]) {
|
|
68
68
|
return async (...[input, callerOptions]) => {
|
69
69
|
const path = options?.path ?? [];
|
70
70
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
71
|
-
const
|
72
|
-
const context = await value(options?.context ?? {}, clientContext);
|
71
|
+
const context = await value(options?.context ?? {}, callerOptions?.context);
|
73
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
|
+
};
|
74
82
|
try {
|
75
83
|
return await intercept(
|
76
84
|
options?.interceptors ?? [],
|
77
|
-
|
78
|
-
|
79
|
-
input,
|
80
|
-
// input only optional when it undefinable so we can safely cast it
|
81
|
-
errors,
|
82
|
-
path,
|
83
|
-
procedure,
|
84
|
-
signal: callerOptions?.signal
|
85
|
-
},
|
86
|
-
(interceptorOptions) => executeProcedureInternal(interceptorOptions.procedure, interceptorOptions)
|
85
|
+
interceptorOptions,
|
86
|
+
(interceptorOptions2) => executeProcedureInternal(interceptorOptions2.procedure, interceptorOptions2)
|
87
87
|
);
|
88
88
|
} catch (e) {
|
89
89
|
if (!(e instanceof ORPCError)) {
|
@@ -375,4 +375,4 @@ export {
|
|
375
375
|
convertPathToHttpPath,
|
376
376
|
createContractedProcedure
|
377
377
|
};
|
378
|
-
//# sourceMappingURL=chunk-
|
378
|
+
//# sourceMappingURL=chunk-OEPDHGQ4.js.map
|
@@ -6,10 +6,10 @@ import {
|
|
6
6
|
getRouterChild,
|
7
7
|
isProcedure,
|
8
8
|
unlazy
|
9
|
-
} from "./chunk-
|
9
|
+
} from "./chunk-OEPDHGQ4.js";
|
10
10
|
import {
|
11
11
|
CompositePlugin
|
12
|
-
} from "./chunk-
|
12
|
+
} from "./chunk-Q2XV45Q4.js";
|
13
13
|
|
14
14
|
// src/adapters/standard/handler.ts
|
15
15
|
import { toORPCError } from "@orpc/contract";
|
@@ -25,35 +25,30 @@ var StandardHandler = class {
|
|
25
25
|
}
|
26
26
|
plugin;
|
27
27
|
handle(request, ...[options]) {
|
28
|
+
const handleOptions = options ?? {};
|
29
|
+
handleOptions.context ??= {};
|
28
30
|
return intercept(
|
29
31
|
this.options.interceptorsRoot ?? [],
|
30
|
-
{
|
31
|
-
|
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) => {
|
32
|
+
{ request, ...handleOptions },
|
33
|
+
async (interceptorRootOptions) => {
|
37
34
|
try {
|
38
35
|
return await intercept(
|
39
36
|
this.options.interceptors ?? [],
|
40
|
-
|
41
|
-
async (
|
42
|
-
const method =
|
43
|
-
const url =
|
44
|
-
const pathname = `/${trim(url.pathname.replace(
|
37
|
+
interceptorRootOptions,
|
38
|
+
async ({ request: request2, context }) => {
|
39
|
+
const method = request2.method;
|
40
|
+
const url = request2.url;
|
41
|
+
const pathname = `/${trim(url.pathname.replace(options?.prefix ?? "", ""), "/")}`;
|
45
42
|
const match = await this.matcher.match(method, pathname);
|
46
43
|
if (!match) {
|
47
44
|
return { matched: false, response: void 0 };
|
48
45
|
}
|
49
|
-
const
|
50
|
-
context
|
46
|
+
const client = createProcedureClient(match.procedure, {
|
47
|
+
context,
|
51
48
|
path: match.path
|
52
|
-
};
|
53
|
-
this.
|
54
|
-
const
|
55
|
-
const input = await this.codec.decode(request, match.params, match.procedure);
|
56
|
-
const output = await client(input, { signal: request.signal });
|
49
|
+
});
|
50
|
+
const input = await this.codec.decode(request2, match.params, match.procedure);
|
51
|
+
const output = await client(input, { signal: request2.signal });
|
57
52
|
const response = this.codec.encode(output, match.procedure);
|
58
53
|
return {
|
59
54
|
matched: true,
|
@@ -75,12 +70,9 @@ var StandardHandler = class {
|
|
75
70
|
};
|
76
71
|
|
77
72
|
// src/adapters/standard/rpc-serializer.ts
|
78
|
-
import { findDeepMatches,
|
73
|
+
import { findDeepMatches, isPlainObject, set } from "@orpc/shared";
|
79
74
|
var RPCSerializer = class {
|
80
75
|
serialize(data) {
|
81
|
-
if (data === void 0) {
|
82
|
-
return void 0;
|
83
|
-
}
|
84
76
|
if (data instanceof Blob) {
|
85
77
|
return data;
|
86
78
|
}
|
@@ -98,9 +90,6 @@ var RPCSerializer = class {
|
|
98
90
|
return form;
|
99
91
|
}
|
100
92
|
deserialize(serialized) {
|
101
|
-
if (serialized === void 0) {
|
102
|
-
return void 0;
|
103
|
-
}
|
104
93
|
if (serialized instanceof Blob) {
|
105
94
|
return serialized;
|
106
95
|
}
|
@@ -137,7 +126,7 @@ function serializeRPCJson(value, segments = [], meta = []) {
|
|
137
126
|
meta.push(["url", segments]);
|
138
127
|
return { json: value.toString(), meta };
|
139
128
|
}
|
140
|
-
if (
|
129
|
+
if (isPlainObject(value)) {
|
141
130
|
const json = {};
|
142
131
|
for (const k in value) {
|
143
132
|
json[k] = serializeRPCJson(value[k], [...segments, k], meta).json;
|
@@ -316,4 +305,4 @@ export {
|
|
316
305
|
RPCCodec,
|
317
306
|
RPCMatcher
|
318
307
|
};
|
319
|
-
//# sourceMappingURL=chunk-
|
308
|
+
//# sourceMappingURL=chunk-PYUF3JOC.js.map
|
@@ -8,11 +8,6 @@ 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
|
-
}
|
16
11
|
};
|
17
12
|
|
18
13
|
// src/plugins/cors.ts
|
@@ -125,4 +120,4 @@ export {
|
|
125
120
|
CORSPlugin,
|
126
121
|
ResponseHeadersPlugin
|
127
122
|
};
|
128
|
-
//# sourceMappingURL=chunk-
|
123
|
+
//# sourceMappingURL=chunk-Q2XV45Q4.js.map
|
package/dist/fetch.js
CHANGED
@@ -2,15 +2,17 @@ import {
|
|
2
2
|
RPCHandler,
|
3
3
|
fetchReToStandardBody,
|
4
4
|
fetchRequestToStandardRequest,
|
5
|
+
standardBodyToFetchBody,
|
5
6
|
standardResponseToFetchResponse
|
6
|
-
} from "./chunk-
|
7
|
-
import "./chunk-
|
8
|
-
import "./chunk-
|
9
|
-
import "./chunk-
|
7
|
+
} from "./chunk-IWQZNJGN.js";
|
8
|
+
import "./chunk-PYUF3JOC.js";
|
9
|
+
import "./chunk-OEPDHGQ4.js";
|
10
|
+
import "./chunk-Q2XV45Q4.js";
|
10
11
|
export {
|
11
12
|
RPCHandler,
|
12
13
|
fetchReToStandardBody,
|
13
14
|
fetchRequestToStandardRequest,
|
15
|
+
standardBodyToFetchBody,
|
14
16
|
standardResponseToFetchResponse
|
15
17
|
};
|
16
18
|
//# sourceMappingURL=fetch.js.map
|
package/dist/hono.js
CHANGED
@@ -2,11 +2,12 @@ import {
|
|
2
2
|
RPCHandler,
|
3
3
|
fetchReToStandardBody,
|
4
4
|
fetchRequestToStandardRequest,
|
5
|
+
standardBodyToFetchBody,
|
5
6
|
standardResponseToFetchResponse
|
6
|
-
} from "./chunk-
|
7
|
-
import "./chunk-
|
8
|
-
import "./chunk-
|
9
|
-
import "./chunk-
|
7
|
+
} from "./chunk-IWQZNJGN.js";
|
8
|
+
import "./chunk-PYUF3JOC.js";
|
9
|
+
import "./chunk-OEPDHGQ4.js";
|
10
|
+
import "./chunk-Q2XV45Q4.js";
|
10
11
|
|
11
12
|
// src/adapters/hono/middleware.ts
|
12
13
|
import { value } from "@orpc/shared";
|
@@ -25,7 +26,7 @@ function createMiddleware(handler, ...[options]) {
|
|
25
26
|
const context = await value(options?.context ?? {}, c);
|
26
27
|
const { matched, response } = await handler.handle(request, { ...options, context });
|
27
28
|
if (matched) {
|
28
|
-
return c.
|
29
|
+
return c.body(response.body, response);
|
29
30
|
}
|
30
31
|
await next();
|
31
32
|
};
|
@@ -35,6 +36,7 @@ export {
|
|
35
36
|
createMiddleware,
|
36
37
|
fetchReToStandardBody,
|
37
38
|
fetchRequestToStandardRequest,
|
39
|
+
standardBodyToFetchBody,
|
38
40
|
standardResponseToFetchResponse
|
39
41
|
};
|
40
42
|
//# 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-OEPDHGQ4.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,11 +2,12 @@ import {
|
|
2
2
|
RPCHandler,
|
3
3
|
fetchReToStandardBody,
|
4
4
|
fetchRequestToStandardRequest,
|
5
|
+
standardBodyToFetchBody,
|
5
6
|
standardResponseToFetchResponse
|
6
|
-
} from "./chunk-
|
7
|
-
import "./chunk-
|
8
|
-
import "./chunk-
|
9
|
-
import "./chunk-
|
7
|
+
} from "./chunk-IWQZNJGN.js";
|
8
|
+
import "./chunk-PYUF3JOC.js";
|
9
|
+
import "./chunk-OEPDHGQ4.js";
|
10
|
+
import "./chunk-Q2XV45Q4.js";
|
10
11
|
|
11
12
|
// src/adapters/next/serve.ts
|
12
13
|
import { value } from "@orpc/shared";
|
@@ -32,6 +33,7 @@ export {
|
|
32
33
|
fetchReToStandardBody,
|
33
34
|
fetchRequestToStandardRequest,
|
34
35
|
serve,
|
36
|
+
standardBodyToFetchBody,
|
35
37
|
standardResponseToFetchResponse
|
36
38
|
};
|
37
39
|
//# 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-PYUF3JOC.js";
|
6
|
+
import "./chunk-OEPDHGQ4.js";
|
7
|
+
import "./chunk-Q2XV45Q4.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 cd from "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,21 +38,20 @@ 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"];
|
44
41
|
if (standardResponse.body === void 0) {
|
45
42
|
res.writeHead(standardResponse.status, standardResponse.headers);
|
46
43
|
res.end();
|
47
44
|
return;
|
48
45
|
}
|
49
46
|
if (standardResponse.body instanceof Blob) {
|
50
|
-
resHeaders
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
)
|
47
|
+
const resHeaders = {
|
48
|
+
...standardResponse.headers,
|
49
|
+
"content-type": standardResponse.body.type,
|
50
|
+
"content-length": standardResponse.body.size.toString()
|
51
|
+
};
|
52
|
+
if (!standardResponse.headers["content-disposition"] && standardResponse.body instanceof Blob) {
|
53
|
+
resHeaders["content-disposition"] = cd(standardResponse.body instanceof File ? standardResponse.body.name : "blob");
|
54
|
+
}
|
56
55
|
res.writeHead(standardResponse.status, resHeaders);
|
57
56
|
Readable.fromWeb(
|
58
57
|
standardResponse.body.stream()
|
@@ -62,8 +61,10 @@ function nodeHttpResponseSendStandardResponse(res, standardResponse) {
|
|
62
61
|
}
|
63
62
|
if (standardResponse.body instanceof FormData) {
|
64
63
|
const response = new Response(standardResponse.body);
|
65
|
-
|
66
|
-
|
64
|
+
res.writeHead(standardResponse.status, {
|
65
|
+
...standardResponse.headers,
|
66
|
+
"content-type": response.headers.get("content-type")
|
67
|
+
});
|
67
68
|
Readable.fromWeb(
|
68
69
|
response.body
|
69
70
|
// Conflict between types=node and lib=dom so we need to cast it
|
@@ -71,14 +72,20 @@ function nodeHttpResponseSendStandardResponse(res, standardResponse) {
|
|
71
72
|
return;
|
72
73
|
}
|
73
74
|
if (standardResponse.body instanceof URLSearchParams) {
|
74
|
-
|
75
|
-
|
76
|
-
|
75
|
+
res.writeHead(standardResponse.status, {
|
76
|
+
...standardResponse.headers,
|
77
|
+
"content-type": "application/x-www-form-urlencoded"
|
78
|
+
});
|
79
|
+
const string2 = standardResponse.body.toString();
|
80
|
+
res.end(string2);
|
77
81
|
return;
|
78
82
|
}
|
79
|
-
|
80
|
-
|
81
|
-
|
83
|
+
res.writeHead(standardResponse.status, {
|
84
|
+
...standardResponse.headers,
|
85
|
+
"content-type": "application/json"
|
86
|
+
});
|
87
|
+
const string = JSON.stringify(standardResponse.body);
|
88
|
+
res.end(string);
|
82
89
|
});
|
83
90
|
}
|
84
91
|
async function nodeHttpRequestToStandardBody(req) {
|
@@ -86,13 +93,11 @@ async function nodeHttpRequestToStandardBody(req) {
|
|
86
93
|
if (method === "GET" || method === "HEAD") {
|
87
94
|
return void 0;
|
88
95
|
}
|
89
|
-
const
|
96
|
+
const contentDisposition = req.headers["content-disposition"];
|
97
|
+
const fileName = contentDisposition ? cd.parse(contentDisposition).parameters.filename : void 0;
|
90
98
|
const contentType = req.headers["content-type"];
|
91
|
-
if (
|
92
|
-
|
93
|
-
if (typeof fileName === "string") {
|
94
|
-
return await streamToFile(req, fileName, contentType || "application/octet-stream");
|
95
|
-
}
|
99
|
+
if (fileName) {
|
100
|
+
return await streamToFile(req, fileName, contentType || "application/octet-stream");
|
96
101
|
}
|
97
102
|
if (!contentType || contentType.startsWith("application/json")) {
|
98
103
|
const text = await streamToString(req);
|
package/dist/plugins.js
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
1
|
import type { Context } from '../../context';
|
3
2
|
import type { Router } from '../../router';
|
4
|
-
import type { RPCHandlerOptions,
|
3
|
+
import type { RPCHandlerOptions, StandardHandleRest } from '../standard';
|
5
4
|
import type { FetchHandler, FetchHandleResult } from './types';
|
6
5
|
export declare class RPCHandler<T extends Context> implements FetchHandler<T> {
|
7
6
|
private readonly standardHandler;
|
8
7
|
constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
|
9
|
-
handle(request: Request, ...rest:
|
8
|
+
handle(request: Request, ...rest: StandardHandleRest<T>): Promise<FetchHandleResult>;
|
10
9
|
}
|
11
10
|
//# sourceMappingURL=rpc-handler.d.ts.map
|
@@ -1,6 +1,5 @@
|
|
1
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
1
|
import type { Context } from '../../context';
|
3
|
-
import type {
|
2
|
+
import type { StandardHandleRest } from '../standard';
|
4
3
|
export type FetchHandleResult = {
|
5
4
|
matched: true;
|
6
5
|
response: Response;
|
@@ -9,6 +8,6 @@ export type FetchHandleResult = {
|
|
9
8
|
response: undefined;
|
10
9
|
};
|
11
10
|
export interface FetchHandler<T extends Context> {
|
12
|
-
handle(request: Request, ...rest:
|
11
|
+
handle(request: Request, ...rest: StandardHandleRest<T>): Promise<FetchHandleResult>;
|
13
12
|
}
|
14
13
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1,5 +1,6 @@
|
|
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;
|
4
5
|
export declare function standardResponseToFetchResponse(response: StandardResponse): Response;
|
5
6
|
//# sourceMappingURL=utils.d.ts.map
|
@@ -1,12 +1,13 @@
|
|
1
|
-
import type { MaybeOptionalOptions, Value } from '@orpc/shared';
|
2
1
|
import type { Context as HonoContext, MiddlewareHandler } from 'hono';
|
3
2
|
import type { Context } from '../../context';
|
4
3
|
import type { FetchHandler } from '../fetch';
|
5
4
|
import type { StandardHandleOptions } from '../standard';
|
5
|
+
import { type Value } from '@orpc/shared';
|
6
6
|
export type CreateMiddlewareOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
7
7
|
context?: Value<T, [HonoContext]>;
|
8
8
|
} : {
|
9
9
|
context: Value<T, [HonoContext]>;
|
10
10
|
});
|
11
|
-
export
|
11
|
+
export type CreateMiddlewareRest<T extends Context> = [options: CreateMiddlewareOptions<T>] | (Record<never, never> extends T ? [] : never);
|
12
|
+
export declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: CreateMiddlewareRest<T>): MiddlewareHandler;
|
12
13
|
//# sourceMappingURL=middleware.d.ts.map
|
@@ -1,13 +1,14 @@
|
|
1
|
-
import type { MaybeOptionalOptions, Value } from '@orpc/shared';
|
2
1
|
import type { NextRequest } from 'next/server';
|
3
2
|
import type { Context } from '../../context';
|
4
3
|
import type { FetchHandler } from '../fetch';
|
5
4
|
import type { StandardHandleOptions } from '../standard';
|
5
|
+
import { type Value } from '@orpc/shared';
|
6
6
|
export type ServeOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
7
7
|
context?: Value<T, [NextRequest]>;
|
8
8
|
} : {
|
9
9
|
context: Value<T, [NextRequest]>;
|
10
10
|
});
|
11
|
+
export type ServeRest<T extends Context> = [options: ServeOptions<T>] | (Record<never, never> extends T ? [] : never);
|
11
12
|
export interface ServeResult {
|
12
13
|
GET(req: NextRequest): Promise<Response>;
|
13
14
|
POST(req: NextRequest): Promise<Response>;
|
@@ -15,5 +16,5 @@ export interface ServeResult {
|
|
15
16
|
PATCH(req: NextRequest): Promise<Response>;
|
16
17
|
DELETE(req: NextRequest): Promise<Response>;
|
17
18
|
}
|
18
|
-
export declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]:
|
19
|
+
export declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]: ServeRest<T>): ServeResult;
|
19
20
|
//# sourceMappingURL=serve.d.ts.map
|
@@ -1,11 +1,10 @@
|
|
1
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
1
|
import type { Context } from '../../context';
|
3
2
|
import type { Router } from '../../router';
|
4
|
-
import type { RPCHandlerOptions,
|
3
|
+
import type { RPCHandlerOptions, StandardHandleRest } from '../standard';
|
5
4
|
import type { NodeHttpHandler, NodeHttpHandleResult, NodeHttpRequest, NodeHttpResponse } from './types';
|
6
5
|
export declare class RPCHandler<T extends Context> implements NodeHttpHandler<T> {
|
7
6
|
private readonly standardHandler;
|
8
7
|
constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
|
9
|
-
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest:
|
8
|
+
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: StandardHandleRest<T>): Promise<NodeHttpHandleResult>;
|
10
9
|
}
|
11
10
|
//# sourceMappingURL=rpc-handler.d.ts.map
|
@@ -1,8 +1,7 @@
|
|
1
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
3
2
|
import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
4
3
|
import type { Context } from '../../context';
|
5
|
-
import type {
|
4
|
+
import type { StandardHandleRest } from '../standard';
|
6
5
|
export type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
|
7
6
|
/**
|
8
7
|
* Replace `req.url` with `req.originalUrl` when `req.originalUrl` is available.
|
@@ -17,6 +16,6 @@ export type NodeHttpHandleResult = {
|
|
17
16
|
matched: false;
|
18
17
|
};
|
19
18
|
export interface NodeHttpHandler<T extends Context> {
|
20
|
-
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest:
|
19
|
+
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: StandardHandleRest<T>): Promise<NodeHttpHandleResult>;
|
21
20
|
}
|
22
21
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1,8 +1,7 @@
|
|
1
|
-
import type {
|
2
|
-
import type { Interceptor
|
1
|
+
import type { HTTPPath } from '@orpc/contract';
|
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';
|
6
5
|
import type { Router } from '../../router';
|
7
6
|
import type { StandardCodec, StandardMatcher, StandardRequest, StandardResponse } from './types';
|
8
7
|
export type StandardHandleOptions<T extends Context> = {
|
@@ -15,6 +14,7 @@ export type StandardHandleOptions<T extends Context> = {
|
|
15
14
|
export type WellStandardHandleOptions<T extends Context> = StandardHandleOptions<T> & {
|
16
15
|
context: T;
|
17
16
|
};
|
17
|
+
export type StandardHandleRest<T extends Context> = [options: StandardHandleOptions<T>] | (Record<never, never> extends T ? [] : never);
|
18
18
|
export type StandardHandleResult = {
|
19
19
|
matched: true;
|
20
20
|
response: StandardResponse;
|
@@ -25,9 +25,6 @@ export type StandardHandleResult = {
|
|
25
25
|
export type StandardHandlerInterceptorOptions<TContext extends Context> = WellStandardHandleOptions<TContext> & {
|
26
26
|
request: StandardRequest;
|
27
27
|
};
|
28
|
-
export type WellCreateProcedureClientOptions<TContext extends Context> = CreateProcedureClientOptions<TContext, Schema, Schema, unknown, ErrorMap, Meta, Record<never, never>> & {
|
29
|
-
context: TContext;
|
30
|
-
};
|
31
28
|
export interface StandardHandlerOptions<TContext extends Context> {
|
32
29
|
plugins?: Plugin<TContext>[];
|
33
30
|
/**
|
@@ -39,12 +36,12 @@ export interface StandardHandlerOptions<TContext extends Context> {
|
|
39
36
|
*/
|
40
37
|
interceptorsRoot?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
|
41
38
|
}
|
42
|
-
export declare class StandardHandler<
|
39
|
+
export declare class StandardHandler<TContext extends Context> {
|
43
40
|
private readonly matcher;
|
44
41
|
private readonly codec;
|
45
42
|
private readonly options;
|
46
43
|
private readonly plugin;
|
47
|
-
constructor(router: Router<
|
48
|
-
handle(request: StandardRequest, ...[options]:
|
44
|
+
constructor(router: Router<TContext, any>, matcher: StandardMatcher, codec: StandardCodec, options?: NoInfer<StandardHandlerOptions<TContext>>);
|
45
|
+
handle(request: StandardRequest, ...[options]: StandardHandleRest<TContext>): Promise<StandardHandleResult>;
|
49
46
|
}
|
50
47
|
//# sourceMappingURL=handler.d.ts.map
|
@@ -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;
|
7
7
|
export type RPCSerializedFormDataMaps = Segment[][];
|
8
8
|
export declare class RPCSerializer {
|
9
9
|
serialize(data: unknown): RPCSerialized;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { HTTPPath, ORPCError } from '@orpc/contract';
|
1
|
+
import type { AbortSignal, HTTPPath, ORPCError } from '@orpc/contract';
|
2
2
|
import type { JsonValue } from '@orpc/shared';
|
3
3
|
import type { AnyProcedure } from '../../procedure';
|
4
4
|
import type { AnyRouter } from '../../router';
|
@@ -1,10 +1,9 @@
|
|
1
|
-
import type {
|
2
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
1
|
+
import type { ClientRest, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
3
2
|
import type { BuilderDef } from './builder';
|
4
3
|
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
5
4
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
6
5
|
import type { Procedure, ProcedureHandler } from './procedure';
|
7
|
-
import type {
|
6
|
+
import type { CreateProcedureClientRest, ProcedureClient } from './procedure-client';
|
8
7
|
import type { DecoratedProcedure } from './procedure-decorated';
|
9
8
|
/**
|
10
9
|
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
@@ -14,11 +13,11 @@ export interface ImplementedProcedure<TInitialContext extends Context, TCurrentC
|
|
14
13
|
/**
|
15
14
|
* Make this procedure callable (works like a function while still being a procedure).
|
16
15
|
*/
|
17
|
-
callable<TClientContext
|
16
|
+
callable<TClientContext>(...rest: CreateProcedureClientRest<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
18
17
|
/**
|
19
18
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
20
19
|
*/
|
21
|
-
actionable<TClientContext
|
20
|
+
actionable<TClientContext>(...rest: CreateProcedureClientRest<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, SchemaInput<TInputSchema>>) => Promise<SchemaOutput<TOutputSchema, THandlerOutput>>);
|
22
21
|
}
|
23
22
|
/**
|
24
23
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
package/dist/src/middleware.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import type { ErrorMap, Meta, ORPCErrorConstructorMap, Schema } from '@orpc/contract';
|
2
|
-
import type {
|
1
|
+
import type { AbortSignal, ErrorMap, Meta, ORPCErrorConstructorMap, Schema } from '@orpc/contract';
|
2
|
+
import type { Promisable } from '@orpc/shared';
|
3
3
|
import type { Context } from './context';
|
4
4
|
import type { Procedure } from './procedure';
|
5
5
|
export type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
@@ -11,8 +11,9 @@ export type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never,
|
|
11
11
|
} : {
|
12
12
|
context: TOutContext;
|
13
13
|
};
|
14
|
+
export type MiddlewareNextFnRest<TOutContext extends Context> = [options: MiddlewareNextFnOptions<TOutContext>] | (Record<never, never> extends TOutContext ? [] : never);
|
14
15
|
export interface MiddlewareNextFn<TInContext extends Context, TOutput> {
|
15
|
-
<U extends Context & Partial<TInContext> = Record<never, never>>(...rest:
|
16
|
+
<U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MiddlewareNextFnRest<U>): MiddlewareResult<U, TOutput>;
|
16
17
|
}
|
17
18
|
export interface MiddlewareOutputFn<TOutput> {
|
18
19
|
(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
@@ -1,13 +1,11 @@
|
|
1
|
-
import type {
|
1
|
+
import type { StandardHandlerOptions } 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;
|
6
5
|
}
|
7
6
|
export declare class CompositePlugin<TContext extends Context> implements Plugin<TContext> {
|
8
7
|
private readonly plugins;
|
9
8
|
constructor(plugins?: Plugin<TContext>[]);
|
10
9
|
init(options: StandardHandlerOptions<TContext>): void;
|
11
|
-
beforeCreateProcedureClient(clientOptions: WellCreateProcedureClientOptions<TContext>, interceptorOptions: StandardHandlerInterceptorOptions<TContext>): void;
|
12
10
|
}
|
13
11
|
//# sourceMappingURL=base.d.ts.map
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import type { Client,
|
2
|
-
import type { Interceptor,
|
1
|
+
import type { Client, ErrorFromErrorMap, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { Interceptor, Value } from '@orpc/shared';
|
3
3
|
import type { Context } from './context';
|
4
4
|
import type { Lazyable } from './lazy';
|
5
5
|
import type { Procedure } from './procedure';
|
6
|
-
export type ProcedureClient<TClientContext
|
6
|
+
export type ProcedureClient<TClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
|
7
7
|
export interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
8
8
|
context: TInitialContext;
|
9
9
|
input: SchemaInput<TInputSchema>;
|
@@ -15,7 +15,7 @@ export interface ProcedureClientInterceptorOptions<TInitialContext extends Conte
|
|
15
15
|
/**
|
16
16
|
* Options for creating a procedure caller with comprehensive type safety
|
17
17
|
*/
|
18
|
-
export type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext
|
18
|
+
export type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext> = {
|
19
19
|
/**
|
20
20
|
* This is helpful for logging and analytics.
|
21
21
|
*/
|
@@ -26,5 +26,6 @@ export type CreateProcedureClientOptions<TInitialContext extends Context, TInput
|
|
26
26
|
} : {
|
27
27
|
context: Value<TInitialContext, [clientContext: TClientContext]>;
|
28
28
|
});
|
29
|
-
export
|
29
|
+
export type CreateProcedureClientRest<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext> = [options: CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>] | (Record<never, never> extends TInitialContext ? [] : never);
|
30
|
+
export declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>>, ...[options]: CreateProcedureClientRest<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
30
31
|
//# sourceMappingURL=procedure-client.d.ts.map
|
@@ -1,8 +1,7 @@
|
|
1
|
-
import type {
|
2
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
1
|
+
import type { ClientRest, ErrorMap, MergedErrorMap, Meta, ORPCErrorConstructorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
3
2
|
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
4
3
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
5
|
-
import type {
|
4
|
+
import type { CreateProcedureClientRest, ProcedureClient } from './procedure-client';
|
6
5
|
import { Procedure } from './procedure';
|
7
6
|
export declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> {
|
8
7
|
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, MergedErrorMap<TErrorMap, U>, TMeta>;
|
@@ -13,10 +12,10 @@ export declare class DecoratedProcedure<TInitialContext extends Context, TCurren
|
|
13
12
|
/**
|
14
13
|
* Make this procedure callable (works like a function while still being a procedure).
|
15
14
|
*/
|
16
|
-
callable<TClientContext
|
15
|
+
callable<TClientContext>(...rest: CreateProcedureClientRest<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
17
16
|
/**
|
18
17
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
19
18
|
*/
|
20
|
-
actionable<TClientContext
|
19
|
+
actionable<TClientContext>(...rest: CreateProcedureClientRest<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, SchemaInput<TInputSchema>>) => Promise<SchemaOutput<TOutputSchema, THandlerOutput>>);
|
21
20
|
}
|
22
21
|
//# sourceMappingURL=procedure-decorated.d.ts.map
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import type { ClientPromiseResult, ErrorFromErrorMap, ErrorMap, Meta, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
3
2
|
import type { Context } from './context';
|
4
3
|
import type { Lazyable } from './lazy';
|
5
4
|
import type { Procedure } from './procedure';
|
6
|
-
import type
|
5
|
+
import { type CreateProcedureClientRest } from './procedure-client';
|
7
6
|
/**
|
8
7
|
* Directly call a procedure without creating a client.
|
9
8
|
*
|
@@ -14,5 +13,5 @@ import type { CreateProcedureClientOptions } from './procedure-client';
|
|
14
13
|
* ```
|
15
14
|
*
|
16
15
|
*/
|
17
|
-
export declare function call<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>>, input: SchemaInput<TInputSchema>, ...rest:
|
16
|
+
export declare function call<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>>, input: SchemaInput<TInputSchema>, ...rest: CreateProcedureClientRest<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, unknown>): ClientPromiseResult<SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
|
18
17
|
//# sourceMappingURL=procedure-utils.d.ts.map
|
package/dist/src/procedure.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { ContractProcedureDef, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
1
|
+
import type { AbortSignal, ContractProcedureDef, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
2
|
import type { Promisable } from '@orpc/shared';
|
3
3
|
import type { Context, TypeInitialContext } from './context';
|
4
4
|
import type { AnyMiddleware } from './middleware';
|
@@ -1,11 +1,10 @@
|
|
1
|
-
import type {
|
2
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
1
|
+
import type { ErrorMap, Meta } from '@orpc/contract';
|
3
2
|
import type { Lazy } from './lazy';
|
4
3
|
import type { Procedure } from './procedure';
|
5
|
-
import type {
|
6
|
-
import type { AnyRouter,
|
7
|
-
export type RouterClient<TRouter extends AnyRouter, TClientContext
|
4
|
+
import type { CreateProcedureClientRest, ProcedureClient } from './procedure-client';
|
5
|
+
import type { AnyRouter, Router } from './router';
|
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> : {
|
8
7
|
[K in keyof TRouter]: TRouter[K] extends AnyRouter ? RouterClient<TRouter[K], TClientContext> : never;
|
9
8
|
};
|
10
|
-
export declare function createRouterClient<TRouter extends AnyRouter, TClientContext
|
9
|
+
export declare function createRouterClient<TRouter extends AnyRouter, TClientContext>(router: TRouter | Lazy<undefined>, ...rest: CreateProcedureClientRest<TRouter extends Router<infer UContext, any> ? UContext : never, undefined, undefined, unknown, ErrorMap, Meta, TClientContext>): RouterClient<TRouter, TClientContext>;
|
11
10
|
//# sourceMappingURL=router-client.d.ts.map
|
package/dist/src/router.d.ts
CHANGED
@@ -9,7 +9,6 @@ export type Router<TInitialContext extends Context, TContract extends AnyContrac
|
|
9
9
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? Router<TInitialContext, TContract[K]> : never;
|
10
10
|
}>;
|
11
11
|
export type AnyRouter = Router<any, any>;
|
12
|
-
export type InferRouterInitialContext<T extends AnyRouter> = T extends Router<infer UInitialContext, any> ? UInitialContext : never;
|
13
12
|
export type InferRouterInputs<T extends AnyRouter> = T extends Lazy<infer U extends AnyRouter> ? InferRouterInputs<U> : T extends Procedure<any, any, infer UInputSchema, any, any, any, any> ? SchemaInput<UInputSchema> : {
|
14
13
|
[K in keyof T]: T[K] extends AnyRouter ? InferRouterInputs<T[K]> : never;
|
15
14
|
};
|
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-PYUF3JOC.js";
|
8
|
+
import "./chunk-OEPDHGQ4.js";
|
9
|
+
import "./chunk-Q2XV45Q4.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.b825e0c",
|
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
|
-
"
|
67
|
-
"@orpc/contract": "0.0.0-next.
|
68
|
-
"@orpc/shared": "0.0.0-next.
|
66
|
+
"content-disposition": "^0.5.4",
|
67
|
+
"@orpc/contract": "0.0.0-next.b825e0c",
|
68
|
+
"@orpc/shared": "0.0.0-next.b825e0c"
|
69
69
|
},
|
70
70
|
"devDependencies": {
|
71
71
|
"light-my-request": "^6.5.1"
|