@semiont/api-client 0.2.2-build.15 → 0.2.2-build.16
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/{types.d.ts → index-DHh0ToZB.d.ts} +460 -6
- package/dist/index.d.ts +909 -13
- package/dist/index.js +1598 -60
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +1 -12
- package/dist/utils/index.js +597 -26
- package/dist/utils/index.js.map +1 -1
- package/package.json +11 -8
- package/dist/__tests__/client.test.d.ts +0 -28
- package/dist/__tests__/client.test.d.ts.map +0 -1
- package/dist/__tests__/client.test.js +0 -567
- package/dist/__tests__/client.test.js.map +0 -1
- package/dist/__tests__/sse-client.test.d.ts +0 -7
- package/dist/__tests__/sse-client.test.d.ts.map +0 -1
- package/dist/__tests__/sse-client.test.js +0 -421
- package/dist/__tests__/sse-client.test.js.map +0 -1
- package/dist/__tests__/sse-stream.test.d.ts +0 -7
- package/dist/__tests__/sse-stream.test.d.ts.map +0 -1
- package/dist/__tests__/sse-stream.test.js +0 -394
- package/dist/__tests__/sse-stream.test.js.map +0 -1
- package/dist/__tests__/svg-selectors.test.d.ts +0 -5
- package/dist/__tests__/svg-selectors.test.d.ts.map +0 -1
- package/dist/__tests__/svg-selectors.test.js +0 -124
- package/dist/__tests__/svg-selectors.test.js.map +0 -1
- package/dist/branded-types.d.ts +0 -70
- package/dist/branded-types.d.ts.map +0 -1
- package/dist/branded-types.js +0 -62
- package/dist/branded-types.js.map +0 -1
- package/dist/client.d.ts +0 -243
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -460
- package/dist/client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/mime-utils.d.ts +0 -27
- package/dist/mime-utils.d.ts.map +0 -1
- package/dist/mime-utils.js +0 -49
- package/dist/mime-utils.js.map +0 -1
- package/dist/sse/index.d.ts +0 -343
- package/dist/sse/index.d.ts.map +0 -1
- package/dist/sse/index.js +0 -404
- package/dist/sse/index.js.map +0 -1
- package/dist/sse/stream.d.ts +0 -58
- package/dist/sse/stream.d.ts.map +0 -1
- package/dist/sse/stream.js +0 -187
- package/dist/sse/stream.js.map +0 -1
- package/dist/sse/types.d.ts +0 -295
- package/dist/sse/types.d.ts.map +0 -1
- package/dist/sse/types.js +0 -10
- package/dist/sse/types.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -7
- package/dist/types.js.map +0 -1
- package/dist/utils/annotations.d.ts +0 -191
- package/dist/utils/annotations.d.ts.map +0 -1
- package/dist/utils/annotations.js +0 -404
- package/dist/utils/annotations.js.map +0 -1
- package/dist/utils/events.d.ts +0 -74
- package/dist/utils/events.d.ts.map +0 -1
- package/dist/utils/events.js +0 -329
- package/dist/utils/events.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/locales.d.ts +0 -31
- package/dist/utils/locales.d.ts.map +0 -1
- package/dist/utils/locales.js +0 -83
- package/dist/utils/locales.js.map +0 -1
- package/dist/utils/resources.d.ts +0 -34
- package/dist/utils/resources.d.ts.map +0 -1
- package/dist/utils/resources.js +0 -63
- package/dist/utils/resources.js.map +0 -1
- package/dist/utils/validation.d.ts +0 -57
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -89
- package/dist/utils/validation.js.map +0 -1
package/dist/sse/index.js
DELETED
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* SSE Client for Semiont Streaming Endpoints
|
|
4
|
-
*
|
|
5
|
-
* Provides type-safe methods for Server-Sent Events streaming.
|
|
6
|
-
* Does NOT use ky - uses native fetch() for SSE support.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.SSEClient = void 0;
|
|
10
|
-
const stream_1 = require("./stream");
|
|
11
|
-
/**
|
|
12
|
-
* SSE Client for real-time streaming operations
|
|
13
|
-
*
|
|
14
|
-
* Separate from the main HTTP client to clearly mark streaming endpoints.
|
|
15
|
-
* Uses native fetch() instead of ky for SSE support.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* const sseClient = new SSEClient({
|
|
20
|
-
* baseUrl: 'http://localhost:4000',
|
|
21
|
-
* accessToken: 'your-token'
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* const stream = sseClient.detectAnnotations(
|
|
25
|
-
* 'http://localhost:4000/resources/doc-123',
|
|
26
|
-
* { entityTypes: ['Person', 'Organization'] }
|
|
27
|
-
* );
|
|
28
|
-
*
|
|
29
|
-
* stream.onProgress((p) => console.log(p.message));
|
|
30
|
-
* stream.onComplete((r) => console.log(`Found ${r.foundCount} entities`));
|
|
31
|
-
* stream.onError((e) => console.error('Detection failed:', e));
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
class SSEClient {
|
|
35
|
-
baseUrl;
|
|
36
|
-
accessToken = null;
|
|
37
|
-
constructor(config) {
|
|
38
|
-
// Remove trailing slash for consistent URL construction
|
|
39
|
-
this.baseUrl = (config.baseUrl.endsWith('/') ? config.baseUrl.slice(0, -1) : config.baseUrl);
|
|
40
|
-
this.accessToken = config.accessToken || null;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Set the access token for authenticated requests
|
|
44
|
-
*/
|
|
45
|
-
setAccessToken(token) {
|
|
46
|
-
this.accessToken = token;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Clear the access token
|
|
50
|
-
*/
|
|
51
|
-
clearAccessToken() {
|
|
52
|
-
this.accessToken = null;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Get common headers for SSE requests
|
|
56
|
-
*/
|
|
57
|
-
getHeaders() {
|
|
58
|
-
const headers = {
|
|
59
|
-
'Content-Type': 'application/json'
|
|
60
|
-
};
|
|
61
|
-
if (this.accessToken) {
|
|
62
|
-
headers['Authorization'] = `Bearer ${this.accessToken}`;
|
|
63
|
-
}
|
|
64
|
-
return headers;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Extract resource ID from URI
|
|
68
|
-
*
|
|
69
|
-
* Handles both full URIs and plain IDs:
|
|
70
|
-
* - 'http://localhost:4000/resources/doc-123' -> 'doc-123'
|
|
71
|
-
* - 'doc-123' -> 'doc-123'
|
|
72
|
-
*/
|
|
73
|
-
extractId(uri) {
|
|
74
|
-
const parts = uri.split('/');
|
|
75
|
-
return parts[parts.length - 1];
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Detect annotations in a resource (streaming)
|
|
79
|
-
*
|
|
80
|
-
* Streams entity detection progress via Server-Sent Events.
|
|
81
|
-
*
|
|
82
|
-
* @param resourceId - Resource URI or ID
|
|
83
|
-
* @param request - Detection configuration (entity types to detect)
|
|
84
|
-
* @returns SSE stream controller with progress/complete/error callbacks
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```typescript
|
|
88
|
-
* const stream = sseClient.detectAnnotations(
|
|
89
|
-
* 'http://localhost:4000/resources/doc-123',
|
|
90
|
-
* { entityTypes: ['Person', 'Organization'] }
|
|
91
|
-
* );
|
|
92
|
-
*
|
|
93
|
-
* stream.onProgress((progress) => {
|
|
94
|
-
* console.log(`Scanning: ${progress.currentEntityType}`);
|
|
95
|
-
* console.log(`Progress: ${progress.processedEntityTypes}/${progress.totalEntityTypes}`);
|
|
96
|
-
* });
|
|
97
|
-
*
|
|
98
|
-
* stream.onComplete((result) => {
|
|
99
|
-
* console.log(`Detection complete! Found ${result.foundCount} entities`);
|
|
100
|
-
* });
|
|
101
|
-
*
|
|
102
|
-
* stream.onError((error) => {
|
|
103
|
-
* console.error('Detection failed:', error.message);
|
|
104
|
-
* });
|
|
105
|
-
*
|
|
106
|
-
* // Cleanup when done
|
|
107
|
-
* stream.close();
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
detectAnnotations(resourceId, request) {
|
|
111
|
-
const id = this.extractId(resourceId);
|
|
112
|
-
const url = `${this.baseUrl}/resources/${id}/detect-annotations-stream`;
|
|
113
|
-
return (0, stream_1.createSSEStream)(url, {
|
|
114
|
-
method: 'POST',
|
|
115
|
-
headers: this.getHeaders(),
|
|
116
|
-
body: JSON.stringify(request)
|
|
117
|
-
}, {
|
|
118
|
-
progressEvents: ['detection-started', 'detection-progress'],
|
|
119
|
-
completeEvent: 'detection-complete',
|
|
120
|
-
errorEvent: 'detection-error'
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Generate resource from annotation (streaming)
|
|
125
|
-
*
|
|
126
|
-
* Streams resource generation progress via Server-Sent Events.
|
|
127
|
-
*
|
|
128
|
-
* @param resourceId - Source resource URI or ID
|
|
129
|
-
* @param annotationId - Annotation URI or ID to use as generation source
|
|
130
|
-
* @param request - Generation options (title, prompt, language)
|
|
131
|
-
* @returns SSE stream controller with progress/complete/error callbacks
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* ```typescript
|
|
135
|
-
* const stream = sseClient.generateResourceFromAnnotation(
|
|
136
|
-
* 'http://localhost:4000/resources/doc-123',
|
|
137
|
-
* 'http://localhost:4000/annotations/ann-456',
|
|
138
|
-
* { language: 'es', title: 'Spanish Summary' }
|
|
139
|
-
* );
|
|
140
|
-
*
|
|
141
|
-
* stream.onProgress((progress) => {
|
|
142
|
-
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
143
|
-
* console.log(progress.message);
|
|
144
|
-
* });
|
|
145
|
-
*
|
|
146
|
-
* stream.onComplete((result) => {
|
|
147
|
-
* console.log(`Generated resource: ${result.resourceId}`);
|
|
148
|
-
* });
|
|
149
|
-
*
|
|
150
|
-
* stream.onError((error) => {
|
|
151
|
-
* console.error('Generation failed:', error.message);
|
|
152
|
-
* });
|
|
153
|
-
*
|
|
154
|
-
* // Cleanup when done
|
|
155
|
-
* stream.close();
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
|
-
generateResourceFromAnnotation(resourceId, annotationId, request) {
|
|
159
|
-
const resId = this.extractId(resourceId);
|
|
160
|
-
const annId = this.extractId(annotationId);
|
|
161
|
-
const url = `${this.baseUrl}/resources/${resId}/annotations/${annId}/generate-resource-stream`;
|
|
162
|
-
return (0, stream_1.createSSEStream)(url, {
|
|
163
|
-
method: 'POST',
|
|
164
|
-
headers: this.getHeaders(),
|
|
165
|
-
body: JSON.stringify(request)
|
|
166
|
-
}, {
|
|
167
|
-
progressEvents: ['generation-started', 'generation-progress'],
|
|
168
|
-
completeEvent: 'generation-complete',
|
|
169
|
-
errorEvent: 'generation-error'
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Detect highlights in a resource (streaming)
|
|
174
|
-
*
|
|
175
|
-
* Streams highlight detection progress via Server-Sent Events.
|
|
176
|
-
*
|
|
177
|
-
* @param resourceId - Resource URI or ID
|
|
178
|
-
* @param request - Detection configuration (optional instructions)
|
|
179
|
-
* @returns SSE stream controller with progress/complete/error callbacks
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```typescript
|
|
183
|
-
* const stream = sseClient.detectHighlights(
|
|
184
|
-
* 'http://localhost:4000/resources/doc-123',
|
|
185
|
-
* { instructions: 'Focus on key technical points' }
|
|
186
|
-
* );
|
|
187
|
-
*
|
|
188
|
-
* stream.onProgress((progress) => {
|
|
189
|
-
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
190
|
-
* console.log(progress.message);
|
|
191
|
-
* });
|
|
192
|
-
*
|
|
193
|
-
* stream.onComplete((result) => {
|
|
194
|
-
* console.log(`Detection complete! Created ${result.createdCount} highlights`);
|
|
195
|
-
* });
|
|
196
|
-
*
|
|
197
|
-
* stream.onError((error) => {
|
|
198
|
-
* console.error('Detection failed:', error.message);
|
|
199
|
-
* });
|
|
200
|
-
*
|
|
201
|
-
* // Cleanup when done
|
|
202
|
-
* stream.close();
|
|
203
|
-
* ```
|
|
204
|
-
*/
|
|
205
|
-
detectHighlights(resourceId, request = {}) {
|
|
206
|
-
const id = this.extractId(resourceId);
|
|
207
|
-
const url = `${this.baseUrl}/resources/${id}/detect-highlights-stream`;
|
|
208
|
-
return (0, stream_1.createSSEStream)(url, {
|
|
209
|
-
method: 'POST',
|
|
210
|
-
headers: this.getHeaders(),
|
|
211
|
-
body: JSON.stringify(request)
|
|
212
|
-
}, {
|
|
213
|
-
progressEvents: ['highlight-detection-started', 'highlight-detection-progress'],
|
|
214
|
-
completeEvent: 'highlight-detection-complete',
|
|
215
|
-
errorEvent: 'highlight-detection-error'
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Detect assessments in a resource (streaming)
|
|
220
|
-
*
|
|
221
|
-
* Streams assessment detection progress via Server-Sent Events.
|
|
222
|
-
*
|
|
223
|
-
* @param resourceId - Resource URI or ID
|
|
224
|
-
* @param request - Detection configuration (optional instructions)
|
|
225
|
-
* @returns SSE stream controller with progress/complete/error callbacks
|
|
226
|
-
*
|
|
227
|
-
* @example
|
|
228
|
-
* ```typescript
|
|
229
|
-
* const stream = sseClient.detectAssessments(
|
|
230
|
-
* 'http://localhost:4000/resources/doc-123',
|
|
231
|
-
* { instructions: 'Evaluate claims for accuracy' }
|
|
232
|
-
* );
|
|
233
|
-
*
|
|
234
|
-
* stream.onProgress((progress) => {
|
|
235
|
-
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
236
|
-
* console.log(progress.message);
|
|
237
|
-
* });
|
|
238
|
-
*
|
|
239
|
-
* stream.onComplete((result) => {
|
|
240
|
-
* console.log(`Detection complete! Created ${result.createdCount} assessments`);
|
|
241
|
-
* });
|
|
242
|
-
*
|
|
243
|
-
* stream.onError((error) => {
|
|
244
|
-
* console.error('Detection failed:', error.message);
|
|
245
|
-
* });
|
|
246
|
-
*
|
|
247
|
-
* // Cleanup when done
|
|
248
|
-
* stream.close();
|
|
249
|
-
* ```
|
|
250
|
-
*/
|
|
251
|
-
detectAssessments(resourceId, request = {}) {
|
|
252
|
-
const id = this.extractId(resourceId);
|
|
253
|
-
const url = `${this.baseUrl}/resources/${id}/detect-assessments-stream`;
|
|
254
|
-
return (0, stream_1.createSSEStream)(url, {
|
|
255
|
-
method: 'POST',
|
|
256
|
-
headers: this.getHeaders(),
|
|
257
|
-
body: JSON.stringify(request)
|
|
258
|
-
}, {
|
|
259
|
-
progressEvents: ['assessment-detection-started', 'assessment-detection-progress'],
|
|
260
|
-
completeEvent: 'assessment-detection-complete',
|
|
261
|
-
errorEvent: 'assessment-detection-error'
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Detect comments in a resource (streaming)
|
|
266
|
-
*
|
|
267
|
-
* Streams comment detection progress via Server-Sent Events.
|
|
268
|
-
* Uses AI to identify passages that would benefit from explanatory comments
|
|
269
|
-
* and creates comment annotations with contextual information.
|
|
270
|
-
*
|
|
271
|
-
* @param resourceId - Resource URI or ID
|
|
272
|
-
* @param request - Detection configuration (optional instructions and tone)
|
|
273
|
-
* @returns SSE stream controller with progress/complete/error callbacks
|
|
274
|
-
*
|
|
275
|
-
* @example
|
|
276
|
-
* ```typescript
|
|
277
|
-
* const stream = sseClient.detectComments('http://localhost:4000/resources/doc-123', {
|
|
278
|
-
* instructions: 'Focus on technical terminology',
|
|
279
|
-
* tone: 'scholarly'
|
|
280
|
-
* });
|
|
281
|
-
*
|
|
282
|
-
* stream.onProgress((progress) => {
|
|
283
|
-
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
284
|
-
* });
|
|
285
|
-
*
|
|
286
|
-
* stream.onComplete((result) => {
|
|
287
|
-
* console.log(`Detection complete! Created ${result.createdCount} comments`);
|
|
288
|
-
* });
|
|
289
|
-
*
|
|
290
|
-
* stream.onError((error) => {
|
|
291
|
-
* console.error('Detection failed:', error.message);
|
|
292
|
-
* });
|
|
293
|
-
*
|
|
294
|
-
* // Cleanup when done
|
|
295
|
-
* stream.close();
|
|
296
|
-
* ```
|
|
297
|
-
*/
|
|
298
|
-
detectComments(resourceId, request = {}) {
|
|
299
|
-
const id = this.extractId(resourceId);
|
|
300
|
-
const url = `${this.baseUrl}/resources/${id}/detect-comments-stream`;
|
|
301
|
-
return (0, stream_1.createSSEStream)(url, {
|
|
302
|
-
method: 'POST',
|
|
303
|
-
headers: this.getHeaders(),
|
|
304
|
-
body: JSON.stringify(request)
|
|
305
|
-
}, {
|
|
306
|
-
progressEvents: ['comment-detection-started', 'comment-detection-progress'],
|
|
307
|
-
completeEvent: 'comment-detection-complete',
|
|
308
|
-
errorEvent: 'comment-detection-error'
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Detect tags in a resource (streaming)
|
|
313
|
-
*
|
|
314
|
-
* Streams tag detection progress via Server-Sent Events.
|
|
315
|
-
* Uses AI to identify passages serving specific structural roles
|
|
316
|
-
* (e.g., IRAC, IMRAD, Toulmin) and creates tag annotations with dual-body structure.
|
|
317
|
-
*
|
|
318
|
-
* @param resourceId - Resource URI or ID
|
|
319
|
-
* @param request - Detection configuration (schema and categories to detect)
|
|
320
|
-
* @returns SSE stream controller with progress/complete/error callbacks
|
|
321
|
-
*
|
|
322
|
-
* @example
|
|
323
|
-
* ```typescript
|
|
324
|
-
* const stream = sseClient.detectTags('http://localhost:4000/resources/doc-123', {
|
|
325
|
-
* schemaId: 'legal-irac',
|
|
326
|
-
* categories: ['Issue', 'Rule', 'Application', 'Conclusion']
|
|
327
|
-
* });
|
|
328
|
-
*
|
|
329
|
-
* stream.onProgress((progress) => {
|
|
330
|
-
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
331
|
-
* console.log(`Processing ${progress.currentCategory}...`);
|
|
332
|
-
* });
|
|
333
|
-
*
|
|
334
|
-
* stream.onComplete((result) => {
|
|
335
|
-
* console.log(`Detection complete! Created ${result.tagsCreated} tags`);
|
|
336
|
-
* });
|
|
337
|
-
*
|
|
338
|
-
* stream.onError((error) => {
|
|
339
|
-
* console.error('Detection failed:', error.message);
|
|
340
|
-
* });
|
|
341
|
-
*
|
|
342
|
-
* // Cleanup when done
|
|
343
|
-
* stream.close();
|
|
344
|
-
* ```
|
|
345
|
-
*/
|
|
346
|
-
detectTags(resourceId, request) {
|
|
347
|
-
const id = this.extractId(resourceId);
|
|
348
|
-
const url = `${this.baseUrl}/resources/${id}/detect-tags-stream`;
|
|
349
|
-
return (0, stream_1.createSSEStream)(url, {
|
|
350
|
-
method: 'POST',
|
|
351
|
-
headers: this.getHeaders(),
|
|
352
|
-
body: JSON.stringify(request)
|
|
353
|
-
}, {
|
|
354
|
-
progressEvents: ['tag-detection-started', 'tag-detection-progress'],
|
|
355
|
-
completeEvent: 'tag-detection-complete',
|
|
356
|
-
errorEvent: 'tag-detection-error'
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Subscribe to resource events (long-lived stream)
|
|
361
|
-
*
|
|
362
|
-
* Opens a long-lived SSE connection to receive real-time events for a resource.
|
|
363
|
-
* Used for collaborative editing - see events from other users as they happen.
|
|
364
|
-
*
|
|
365
|
-
* This stream does NOT have a complete event - it stays open until explicitly closed.
|
|
366
|
-
*
|
|
367
|
-
* @param resourceId - Resource URI or ID to subscribe to
|
|
368
|
-
* @returns SSE stream controller with event callback
|
|
369
|
-
*
|
|
370
|
-
* @example
|
|
371
|
-
* ```typescript
|
|
372
|
-
* const stream = sseClient.resourceEvents('http://localhost:4000/resources/doc-123');
|
|
373
|
-
*
|
|
374
|
-
* stream.onProgress((event) => {
|
|
375
|
-
* console.log(`Event: ${event.type}`);
|
|
376
|
-
* console.log(`User: ${event.userId}`);
|
|
377
|
-
* console.log(`Sequence: ${event.metadata.sequenceNumber}`);
|
|
378
|
-
* console.log(`Payload:`, event.payload);
|
|
379
|
-
* });
|
|
380
|
-
*
|
|
381
|
-
* stream.onError((error) => {
|
|
382
|
-
* console.error('Stream error:', error.message);
|
|
383
|
-
* });
|
|
384
|
-
*
|
|
385
|
-
* // Close when no longer needed (e.g., component unmount)
|
|
386
|
-
* stream.close();
|
|
387
|
-
* ```
|
|
388
|
-
*/
|
|
389
|
-
resourceEvents(resourceId) {
|
|
390
|
-
const id = this.extractId(resourceId);
|
|
391
|
-
const url = `${this.baseUrl}/resources/${id}/events/stream`;
|
|
392
|
-
return (0, stream_1.createSSEStream)(url, {
|
|
393
|
-
method: 'GET',
|
|
394
|
-
headers: this.getHeaders()
|
|
395
|
-
}, {
|
|
396
|
-
progressEvents: ['*'], // Accept all event types
|
|
397
|
-
completeEvent: null, // Long-lived stream - no completion
|
|
398
|
-
errorEvent: 'error', // Generic error event
|
|
399
|
-
customEventHandler: true // Use custom event handling
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
exports.SSEClient = SSEClient;
|
|
404
|
-
//# sourceMappingURL=index.js.map
|
package/dist/sse/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sse/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,qCAA2C;AAkE3C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,SAAS;IACZ,OAAO,CAAU;IACjB,WAAW,GAAuB,IAAI,CAAC;IAE/C,YAAY,MAAuB;QACjC,wDAAwD;QACxD,IAAI,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAY,CAAC;QACxG,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,KAAkB;QAC/B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,IAAI,C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;YACE,cAAc,EAAE,CAAC,uBAAuB,EAAE,wBAAwB,CAAC;YACnE,aAAa,EAAE,wBAAwB;YACvC,UAAU,EAAE,qBAAqB;SAClC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,cAAc,CAAC,UAAuB;QACpC,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QACtC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,cAAc,EAAE,gBAAgB,CAAC;QAE5D,OAAO,IAAA,wBAAe,EACpB,GAAG,EACH;YACE,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;SAC3B,EACD;YACE,cAAc,EAAE,CAAC,GAAG,CAAC,EAAE,yBAAyB;YAChD,aAAa,EAAE,IAAI,EAAE,oCAAoC;YACzD,UAAU,EAAE,OAAO,EAAE,sBAAsB;YAC3C,kBAAkB,EAAE,IAAI,CAAC,4BAA4B;SACtD,CACF,CAAC;IACJ,CAAC;CACF;AApbD,8BAobC"}
|
package/dist/sse/stream.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SSE Stream Factory
|
|
3
|
-
*
|
|
4
|
-
* Creates Server-Sent Events streams using native fetch() and manual parsing.
|
|
5
|
-
* Does NOT use the EventSource API for better control over connection lifecycle.
|
|
6
|
-
*/
|
|
7
|
-
import type { SSEStream } from './types';
|
|
8
|
-
/**
|
|
9
|
-
* Configuration for SSE stream event handling
|
|
10
|
-
*/
|
|
11
|
-
interface SSEConfig {
|
|
12
|
-
/** Event types that trigger onProgress callback */
|
|
13
|
-
progressEvents: string[];
|
|
14
|
-
/** Event type that triggers onComplete callback (null for long-lived streams) */
|
|
15
|
-
completeEvent: string | null;
|
|
16
|
-
/** Event type that triggers onError callback */
|
|
17
|
-
errorEvent: string | null;
|
|
18
|
-
/** If true, use custom event handlers instead of standard mapping */
|
|
19
|
-
customEventHandler?: boolean;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Create an SSE stream with typed event callbacks
|
|
23
|
-
*
|
|
24
|
-
* Uses native fetch() with manual SSE parsing for fine-grained control.
|
|
25
|
-
* Supports AbortController for cancellation.
|
|
26
|
-
*
|
|
27
|
-
* @typeParam TProgress - Type of progress event data
|
|
28
|
-
* @typeParam TComplete - Type of completion event data
|
|
29
|
-
*
|
|
30
|
-
* @param url - Full URL to SSE endpoint
|
|
31
|
-
* @param fetchOptions - fetch() options (method, headers, body)
|
|
32
|
-
* @param config - Event mapping configuration
|
|
33
|
-
* @returns SSEStream controller with callback registration and cleanup
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* const stream = createSSEStream<DetectionProgress, DetectionProgress>(
|
|
38
|
-
* 'http://localhost:4000/resources/123/detect-annotations-stream',
|
|
39
|
-
* {
|
|
40
|
-
* method: 'POST',
|
|
41
|
-
* headers: { 'Authorization': 'Bearer token', 'Content-Type': 'application/json' },
|
|
42
|
-
* body: JSON.stringify({ entityTypes: ['Person'] })
|
|
43
|
-
* },
|
|
44
|
-
* {
|
|
45
|
-
* progressEvents: ['detection-started', 'detection-progress'],
|
|
46
|
-
* completeEvent: 'detection-complete',
|
|
47
|
-
* errorEvent: 'detection-error'
|
|
48
|
-
* }
|
|
49
|
-
* );
|
|
50
|
-
*
|
|
51
|
-
* stream.onProgress((p) => console.log(p.message));
|
|
52
|
-
* stream.onComplete((r) => console.log('Done!'));
|
|
53
|
-
* stream.close(); // Cleanup
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
export declare function createSSEStream<TProgress, TComplete>(url: string, fetchOptions: RequestInit, config: SSEConfig): SSEStream<TProgress, TComplete>;
|
|
57
|
-
export {};
|
|
58
|
-
//# sourceMappingURL=stream.d.ts.map
|
package/dist/sse/stream.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/sse/stream.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;GAEG;AACH,UAAU,SAAS;IACjB,mDAAmD;IACnD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,iFAAiF;IACjF,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,gDAAgD;IAChD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,EAClD,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,WAAW,EACzB,MAAM,EAAE,SAAS,GAChB,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CA4JjC"}
|
package/dist/sse/stream.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* SSE Stream Factory
|
|
4
|
-
*
|
|
5
|
-
* Creates Server-Sent Events streams using native fetch() and manual parsing.
|
|
6
|
-
* Does NOT use the EventSource API for better control over connection lifecycle.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.createSSEStream = createSSEStream;
|
|
10
|
-
/**
|
|
11
|
-
* Create an SSE stream with typed event callbacks
|
|
12
|
-
*
|
|
13
|
-
* Uses native fetch() with manual SSE parsing for fine-grained control.
|
|
14
|
-
* Supports AbortController for cancellation.
|
|
15
|
-
*
|
|
16
|
-
* @typeParam TProgress - Type of progress event data
|
|
17
|
-
* @typeParam TComplete - Type of completion event data
|
|
18
|
-
*
|
|
19
|
-
* @param url - Full URL to SSE endpoint
|
|
20
|
-
* @param fetchOptions - fetch() options (method, headers, body)
|
|
21
|
-
* @param config - Event mapping configuration
|
|
22
|
-
* @returns SSEStream controller with callback registration and cleanup
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* const stream = createSSEStream<DetectionProgress, DetectionProgress>(
|
|
27
|
-
* 'http://localhost:4000/resources/123/detect-annotations-stream',
|
|
28
|
-
* {
|
|
29
|
-
* method: 'POST',
|
|
30
|
-
* headers: { 'Authorization': 'Bearer token', 'Content-Type': 'application/json' },
|
|
31
|
-
* body: JSON.stringify({ entityTypes: ['Person'] })
|
|
32
|
-
* },
|
|
33
|
-
* {
|
|
34
|
-
* progressEvents: ['detection-started', 'detection-progress'],
|
|
35
|
-
* completeEvent: 'detection-complete',
|
|
36
|
-
* errorEvent: 'detection-error'
|
|
37
|
-
* }
|
|
38
|
-
* );
|
|
39
|
-
*
|
|
40
|
-
* stream.onProgress((p) => console.log(p.message));
|
|
41
|
-
* stream.onComplete((r) => console.log('Done!'));
|
|
42
|
-
* stream.close(); // Cleanup
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
function createSSEStream(url, fetchOptions, config) {
|
|
46
|
-
const abortController = new AbortController();
|
|
47
|
-
let progressCallback = null;
|
|
48
|
-
let completeCallback = null;
|
|
49
|
-
let errorCallback = null;
|
|
50
|
-
const customHandlers = new Map();
|
|
51
|
-
let closed = false; // Flag to stop processing events after close/complete/error
|
|
52
|
-
/**
|
|
53
|
-
* Start the SSE connection and parse the stream
|
|
54
|
-
*/
|
|
55
|
-
const connect = async () => {
|
|
56
|
-
try {
|
|
57
|
-
const response = await fetch(url, {
|
|
58
|
-
...fetchOptions,
|
|
59
|
-
signal: abortController.signal,
|
|
60
|
-
headers: {
|
|
61
|
-
...fetchOptions.headers,
|
|
62
|
-
'Accept': 'text/event-stream'
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
if (!response.ok) {
|
|
66
|
-
const errorData = await response.json().catch(() => ({}));
|
|
67
|
-
throw new Error(errorData.message || `HTTP ${response.status}: ${response.statusText}`);
|
|
68
|
-
}
|
|
69
|
-
if (!response.body) {
|
|
70
|
-
throw new Error('Response body is null - server did not return a stream');
|
|
71
|
-
}
|
|
72
|
-
// Parse SSE stream
|
|
73
|
-
const reader = response.body.getReader();
|
|
74
|
-
const decoder = new TextDecoder();
|
|
75
|
-
let buffer = '';
|
|
76
|
-
// Event state persists across reads to handle multi-chunk events
|
|
77
|
-
let eventType = '';
|
|
78
|
-
let eventData = '';
|
|
79
|
-
let eventId = '';
|
|
80
|
-
while (true) {
|
|
81
|
-
const { done, value } = await reader.read();
|
|
82
|
-
if (done || closed)
|
|
83
|
-
break;
|
|
84
|
-
buffer += decoder.decode(value, { stream: true });
|
|
85
|
-
const lines = buffer.split('\n');
|
|
86
|
-
// Keep the last partial line in the buffer
|
|
87
|
-
buffer = lines.pop() || '';
|
|
88
|
-
for (const line of lines) {
|
|
89
|
-
if (line.startsWith('event:')) {
|
|
90
|
-
eventType = line.slice(6).trim();
|
|
91
|
-
}
|
|
92
|
-
else if (line.startsWith('data:')) {
|
|
93
|
-
eventData = line.slice(5).trim();
|
|
94
|
-
}
|
|
95
|
-
else if (line.startsWith('id:')) {
|
|
96
|
-
eventId = line.slice(3).trim();
|
|
97
|
-
}
|
|
98
|
-
else if (line === '') {
|
|
99
|
-
// Empty line marks end of event
|
|
100
|
-
if (eventData && !closed) {
|
|
101
|
-
handleEvent(eventType, eventData, eventId);
|
|
102
|
-
if (closed)
|
|
103
|
-
break; // Stop processing if event triggered close
|
|
104
|
-
eventType = '';
|
|
105
|
-
eventData = '';
|
|
106
|
-
eventId = '';
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (closed)
|
|
111
|
-
break; // Exit outer loop if closed
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
// Don't report AbortError (normal cleanup)
|
|
116
|
-
if (error instanceof Error && error.name !== 'AbortError') {
|
|
117
|
-
errorCallback?.(error);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Handle a parsed SSE event
|
|
123
|
-
*/
|
|
124
|
-
const handleEvent = (eventType, data, _id) => {
|
|
125
|
-
// Skip keep-alive comments
|
|
126
|
-
if (data.startsWith(':')) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
try {
|
|
130
|
-
const parsed = JSON.parse(data);
|
|
131
|
-
// Custom event handler (for resourceEvents which handles all events)
|
|
132
|
-
if (config.customEventHandler) {
|
|
133
|
-
const handler = customHandlers.get(eventType);
|
|
134
|
-
if (handler) {
|
|
135
|
-
handler(parsed);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
// Pass all events to progress handler if no specific handler
|
|
139
|
-
progressCallback?.(parsed);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
// Progress events
|
|
143
|
-
if (config.progressEvents.includes(eventType)) {
|
|
144
|
-
progressCallback?.(parsed);
|
|
145
|
-
}
|
|
146
|
-
// Complete event
|
|
147
|
-
if (config.completeEvent && eventType === config.completeEvent) {
|
|
148
|
-
completeCallback?.(parsed);
|
|
149
|
-
closed = true; // Stop processing further events
|
|
150
|
-
abortController.abort(); // Close stream on completion
|
|
151
|
-
}
|
|
152
|
-
// Error event
|
|
153
|
-
if (config.errorEvent && eventType === config.errorEvent) {
|
|
154
|
-
errorCallback?.(new Error(parsed.message || 'Stream error'));
|
|
155
|
-
closed = true; // Stop processing further events
|
|
156
|
-
abortController.abort(); // Close stream on error
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
console.error('[SSE] Failed to parse event data:', error);
|
|
161
|
-
console.error('[SSE] Event type:', eventType);
|
|
162
|
-
console.error('[SSE] Data:', data);
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
// Start connection immediately
|
|
166
|
-
connect();
|
|
167
|
-
// Return SSE stream controller
|
|
168
|
-
return {
|
|
169
|
-
onProgress(callback) {
|
|
170
|
-
progressCallback = callback;
|
|
171
|
-
},
|
|
172
|
-
onComplete(callback) {
|
|
173
|
-
completeCallback = callback;
|
|
174
|
-
},
|
|
175
|
-
onError(callback) {
|
|
176
|
-
errorCallback = callback;
|
|
177
|
-
},
|
|
178
|
-
close() {
|
|
179
|
-
abortController.abort();
|
|
180
|
-
},
|
|
181
|
-
// Internal method for custom event handlers (used by resourceEvents)
|
|
182
|
-
on(event, callback) {
|
|
183
|
-
customHandlers.set(event, callback);
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
//# sourceMappingURL=stream.js.map
|
package/dist/sse/stream.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/sse/stream.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAqDH,0CAgKC;AAnMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,eAAe,CAC7B,GAAW,EACX,YAAyB,EACzB,MAAiB;IAEjB,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAC9C,IAAI,gBAAgB,GAAuC,IAAI,CAAC;IAChE,IAAI,gBAAgB,GAAuC,IAAI,CAAC;IAChE,IAAI,aAAa,GAAoC,IAAI,CAAC;IAC1D,MAAM,cAAc,GAAG,IAAI,GAAG,EAAgC,CAAC;IAC/D,IAAI,MAAM,GAAG,KAAK,CAAC,CAAC,4DAA4D;IAEhF;;OAEG;IACH,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;QACzB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAChC,GAAG,YAAY;gBACf,MAAM,EAAE,eAAe,CAAC,MAAM;gBAC9B,OAAO,EAAE;oBACP,GAAG,YAAY,CAAC,OAAO;oBACvB,QAAQ,EAAE,mBAAmB;iBAC9B;aACF,CAAC,CAAC;YAEH,IAA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