@bagelink/sdk 1.8.41 → 1.8.45
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 +31 -11
- package/dist/index.mjs +31 -11
- package/package.json +1 -1
- package/src/openAPITools/streamClient.ts +39 -13
package/dist/index.cjs
CHANGED
|
@@ -1214,11 +1214,14 @@ function createSSEStream(url, options = {}) {
|
|
|
1214
1214
|
fetch(url, {
|
|
1215
1215
|
method: "GET",
|
|
1216
1216
|
headers: {
|
|
1217
|
-
Accept: "text/event-stream",
|
|
1217
|
+
"Accept": "text/event-stream",
|
|
1218
|
+
"Cache-Control": "no-cache",
|
|
1218
1219
|
...headers
|
|
1219
1220
|
},
|
|
1220
1221
|
credentials: withCredentials ? "include" : "same-origin",
|
|
1221
|
-
signal: controller.signal
|
|
1222
|
+
signal: controller.signal,
|
|
1223
|
+
// Disable keepalive for streaming
|
|
1224
|
+
keepalive: false
|
|
1222
1225
|
}).then(async (response) => {
|
|
1223
1226
|
if (!response.ok) {
|
|
1224
1227
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
@@ -1260,13 +1263,20 @@ function createSSEStream(url, options = {}) {
|
|
|
1260
1263
|
}
|
|
1261
1264
|
}
|
|
1262
1265
|
} catch (error) {
|
|
1263
|
-
if (error
|
|
1264
|
-
|
|
1266
|
+
if (error?.name !== "AbortError") {
|
|
1267
|
+
const errorMessage = error?.message || "Stream connection error";
|
|
1268
|
+
stream.emit("error", new Error(errorMessage));
|
|
1269
|
+
}
|
|
1270
|
+
} finally {
|
|
1271
|
+
try {
|
|
1272
|
+
reader.releaseLock();
|
|
1273
|
+
} catch {
|
|
1265
1274
|
}
|
|
1266
1275
|
}
|
|
1267
1276
|
}).catch((error) => {
|
|
1268
|
-
if (error
|
|
1269
|
-
|
|
1277
|
+
if (error?.name !== "AbortError") {
|
|
1278
|
+
const errorMessage = error?.message || "Failed to establish stream connection";
|
|
1279
|
+
stream.emit("error", new Error(errorMessage));
|
|
1270
1280
|
}
|
|
1271
1281
|
});
|
|
1272
1282
|
return stream;
|
|
@@ -1282,11 +1292,14 @@ function createSSEStreamPost(url, body, options = {}) {
|
|
|
1282
1292
|
headers: {
|
|
1283
1293
|
"Accept": "text/event-stream",
|
|
1284
1294
|
"Content-Type": "application/json",
|
|
1295
|
+
"Cache-Control": "no-cache",
|
|
1285
1296
|
...headers
|
|
1286
1297
|
},
|
|
1287
1298
|
credentials: withCredentials ? "include" : "same-origin",
|
|
1288
1299
|
body: JSON.stringify(body),
|
|
1289
|
-
signal: controller.signal
|
|
1300
|
+
signal: controller.signal,
|
|
1301
|
+
// Disable keepalive for streaming
|
|
1302
|
+
keepalive: false
|
|
1290
1303
|
}).then(async (response) => {
|
|
1291
1304
|
if (!response.ok) {
|
|
1292
1305
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
@@ -1328,13 +1341,20 @@ function createSSEStreamPost(url, body, options = {}) {
|
|
|
1328
1341
|
}
|
|
1329
1342
|
}
|
|
1330
1343
|
} catch (error) {
|
|
1331
|
-
if (error
|
|
1332
|
-
|
|
1344
|
+
if (error?.name !== "AbortError") {
|
|
1345
|
+
const errorMessage = error?.message || "Stream connection error";
|
|
1346
|
+
stream.emit("error", new Error(errorMessage));
|
|
1347
|
+
}
|
|
1348
|
+
} finally {
|
|
1349
|
+
try {
|
|
1350
|
+
reader.releaseLock();
|
|
1351
|
+
} catch {
|
|
1333
1352
|
}
|
|
1334
1353
|
}
|
|
1335
1354
|
}).catch((error) => {
|
|
1336
|
-
if (error
|
|
1337
|
-
|
|
1355
|
+
if (error?.name !== "AbortError") {
|
|
1356
|
+
const errorMessage = error?.message || "Failed to establish stream connection";
|
|
1357
|
+
stream.emit("error", new Error(errorMessage));
|
|
1338
1358
|
}
|
|
1339
1359
|
});
|
|
1340
1360
|
return stream;
|
package/dist/index.mjs
CHANGED
|
@@ -1208,11 +1208,14 @@ function createSSEStream(url, options = {}) {
|
|
|
1208
1208
|
fetch(url, {
|
|
1209
1209
|
method: "GET",
|
|
1210
1210
|
headers: {
|
|
1211
|
-
Accept: "text/event-stream",
|
|
1211
|
+
"Accept": "text/event-stream",
|
|
1212
|
+
"Cache-Control": "no-cache",
|
|
1212
1213
|
...headers
|
|
1213
1214
|
},
|
|
1214
1215
|
credentials: withCredentials ? "include" : "same-origin",
|
|
1215
|
-
signal: controller.signal
|
|
1216
|
+
signal: controller.signal,
|
|
1217
|
+
// Disable keepalive for streaming
|
|
1218
|
+
keepalive: false
|
|
1216
1219
|
}).then(async (response) => {
|
|
1217
1220
|
if (!response.ok) {
|
|
1218
1221
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
@@ -1254,13 +1257,20 @@ function createSSEStream(url, options = {}) {
|
|
|
1254
1257
|
}
|
|
1255
1258
|
}
|
|
1256
1259
|
} catch (error) {
|
|
1257
|
-
if (error
|
|
1258
|
-
|
|
1260
|
+
if (error?.name !== "AbortError") {
|
|
1261
|
+
const errorMessage = error?.message || "Stream connection error";
|
|
1262
|
+
stream.emit("error", new Error(errorMessage));
|
|
1263
|
+
}
|
|
1264
|
+
} finally {
|
|
1265
|
+
try {
|
|
1266
|
+
reader.releaseLock();
|
|
1267
|
+
} catch {
|
|
1259
1268
|
}
|
|
1260
1269
|
}
|
|
1261
1270
|
}).catch((error) => {
|
|
1262
|
-
if (error
|
|
1263
|
-
|
|
1271
|
+
if (error?.name !== "AbortError") {
|
|
1272
|
+
const errorMessage = error?.message || "Failed to establish stream connection";
|
|
1273
|
+
stream.emit("error", new Error(errorMessage));
|
|
1264
1274
|
}
|
|
1265
1275
|
});
|
|
1266
1276
|
return stream;
|
|
@@ -1276,11 +1286,14 @@ function createSSEStreamPost(url, body, options = {}) {
|
|
|
1276
1286
|
headers: {
|
|
1277
1287
|
"Accept": "text/event-stream",
|
|
1278
1288
|
"Content-Type": "application/json",
|
|
1289
|
+
"Cache-Control": "no-cache",
|
|
1279
1290
|
...headers
|
|
1280
1291
|
},
|
|
1281
1292
|
credentials: withCredentials ? "include" : "same-origin",
|
|
1282
1293
|
body: JSON.stringify(body),
|
|
1283
|
-
signal: controller.signal
|
|
1294
|
+
signal: controller.signal,
|
|
1295
|
+
// Disable keepalive for streaming
|
|
1296
|
+
keepalive: false
|
|
1284
1297
|
}).then(async (response) => {
|
|
1285
1298
|
if (!response.ok) {
|
|
1286
1299
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
@@ -1322,13 +1335,20 @@ function createSSEStreamPost(url, body, options = {}) {
|
|
|
1322
1335
|
}
|
|
1323
1336
|
}
|
|
1324
1337
|
} catch (error) {
|
|
1325
|
-
if (error
|
|
1326
|
-
|
|
1338
|
+
if (error?.name !== "AbortError") {
|
|
1339
|
+
const errorMessage = error?.message || "Stream connection error";
|
|
1340
|
+
stream.emit("error", new Error(errorMessage));
|
|
1341
|
+
}
|
|
1342
|
+
} finally {
|
|
1343
|
+
try {
|
|
1344
|
+
reader.releaseLock();
|
|
1345
|
+
} catch {
|
|
1327
1346
|
}
|
|
1328
1347
|
}
|
|
1329
1348
|
}).catch((error) => {
|
|
1330
|
-
if (error
|
|
1331
|
-
|
|
1349
|
+
if (error?.name !== "AbortError") {
|
|
1350
|
+
const errorMessage = error?.message || "Failed to establish stream connection";
|
|
1351
|
+
stream.emit("error", new Error(errorMessage));
|
|
1332
1352
|
}
|
|
1333
1353
|
});
|
|
1334
1354
|
return stream;
|
package/package.json
CHANGED
|
@@ -49,11 +49,14 @@ export function createSSEStream<TEventMap extends StreamEventMap = StreamEventMa
|
|
|
49
49
|
fetch(url, {
|
|
50
50
|
method: 'GET',
|
|
51
51
|
headers: {
|
|
52
|
-
Accept: 'text/event-stream',
|
|
52
|
+
'Accept': 'text/event-stream',
|
|
53
|
+
'Cache-Control': 'no-cache',
|
|
53
54
|
...headers,
|
|
54
55
|
},
|
|
55
56
|
credentials: withCredentials ? 'include' : 'same-origin',
|
|
56
57
|
signal: controller.signal,
|
|
58
|
+
// Disable keepalive for streaming
|
|
59
|
+
keepalive: false,
|
|
57
60
|
})
|
|
58
61
|
.then(async (response) => {
|
|
59
62
|
if (!response.ok) {
|
|
@@ -108,15 +111,25 @@ export function createSSEStream<TEventMap extends StreamEventMap = StreamEventMa
|
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
|
-
} catch (error) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
} catch (error: any) {
|
|
115
|
+
// Handle all stream errors (network errors, protocol errors, etc.)
|
|
116
|
+
if (error?.name !== 'AbortError') {
|
|
117
|
+
const errorMessage = error?.message || 'Stream connection error'
|
|
118
|
+
stream.emit('error', new Error(errorMessage))
|
|
119
|
+
}
|
|
120
|
+
} finally {
|
|
121
|
+
// Clean up reader
|
|
122
|
+
try {
|
|
123
|
+
reader.releaseLock()
|
|
124
|
+
} catch {
|
|
125
|
+
// Ignore cleanup errors
|
|
114
126
|
}
|
|
115
127
|
}
|
|
116
128
|
})
|
|
117
|
-
.catch((error) => {
|
|
118
|
-
if (error
|
|
119
|
-
|
|
129
|
+
.catch((error: any) => {
|
|
130
|
+
if (error?.name !== 'AbortError') {
|
|
131
|
+
const errorMessage = error?.message || 'Failed to establish stream connection'
|
|
132
|
+
stream.emit('error', new Error(errorMessage))
|
|
120
133
|
}
|
|
121
134
|
})
|
|
122
135
|
|
|
@@ -154,11 +167,14 @@ export function createSSEStreamPost<TEventMap extends StreamEventMap = StreamEve
|
|
|
154
167
|
headers: {
|
|
155
168
|
'Accept': 'text/event-stream',
|
|
156
169
|
'Content-Type': 'application/json',
|
|
170
|
+
'Cache-Control': 'no-cache',
|
|
157
171
|
...headers,
|
|
158
172
|
},
|
|
159
173
|
credentials: withCredentials ? 'include' : 'same-origin',
|
|
160
174
|
body: JSON.stringify(body),
|
|
161
175
|
signal: controller.signal,
|
|
176
|
+
// Disable keepalive for streaming
|
|
177
|
+
keepalive: false,
|
|
162
178
|
})
|
|
163
179
|
.then(async (response) => {
|
|
164
180
|
if (!response.ok) {
|
|
@@ -213,15 +229,25 @@ export function createSSEStreamPost<TEventMap extends StreamEventMap = StreamEve
|
|
|
213
229
|
}
|
|
214
230
|
}
|
|
215
231
|
}
|
|
216
|
-
} catch (error) {
|
|
217
|
-
|
|
218
|
-
|
|
232
|
+
} catch (error: any) {
|
|
233
|
+
// Handle all stream errors (network errors, protocol errors, etc.)
|
|
234
|
+
if (error?.name !== 'AbortError') {
|
|
235
|
+
const errorMessage = error?.message || 'Stream connection error'
|
|
236
|
+
stream.emit('error', new Error(errorMessage))
|
|
237
|
+
}
|
|
238
|
+
} finally {
|
|
239
|
+
// Clean up reader
|
|
240
|
+
try {
|
|
241
|
+
reader.releaseLock()
|
|
242
|
+
} catch {
|
|
243
|
+
// Ignore cleanup errors
|
|
219
244
|
}
|
|
220
245
|
}
|
|
221
246
|
})
|
|
222
|
-
.catch((error) => {
|
|
223
|
-
if (error
|
|
224
|
-
|
|
247
|
+
.catch((error: any) => {
|
|
248
|
+
if (error?.name !== 'AbortError') {
|
|
249
|
+
const errorMessage = error?.message || 'Failed to establish stream connection'
|
|
250
|
+
stream.emit('error', new Error(errorMessage))
|
|
225
251
|
}
|
|
226
252
|
})
|
|
227
253
|
|