@withmarfa/client 0.0.74 → 0.0.76
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/index.d.ts +10807 -3926
- package/dist/index.js +8 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,8 +7,7 @@ import createFetchClient, {
|
|
|
7
7
|
// src/generated/byte-bodies.ts
|
|
8
8
|
var BYTE_BODIES = {
|
|
9
9
|
"POST /blobs": "application/octet-stream",
|
|
10
|
-
"PUT /
|
|
11
|
-
"PUT /profile/picture": "application/octet-stream",
|
|
10
|
+
"PUT /profile/avatar": "application/octet-stream",
|
|
12
11
|
"POST /restore": "application/x-tar"
|
|
13
12
|
};
|
|
14
13
|
|
|
@@ -65,6 +64,11 @@ function createClient(options) {
|
|
|
65
64
|
await response.body?.cancel();
|
|
66
65
|
throw new ContractMismatchError(served, response.status);
|
|
67
66
|
};
|
|
67
|
+
const describesServer = (request) => {
|
|
68
|
+
if (request.method !== "GET") return false;
|
|
69
|
+
const path = request.url.slice(root.length).split(/[?#]/, 1)[0];
|
|
70
|
+
return path === "" || path === "health";
|
|
71
|
+
};
|
|
68
72
|
const send = async (request) => {
|
|
69
73
|
if (!request.url.startsWith(root)) {
|
|
70
74
|
throw new Error(
|
|
@@ -73,6 +77,8 @@ function createClient(options) {
|
|
|
73
77
|
}
|
|
74
78
|
const headers = new Headers(request.headers);
|
|
75
79
|
headers.set("Authorization", `Bearer ${credential}`);
|
|
80
|
+
if (describesServer(request)) headers.delete(CONTRACT_HEADER);
|
|
81
|
+
else headers.set(CONTRACT_HEADER, expected);
|
|
76
82
|
return hold(
|
|
77
83
|
await fetcher(new Request(request, { headers, redirect: "error" }))
|
|
78
84
|
);
|