@prosopo/api 3.5.19 → 3.5.20
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/.turbo/turbo-build$colon$cjs.log +14 -14
- package/.turbo/turbo-build$colon$tsc.log +9 -9
- package/.turbo/turbo-build.log +16 -13
- package/CHANGELOG.md +9 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/api/HttpClientBase.js +68 -81
- package/dist/api/HttpError.js +11 -11
- package/dist/api/ProviderApi.js +304 -430
- package/dist/api/apiClient.js +9 -9
- package/dist/api/index.js +3 -9
- package/dist/cjs/api/HttpClientBase.cjs +69 -81
- package/dist/cjs/api/HttpError.cjs +11 -11
- package/dist/cjs/api/ProviderApi.cjs +305 -430
- package/dist/cjs/api/apiClient.cjs +10 -10
- package/dist/cjs/api/index.cjs +9 -11
- package/dist/cjs/index.cjs +9 -11
- package/dist/index.js +4 -10
- package/package.json +6 -6
package/dist/api/apiClient.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { HttpClientBase } from "./HttpClientBase.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
export {
|
|
10
|
-
ApiClient
|
|
2
|
+
//#region src/api/apiClient.ts
|
|
3
|
+
var ApiClient = class extends HttpClientBase {
|
|
4
|
+
constructor(baseUrl, account) {
|
|
5
|
+
const baseUrlWithProtocol = !baseUrl.startsWith("http") ? `https://${baseUrl}` : baseUrl;
|
|
6
|
+
super(baseUrlWithProtocol);
|
|
7
|
+
this.account = account;
|
|
8
|
+
}
|
|
11
9
|
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { ApiClient };
|
package/dist/api/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { HttpClientBase } from "./HttpClientBase.js";
|
|
2
1
|
import { HttpError } from "./HttpError.js";
|
|
3
|
-
import {
|
|
2
|
+
import { HttpClientBase } from "./HttpClientBase.js";
|
|
4
3
|
import { ApiClient } from "./apiClient.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
HttpClientBase,
|
|
8
|
-
HttpError,
|
|
9
|
-
default2 as ProviderApi,
|
|
10
|
-
VERIFY_FORWARDED_HEADER
|
|
11
|
-
};
|
|
4
|
+
import ProviderApi, { VERIFY_FORWARDED_HEADER } from "./ProviderApi.js";
|
|
5
|
+
export { ApiClient, HttpClientBase, HttpError, ProviderApi, VERIFY_FORWARDED_HEADER };
|
|
@@ -1,83 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
errorHandler(error) {
|
|
74
|
-
if (error instanceof HttpError.HttpError) {
|
|
75
|
-
console.error("HTTP error:", error);
|
|
76
|
-
} else {
|
|
77
|
-
console.error("API request error:", error);
|
|
78
|
-
}
|
|
79
|
-
return Promise.reject(error);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
1
|
+
const require_HttpError = require("./HttpError.cjs");
|
|
2
|
+
//#region src/api/HttpClientBase.ts
|
|
3
|
+
var HttpClientBase = class {
|
|
4
|
+
constructor(baseURL, prefix = "") {
|
|
5
|
+
this.baseURL = baseURL + prefix;
|
|
6
|
+
}
|
|
7
|
+
async fetch(input, init) {
|
|
8
|
+
try {
|
|
9
|
+
const response = await fetch(this.baseURL + input, init);
|
|
10
|
+
if (!response.ok && response.status !== 400 && !response.headers.get("content-type")?.includes("application/json")) throw new require_HttpError.HttpError(response.status, response.statusText, response.url);
|
|
11
|
+
return this.responseHandler(response);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
return this.errorHandler(error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async post(input, body, init) {
|
|
17
|
+
const headers = {
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
...init?.headers || {}
|
|
20
|
+
};
|
|
21
|
+
try {
|
|
22
|
+
const response = await fetch(this.baseURL + input, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
body: JSON.stringify(body),
|
|
25
|
+
...init,
|
|
26
|
+
headers
|
|
27
|
+
});
|
|
28
|
+
if (!response.ok && response.status !== 400 && !response.headers.get("content-type")?.includes("application/json")) throw new require_HttpError.HttpError(response.status, response.statusText, response.url);
|
|
29
|
+
return this.responseHandler(response);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return this.errorHandler(error);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async postWithHeaders(input, body, init) {
|
|
35
|
+
const headers = {
|
|
36
|
+
"Content-Type": "application/json",
|
|
37
|
+
...init?.headers || {}
|
|
38
|
+
};
|
|
39
|
+
try {
|
|
40
|
+
const response = await fetch(this.baseURL + input, {
|
|
41
|
+
method: "POST",
|
|
42
|
+
body: JSON.stringify(body),
|
|
43
|
+
...init,
|
|
44
|
+
headers
|
|
45
|
+
});
|
|
46
|
+
if (!response.ok && response.status !== 400 && !response.headers.get("content-type")?.includes("application/json")) throw new require_HttpError.HttpError(response.status, response.statusText, response.url);
|
|
47
|
+
return {
|
|
48
|
+
data: await this.responseHandler(response),
|
|
49
|
+
headers: response.headers
|
|
50
|
+
};
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return this.errorHandler(error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async responseHandler(response) {
|
|
56
|
+
try {
|
|
57
|
+
return await response.json();
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error("Error parsing JSON:", error);
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
errorHandler(error) {
|
|
64
|
+
if (error instanceof require_HttpError.HttpError) console.error("HTTP error:", error);
|
|
65
|
+
else console.error("API request error:", error);
|
|
66
|
+
return Promise.reject(error);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
82
70
|
exports.HttpClientBase = HttpClientBase;
|
|
83
71
|
exports.default = HttpClientBase;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
//#region src/api/HttpError.ts
|
|
2
|
+
var HttpError = class extends Error {
|
|
3
|
+
constructor(status, statusText, url) {
|
|
4
|
+
super(`HTTP error! status: ${status} (${statusText}) for URL: ${url}`);
|
|
5
|
+
this.status = status;
|
|
6
|
+
this.statusText = statusText;
|
|
7
|
+
this.url = url;
|
|
8
|
+
this.name = "HttpError";
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
12
|
exports.HttpError = HttpError;
|