@orpc/client 0.0.0-next.568a5ad → 0.0.0-next.56e31fa
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +12 -8
- package/package.json +6 -6
package/dist/index.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
// src/procedure.ts
|
2
|
-
import {
|
3
|
-
import { trim } from "@orpc/shared";
|
2
|
+
import { ORPC_PROTOCOL_HEADER, ORPC_PROTOCOL_VALUE, trim } from "@orpc/shared";
|
4
3
|
import { ORPCError } from "@orpc/shared/error";
|
5
4
|
import { ORPCDeserializer, ORPCSerializer } from "@orpc/transformer";
|
6
5
|
var serializer = new ORPCSerializer();
|
@@ -10,17 +9,22 @@ function createProcedureClient(options) {
|
|
10
9
|
const [input, callerOptions] = args;
|
11
10
|
const fetch_ = options.fetch ?? fetch;
|
12
11
|
const url = `${trim(options.baseURL, "/")}/${options.path.map(encodeURIComponent).join("/")}`;
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
const headers = new Headers({
|
13
|
+
[ORPC_PROTOCOL_HEADER]: ORPC_PROTOCOL_VALUE
|
14
|
+
});
|
15
|
+
let customHeaders = await options.headers?.(input);
|
16
|
+
customHeaders = customHeaders instanceof Headers ? customHeaders : new Headers(customHeaders);
|
17
|
+
for (const [key, value] of customHeaders.entries()) {
|
18
|
+
headers.append(key, value);
|
19
|
+
}
|
20
|
+
const serialized = serializer.serialize(input);
|
21
|
+
for (const [key, value] of serialized.headers.entries()) {
|
17
22
|
headers.append(key, value);
|
18
23
|
}
|
19
|
-
headers.set(ORPC_HEADER, ORPC_HEADER_VALUE);
|
20
24
|
const response = await fetch_(url, {
|
21
25
|
method: "POST",
|
22
26
|
headers,
|
23
|
-
body,
|
27
|
+
body: serialized.body,
|
24
28
|
signal: callerOptions?.signal
|
25
29
|
});
|
26
30
|
const json = await (async () => {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/client",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.56e31fa",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -29,16 +29,16 @@
|
|
29
29
|
"dist"
|
30
30
|
],
|
31
31
|
"peerDependencies": {
|
32
|
-
"@orpc/contract": "0.0.0-next.
|
33
|
-
"@orpc/server": "0.0.0-next.
|
32
|
+
"@orpc/contract": "0.0.0-next.56e31fa",
|
33
|
+
"@orpc/server": "0.0.0-next.56e31fa"
|
34
34
|
},
|
35
35
|
"dependencies": {
|
36
|
-
"@orpc/shared": "0.0.0-next.
|
37
|
-
"@orpc/transformer": "0.0.0-next.
|
36
|
+
"@orpc/shared": "0.0.0-next.56e31fa",
|
37
|
+
"@orpc/transformer": "0.0.0-next.56e31fa"
|
38
38
|
},
|
39
39
|
"devDependencies": {
|
40
40
|
"zod": "^3.24.1",
|
41
|
-
"@orpc/openapi": "0.0.0-next.
|
41
|
+
"@orpc/openapi": "0.0.0-next.56e31fa"
|
42
42
|
},
|
43
43
|
"scripts": {
|
44
44
|
"build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
|