@unboundcx/sdk 4.0.8 → 4.0.9
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/base.js +22 -0
- package/package.json +1 -1
package/base.js
CHANGED
|
@@ -297,6 +297,17 @@ export class BaseSDK {
|
|
|
297
297
|
return true;
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
// Streaming bodies (Node Readable or Web ReadableStream) — caller is
|
|
301
|
+
// expected to set an explicit content-type header alongside.
|
|
302
|
+
if (
|
|
303
|
+
typeof body === 'object' &&
|
|
304
|
+
body !== null &&
|
|
305
|
+
(typeof body.pipe === 'function' ||
|
|
306
|
+
typeof body.getReader === 'function')
|
|
307
|
+
) {
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
|
|
300
311
|
return false;
|
|
301
312
|
}
|
|
302
313
|
|
|
@@ -353,9 +364,20 @@ export class BaseSDK {
|
|
|
353
364
|
typeof Buffer !== 'undefined' &&
|
|
354
365
|
Buffer.isBuffer &&
|
|
355
366
|
Buffer.isBuffer(body);
|
|
367
|
+
const isStream =
|
|
368
|
+
body &&
|
|
369
|
+
typeof body === 'object' &&
|
|
370
|
+
(typeof body.pipe === 'function' ||
|
|
371
|
+
typeof body.getReader === 'function');
|
|
356
372
|
|
|
357
373
|
if (isFormData || isBuffer) {
|
|
358
374
|
options.body = body;
|
|
375
|
+
} else if (isStream) {
|
|
376
|
+
// Node 18+ native fetch (undici) requires duplex: 'half' for
|
|
377
|
+
// streaming request bodies. Without this the fetch throws
|
|
378
|
+
// synchronously before the first byte is sent.
|
|
379
|
+
options.body = body;
|
|
380
|
+
options.duplex = 'half';
|
|
359
381
|
} else {
|
|
360
382
|
options.body = JSON.stringify(body);
|
|
361
383
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.9",
|
|
4
4
|
"description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|