shred-api-client 2.3.4 → 2.3.5-rc.1
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.js +28 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ __export(index_exports, {
|
|
|
48
48
|
module.exports = __toCommonJS(index_exports);
|
|
49
49
|
|
|
50
50
|
// src/util/HTTPClient.ts
|
|
51
|
-
var
|
|
51
|
+
var import_axios = __toESM(require("axios"));
|
|
52
52
|
var HOSTS = {
|
|
53
53
|
prod: "https://api.shreditapp.com",
|
|
54
54
|
staging: "https://api.staging.shreditapp.com",
|
|
@@ -73,37 +73,40 @@ var HTTPClient = class {
|
|
|
73
73
|
if (context?.requestId) {
|
|
74
74
|
headers["X-Request-ID"] = context.requestId;
|
|
75
75
|
}
|
|
76
|
-
const fetchOptions = {
|
|
77
|
-
method,
|
|
78
|
-
headers
|
|
79
|
-
};
|
|
80
|
-
if (method !== "GET" && data) {
|
|
81
|
-
fetchOptions.body = useLegacyApi ? new URLSearchParams(data).toString() : JSON.stringify(data);
|
|
82
|
-
}
|
|
83
76
|
try {
|
|
84
|
-
const response = await
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
77
|
+
const response = await import_axios.default.request({
|
|
78
|
+
url,
|
|
79
|
+
method,
|
|
80
|
+
headers,
|
|
81
|
+
data: method !== "GET" && data ? useLegacyApi ? new URLSearchParams(data).toString() : data : void 0,
|
|
82
|
+
transformResponse: [(raw) => raw]
|
|
83
|
+
// evita parse automático para podermos tratar manual
|
|
84
|
+
});
|
|
93
85
|
try {
|
|
94
|
-
return
|
|
86
|
+
return JSON.parse(response.data);
|
|
95
87
|
} catch {
|
|
96
|
-
return
|
|
88
|
+
return response.data;
|
|
97
89
|
}
|
|
98
|
-
} catch (
|
|
90
|
+
} catch (err) {
|
|
91
|
+
const error = err;
|
|
99
92
|
let parsedBody = {};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
if (error.response) {
|
|
94
|
+
try {
|
|
95
|
+
parsedBody = typeof error.response.data === "string" ? JSON.parse(error.response.data) : error.response.data;
|
|
96
|
+
} catch {
|
|
97
|
+
parsedBody = {
|
|
98
|
+
message: error.response.data?.message || error.response.statusText || "Unknown error"
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
throw {
|
|
102
|
+
message: parsedBody.message || "Unexpected error occurred",
|
|
103
|
+
status: error.response.status,
|
|
104
|
+
body: error.response.data,
|
|
105
|
+
original: error
|
|
106
|
+
};
|
|
104
107
|
}
|
|
105
108
|
throw {
|
|
106
|
-
message:
|
|
109
|
+
message: error.message || "Network error",
|
|
107
110
|
original: error
|
|
108
111
|
};
|
|
109
112
|
}
|
|
@@ -2038,20 +2041,4 @@ var core_exports = {};
|
|
|
2038
2041
|
|
|
2039
2042
|
// src/index.ts
|
|
2040
2043
|
var index_default = ShredAPI;
|
|
2041
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
2042
|
-
0 && (module.exports = {
|
|
2043
|
-
Asset,
|
|
2044
|
-
Core,
|
|
2045
|
-
Email,
|
|
2046
|
-
Exceptions,
|
|
2047
|
-
Goal,
|
|
2048
|
-
Note,
|
|
2049
|
-
Notification,
|
|
2050
|
-
Project,
|
|
2051
|
-
Prompt,
|
|
2052
|
-
Subscription,
|
|
2053
|
-
Tenant,
|
|
2054
|
-
Track,
|
|
2055
|
-
User
|
|
2056
|
-
});
|
|
2057
2044
|
//# sourceMappingURL=index.js.map
|