@semiont/api-client 0.2.1 → 0.2.2
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/index.d.ts
CHANGED
|
@@ -1,3 +1,907 @@
|
|
|
1
|
+
import { B as BaseUrl, A as AccessToken, R as ResourceUri, E as EntityType, a as AnnotationUri, c as components, b as Email, p as paths, d as RefreshToken, G as GoogleCredential, C as ContentFormat, S as SearchQuery, e as CloneToken, f as ResourceAnnotationUri, M as Motivation, U as UserDID, J as JobId } from './index-DHh0ToZB.js';
|
|
2
|
+
export { $ as $defs, aq as AuthCode, X as EventMetadata, an as JWTTokenSchema, a9 as LOCALES, a8 as LocaleInfo, ar as MCPToken, a6 as ResourceCreationDetails, Y as ResourceEventType, i as Selector, W as StoredEvent, h as SvgSelector, T as TextPositionSelector, g as TextQuoteSelector, al as ValidationFailure, am as ValidationResult, ak as ValidationSuccess, av as accessToken, aF as annotationUri, at as authCode, aD as baseUrl, ay as cloneToken, as as email, aB as entityType, V as extractBoundingBox, a1 as formatEventType, ad as formatLocaleDisplay, a3 as formatRelativeTime, ae as getAllLocaleCodes, K as getAnnotationExactText, Z as getAnnotationUriFromEvent, j as getBodySource, k as getBodyType, ai as getChecksum, y as getCommentText, r as getEntityTypes, a4 as getEventDisplayContent, a2 as getEventEmoji, a5 as getEventEntityTypes, I as getExactText, aj as getLanguage, ac as getLocaleEnglishName, aa as getLocaleInfo, ab as getLocaleNativeName, ah as getPrimaryMediaType, ag as getPrimaryRepresentation, L as getPrimarySelector, a7 as getResourceCreationDetails, af as getResourceId, P as getSvgSelector, z as getTagCategory, D as getTagSchemaId, n as getTargetSelector, m as getTargetSource, N as getTextPositionSelector, O as getTextQuoteSelector, au as googleCredential, q as hasTargetSelector, u as isAssessment, l as isBodyResolved, v as isComment, _ as isEventRelatedToAnnotation, s as isHighlight, t as isReference, H as isResolvedReference, a0 as isResourceEvent, F as isStubReference, x as isTag, ap as isValidEmail, az as jobId, ax as mcpToken, o as operations, aw as refreshToken, aG as resourceAnnotationUri, aE as resourceUri, aC as searchQuery, aA as userDID, ao as validateData, Q as validateSvgMarkup, w as webhooks } from './index-DHh0ToZB.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* TypeScript types for Server-Sent Events (SSE) streaming
|
|
6
|
+
*
|
|
7
|
+
* These types match the event payloads sent by backend SSE endpoints.
|
|
8
|
+
* They are not validated (per SSE-VALIDATION-CONSIDERATIONS.md) but provide
|
|
9
|
+
* type safety for client code consuming the streams.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Progress event for entity detection stream
|
|
13
|
+
*
|
|
14
|
+
* Sent by POST /resources/:id/detect-annotations-stream
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* stream.onProgress((progress: DetectionProgress) => {
|
|
19
|
+
* if (progress.status === 'scanning') {
|
|
20
|
+
* console.log(`Scanning for ${progress.currentEntityType}...`);
|
|
21
|
+
* console.log(`Progress: ${progress.processedEntityTypes}/${progress.totalEntityTypes}`);
|
|
22
|
+
* }
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
interface DetectionProgress {
|
|
27
|
+
/** Current status of detection operation */
|
|
28
|
+
status: 'started' | 'scanning' | 'complete' | 'error';
|
|
29
|
+
/** Resource ID being scanned */
|
|
30
|
+
resourceId: string;
|
|
31
|
+
/** Currently scanning for this entity type (only present during 'scanning') */
|
|
32
|
+
currentEntityType?: string;
|
|
33
|
+
/** Total number of entity types to scan */
|
|
34
|
+
totalEntityTypes: number;
|
|
35
|
+
/** Number of entity types processed so far */
|
|
36
|
+
processedEntityTypes: number;
|
|
37
|
+
/** Human-readable status message */
|
|
38
|
+
message?: string;
|
|
39
|
+
/** Total entities found (only present in 'complete') */
|
|
40
|
+
foundCount?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Progress event for resource generation stream
|
|
44
|
+
*
|
|
45
|
+
* Sent by POST /resources/:resourceId/annotations/:annotationId/generate-resource-stream
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* stream.onProgress((progress: GenerationProgress) => {
|
|
50
|
+
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
51
|
+
* console.log(progress.message);
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
interface GenerationProgress {
|
|
56
|
+
/** Current stage of generation operation */
|
|
57
|
+
status: 'started' | 'fetching' | 'generating' | 'creating' | 'complete' | 'error';
|
|
58
|
+
/** Annotation ID being used as source */
|
|
59
|
+
referenceId: string;
|
|
60
|
+
/** Name of resource being generated */
|
|
61
|
+
resourceName?: string;
|
|
62
|
+
/** ID of generated resource (only present in 'complete') */
|
|
63
|
+
resourceId?: string;
|
|
64
|
+
/** ID of source resource */
|
|
65
|
+
sourceResourceId?: string;
|
|
66
|
+
/** Percentage complete (0-100) */
|
|
67
|
+
percentage: number;
|
|
68
|
+
/** Human-readable status message */
|
|
69
|
+
message?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Progress event for highlight detection stream
|
|
73
|
+
*
|
|
74
|
+
* Sent by POST /resources/:id/detect-highlights-stream
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* stream.onProgress((progress: HighlightDetectionProgress) => {
|
|
79
|
+
* if (progress.status === 'analyzing') {
|
|
80
|
+
* console.log(`Analyzing: ${progress.percentage}%`);
|
|
81
|
+
* }
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
interface HighlightDetectionProgress {
|
|
86
|
+
/** Current status of highlight detection operation */
|
|
87
|
+
status: 'started' | 'analyzing' | 'creating' | 'complete' | 'error';
|
|
88
|
+
/** Resource ID being analyzed */
|
|
89
|
+
resourceId: string;
|
|
90
|
+
/** Current stage of processing */
|
|
91
|
+
stage?: 'analyzing' | 'creating';
|
|
92
|
+
/** Percentage complete (0-100) */
|
|
93
|
+
percentage?: number;
|
|
94
|
+
/** Human-readable status message */
|
|
95
|
+
message?: string;
|
|
96
|
+
/** Total highlights found */
|
|
97
|
+
foundCount?: number;
|
|
98
|
+
/** Total highlights created */
|
|
99
|
+
createdCount?: number;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Progress event for assessment detection stream
|
|
103
|
+
*
|
|
104
|
+
* Sent by POST /resources/:id/detect-assessments-stream
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* stream.onProgress((progress: AssessmentDetectionProgress) => {
|
|
109
|
+
* if (progress.status === 'analyzing') {
|
|
110
|
+
* console.log(`Analyzing: ${progress.percentage}%`);
|
|
111
|
+
* }
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
interface AssessmentDetectionProgress {
|
|
116
|
+
/** Current status of assessment detection operation */
|
|
117
|
+
status: 'started' | 'analyzing' | 'creating' | 'complete' | 'error';
|
|
118
|
+
/** Resource ID being analyzed */
|
|
119
|
+
resourceId: string;
|
|
120
|
+
/** Current stage of processing */
|
|
121
|
+
stage?: 'analyzing' | 'creating';
|
|
122
|
+
/** Percentage complete (0-100) */
|
|
123
|
+
percentage?: number;
|
|
124
|
+
/** Human-readable status message */
|
|
125
|
+
message?: string;
|
|
126
|
+
/** Total assessments found */
|
|
127
|
+
foundCount?: number;
|
|
128
|
+
/** Total assessments created */
|
|
129
|
+
createdCount?: number;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Progress event for comment detection stream
|
|
133
|
+
*
|
|
134
|
+
* Sent by POST /resources/:id/detect-comments-stream
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* stream.onProgress((progress: CommentDetectionProgress) => {
|
|
139
|
+
* if (progress.status === 'analyzing') {
|
|
140
|
+
* console.log(`Analyzing: ${progress.percentage}%`);
|
|
141
|
+
* }
|
|
142
|
+
* });
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
interface CommentDetectionProgress {
|
|
146
|
+
/** Current status of comment detection operation */
|
|
147
|
+
status: 'started' | 'analyzing' | 'creating' | 'complete' | 'error';
|
|
148
|
+
/** Resource ID being analyzed */
|
|
149
|
+
resourceId: string;
|
|
150
|
+
/** Current stage of processing */
|
|
151
|
+
stage?: 'analyzing' | 'creating';
|
|
152
|
+
/** Percentage complete (0-100) */
|
|
153
|
+
percentage?: number;
|
|
154
|
+
/** Human-readable status message */
|
|
155
|
+
message?: string;
|
|
156
|
+
/** Total comments found */
|
|
157
|
+
foundCount?: number;
|
|
158
|
+
/** Total comments created */
|
|
159
|
+
createdCount?: number;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Progress event for tag detection stream
|
|
163
|
+
*
|
|
164
|
+
* Sent by POST /resources/:id/detect-tags-stream
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* stream.onProgress((progress: TagDetectionProgress) => {
|
|
169
|
+
* if (progress.status === 'analyzing') {
|
|
170
|
+
* console.log(`Analyzing ${progress.currentCategory}: ${progress.percentage}%`);
|
|
171
|
+
* }
|
|
172
|
+
* });
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
interface TagDetectionProgress {
|
|
176
|
+
/** Current status of tag detection operation */
|
|
177
|
+
status: 'started' | 'analyzing' | 'creating' | 'complete' | 'error';
|
|
178
|
+
/** Resource ID being analyzed */
|
|
179
|
+
resourceId: string;
|
|
180
|
+
/** Current stage of processing */
|
|
181
|
+
stage?: 'analyzing' | 'creating';
|
|
182
|
+
/** Percentage complete (0-100) */
|
|
183
|
+
percentage?: number;
|
|
184
|
+
/** Currently processing this category */
|
|
185
|
+
currentCategory?: string;
|
|
186
|
+
/** Number of categories processed */
|
|
187
|
+
processedCategories?: number;
|
|
188
|
+
/** Total number of categories */
|
|
189
|
+
totalCategories?: number;
|
|
190
|
+
/** Human-readable status message */
|
|
191
|
+
message?: string;
|
|
192
|
+
/** Total tags found */
|
|
193
|
+
tagsFound?: number;
|
|
194
|
+
/** Total tags created */
|
|
195
|
+
tagsCreated?: number;
|
|
196
|
+
/** Tags found by category */
|
|
197
|
+
byCategory?: Record<string, number>;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Resource event from real-time event stream
|
|
201
|
+
*
|
|
202
|
+
* Sent by GET /resources/:id/events/stream
|
|
203
|
+
*
|
|
204
|
+
* This represents a single event from the event store, broadcast in real-time
|
|
205
|
+
* as it occurs. Used for real-time collaboration - multiple users see each
|
|
206
|
+
* other's changes as they happen.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* stream.onEvent((event: ResourceEvent) => {
|
|
211
|
+
* console.log(`Event: ${event.type}`);
|
|
212
|
+
* console.log(`User: ${event.userId}`);
|
|
213
|
+
* console.log(`Payload:`, event.payload);
|
|
214
|
+
* console.log(`Sequence: ${event.metadata.sequenceNumber}`);
|
|
215
|
+
* });
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
interface ResourceEvent {
|
|
219
|
+
/** Event ID (unique) */
|
|
220
|
+
id: string;
|
|
221
|
+
/** Event type (e.g., 'resource.created', 'annotation.created', etc.) */
|
|
222
|
+
type: string;
|
|
223
|
+
/** ISO 8601 timestamp */
|
|
224
|
+
timestamp: string;
|
|
225
|
+
/** User ID who triggered the event */
|
|
226
|
+
userId: string;
|
|
227
|
+
/** Resource ID this event relates to */
|
|
228
|
+
resourceId: string;
|
|
229
|
+
/** Event-specific payload (varies by event type) */
|
|
230
|
+
payload: any;
|
|
231
|
+
/** Event store metadata */
|
|
232
|
+
metadata: {
|
|
233
|
+
/** Monotonically increasing sequence number */
|
|
234
|
+
sequenceNumber: number;
|
|
235
|
+
/** SHA-256 hash of previous event (for integrity) */
|
|
236
|
+
prevEventHash: string;
|
|
237
|
+
/** SHA-256 checksum of this event */
|
|
238
|
+
checksum: string;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* SSE stream controller interface
|
|
243
|
+
*
|
|
244
|
+
* Returned by all SSE methods. Provides callback registration and cleanup.
|
|
245
|
+
*
|
|
246
|
+
* @typeParam TProgress - Type of progress events
|
|
247
|
+
* @typeParam TComplete - Type of completion event
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* const stream: SSEStream<DetectionProgress, DetectionProgress> =
|
|
252
|
+
* client.sse.detectAnnotations(resourceId, { entityTypes: ['Person'] });
|
|
253
|
+
*
|
|
254
|
+
* stream.onProgress((p) => console.log(p.message));
|
|
255
|
+
* stream.onComplete((r) => console.log(`Done! Found ${r.foundCount} entities`));
|
|
256
|
+
* stream.onError((e) => console.error('Failed:', e.message));
|
|
257
|
+
*
|
|
258
|
+
* // Cleanup when done
|
|
259
|
+
* stream.close();
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
interface SSEStream<TProgress, TComplete> {
|
|
263
|
+
/**
|
|
264
|
+
* Register callback for progress events
|
|
265
|
+
*
|
|
266
|
+
* Called for each progress update (e.g., detection-started, detection-progress)
|
|
267
|
+
*/
|
|
268
|
+
onProgress(callback: (progress: TProgress) => void): void;
|
|
269
|
+
/**
|
|
270
|
+
* Register callback for completion event
|
|
271
|
+
*
|
|
272
|
+
* Called once when operation completes successfully (e.g., detection-complete)
|
|
273
|
+
*/
|
|
274
|
+
onComplete(callback: (result: TComplete) => void): void;
|
|
275
|
+
/**
|
|
276
|
+
* Register callback for error events
|
|
277
|
+
*
|
|
278
|
+
* Called if operation fails or stream encounters an error
|
|
279
|
+
*/
|
|
280
|
+
onError(callback: (error: Error) => void): void;
|
|
281
|
+
/**
|
|
282
|
+
* Close the SSE stream and abort the connection
|
|
283
|
+
*
|
|
284
|
+
* Should be called to cleanup resources when stream is no longer needed.
|
|
285
|
+
* Safe to call multiple times.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```typescript
|
|
289
|
+
* // React cleanup
|
|
290
|
+
* useEffect(() => {
|
|
291
|
+
* const stream = client.sse.detectAnnotations(...);
|
|
292
|
+
* return () => stream.close();
|
|
293
|
+
* }, []);
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
close(): void;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* SSE Client for Semiont Streaming Endpoints
|
|
301
|
+
*
|
|
302
|
+
* Provides type-safe methods for Server-Sent Events streaming.
|
|
303
|
+
* Does NOT use ky - uses native fetch() for SSE support.
|
|
304
|
+
*/
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Request body for detection stream
|
|
308
|
+
*/
|
|
309
|
+
interface DetectAnnotationsStreamRequest {
|
|
310
|
+
entityTypes: EntityType[];
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Request body for generation stream
|
|
314
|
+
* Uses generated type from OpenAPI schema
|
|
315
|
+
*/
|
|
316
|
+
type GenerateResourceStreamRequest = components['schemas']['GenerateResourceStreamRequest'];
|
|
317
|
+
/**
|
|
318
|
+
* Request body for highlight detection stream
|
|
319
|
+
*/
|
|
320
|
+
interface DetectHighlightsStreamRequest {
|
|
321
|
+
instructions?: string;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Request body for assessment detection stream
|
|
325
|
+
*/
|
|
326
|
+
interface DetectAssessmentsStreamRequest {
|
|
327
|
+
instructions?: string;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Request body for comment detection stream
|
|
331
|
+
*/
|
|
332
|
+
interface DetectCommentsStreamRequest {
|
|
333
|
+
instructions?: string;
|
|
334
|
+
tone?: 'scholarly' | 'explanatory' | 'conversational' | 'technical';
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Request body for tag detection stream
|
|
338
|
+
*/
|
|
339
|
+
interface DetectTagsStreamRequest {
|
|
340
|
+
schemaId: string;
|
|
341
|
+
categories: string[];
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* SSE Client configuration
|
|
345
|
+
*/
|
|
346
|
+
interface SSEClientConfig {
|
|
347
|
+
baseUrl: BaseUrl;
|
|
348
|
+
accessToken?: AccessToken;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* SSE Client for real-time streaming operations
|
|
352
|
+
*
|
|
353
|
+
* Separate from the main HTTP client to clearly mark streaming endpoints.
|
|
354
|
+
* Uses native fetch() instead of ky for SSE support.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```typescript
|
|
358
|
+
* const sseClient = new SSEClient({
|
|
359
|
+
* baseUrl: 'http://localhost:4000',
|
|
360
|
+
* accessToken: 'your-token'
|
|
361
|
+
* });
|
|
362
|
+
*
|
|
363
|
+
* const stream = sseClient.detectAnnotations(
|
|
364
|
+
* 'http://localhost:4000/resources/doc-123',
|
|
365
|
+
* { entityTypes: ['Person', 'Organization'] }
|
|
366
|
+
* );
|
|
367
|
+
*
|
|
368
|
+
* stream.onProgress((p) => console.log(p.message));
|
|
369
|
+
* stream.onComplete((r) => console.log(`Found ${r.foundCount} entities`));
|
|
370
|
+
* stream.onError((e) => console.error('Detection failed:', e));
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
declare class SSEClient {
|
|
374
|
+
private baseUrl;
|
|
375
|
+
private accessToken;
|
|
376
|
+
constructor(config: SSEClientConfig);
|
|
377
|
+
/**
|
|
378
|
+
* Set the access token for authenticated requests
|
|
379
|
+
*/
|
|
380
|
+
setAccessToken(token: AccessToken): void;
|
|
381
|
+
/**
|
|
382
|
+
* Clear the access token
|
|
383
|
+
*/
|
|
384
|
+
clearAccessToken(): void;
|
|
385
|
+
/**
|
|
386
|
+
* Get common headers for SSE requests
|
|
387
|
+
*/
|
|
388
|
+
private getHeaders;
|
|
389
|
+
/**
|
|
390
|
+
* Extract resource ID from URI
|
|
391
|
+
*
|
|
392
|
+
* Handles both full URIs and plain IDs:
|
|
393
|
+
* - 'http://localhost:4000/resources/doc-123' -> 'doc-123'
|
|
394
|
+
* - 'doc-123' -> 'doc-123'
|
|
395
|
+
*/
|
|
396
|
+
private extractId;
|
|
397
|
+
/**
|
|
398
|
+
* Detect annotations in a resource (streaming)
|
|
399
|
+
*
|
|
400
|
+
* Streams entity detection progress via Server-Sent Events.
|
|
401
|
+
*
|
|
402
|
+
* @param resourceId - Resource URI or ID
|
|
403
|
+
* @param request - Detection configuration (entity types to detect)
|
|
404
|
+
* @returns SSE stream controller with progress/complete/error callbacks
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* const stream = sseClient.detectAnnotations(
|
|
409
|
+
* 'http://localhost:4000/resources/doc-123',
|
|
410
|
+
* { entityTypes: ['Person', 'Organization'] }
|
|
411
|
+
* );
|
|
412
|
+
*
|
|
413
|
+
* stream.onProgress((progress) => {
|
|
414
|
+
* console.log(`Scanning: ${progress.currentEntityType}`);
|
|
415
|
+
* console.log(`Progress: ${progress.processedEntityTypes}/${progress.totalEntityTypes}`);
|
|
416
|
+
* });
|
|
417
|
+
*
|
|
418
|
+
* stream.onComplete((result) => {
|
|
419
|
+
* console.log(`Detection complete! Found ${result.foundCount} entities`);
|
|
420
|
+
* });
|
|
421
|
+
*
|
|
422
|
+
* stream.onError((error) => {
|
|
423
|
+
* console.error('Detection failed:', error.message);
|
|
424
|
+
* });
|
|
425
|
+
*
|
|
426
|
+
* // Cleanup when done
|
|
427
|
+
* stream.close();
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
430
|
+
detectAnnotations(resourceId: ResourceUri, request: DetectAnnotationsStreamRequest): SSEStream<DetectionProgress, DetectionProgress>;
|
|
431
|
+
/**
|
|
432
|
+
* Generate resource from annotation (streaming)
|
|
433
|
+
*
|
|
434
|
+
* Streams resource generation progress via Server-Sent Events.
|
|
435
|
+
*
|
|
436
|
+
* @param resourceId - Source resource URI or ID
|
|
437
|
+
* @param annotationId - Annotation URI or ID to use as generation source
|
|
438
|
+
* @param request - Generation options (title, prompt, language)
|
|
439
|
+
* @returns SSE stream controller with progress/complete/error callbacks
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```typescript
|
|
443
|
+
* const stream = sseClient.generateResourceFromAnnotation(
|
|
444
|
+
* 'http://localhost:4000/resources/doc-123',
|
|
445
|
+
* 'http://localhost:4000/annotations/ann-456',
|
|
446
|
+
* { language: 'es', title: 'Spanish Summary' }
|
|
447
|
+
* );
|
|
448
|
+
*
|
|
449
|
+
* stream.onProgress((progress) => {
|
|
450
|
+
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
451
|
+
* console.log(progress.message);
|
|
452
|
+
* });
|
|
453
|
+
*
|
|
454
|
+
* stream.onComplete((result) => {
|
|
455
|
+
* console.log(`Generated resource: ${result.resourceId}`);
|
|
456
|
+
* });
|
|
457
|
+
*
|
|
458
|
+
* stream.onError((error) => {
|
|
459
|
+
* console.error('Generation failed:', error.message);
|
|
460
|
+
* });
|
|
461
|
+
*
|
|
462
|
+
* // Cleanup when done
|
|
463
|
+
* stream.close();
|
|
464
|
+
* ```
|
|
465
|
+
*/
|
|
466
|
+
generateResourceFromAnnotation(resourceId: ResourceUri, annotationId: AnnotationUri, request: GenerateResourceStreamRequest): SSEStream<GenerationProgress, GenerationProgress>;
|
|
467
|
+
/**
|
|
468
|
+
* Detect highlights in a resource (streaming)
|
|
469
|
+
*
|
|
470
|
+
* Streams highlight detection progress via Server-Sent Events.
|
|
471
|
+
*
|
|
472
|
+
* @param resourceId - Resource URI or ID
|
|
473
|
+
* @param request - Detection configuration (optional instructions)
|
|
474
|
+
* @returns SSE stream controller with progress/complete/error callbacks
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* ```typescript
|
|
478
|
+
* const stream = sseClient.detectHighlights(
|
|
479
|
+
* 'http://localhost:4000/resources/doc-123',
|
|
480
|
+
* { instructions: 'Focus on key technical points' }
|
|
481
|
+
* );
|
|
482
|
+
*
|
|
483
|
+
* stream.onProgress((progress) => {
|
|
484
|
+
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
485
|
+
* console.log(progress.message);
|
|
486
|
+
* });
|
|
487
|
+
*
|
|
488
|
+
* stream.onComplete((result) => {
|
|
489
|
+
* console.log(`Detection complete! Created ${result.createdCount} highlights`);
|
|
490
|
+
* });
|
|
491
|
+
*
|
|
492
|
+
* stream.onError((error) => {
|
|
493
|
+
* console.error('Detection failed:', error.message);
|
|
494
|
+
* });
|
|
495
|
+
*
|
|
496
|
+
* // Cleanup when done
|
|
497
|
+
* stream.close();
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
500
|
+
detectHighlights(resourceId: ResourceUri, request?: DetectHighlightsStreamRequest): SSEStream<HighlightDetectionProgress, HighlightDetectionProgress>;
|
|
501
|
+
/**
|
|
502
|
+
* Detect assessments in a resource (streaming)
|
|
503
|
+
*
|
|
504
|
+
* Streams assessment detection progress via Server-Sent Events.
|
|
505
|
+
*
|
|
506
|
+
* @param resourceId - Resource URI or ID
|
|
507
|
+
* @param request - Detection configuration (optional instructions)
|
|
508
|
+
* @returns SSE stream controller with progress/complete/error callbacks
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* ```typescript
|
|
512
|
+
* const stream = sseClient.detectAssessments(
|
|
513
|
+
* 'http://localhost:4000/resources/doc-123',
|
|
514
|
+
* { instructions: 'Evaluate claims for accuracy' }
|
|
515
|
+
* );
|
|
516
|
+
*
|
|
517
|
+
* stream.onProgress((progress) => {
|
|
518
|
+
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
519
|
+
* console.log(progress.message);
|
|
520
|
+
* });
|
|
521
|
+
*
|
|
522
|
+
* stream.onComplete((result) => {
|
|
523
|
+
* console.log(`Detection complete! Created ${result.createdCount} assessments`);
|
|
524
|
+
* });
|
|
525
|
+
*
|
|
526
|
+
* stream.onError((error) => {
|
|
527
|
+
* console.error('Detection failed:', error.message);
|
|
528
|
+
* });
|
|
529
|
+
*
|
|
530
|
+
* // Cleanup when done
|
|
531
|
+
* stream.close();
|
|
532
|
+
* ```
|
|
533
|
+
*/
|
|
534
|
+
detectAssessments(resourceId: ResourceUri, request?: DetectAssessmentsStreamRequest): SSEStream<AssessmentDetectionProgress, AssessmentDetectionProgress>;
|
|
535
|
+
/**
|
|
536
|
+
* Detect comments in a resource (streaming)
|
|
537
|
+
*
|
|
538
|
+
* Streams comment detection progress via Server-Sent Events.
|
|
539
|
+
* Uses AI to identify passages that would benefit from explanatory comments
|
|
540
|
+
* and creates comment annotations with contextual information.
|
|
541
|
+
*
|
|
542
|
+
* @param resourceId - Resource URI or ID
|
|
543
|
+
* @param request - Detection configuration (optional instructions and tone)
|
|
544
|
+
* @returns SSE stream controller with progress/complete/error callbacks
|
|
545
|
+
*
|
|
546
|
+
* @example
|
|
547
|
+
* ```typescript
|
|
548
|
+
* const stream = sseClient.detectComments('http://localhost:4000/resources/doc-123', {
|
|
549
|
+
* instructions: 'Focus on technical terminology',
|
|
550
|
+
* tone: 'scholarly'
|
|
551
|
+
* });
|
|
552
|
+
*
|
|
553
|
+
* stream.onProgress((progress) => {
|
|
554
|
+
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
555
|
+
* });
|
|
556
|
+
*
|
|
557
|
+
* stream.onComplete((result) => {
|
|
558
|
+
* console.log(`Detection complete! Created ${result.createdCount} comments`);
|
|
559
|
+
* });
|
|
560
|
+
*
|
|
561
|
+
* stream.onError((error) => {
|
|
562
|
+
* console.error('Detection failed:', error.message);
|
|
563
|
+
* });
|
|
564
|
+
*
|
|
565
|
+
* // Cleanup when done
|
|
566
|
+
* stream.close();
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
569
|
+
detectComments(resourceId: ResourceUri, request?: DetectCommentsStreamRequest): SSEStream<CommentDetectionProgress, CommentDetectionProgress>;
|
|
570
|
+
/**
|
|
571
|
+
* Detect tags in a resource (streaming)
|
|
572
|
+
*
|
|
573
|
+
* Streams tag detection progress via Server-Sent Events.
|
|
574
|
+
* Uses AI to identify passages serving specific structural roles
|
|
575
|
+
* (e.g., IRAC, IMRAD, Toulmin) and creates tag annotations with dual-body structure.
|
|
576
|
+
*
|
|
577
|
+
* @param resourceId - Resource URI or ID
|
|
578
|
+
* @param request - Detection configuration (schema and categories to detect)
|
|
579
|
+
* @returns SSE stream controller with progress/complete/error callbacks
|
|
580
|
+
*
|
|
581
|
+
* @example
|
|
582
|
+
* ```typescript
|
|
583
|
+
* const stream = sseClient.detectTags('http://localhost:4000/resources/doc-123', {
|
|
584
|
+
* schemaId: 'legal-irac',
|
|
585
|
+
* categories: ['Issue', 'Rule', 'Application', 'Conclusion']
|
|
586
|
+
* });
|
|
587
|
+
*
|
|
588
|
+
* stream.onProgress((progress) => {
|
|
589
|
+
* console.log(`${progress.status}: ${progress.percentage}%`);
|
|
590
|
+
* console.log(`Processing ${progress.currentCategory}...`);
|
|
591
|
+
* });
|
|
592
|
+
*
|
|
593
|
+
* stream.onComplete((result) => {
|
|
594
|
+
* console.log(`Detection complete! Created ${result.tagsCreated} tags`);
|
|
595
|
+
* });
|
|
596
|
+
*
|
|
597
|
+
* stream.onError((error) => {
|
|
598
|
+
* console.error('Detection failed:', error.message);
|
|
599
|
+
* });
|
|
600
|
+
*
|
|
601
|
+
* // Cleanup when done
|
|
602
|
+
* stream.close();
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
605
|
+
detectTags(resourceId: ResourceUri, request: DetectTagsStreamRequest): SSEStream<TagDetectionProgress, TagDetectionProgress>;
|
|
606
|
+
/**
|
|
607
|
+
* Subscribe to resource events (long-lived stream)
|
|
608
|
+
*
|
|
609
|
+
* Opens a long-lived SSE connection to receive real-time events for a resource.
|
|
610
|
+
* Used for collaborative editing - see events from other users as they happen.
|
|
611
|
+
*
|
|
612
|
+
* This stream does NOT have a complete event - it stays open until explicitly closed.
|
|
613
|
+
*
|
|
614
|
+
* @param resourceId - Resource URI or ID to subscribe to
|
|
615
|
+
* @returns SSE stream controller with event callback
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* ```typescript
|
|
619
|
+
* const stream = sseClient.resourceEvents('http://localhost:4000/resources/doc-123');
|
|
620
|
+
*
|
|
621
|
+
* stream.onProgress((event) => {
|
|
622
|
+
* console.log(`Event: ${event.type}`);
|
|
623
|
+
* console.log(`User: ${event.userId}`);
|
|
624
|
+
* console.log(`Sequence: ${event.metadata.sequenceNumber}`);
|
|
625
|
+
* console.log(`Payload:`, event.payload);
|
|
626
|
+
* });
|
|
627
|
+
*
|
|
628
|
+
* stream.onError((error) => {
|
|
629
|
+
* console.error('Stream error:', error.message);
|
|
630
|
+
* });
|
|
631
|
+
*
|
|
632
|
+
* // Close when no longer needed (e.g., component unmount)
|
|
633
|
+
* stream.close();
|
|
634
|
+
* ```
|
|
635
|
+
*/
|
|
636
|
+
resourceEvents(resourceId: ResourceUri): SSEStream<ResourceEvent, never>;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Common API client for Semiont backend
|
|
641
|
+
*
|
|
642
|
+
* This client can be used by:
|
|
643
|
+
* - MCP server (Node.js)
|
|
644
|
+
* - Demo scripts (Node.js)
|
|
645
|
+
* - Frontend (Next.js/React - can wrap with hooks)
|
|
646
|
+
*
|
|
647
|
+
* Uses ky for HTTP requests with built-in retry, timeout, and error handling.
|
|
648
|
+
*/
|
|
649
|
+
|
|
650
|
+
type ResponseContent<T> = T extends {
|
|
651
|
+
responses: {
|
|
652
|
+
200: {
|
|
653
|
+
content: {
|
|
654
|
+
'application/json': infer R;
|
|
655
|
+
};
|
|
656
|
+
};
|
|
657
|
+
};
|
|
658
|
+
} ? R : T extends {
|
|
659
|
+
responses: {
|
|
660
|
+
201: {
|
|
661
|
+
content: {
|
|
662
|
+
'application/json': infer R;
|
|
663
|
+
};
|
|
664
|
+
};
|
|
665
|
+
};
|
|
666
|
+
} ? R : never;
|
|
667
|
+
type RequestContent<T> = T extends {
|
|
668
|
+
requestBody?: {
|
|
669
|
+
content: {
|
|
670
|
+
'application/json': infer R;
|
|
671
|
+
};
|
|
672
|
+
};
|
|
673
|
+
} ? R : never;
|
|
674
|
+
declare class APIError extends Error {
|
|
675
|
+
status: number;
|
|
676
|
+
statusText: string;
|
|
677
|
+
details?: unknown | undefined;
|
|
678
|
+
constructor(message: string, status: number, statusText: string, details?: unknown | undefined);
|
|
679
|
+
}
|
|
680
|
+
interface SemiontApiClientConfig {
|
|
681
|
+
baseUrl: BaseUrl;
|
|
682
|
+
accessToken?: AccessToken;
|
|
683
|
+
timeout?: number;
|
|
684
|
+
retry?: number;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Semiont API Client
|
|
688
|
+
*
|
|
689
|
+
* Provides type-safe methods for all Semiont backend API endpoints.
|
|
690
|
+
*/
|
|
691
|
+
declare class SemiontApiClient {
|
|
692
|
+
private http;
|
|
693
|
+
private baseUrl;
|
|
694
|
+
private accessToken;
|
|
695
|
+
/**
|
|
696
|
+
* SSE streaming client for real-time operations
|
|
697
|
+
*
|
|
698
|
+
* Separate from the main HTTP client to clearly mark streaming endpoints.
|
|
699
|
+
* Uses native fetch() instead of ky for SSE support.
|
|
700
|
+
*
|
|
701
|
+
* @example
|
|
702
|
+
* ```typescript
|
|
703
|
+
* const stream = client.sse.detectAnnotations(
|
|
704
|
+
* resourceId,
|
|
705
|
+
* { entityTypes: ['Person', 'Organization'] }
|
|
706
|
+
* );
|
|
707
|
+
*
|
|
708
|
+
* stream.onProgress((p) => console.log(p.message));
|
|
709
|
+
* stream.onComplete((r) => console.log(`Found ${r.foundCount} entities`));
|
|
710
|
+
* stream.close();
|
|
711
|
+
* ```
|
|
712
|
+
*/
|
|
713
|
+
readonly sse: SSEClient;
|
|
714
|
+
constructor(config: SemiontApiClientConfig);
|
|
715
|
+
/**
|
|
716
|
+
* Set the access token for authenticated requests
|
|
717
|
+
*/
|
|
718
|
+
setAccessToken(token: AccessToken): void;
|
|
719
|
+
/**
|
|
720
|
+
* Clear the access token
|
|
721
|
+
*/
|
|
722
|
+
clearAccessToken(): void;
|
|
723
|
+
authenticatePassword(email: Email, password: string): Promise<ResponseContent<paths['/api/tokens/password']['post']>>;
|
|
724
|
+
refreshToken(token: RefreshToken): Promise<ResponseContent<paths['/api/tokens/refresh']['post']>>;
|
|
725
|
+
authenticateGoogle(credential: GoogleCredential): Promise<ResponseContent<paths['/api/tokens/google']['post']>>;
|
|
726
|
+
generateMCPToken(): Promise<ResponseContent<paths['/api/tokens/mcp-generate']['post']>>;
|
|
727
|
+
getMe(): Promise<ResponseContent<paths['/api/users/me']['get']>>;
|
|
728
|
+
acceptTerms(): Promise<ResponseContent<paths['/api/users/accept-terms']['post']>>;
|
|
729
|
+
logout(): Promise<ResponseContent<paths['/api/users/logout']['post']>>;
|
|
730
|
+
/**
|
|
731
|
+
* Create a new resource with binary content support
|
|
732
|
+
*
|
|
733
|
+
* @param data - Resource creation data
|
|
734
|
+
* @param data.name - Resource name
|
|
735
|
+
* @param data.file - File object or Buffer with binary content
|
|
736
|
+
* @param data.format - MIME type (e.g., 'text/markdown', 'image/png')
|
|
737
|
+
* @param data.entityTypes - Optional array of entity types
|
|
738
|
+
* @param data.language - Optional ISO 639-1 language code
|
|
739
|
+
* @param data.creationMethod - Optional creation method
|
|
740
|
+
* @param data.sourceAnnotationId - Optional source annotation ID
|
|
741
|
+
* @param data.sourceResourceId - Optional source resource ID
|
|
742
|
+
*/
|
|
743
|
+
createResource(data: {
|
|
744
|
+
name: string;
|
|
745
|
+
file: File | Buffer;
|
|
746
|
+
format: string;
|
|
747
|
+
entityTypes?: string[];
|
|
748
|
+
language?: string;
|
|
749
|
+
creationMethod?: string;
|
|
750
|
+
sourceAnnotationId?: string;
|
|
751
|
+
sourceResourceId?: string;
|
|
752
|
+
}): Promise<ResponseContent<paths['/resources']['post']>>;
|
|
753
|
+
getResource(resourceUri: ResourceUri): Promise<ResponseContent<paths['/resources/{id}']['get']>>;
|
|
754
|
+
/**
|
|
755
|
+
* Get resource representation using W3C content negotiation
|
|
756
|
+
* Returns raw binary content (images, PDFs, text, etc.) with content type
|
|
757
|
+
*
|
|
758
|
+
* @param resourceUri - Full resource URI
|
|
759
|
+
* @param options - Options including Accept header for content negotiation
|
|
760
|
+
* @returns Object with data (ArrayBuffer) and contentType (string)
|
|
761
|
+
*
|
|
762
|
+
* @example
|
|
763
|
+
* ```typescript
|
|
764
|
+
* // Get markdown representation
|
|
765
|
+
* const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'text/markdown' });
|
|
766
|
+
* const markdown = new TextDecoder().decode(data);
|
|
767
|
+
*
|
|
768
|
+
* // Get image representation
|
|
769
|
+
* const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'image/png' });
|
|
770
|
+
* const blob = new Blob([data], { type: contentType });
|
|
771
|
+
*
|
|
772
|
+
* // Get PDF representation
|
|
773
|
+
* const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'application/pdf' });
|
|
774
|
+
* ```
|
|
775
|
+
*/
|
|
776
|
+
getResourceRepresentation(resourceUri: ResourceUri, options?: {
|
|
777
|
+
accept?: ContentFormat;
|
|
778
|
+
}): Promise<{
|
|
779
|
+
data: ArrayBuffer;
|
|
780
|
+
contentType: string;
|
|
781
|
+
}>;
|
|
782
|
+
/**
|
|
783
|
+
* Get resource representation as a stream using W3C content negotiation
|
|
784
|
+
* Returns streaming binary content (for large files: videos, large PDFs, etc.)
|
|
785
|
+
*
|
|
786
|
+
* Use this for large files to avoid loading entire content into memory.
|
|
787
|
+
* The stream is consumed incrementally and the backend connection stays open
|
|
788
|
+
* until the stream is fully consumed or closed.
|
|
789
|
+
*
|
|
790
|
+
* @param resourceUri - Full resource URI
|
|
791
|
+
* @param options - Options including Accept header for content negotiation
|
|
792
|
+
* @returns Object with stream (ReadableStream) and contentType (string)
|
|
793
|
+
*
|
|
794
|
+
* @example
|
|
795
|
+
* ```typescript
|
|
796
|
+
* // Stream large file
|
|
797
|
+
* const { stream, contentType } = await client.getResourceRepresentationStream(rUri, {
|
|
798
|
+
* accept: 'video/mp4'
|
|
799
|
+
* });
|
|
800
|
+
*
|
|
801
|
+
* // Consume stream chunk by chunk (never loads entire file into memory)
|
|
802
|
+
* for await (const chunk of stream) {
|
|
803
|
+
* // Process chunk
|
|
804
|
+
* console.log(`Received ${chunk.length} bytes`);
|
|
805
|
+
* }
|
|
806
|
+
*
|
|
807
|
+
* // Or pipe to a file in Node.js
|
|
808
|
+
* const fileStream = fs.createWriteStream('output.mp4');
|
|
809
|
+
* const reader = stream.getReader();
|
|
810
|
+
* while (true) {
|
|
811
|
+
* const { done, value } = await reader.read();
|
|
812
|
+
* if (done) break;
|
|
813
|
+
* fileStream.write(value);
|
|
814
|
+
* }
|
|
815
|
+
* ```
|
|
816
|
+
*/
|
|
817
|
+
getResourceRepresentationStream(resourceUri: ResourceUri, options?: {
|
|
818
|
+
accept?: ContentFormat;
|
|
819
|
+
}): Promise<{
|
|
820
|
+
stream: ReadableStream<Uint8Array>;
|
|
821
|
+
contentType: string;
|
|
822
|
+
}>;
|
|
823
|
+
listResources(limit?: number, archived?: boolean, query?: SearchQuery): Promise<ResponseContent<paths['/resources']['get']>>;
|
|
824
|
+
updateResource(resourceUri: ResourceUri, data: RequestContent<paths['/resources/{id}']['patch']>): Promise<ResponseContent<paths['/resources/{id}']['patch']>>;
|
|
825
|
+
getResourceEvents(resourceUri: ResourceUri): Promise<{
|
|
826
|
+
events: any[];
|
|
827
|
+
}>;
|
|
828
|
+
getResourceAnnotations(resourceUri: ResourceUri): Promise<ResponseContent<paths['/resources/{id}/annotations']['get']>>;
|
|
829
|
+
getAnnotationLLMContext(resourceUri: ResourceUri, annotationId: string, options?: {
|
|
830
|
+
contextWindow?: number;
|
|
831
|
+
}): Promise<ResponseContent<paths['/resources/{resourceId}/annotations/{annotationId}/llm-context']['get']>>;
|
|
832
|
+
getResourceReferencedBy(resourceUri: ResourceUri): Promise<{
|
|
833
|
+
referencedBy: any[];
|
|
834
|
+
}>;
|
|
835
|
+
generateCloneToken(resourceUri: ResourceUri): Promise<ResponseContent<paths['/resources/{id}/clone-with-token']['post']>>;
|
|
836
|
+
getResourceByToken(token: CloneToken): Promise<ResponseContent<paths['/api/resources/token/{token}']['get']>>;
|
|
837
|
+
createResourceFromToken(data: RequestContent<paths['/api/resources/create-from-token']['post']>): Promise<ResponseContent<paths['/api/resources/create-from-token']['post']>>;
|
|
838
|
+
createAnnotation(resourceUri: ResourceUri, data: RequestContent<paths['/resources/{id}/annotations']['post']>): Promise<ResponseContent<paths['/resources/{id}/annotations']['post']>>;
|
|
839
|
+
getAnnotation(annotationUri: AnnotationUri): Promise<ResponseContent<paths['/annotations/{id}']['get']>>;
|
|
840
|
+
getResourceAnnotation(annotationUri: ResourceAnnotationUri): Promise<ResponseContent<paths['/resources/{resourceId}/annotations/{annotationId}']['get']>>;
|
|
841
|
+
listAnnotations(resourceUri: ResourceUri, motivation?: Motivation): Promise<ResponseContent<paths['/resources/{id}/annotations']['get']>>;
|
|
842
|
+
deleteAnnotation(annotationUri: ResourceAnnotationUri): Promise<void>;
|
|
843
|
+
updateAnnotationBody(annotationUri: ResourceAnnotationUri, data: RequestContent<paths['/resources/{resourceId}/annotations/{annotationId}/body']['put']>): Promise<ResponseContent<paths['/resources/{resourceId}/annotations/{annotationId}/body']['put']>>;
|
|
844
|
+
getAnnotationHistory(annotationUri: ResourceAnnotationUri): Promise<ResponseContent<paths['/resources/{resourceId}/annotations/{annotationId}/history']['get']>>;
|
|
845
|
+
addEntityType(type: EntityType): Promise<ResponseContent<paths['/api/entity-types']['post']>>;
|
|
846
|
+
addEntityTypesBulk(types: EntityType[]): Promise<ResponseContent<paths['/api/entity-types/bulk']['post']>>;
|
|
847
|
+
listEntityTypes(): Promise<ResponseContent<paths['/api/entity-types']['get']>>;
|
|
848
|
+
listUsers(): Promise<ResponseContent<paths['/api/admin/users']['get']>>;
|
|
849
|
+
getUserStats(): Promise<ResponseContent<paths['/api/admin/users/stats']['get']>>;
|
|
850
|
+
/**
|
|
851
|
+
* Update a user by ID
|
|
852
|
+
* Note: Users use DID identifiers (did:web:domain:users:id), not HTTP URIs.
|
|
853
|
+
*/
|
|
854
|
+
updateUser(id: UserDID, data: RequestContent<paths['/api/admin/users/{id}']['patch']>): Promise<ResponseContent<paths['/api/admin/users/{id}']['patch']>>;
|
|
855
|
+
getOAuthConfig(): Promise<ResponseContent<paths['/api/admin/oauth/config']['get']>>;
|
|
856
|
+
getJobStatus(id: JobId): Promise<ResponseContent<paths['/api/jobs/{id}']['get']>>;
|
|
857
|
+
/**
|
|
858
|
+
* Poll a job until it completes or fails
|
|
859
|
+
* @param id - The job ID to poll
|
|
860
|
+
* @param options - Polling options
|
|
861
|
+
* @returns The final job status
|
|
862
|
+
*/
|
|
863
|
+
pollJobUntilComplete(id: JobId, options?: {
|
|
864
|
+
interval?: number;
|
|
865
|
+
timeout?: number;
|
|
866
|
+
onProgress?: (status: ResponseContent<paths['/api/jobs/{id}']['get']>) => void;
|
|
867
|
+
}): Promise<ResponseContent<paths['/api/jobs/{id}']['get']>>;
|
|
868
|
+
getResourceLLMContext(resourceUri: ResourceUri, options?: {
|
|
869
|
+
depth?: number;
|
|
870
|
+
maxResources?: number;
|
|
871
|
+
includeContent?: boolean;
|
|
872
|
+
includeSummary?: boolean;
|
|
873
|
+
}): Promise<ResponseContent<paths['/resources/{id}/llm-context']['get']>>;
|
|
874
|
+
healthCheck(): Promise<ResponseContent<paths['/api/health']['get']>>;
|
|
875
|
+
getStatus(): Promise<ResponseContent<paths['/api/status']['get']>>;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* MIME type utilities for Semiont
|
|
880
|
+
*
|
|
881
|
+
* Initial support for:
|
|
882
|
+
* - text/plain
|
|
883
|
+
* - text/markdown
|
|
884
|
+
* - image/png
|
|
885
|
+
* - image/jpeg
|
|
886
|
+
*/
|
|
887
|
+
/**
|
|
888
|
+
* Map MIME type to file extension
|
|
889
|
+
*/
|
|
890
|
+
declare function getExtensionForMimeType(mimeType: string): string;
|
|
891
|
+
/**
|
|
892
|
+
* Detect if MIME type is an image (png or jpeg only for now)
|
|
893
|
+
*/
|
|
894
|
+
declare function isImageMimeType(mimeType: string): boolean;
|
|
895
|
+
/**
|
|
896
|
+
* Detect if MIME type is text-based (plain or markdown only for now)
|
|
897
|
+
*/
|
|
898
|
+
declare function isTextMimeType(mimeType: string): boolean;
|
|
899
|
+
/**
|
|
900
|
+
* Get category for MIME type (for routing to appropriate viewer)
|
|
901
|
+
*/
|
|
902
|
+
type MimeCategory = 'text' | 'image' | 'unsupported';
|
|
903
|
+
declare function getMimeCategory(mimeType: string): MimeCategory;
|
|
904
|
+
|
|
1
905
|
/**
|
|
2
906
|
* @semiont/api-client
|
|
3
907
|
*
|
|
@@ -28,16 +932,8 @@
|
|
|
28
932
|
* }
|
|
29
933
|
* ```
|
|
30
934
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export type GenerationContext
|
|
36
|
-
export type AnnotationLLMContextResponse = components['schemas']['AnnotationLLMContextResponse'];
|
|
37
|
-
export type { DetectionProgress, GenerationProgress, ResourceEvent, SSEStream } from './sse/types';
|
|
38
|
-
export { SSEClient } from './sse';
|
|
39
|
-
export type { DetectAnnotationsStreamRequest, GenerateResourceStreamRequest, SSEClientConfig } from './sse';
|
|
40
|
-
export * from './utils';
|
|
41
|
-
export { getExtensionForMimeType, isImageMimeType, isTextMimeType, getMimeCategory, type MimeCategory } from './mime-utils';
|
|
42
|
-
export * from './branded-types';
|
|
43
|
-
//# sourceMappingURL=index.d.ts.map
|
|
935
|
+
|
|
936
|
+
type GenerationContext = components['schemas']['GenerationContext'];
|
|
937
|
+
type AnnotationLLMContextResponse = components['schemas']['AnnotationLLMContextResponse'];
|
|
938
|
+
|
|
939
|
+
export { APIError, AccessToken, type AnnotationLLMContextResponse, AnnotationUri, BaseUrl, CloneToken, ContentFormat, type DetectAnnotationsStreamRequest, type DetectionProgress, Email, EntityType, type GenerateResourceStreamRequest, type GenerationContext, type GenerationProgress, GoogleCredential, JobId, type MimeCategory, Motivation, RefreshToken, ResourceAnnotationUri, type ResourceEvent, ResourceUri, SSEClient, type SSEClientConfig, type SSEStream, SearchQuery, SemiontApiClient, type SemiontApiClientConfig, UserDID, components, getExtensionForMimeType, getMimeCategory, isImageMimeType, isTextMimeType, paths };
|