@memnexus-ai/typescript-sdk 1.39.1 → 1.39.3
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.cjs +36 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -240,41 +240,48 @@ var ExecuteHandler = class extends BaseHandler {
|
|
|
240
240
|
if (request.body && request.method !== "GET") {
|
|
241
241
|
fetchOptions.body = typeof request.body === "string" ? request.body : JSON.stringify(request.body);
|
|
242
242
|
}
|
|
243
|
+
let timeoutId;
|
|
243
244
|
if (request.config.timeoutMs) {
|
|
244
245
|
const controller = new AbortController();
|
|
245
|
-
setTimeout(() => controller.abort(), request.config.timeoutMs);
|
|
246
|
+
timeoutId = setTimeout(() => controller.abort(), request.config.timeoutMs);
|
|
246
247
|
fetchOptions.signal = controller.signal;
|
|
247
248
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
249
|
+
try {
|
|
250
|
+
const response = await fetch(url, fetchOptions);
|
|
251
|
+
const responseHeaders = {};
|
|
252
|
+
response.headers.forEach((value, key) => {
|
|
253
|
+
responseHeaders[key] = value;
|
|
254
|
+
});
|
|
255
|
+
const raw = await response.arrayBuffer();
|
|
256
|
+
let data;
|
|
257
|
+
const contentType = response.headers.get("content-type") || "";
|
|
258
|
+
if (contentType.includes("application/json") && raw.byteLength > 0) {
|
|
259
|
+
const text = new TextDecoder().decode(raw);
|
|
260
|
+
try {
|
|
261
|
+
data = JSON.parse(text);
|
|
262
|
+
} catch {
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const httpResponse = {
|
|
266
|
+
data,
|
|
267
|
+
metadata: {
|
|
268
|
+
status: response.status,
|
|
269
|
+
statusText: response.statusText,
|
|
270
|
+
headers: responseHeaders
|
|
271
|
+
},
|
|
272
|
+
raw
|
|
273
|
+
};
|
|
274
|
+
if (!response.ok) {
|
|
275
|
+
const error2 = new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
276
|
+
error2.response = httpResponse;
|
|
277
|
+
throw error2;
|
|
278
|
+
}
|
|
279
|
+
return httpResponse;
|
|
280
|
+
} finally {
|
|
281
|
+
if (timeoutId) {
|
|
282
|
+
clearTimeout(timeoutId);
|
|
261
283
|
}
|
|
262
284
|
}
|
|
263
|
-
const httpResponse = {
|
|
264
|
-
data,
|
|
265
|
-
metadata: {
|
|
266
|
-
status: response.status,
|
|
267
|
-
statusText: response.statusText,
|
|
268
|
-
headers: responseHeaders
|
|
269
|
-
},
|
|
270
|
-
raw
|
|
271
|
-
};
|
|
272
|
-
if (!response.ok) {
|
|
273
|
-
const error2 = new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
274
|
-
error2.response = httpResponse;
|
|
275
|
-
throw error2;
|
|
276
|
-
}
|
|
277
|
-
return httpResponse;
|
|
278
285
|
}
|
|
279
286
|
};
|
|
280
287
|
var CustomHook = class {
|