@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/client.js
DELETED
|
@@ -1,460 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Common API client for Semiont backend
|
|
4
|
-
*
|
|
5
|
-
* This client can be used by:
|
|
6
|
-
* - MCP server (Node.js)
|
|
7
|
-
* - Demo scripts (Node.js)
|
|
8
|
-
* - Frontend (Next.js/React - can wrap with hooks)
|
|
9
|
-
*
|
|
10
|
-
* Uses ky for HTTP requests with built-in retry, timeout, and error handling.
|
|
11
|
-
*/
|
|
12
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
-
};
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.SemiontApiClient = exports.APIError = void 0;
|
|
17
|
-
const ky_1 = __importDefault(require("ky"));
|
|
18
|
-
const sse_1 = require("./sse");
|
|
19
|
-
// API Error class
|
|
20
|
-
class APIError extends Error {
|
|
21
|
-
status;
|
|
22
|
-
statusText;
|
|
23
|
-
details;
|
|
24
|
-
constructor(message, status, statusText, details) {
|
|
25
|
-
super(message);
|
|
26
|
-
this.status = status;
|
|
27
|
-
this.statusText = statusText;
|
|
28
|
-
this.details = details;
|
|
29
|
-
this.name = 'APIError';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.APIError = APIError;
|
|
33
|
-
/**
|
|
34
|
-
* Semiont API Client
|
|
35
|
-
*
|
|
36
|
-
* Provides type-safe methods for all Semiont backend API endpoints.
|
|
37
|
-
*/
|
|
38
|
-
class SemiontApiClient {
|
|
39
|
-
http;
|
|
40
|
-
baseUrl;
|
|
41
|
-
accessToken = null;
|
|
42
|
-
/**
|
|
43
|
-
* SSE streaming client for real-time operations
|
|
44
|
-
*
|
|
45
|
-
* Separate from the main HTTP client to clearly mark streaming endpoints.
|
|
46
|
-
* Uses native fetch() instead of ky for SSE support.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* const stream = client.sse.detectAnnotations(
|
|
51
|
-
* resourceId,
|
|
52
|
-
* { entityTypes: ['Person', 'Organization'] }
|
|
53
|
-
* );
|
|
54
|
-
*
|
|
55
|
-
* stream.onProgress((p) => console.log(p.message));
|
|
56
|
-
* stream.onComplete((r) => console.log(`Found ${r.foundCount} entities`));
|
|
57
|
-
* stream.close();
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
sse;
|
|
61
|
-
constructor(config) {
|
|
62
|
-
const { baseUrl, accessToken, timeout = 30000, retry = 2 } = config;
|
|
63
|
-
// Store baseUrl for constructing full URLs
|
|
64
|
-
// Remove trailing slash for consistent URL construction
|
|
65
|
-
this.baseUrl = (baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl);
|
|
66
|
-
// Don't use prefixUrl - we'll construct full URLs or use provided full URIs
|
|
67
|
-
this.http = ky_1.default.create({
|
|
68
|
-
timeout,
|
|
69
|
-
retry,
|
|
70
|
-
hooks: {
|
|
71
|
-
beforeRequest: [
|
|
72
|
-
(request) => {
|
|
73
|
-
if (this.accessToken) {
|
|
74
|
-
request.headers.set('Authorization', `Bearer ${this.accessToken}`);
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
beforeError: [
|
|
79
|
-
async (error) => {
|
|
80
|
-
const { response } = error;
|
|
81
|
-
if (response) {
|
|
82
|
-
const body = await response.json().catch(() => ({}));
|
|
83
|
-
throw new APIError(body.message || `HTTP ${response.status}: ${response.statusText}`, response.status, response.statusText, body);
|
|
84
|
-
}
|
|
85
|
-
return error;
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
if (accessToken) {
|
|
91
|
-
this.accessToken = accessToken;
|
|
92
|
-
}
|
|
93
|
-
// Initialize SSE client (uses native fetch, not ky)
|
|
94
|
-
this.sse = new sse_1.SSEClient({
|
|
95
|
-
baseUrl: this.baseUrl,
|
|
96
|
-
accessToken: this.accessToken || undefined
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Set the access token for authenticated requests
|
|
101
|
-
*/
|
|
102
|
-
setAccessToken(token) {
|
|
103
|
-
this.accessToken = token;
|
|
104
|
-
this.sse.setAccessToken(token);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Clear the access token
|
|
108
|
-
*/
|
|
109
|
-
clearAccessToken() {
|
|
110
|
-
this.accessToken = null;
|
|
111
|
-
this.sse.clearAccessToken();
|
|
112
|
-
}
|
|
113
|
-
// ============================================================================
|
|
114
|
-
// AUTHENTICATION
|
|
115
|
-
// ============================================================================
|
|
116
|
-
async authenticatePassword(email, password) {
|
|
117
|
-
const response = await this.http.post(`${this.baseUrl}/api/tokens/password`, { json: { email, password } }).json();
|
|
118
|
-
if (response.token) {
|
|
119
|
-
this.setAccessToken(response.token);
|
|
120
|
-
}
|
|
121
|
-
return response;
|
|
122
|
-
}
|
|
123
|
-
async refreshToken(token) {
|
|
124
|
-
const response = await this.http.post(`${this.baseUrl}/api/tokens/refresh`, { json: { refreshToken: token } }).json();
|
|
125
|
-
if (response.access_token) {
|
|
126
|
-
this.setAccessToken(response.access_token);
|
|
127
|
-
}
|
|
128
|
-
return response;
|
|
129
|
-
}
|
|
130
|
-
async authenticateGoogle(credential) {
|
|
131
|
-
const response = await this.http.post(`${this.baseUrl}/api/tokens/google`, { json: { credential } }).json();
|
|
132
|
-
if (response.token) {
|
|
133
|
-
this.setAccessToken(response.token);
|
|
134
|
-
}
|
|
135
|
-
return response;
|
|
136
|
-
}
|
|
137
|
-
async generateMCPToken() {
|
|
138
|
-
return this.http.post(`${this.baseUrl}/api/tokens/mcp-generate`).json();
|
|
139
|
-
}
|
|
140
|
-
// ============================================================================
|
|
141
|
-
// USERS
|
|
142
|
-
// ============================================================================
|
|
143
|
-
async getMe() {
|
|
144
|
-
return this.http.get(`${this.baseUrl}/api/users/me`).json();
|
|
145
|
-
}
|
|
146
|
-
async acceptTerms() {
|
|
147
|
-
return this.http.post(`${this.baseUrl}/api/users/accept-terms`).json();
|
|
148
|
-
}
|
|
149
|
-
async logout() {
|
|
150
|
-
return this.http.post(`${this.baseUrl}/api/users/logout`).json();
|
|
151
|
-
}
|
|
152
|
-
// ============================================================================
|
|
153
|
-
// RESOURCES
|
|
154
|
-
// ============================================================================
|
|
155
|
-
/**
|
|
156
|
-
* Create a new resource with binary content support
|
|
157
|
-
*
|
|
158
|
-
* @param data - Resource creation data
|
|
159
|
-
* @param data.name - Resource name
|
|
160
|
-
* @param data.file - File object or Buffer with binary content
|
|
161
|
-
* @param data.format - MIME type (e.g., 'text/markdown', 'image/png')
|
|
162
|
-
* @param data.entityTypes - Optional array of entity types
|
|
163
|
-
* @param data.language - Optional ISO 639-1 language code
|
|
164
|
-
* @param data.creationMethod - Optional creation method
|
|
165
|
-
* @param data.sourceAnnotationId - Optional source annotation ID
|
|
166
|
-
* @param data.sourceResourceId - Optional source resource ID
|
|
167
|
-
*/
|
|
168
|
-
async createResource(data) {
|
|
169
|
-
// Build FormData
|
|
170
|
-
const formData = new FormData();
|
|
171
|
-
formData.append('name', data.name);
|
|
172
|
-
formData.append('format', data.format);
|
|
173
|
-
// Handle File or Buffer
|
|
174
|
-
if (data.file instanceof File) {
|
|
175
|
-
formData.append('file', data.file);
|
|
176
|
-
}
|
|
177
|
-
else if (Buffer.isBuffer(data.file)) {
|
|
178
|
-
// Node.js environment: convert Buffer to Blob
|
|
179
|
-
const blob = new Blob([data.file], { type: data.format });
|
|
180
|
-
formData.append('file', blob, data.name);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
throw new Error('file must be a File or Buffer');
|
|
184
|
-
}
|
|
185
|
-
// Optional fields
|
|
186
|
-
if (data.entityTypes && data.entityTypes.length > 0) {
|
|
187
|
-
formData.append('entityTypes', JSON.stringify(data.entityTypes));
|
|
188
|
-
}
|
|
189
|
-
if (data.language) {
|
|
190
|
-
formData.append('language', data.language);
|
|
191
|
-
}
|
|
192
|
-
if (data.creationMethod) {
|
|
193
|
-
formData.append('creationMethod', data.creationMethod);
|
|
194
|
-
}
|
|
195
|
-
if (data.sourceAnnotationId) {
|
|
196
|
-
formData.append('sourceAnnotationId', data.sourceAnnotationId);
|
|
197
|
-
}
|
|
198
|
-
if (data.sourceResourceId) {
|
|
199
|
-
formData.append('sourceResourceId', data.sourceResourceId);
|
|
200
|
-
}
|
|
201
|
-
// POST with multipart/form-data (ky automatically sets Content-Type)
|
|
202
|
-
return this.http.post(`${this.baseUrl}/resources`, { body: formData }).json();
|
|
203
|
-
}
|
|
204
|
-
async getResource(resourceUri) {
|
|
205
|
-
// resourceUri is already a full URI, use it directly
|
|
206
|
-
return this.http.get(resourceUri).json();
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Get resource representation using W3C content negotiation
|
|
210
|
-
* Returns raw binary content (images, PDFs, text, etc.) with content type
|
|
211
|
-
*
|
|
212
|
-
* @param resourceUri - Full resource URI
|
|
213
|
-
* @param options - Options including Accept header for content negotiation
|
|
214
|
-
* @returns Object with data (ArrayBuffer) and contentType (string)
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
* ```typescript
|
|
218
|
-
* // Get markdown representation
|
|
219
|
-
* const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'text/markdown' });
|
|
220
|
-
* const markdown = new TextDecoder().decode(data);
|
|
221
|
-
*
|
|
222
|
-
* // Get image representation
|
|
223
|
-
* const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'image/png' });
|
|
224
|
-
* const blob = new Blob([data], { type: contentType });
|
|
225
|
-
*
|
|
226
|
-
* // Get PDF representation
|
|
227
|
-
* const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'application/pdf' });
|
|
228
|
-
* ```
|
|
229
|
-
*/
|
|
230
|
-
async getResourceRepresentation(resourceUri, options) {
|
|
231
|
-
// resourceUri is already a full URI, use it directly with Accept header
|
|
232
|
-
const response = await this.http.get(resourceUri, {
|
|
233
|
-
headers: {
|
|
234
|
-
Accept: options?.accept || 'text/plain'
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
const contentType = response.headers.get('content-type') || 'application/octet-stream';
|
|
238
|
-
const data = await response.arrayBuffer();
|
|
239
|
-
return { data, contentType };
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Get resource representation as a stream using W3C content negotiation
|
|
243
|
-
* Returns streaming binary content (for large files: videos, large PDFs, etc.)
|
|
244
|
-
*
|
|
245
|
-
* Use this for large files to avoid loading entire content into memory.
|
|
246
|
-
* The stream is consumed incrementally and the backend connection stays open
|
|
247
|
-
* until the stream is fully consumed or closed.
|
|
248
|
-
*
|
|
249
|
-
* @param resourceUri - Full resource URI
|
|
250
|
-
* @param options - Options including Accept header for content negotiation
|
|
251
|
-
* @returns Object with stream (ReadableStream) and contentType (string)
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* ```typescript
|
|
255
|
-
* // Stream large file
|
|
256
|
-
* const { stream, contentType } = await client.getResourceRepresentationStream(rUri, {
|
|
257
|
-
* accept: 'video/mp4'
|
|
258
|
-
* });
|
|
259
|
-
*
|
|
260
|
-
* // Consume stream chunk by chunk (never loads entire file into memory)
|
|
261
|
-
* for await (const chunk of stream) {
|
|
262
|
-
* // Process chunk
|
|
263
|
-
* console.log(`Received ${chunk.length} bytes`);
|
|
264
|
-
* }
|
|
265
|
-
*
|
|
266
|
-
* // Or pipe to a file in Node.js
|
|
267
|
-
* const fileStream = fs.createWriteStream('output.mp4');
|
|
268
|
-
* const reader = stream.getReader();
|
|
269
|
-
* while (true) {
|
|
270
|
-
* const { done, value } = await reader.read();
|
|
271
|
-
* if (done) break;
|
|
272
|
-
* fileStream.write(value);
|
|
273
|
-
* }
|
|
274
|
-
* ```
|
|
275
|
-
*/
|
|
276
|
-
async getResourceRepresentationStream(resourceUri, options) {
|
|
277
|
-
// resourceUri is already a full URI, use it directly with Accept header
|
|
278
|
-
const response = await this.http.get(resourceUri, {
|
|
279
|
-
headers: {
|
|
280
|
-
Accept: options?.accept || 'text/plain'
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
const contentType = response.headers.get('content-type') || 'application/octet-stream';
|
|
284
|
-
if (!response.body) {
|
|
285
|
-
throw new Error('Response body is null - cannot create stream');
|
|
286
|
-
}
|
|
287
|
-
return { stream: response.body, contentType };
|
|
288
|
-
}
|
|
289
|
-
async listResources(limit, archived, query) {
|
|
290
|
-
const searchParams = new URLSearchParams();
|
|
291
|
-
if (limit)
|
|
292
|
-
searchParams.append('limit', limit.toString());
|
|
293
|
-
if (archived !== undefined)
|
|
294
|
-
searchParams.append('archived', archived.toString());
|
|
295
|
-
if (query)
|
|
296
|
-
searchParams.append('q', query);
|
|
297
|
-
return this.http.get(`${this.baseUrl}/resources`, { searchParams }).json();
|
|
298
|
-
}
|
|
299
|
-
async updateResource(resourceUri, data) {
|
|
300
|
-
// resourceUri is already a full URI, use it directly
|
|
301
|
-
return this.http.patch(resourceUri, { json: data }).json();
|
|
302
|
-
}
|
|
303
|
-
async getResourceEvents(resourceUri) {
|
|
304
|
-
// resourceUri is already a full URI, use it directly
|
|
305
|
-
return this.http.get(`${resourceUri}/events`).json();
|
|
306
|
-
}
|
|
307
|
-
async getResourceAnnotations(resourceUri) {
|
|
308
|
-
// resourceUri is already a full URI, use it directly
|
|
309
|
-
return this.http.get(`${resourceUri}/annotations`).json();
|
|
310
|
-
}
|
|
311
|
-
async getAnnotationLLMContext(resourceUri, annotationId, options) {
|
|
312
|
-
const searchParams = new URLSearchParams();
|
|
313
|
-
if (options?.contextWindow) {
|
|
314
|
-
searchParams.append('contextWindow', options.contextWindow.toString());
|
|
315
|
-
}
|
|
316
|
-
// resourceUri is already a full URI, use it directly
|
|
317
|
-
return this.http.get(`${resourceUri}/annotations/${annotationId}/llm-context`, { searchParams }).json();
|
|
318
|
-
}
|
|
319
|
-
async getResourceReferencedBy(resourceUri) {
|
|
320
|
-
// resourceUri is already a full URI, use it directly
|
|
321
|
-
return this.http.get(`${resourceUri}/referenced-by`).json();
|
|
322
|
-
}
|
|
323
|
-
async generateCloneToken(resourceUri) {
|
|
324
|
-
// resourceUri is already a full URI, use it directly
|
|
325
|
-
return this.http.post(`${resourceUri}/clone-with-token`).json();
|
|
326
|
-
}
|
|
327
|
-
async getResourceByToken(token) {
|
|
328
|
-
return this.http.get(`${this.baseUrl}/api/resources/token/${token}`).json();
|
|
329
|
-
}
|
|
330
|
-
async createResourceFromToken(data) {
|
|
331
|
-
return this.http.post(`${this.baseUrl}/api/resources/create-from-token`, { json: data }).json();
|
|
332
|
-
}
|
|
333
|
-
// ============================================================================
|
|
334
|
-
// ANNOTATIONS
|
|
335
|
-
// ============================================================================
|
|
336
|
-
async createAnnotation(resourceUri, data) {
|
|
337
|
-
// resourceUri is already a full URI, use it directly
|
|
338
|
-
return this.http.post(`${resourceUri}/annotations`, { json: data }).json();
|
|
339
|
-
}
|
|
340
|
-
async getAnnotation(annotationUri) {
|
|
341
|
-
// annotationUri is already a full URI, use it directly
|
|
342
|
-
return this.http.get(annotationUri).json();
|
|
343
|
-
}
|
|
344
|
-
async getResourceAnnotation(annotationUri) {
|
|
345
|
-
// annotationUri is already a full URI, use it directly
|
|
346
|
-
return this.http.get(annotationUri).json();
|
|
347
|
-
}
|
|
348
|
-
async listAnnotations(resourceUri, motivation) {
|
|
349
|
-
const searchParams = new URLSearchParams();
|
|
350
|
-
if (motivation)
|
|
351
|
-
searchParams.append('motivation', motivation);
|
|
352
|
-
// resourceUri is already a full URI, use it directly
|
|
353
|
-
return this.http.get(`${resourceUri}/annotations`, { searchParams }).json();
|
|
354
|
-
}
|
|
355
|
-
async deleteAnnotation(annotationUri) {
|
|
356
|
-
// annotationUri is already a full URI, use it directly
|
|
357
|
-
await this.http.delete(annotationUri);
|
|
358
|
-
}
|
|
359
|
-
async updateAnnotationBody(annotationUri, data) {
|
|
360
|
-
// annotationUri is already a full URI, use it directly
|
|
361
|
-
return this.http.put(`${annotationUri}/body`, {
|
|
362
|
-
json: data,
|
|
363
|
-
}).json();
|
|
364
|
-
}
|
|
365
|
-
async getAnnotationHistory(annotationUri) {
|
|
366
|
-
// annotationUri is already a full URI, use it directly
|
|
367
|
-
return this.http.get(`${annotationUri}/history`).json();
|
|
368
|
-
}
|
|
369
|
-
// ============================================================================
|
|
370
|
-
// ENTITY TYPES
|
|
371
|
-
// ============================================================================
|
|
372
|
-
async addEntityType(type) {
|
|
373
|
-
return this.http.post(`${this.baseUrl}/api/entity-types`, { json: { type } }).json();
|
|
374
|
-
}
|
|
375
|
-
async addEntityTypesBulk(types) {
|
|
376
|
-
return this.http.post(`${this.baseUrl}/api/entity-types/bulk`, { json: { tags: types } }).json();
|
|
377
|
-
}
|
|
378
|
-
async listEntityTypes() {
|
|
379
|
-
return this.http.get(`${this.baseUrl}/api/entity-types`).json();
|
|
380
|
-
}
|
|
381
|
-
// ============================================================================
|
|
382
|
-
// ADMIN
|
|
383
|
-
// ============================================================================
|
|
384
|
-
async listUsers() {
|
|
385
|
-
return this.http.get(`${this.baseUrl}/api/admin/users`).json();
|
|
386
|
-
}
|
|
387
|
-
async getUserStats() {
|
|
388
|
-
return this.http.get(`${this.baseUrl}/api/admin/users/stats`).json();
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Update a user by ID
|
|
392
|
-
* Note: Users use DID identifiers (did:web:domain:users:id), not HTTP URIs.
|
|
393
|
-
*/
|
|
394
|
-
async updateUser(id, data) {
|
|
395
|
-
return this.http.patch(`${this.baseUrl}/api/admin/users/${id}`, { json: data }).json();
|
|
396
|
-
}
|
|
397
|
-
async getOAuthConfig() {
|
|
398
|
-
return this.http.get(`${this.baseUrl}/api/admin/oauth/config`).json();
|
|
399
|
-
}
|
|
400
|
-
// ============================================================================
|
|
401
|
-
// JOB STATUS
|
|
402
|
-
// ============================================================================
|
|
403
|
-
async getJobStatus(id) {
|
|
404
|
-
return this.http.get(`${this.baseUrl}/api/jobs/${id}`).json();
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Poll a job until it completes or fails
|
|
408
|
-
* @param id - The job ID to poll
|
|
409
|
-
* @param options - Polling options
|
|
410
|
-
* @returns The final job status
|
|
411
|
-
*/
|
|
412
|
-
async pollJobUntilComplete(id, options) {
|
|
413
|
-
const interval = options?.interval ?? 1000;
|
|
414
|
-
const timeout = options?.timeout ?? 60000;
|
|
415
|
-
const startTime = Date.now();
|
|
416
|
-
while (true) {
|
|
417
|
-
const status = await this.getJobStatus(id);
|
|
418
|
-
// Call progress callback if provided
|
|
419
|
-
if (options?.onProgress) {
|
|
420
|
-
options.onProgress(status);
|
|
421
|
-
}
|
|
422
|
-
// Check if job is in a terminal state
|
|
423
|
-
if (status.status === 'complete' || status.status === 'failed' || status.status === 'cancelled') {
|
|
424
|
-
return status;
|
|
425
|
-
}
|
|
426
|
-
// Check timeout
|
|
427
|
-
if (Date.now() - startTime > timeout) {
|
|
428
|
-
throw new Error(`Job polling timeout after ${timeout}ms`);
|
|
429
|
-
}
|
|
430
|
-
// Wait before next poll
|
|
431
|
-
await new Promise(resolve => setTimeout(resolve, interval));
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
// ============================================================================
|
|
435
|
-
// LLM CONTEXT
|
|
436
|
-
// ============================================================================
|
|
437
|
-
async getResourceLLMContext(resourceUri, options) {
|
|
438
|
-
const searchParams = new URLSearchParams();
|
|
439
|
-
if (options?.depth !== undefined)
|
|
440
|
-
searchParams.append('depth', options.depth.toString());
|
|
441
|
-
if (options?.maxResources !== undefined)
|
|
442
|
-
searchParams.append('maxResources', options.maxResources.toString());
|
|
443
|
-
if (options?.includeContent !== undefined)
|
|
444
|
-
searchParams.append('includeContent', options.includeContent.toString());
|
|
445
|
-
if (options?.includeSummary !== undefined)
|
|
446
|
-
searchParams.append('includeSummary', options.includeSummary.toString());
|
|
447
|
-
return this.http.get(`${resourceUri}/llm-context`, { searchParams }).json();
|
|
448
|
-
}
|
|
449
|
-
// ============================================================================
|
|
450
|
-
// SYSTEM STATUS
|
|
451
|
-
// ============================================================================
|
|
452
|
-
async healthCheck() {
|
|
453
|
-
return this.http.get(`${this.baseUrl}/api/health`).json();
|
|
454
|
-
}
|
|
455
|
-
async getStatus() {
|
|
456
|
-
return this.http.get(`${this.baseUrl}/api/status`).json();
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
exports.SemiontApiClient = SemiontApiClient;
|
|
460
|
-
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client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,CAAC,SAAS,CAAC,CAAC,8BAA8B,CAAC,CAAC;AAGjG,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,YAAY,EACV,8BAA8B,EAC9B,6BAA6B,EAC7B,eAAe,EAChB,MAAM,OAAO,CAAC;AAGf,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,eAAe,EACf,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAGtB,cAAc,iBAAiB,CAAC"}
|
package/dist/mime-utils.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIME type utilities for Semiont
|
|
3
|
-
*
|
|
4
|
-
* Initial support for:
|
|
5
|
-
* - text/plain
|
|
6
|
-
* - text/markdown
|
|
7
|
-
* - image/png
|
|
8
|
-
* - image/jpeg
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Map MIME type to file extension
|
|
12
|
-
*/
|
|
13
|
-
export declare function getExtensionForMimeType(mimeType: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* Detect if MIME type is an image (png or jpeg only for now)
|
|
16
|
-
*/
|
|
17
|
-
export declare function isImageMimeType(mimeType: string): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Detect if MIME type is text-based (plain or markdown only for now)
|
|
20
|
-
*/
|
|
21
|
-
export declare function isTextMimeType(mimeType: string): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Get category for MIME type (for routing to appropriate viewer)
|
|
24
|
-
*/
|
|
25
|
-
export type MimeCategory = 'text' | 'image' | 'unsupported';
|
|
26
|
-
export declare function getMimeCategory(mimeType: string): MimeCategory;
|
|
27
|
-
//# sourceMappingURL=mime-utils.d.ts.map
|
package/dist/mime-utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mime-utils.d.ts","sourceRoot":"","sources":["../src/mime-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAShE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,aAAa,CAAC;AAE5D,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAQ9D"}
|
package/dist/mime-utils.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* MIME type utilities for Semiont
|
|
4
|
-
*
|
|
5
|
-
* Initial support for:
|
|
6
|
-
* - text/plain
|
|
7
|
-
* - text/markdown
|
|
8
|
-
* - image/png
|
|
9
|
-
* - image/jpeg
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getExtensionForMimeType = getExtensionForMimeType;
|
|
13
|
-
exports.isImageMimeType = isImageMimeType;
|
|
14
|
-
exports.isTextMimeType = isTextMimeType;
|
|
15
|
-
exports.getMimeCategory = getMimeCategory;
|
|
16
|
-
/**
|
|
17
|
-
* Map MIME type to file extension
|
|
18
|
-
*/
|
|
19
|
-
function getExtensionForMimeType(mimeType) {
|
|
20
|
-
const map = {
|
|
21
|
-
'text/plain': 'txt',
|
|
22
|
-
'text/markdown': 'md',
|
|
23
|
-
'image/png': 'png',
|
|
24
|
-
'image/jpeg': 'jpg',
|
|
25
|
-
};
|
|
26
|
-
return map[mimeType] || 'dat'; // fallback to .dat for unknown types
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Detect if MIME type is an image (png or jpeg only for now)
|
|
30
|
-
*/
|
|
31
|
-
function isImageMimeType(mimeType) {
|
|
32
|
-
return mimeType === 'image/png' || mimeType === 'image/jpeg';
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Detect if MIME type is text-based (plain or markdown only for now)
|
|
36
|
-
*/
|
|
37
|
-
function isTextMimeType(mimeType) {
|
|
38
|
-
return mimeType === 'text/plain' || mimeType === 'text/markdown';
|
|
39
|
-
}
|
|
40
|
-
function getMimeCategory(mimeType) {
|
|
41
|
-
if (isTextMimeType(mimeType)) {
|
|
42
|
-
return 'text';
|
|
43
|
-
}
|
|
44
|
-
if (isImageMimeType(mimeType)) {
|
|
45
|
-
return 'image';
|
|
46
|
-
}
|
|
47
|
-
return 'unsupported';
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=mime-utils.js.map
|
package/dist/mime-utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mime-utils.js","sourceRoot":"","sources":["../src/mime-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAKH,0DASC;AAKD,0CAEC;AAKD,wCAEC;AAOD,0CAQC;AAzCD;;GAEG;AACH,SAAgB,uBAAuB,CAAC,QAAgB;IACtD,MAAM,GAAG,GAA2B;QAClC,YAAY,EAAE,KAAK;QACnB,eAAe,EAAE,IAAI;QACrB,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,KAAK;KACpB,CAAC;IAEF,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,qCAAqC;AACtE,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,QAAgB;IAC9C,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,YAAY,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,QAAgB;IAC7C,OAAO,QAAQ,KAAK,YAAY,IAAI,QAAQ,KAAK,eAAe,CAAC;AACnE,CAAC;AAOD,SAAgB,eAAe,CAAC,QAAgB;IAC9C,IAAI,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC"}
|