@semiont/api-client 0.2.33-build.79 → 0.2.33-build.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -172,34 +172,20 @@ function createSSEStream(url, fetchOptions, config, logger) {
172
172
  // src/sse/index.ts
173
173
  var SSEClient = class {
174
174
  baseUrl;
175
- accessToken = null;
176
175
  logger;
177
176
  constructor(config) {
178
177
  this.baseUrl = config.baseUrl.endsWith("/") ? config.baseUrl.slice(0, -1) : config.baseUrl;
179
- this.accessToken = config.accessToken || null;
180
178
  this.logger = config.logger;
181
179
  }
182
- /**
183
- * Set the access token for authenticated requests
184
- */
185
- setAccessToken(token) {
186
- this.accessToken = token;
187
- }
188
- /**
189
- * Clear the access token
190
- */
191
- clearAccessToken() {
192
- this.accessToken = null;
193
- }
194
180
  /**
195
181
  * Get common headers for SSE requests
196
182
  */
197
- getHeaders() {
183
+ getHeaders(auth) {
198
184
  const headers = {
199
185
  "Content-Type": "application/json"
200
186
  };
201
- if (this.accessToken) {
202
- headers["Authorization"] = `Bearer ${this.accessToken}`;
187
+ if (auth) {
188
+ headers["Authorization"] = `Bearer ${auth}`;
203
189
  }
204
190
  return headers;
205
191
  }
@@ -221,13 +207,15 @@ var SSEClient = class {
221
207
  *
222
208
  * @param resourceId - Resource URI or ID
223
209
  * @param request - Detection configuration (entity types to detect)
210
+ * @param options - Request options (auth token)
224
211
  * @returns SSE stream controller with progress/complete/error callbacks
225
212
  *
226
213
  * @example
227
214
  * ```typescript
228
- * const stream = sseClient.detectAnnotations(
215
+ * const stream = sseClient.detectReferences(
229
216
  * 'http://localhost:4000/resources/doc-123',
230
- * { entityTypes: ['Person', 'Organization'] }
217
+ * { entityTypes: ['Person', 'Organization'] },
218
+ * { auth: 'your-token' }
231
219
  * );
232
220
  *
233
221
  * stream.onProgress((progress) => {
@@ -247,20 +235,20 @@ var SSEClient = class {
247
235
  * stream.close();
248
236
  * ```
249
237
  */
250
- detectAnnotations(resourceId, request) {
238
+ detectReferences(resourceId, request, options) {
251
239
  const id = this.extractId(resourceId);
252
240
  const url = `${this.baseUrl}/resources/${id}/detect-annotations-stream`;
253
241
  return createSSEStream(
254
242
  url,
255
243
  {
256
244
  method: "POST",
257
- headers: this.getHeaders(),
245
+ headers: this.getHeaders(options?.auth),
258
246
  body: JSON.stringify(request)
259
247
  },
260
248
  {
261
- progressEvents: ["detection-started", "detection-progress"],
262
- completeEvent: "detection-complete",
263
- errorEvent: "detection-error"
249
+ progressEvents: ["reference-detection-started", "reference-detection-progress"],
250
+ completeEvent: "reference-detection-complete",
251
+ errorEvent: "reference-detection-error"
264
252
  },
265
253
  this.logger
266
254
  );
@@ -273,6 +261,7 @@ var SSEClient = class {
273
261
  * @param resourceId - Source resource URI or ID
274
262
  * @param annotationId - Annotation URI or ID to use as generation source
275
263
  * @param request - Generation options (title, prompt, language)
264
+ * @param options - Request options (auth token)
276
265
  * @returns SSE stream controller with progress/complete/error callbacks
277
266
  *
278
267
  * @example
@@ -280,7 +269,8 @@ var SSEClient = class {
280
269
  * const stream = sseClient.generateResourceFromAnnotation(
281
270
  * 'http://localhost:4000/resources/doc-123',
282
271
  * 'http://localhost:4000/annotations/ann-456',
283
- * { language: 'es', title: 'Spanish Summary' }
272
+ * { language: 'es', title: 'Spanish Summary' },
273
+ * { auth: 'your-token' }
284
274
  * );
285
275
  *
286
276
  * stream.onProgress((progress) => {
@@ -300,7 +290,7 @@ var SSEClient = class {
300
290
  * stream.close();
301
291
  * ```
302
292
  */
303
- generateResourceFromAnnotation(resourceId, annotationId, request) {
293
+ generateResourceFromAnnotation(resourceId, annotationId, request, options) {
304
294
  const resId = this.extractId(resourceId);
305
295
  const annId = this.extractId(annotationId);
306
296
  const url = `${this.baseUrl}/resources/${resId}/annotations/${annId}/generate-resource-stream`;
@@ -308,7 +298,7 @@ var SSEClient = class {
308
298
  url,
309
299
  {
310
300
  method: "POST",
311
- headers: this.getHeaders(),
301
+ headers: this.getHeaders(options?.auth),
312
302
  body: JSON.stringify(request)
313
303
  },
314
304
  {
@@ -326,13 +316,15 @@ var SSEClient = class {
326
316
  *
327
317
  * @param resourceId - Resource URI or ID
328
318
  * @param request - Detection configuration (optional instructions)
319
+ * @param options - Request options (auth token)
329
320
  * @returns SSE stream controller with progress/complete/error callbacks
330
321
  *
331
322
  * @example
332
323
  * ```typescript
333
324
  * const stream = sseClient.detectHighlights(
334
325
  * 'http://localhost:4000/resources/doc-123',
335
- * { instructions: 'Focus on key technical points' }
326
+ * { instructions: 'Focus on key technical points' },
327
+ * { auth: 'your-token' }
336
328
  * );
337
329
  *
338
330
  * stream.onProgress((progress) => {
@@ -352,14 +344,14 @@ var SSEClient = class {
352
344
  * stream.close();
353
345
  * ```
354
346
  */
355
- detectHighlights(resourceId, request = {}) {
347
+ detectHighlights(resourceId, request = {}, options) {
356
348
  const id = this.extractId(resourceId);
357
349
  const url = `${this.baseUrl}/resources/${id}/detect-highlights-stream`;
358
350
  return createSSEStream(
359
351
  url,
360
352
  {
361
353
  method: "POST",
362
- headers: this.getHeaders(),
354
+ headers: this.getHeaders(options?.auth),
363
355
  body: JSON.stringify(request)
364
356
  },
365
357
  {
@@ -377,13 +369,15 @@ var SSEClient = class {
377
369
  *
378
370
  * @param resourceId - Resource URI or ID
379
371
  * @param request - Detection configuration (optional instructions)
372
+ * @param options - Request options (auth token)
380
373
  * @returns SSE stream controller with progress/complete/error callbacks
381
374
  *
382
375
  * @example
383
376
  * ```typescript
384
377
  * const stream = sseClient.detectAssessments(
385
378
  * 'http://localhost:4000/resources/doc-123',
386
- * { instructions: 'Evaluate claims for accuracy' }
379
+ * { instructions: 'Evaluate claims for accuracy' },
380
+ * { auth: 'your-token' }
387
381
  * );
388
382
  *
389
383
  * stream.onProgress((progress) => {
@@ -403,14 +397,14 @@ var SSEClient = class {
403
397
  * stream.close();
404
398
  * ```
405
399
  */
406
- detectAssessments(resourceId, request = {}) {
400
+ detectAssessments(resourceId, request = {}, options) {
407
401
  const id = this.extractId(resourceId);
408
402
  const url = `${this.baseUrl}/resources/${id}/detect-assessments-stream`;
409
403
  return createSSEStream(
410
404
  url,
411
405
  {
412
406
  method: "POST",
413
- headers: this.getHeaders(),
407
+ headers: this.getHeaders(options?.auth),
414
408
  body: JSON.stringify(request)
415
409
  },
416
410
  {
@@ -430,14 +424,19 @@ var SSEClient = class {
430
424
  *
431
425
  * @param resourceId - Resource URI or ID
432
426
  * @param request - Detection configuration (optional instructions and tone)
427
+ * @param options - Request options (auth token)
433
428
  * @returns SSE stream controller with progress/complete/error callbacks
434
429
  *
435
430
  * @example
436
431
  * ```typescript
437
- * const stream = sseClient.detectComments('http://localhost:4000/resources/doc-123', {
438
- * instructions: 'Focus on technical terminology',
439
- * tone: 'scholarly'
440
- * });
432
+ * const stream = sseClient.detectComments(
433
+ * 'http://localhost:4000/resources/doc-123',
434
+ * {
435
+ * instructions: 'Focus on technical terminology',
436
+ * tone: 'scholarly'
437
+ * },
438
+ * { auth: 'your-token' }
439
+ * );
441
440
  *
442
441
  * stream.onProgress((progress) => {
443
442
  * console.log(`${progress.status}: ${progress.percentage}%`);
@@ -455,14 +454,14 @@ var SSEClient = class {
455
454
  * stream.close();
456
455
  * ```
457
456
  */
458
- detectComments(resourceId, request = {}) {
457
+ detectComments(resourceId, request = {}, options) {
459
458
  const id = this.extractId(resourceId);
460
459
  const url = `${this.baseUrl}/resources/${id}/detect-comments-stream`;
461
460
  return createSSEStream(
462
461
  url,
463
462
  {
464
463
  method: "POST",
465
- headers: this.getHeaders(),
464
+ headers: this.getHeaders(options?.auth),
466
465
  body: JSON.stringify(request)
467
466
  },
468
467
  {
@@ -482,14 +481,19 @@ var SSEClient = class {
482
481
  *
483
482
  * @param resourceId - Resource URI or ID
484
483
  * @param request - Detection configuration (schema and categories to detect)
484
+ * @param options - Request options (auth token)
485
485
  * @returns SSE stream controller with progress/complete/error callbacks
486
486
  *
487
487
  * @example
488
488
  * ```typescript
489
- * const stream = sseClient.detectTags('http://localhost:4000/resources/doc-123', {
490
- * schemaId: 'legal-irac',
491
- * categories: ['Issue', 'Rule', 'Application', 'Conclusion']
492
- * });
489
+ * const stream = sseClient.detectTags(
490
+ * 'http://localhost:4000/resources/doc-123',
491
+ * {
492
+ * schemaId: 'legal-irac',
493
+ * categories: ['Issue', 'Rule', 'Application', 'Conclusion']
494
+ * },
495
+ * { auth: 'your-token' }
496
+ * );
493
497
  *
494
498
  * stream.onProgress((progress) => {
495
499
  * console.log(`${progress.status}: ${progress.percentage}%`);
@@ -508,14 +512,14 @@ var SSEClient = class {
508
512
  * stream.close();
509
513
  * ```
510
514
  */
511
- detectTags(resourceId, request) {
515
+ detectTags(resourceId, request, options) {
512
516
  const id = this.extractId(resourceId);
513
517
  const url = `${this.baseUrl}/resources/${id}/detect-tags-stream`;
514
518
  return createSSEStream(
515
519
  url,
516
520
  {
517
521
  method: "POST",
518
- headers: this.getHeaders(),
522
+ headers: this.getHeaders(options?.auth),
519
523
  body: JSON.stringify(request)
520
524
  },
521
525
  {
@@ -535,11 +539,15 @@ var SSEClient = class {
535
539
  * This stream does NOT have a complete event - it stays open until explicitly closed.
536
540
  *
537
541
  * @param resourceId - Resource URI or ID to subscribe to
542
+ * @param options - Request options (auth token)
538
543
  * @returns SSE stream controller with event callback
539
544
  *
540
545
  * @example
541
546
  * ```typescript
542
- * const stream = sseClient.resourceEvents('http://localhost:4000/resources/doc-123');
547
+ * const stream = sseClient.resourceEvents(
548
+ * 'http://localhost:4000/resources/doc-123',
549
+ * { auth: 'your-token' }
550
+ * );
543
551
  *
544
552
  * stream.onProgress((event) => {
545
553
  * console.log(`Event: ${event.type}`);
@@ -556,14 +564,14 @@ var SSEClient = class {
556
564
  * stream.close();
557
565
  * ```
558
566
  */
559
- resourceEvents(resourceId) {
567
+ resourceEvents(resourceId, options) {
560
568
  const id = this.extractId(resourceId);
561
569
  const url = `${this.baseUrl}/resources/${id}/events/stream`;
562
- return createSSEStream(
570
+ const stream = createSSEStream(
563
571
  url,
564
572
  {
565
573
  method: "GET",
566
- headers: this.getHeaders()
574
+ headers: this.getHeaders(options?.auth)
567
575
  },
568
576
  {
569
577
  progressEvents: ["*"],
@@ -577,6 +585,13 @@ var SSEClient = class {
577
585
  },
578
586
  this.logger
579
587
  );
588
+ if (options?.onConnected) {
589
+ stream.on?.("stream-connected", options.onConnected);
590
+ } else {
591
+ stream.on?.("stream-connected", () => {
592
+ });
593
+ }
594
+ return stream;
580
595
  }
581
596
  };
582
597
 
@@ -593,7 +608,6 @@ var APIError = class extends Error {
593
608
  var SemiontApiClient = class {
594
609
  http;
595
610
  baseUrl;
596
- accessToken = null;
597
611
  logger;
598
612
  /**
599
613
  * SSE streaming client for real-time operations
@@ -605,7 +619,8 @@ var SemiontApiClient = class {
605
619
  * ```typescript
606
620
  * const stream = client.sse.detectAnnotations(
607
621
  * resourceId,
608
- * { entityTypes: ['Person', 'Organization'] }
622
+ * { entityTypes: ['Person', 'Organization'] },
623
+ * { auth: accessToken }
609
624
  * );
610
625
  *
611
626
  * stream.onProgress((p) => console.log(p.message));
@@ -615,7 +630,7 @@ var SemiontApiClient = class {
615
630
  */
616
631
  sse;
617
632
  constructor(config) {
618
- const { baseUrl: baseUrl2, accessToken: accessToken2, timeout = 3e4, retry = 2, logger } = config;
633
+ const { baseUrl: baseUrl2, timeout = 3e4, retry = 2, logger } = config;
619
634
  this.logger = logger;
620
635
  this.baseUrl = baseUrl2.endsWith("/") ? baseUrl2.slice(0, -1) : baseUrl2;
621
636
  this.http = ky.create({
@@ -623,9 +638,10 @@ var SemiontApiClient = class {
623
638
  retry,
624
639
  hooks: {
625
640
  beforeRequest: [
626
- (request) => {
627
- if (this.accessToken) {
628
- request.headers.set("Authorization", `Bearer ${this.accessToken}`);
641
+ (request, options) => {
642
+ const auth = options.auth;
643
+ if (auth) {
644
+ request.headers.set("Authorization", `Bearer ${auth}`);
629
645
  }
630
646
  if (this.logger) {
631
647
  this.logger.debug("HTTP Request", {
@@ -633,7 +649,7 @@ var SemiontApiClient = class {
633
649
  url: request.url,
634
650
  method: request.method,
635
651
  timestamp: Date.now(),
636
- hasAuth: !!this.accessToken
652
+ hasAuth: !!auth
637
653
  });
638
654
  }
639
655
  }
@@ -679,66 +695,60 @@ var SemiontApiClient = class {
679
695
  ]
680
696
  }
681
697
  });
682
- if (accessToken2) {
683
- this.accessToken = accessToken2;
684
- }
685
698
  this.sse = new SSEClient({
686
699
  baseUrl: this.baseUrl,
687
- accessToken: this.accessToken || void 0,
688
700
  logger: this.logger
689
701
  });
690
702
  }
691
- /**
692
- * Set the access token for authenticated requests
693
- */
694
- setAccessToken(token) {
695
- this.accessToken = token;
696
- this.sse.setAccessToken(token);
697
- }
698
- /**
699
- * Clear the access token
700
- */
701
- clearAccessToken() {
702
- this.accessToken = null;
703
- this.sse.clearAccessToken();
704
- }
705
703
  // ============================================================================
706
704
  // AUTHENTICATION
707
705
  // ============================================================================
708
- async authenticatePassword(email2, password) {
709
- const response = await this.http.post(`${this.baseUrl}/api/tokens/password`, { json: { email: email2, password } }).json();
710
- if (response.token) {
711
- this.setAccessToken(response.token);
712
- }
713
- return response;
706
+ async authenticatePassword(email2, password, options) {
707
+ return this.http.post(`${this.baseUrl}/api/tokens/password`, {
708
+ json: { email: email2, password },
709
+ ...options,
710
+ auth: options?.auth
711
+ }).json();
714
712
  }
715
- async refreshToken(token) {
716
- const response = await this.http.post(`${this.baseUrl}/api/tokens/refresh`, { json: { refreshToken: token } }).json();
717
- if (response.access_token) {
718
- this.setAccessToken(response.access_token);
719
- }
720
- return response;
713
+ async refreshToken(token, options) {
714
+ return this.http.post(`${this.baseUrl}/api/tokens/refresh`, {
715
+ json: { refreshToken: token },
716
+ ...options,
717
+ auth: options?.auth
718
+ }).json();
721
719
  }
722
- async authenticateGoogle(credential) {
723
- const response = await this.http.post(`${this.baseUrl}/api/tokens/google`, { json: { credential } }).json();
724
- if (response.token) {
725
- this.setAccessToken(response.token);
726
- }
727
- return response;
720
+ async authenticateGoogle(credential, options) {
721
+ return this.http.post(`${this.baseUrl}/api/tokens/google`, {
722
+ json: { credential },
723
+ ...options,
724
+ auth: options?.auth
725
+ }).json();
728
726
  }
729
- async generateMCPToken() {
730
- return this.http.post(`${this.baseUrl}/api/tokens/mcp-generate`).json();
727
+ async generateMCPToken(options) {
728
+ return this.http.post(`${this.baseUrl}/api/tokens/mcp-generate`, {
729
+ ...options,
730
+ auth: options?.auth
731
+ }).json();
731
732
  }
732
733
  // ============================================================================
733
734
  // USERS
734
735
  // ============================================================================
735
- async getMe() {
736
- return this.http.get(`${this.baseUrl}/api/users/me`).json();
736
+ async getMe(options) {
737
+ return this.http.get(`${this.baseUrl}/api/users/me`, {
738
+ ...options,
739
+ auth: options?.auth
740
+ }).json();
737
741
  }
738
- async acceptTerms() {
739
- return this.http.post(`${this.baseUrl}/api/users/accept-terms`).json();
742
+ async acceptTerms(options) {
743
+ return this.http.post(`${this.baseUrl}/api/users/accept-terms`, {
744
+ ...options,
745
+ auth: options?.auth
746
+ }).json();
740
747
  }
741
- async logout() {
748
+ async logout(options) {
749
+ if (options) {
750
+ return this.http.post(`${this.baseUrl}/api/users/logout`, options).json();
751
+ }
742
752
  return this.http.post(`${this.baseUrl}/api/users/logout`).json();
743
753
  }
744
754
  // ============================================================================
@@ -756,8 +766,9 @@ var SemiontApiClient = class {
756
766
  * @param data.creationMethod - Optional creation method
757
767
  * @param data.sourceAnnotationId - Optional source annotation ID
758
768
  * @param data.sourceResourceId - Optional source resource ID
769
+ * @param options - Request options including auth
759
770
  */
760
- async createResource(data) {
771
+ async createResource(data, options) {
761
772
  const formData = new FormData();
762
773
  formData.append("name", data.name);
763
774
  formData.append("format", data.format);
@@ -784,38 +795,46 @@ var SemiontApiClient = class {
784
795
  if (data.sourceResourceId) {
785
796
  formData.append("sourceResourceId", data.sourceResourceId);
786
797
  }
787
- return this.http.post(`${this.baseUrl}/resources`, { body: formData }).json();
798
+ return this.http.post(`${this.baseUrl}/resources`, {
799
+ body: formData,
800
+ ...options,
801
+ auth: options?.auth
802
+ }).json();
788
803
  }
789
- async getResource(resourceUri2) {
790
- return this.http.get(resourceUri2).json();
804
+ async getResource(resourceUri2, options) {
805
+ return this.http.get(resourceUri2, {
806
+ ...options,
807
+ auth: options?.auth
808
+ }).json();
791
809
  }
792
810
  /**
793
811
  * Get resource representation using W3C content negotiation
794
812
  * Returns raw binary content (images, PDFs, text, etc.) with content type
795
813
  *
796
814
  * @param resourceUri - Full resource URI
797
- * @param options - Options including Accept header for content negotiation
815
+ * @param options - Options including Accept header for content negotiation and auth
798
816
  * @returns Object with data (ArrayBuffer) and contentType (string)
799
817
  *
800
818
  * @example
801
819
  * ```typescript
802
820
  * // Get markdown representation
803
- * const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'text/markdown' });
821
+ * const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'text/markdown', auth: token });
804
822
  * const markdown = new TextDecoder().decode(data);
805
823
  *
806
824
  * // Get image representation
807
- * const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'image/png' });
825
+ * const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'image/png', auth: token });
808
826
  * const blob = new Blob([data], { type: contentType });
809
827
  *
810
828
  * // Get PDF representation
811
- * const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'application/pdf' });
829
+ * const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'application/pdf', auth: token });
812
830
  * ```
813
831
  */
814
832
  async getResourceRepresentation(resourceUri2, options) {
815
833
  const response = await this.http.get(resourceUri2, {
816
834
  headers: {
817
835
  Accept: options?.accept || "text/plain"
818
- }
836
+ },
837
+ auth: options?.auth
819
838
  });
820
839
  const contentType = response.headers.get("content-type") || "application/octet-stream";
821
840
  const data = await response.arrayBuffer();
@@ -830,14 +849,15 @@ var SemiontApiClient = class {
830
849
  * until the stream is fully consumed or closed.
831
850
  *
832
851
  * @param resourceUri - Full resource URI
833
- * @param options - Options including Accept header for content negotiation
852
+ * @param options - Options including Accept header for content negotiation and auth
834
853
  * @returns Object with stream (ReadableStream) and contentType (string)
835
854
  *
836
855
  * @example
837
856
  * ```typescript
838
857
  * // Stream large file
839
858
  * const { stream, contentType } = await client.getResourceRepresentationStream(rUri, {
840
- * accept: 'video/mp4'
859
+ * accept: 'video/mp4',
860
+ * auth: token
841
861
  * });
842
862
  *
843
863
  * // Consume stream chunk by chunk (never loads entire file into memory)
@@ -860,7 +880,8 @@ var SemiontApiClient = class {
860
880
  const response = await this.http.get(resourceUri2, {
861
881
  headers: {
862
882
  Accept: options?.accept || "text/plain"
863
- }
883
+ },
884
+ auth: options?.auth
864
885
  });
865
886
  const contentType = response.headers.get("content-type") || "application/octet-stream";
866
887
  if (!response.body) {
@@ -868,21 +889,35 @@ var SemiontApiClient = class {
868
889
  }
869
890
  return { stream: response.body, contentType };
870
891
  }
871
- async listResources(limit, archived, query) {
892
+ async listResources(limit, archived, query, options) {
872
893
  const searchParams = new URLSearchParams();
873
894
  if (limit) searchParams.append("limit", limit.toString());
874
895
  if (archived !== void 0) searchParams.append("archived", archived.toString());
875
896
  if (query) searchParams.append("q", query);
876
- return this.http.get(`${this.baseUrl}/resources`, { searchParams }).json();
897
+ return this.http.get(`${this.baseUrl}/resources`, {
898
+ searchParams,
899
+ ...options,
900
+ auth: options?.auth
901
+ }).json();
877
902
  }
878
- async updateResource(resourceUri2, data) {
879
- return this.http.patch(resourceUri2, { json: data }).json();
903
+ async updateResource(resourceUri2, data, options) {
904
+ return this.http.patch(resourceUri2, {
905
+ json: data,
906
+ ...options,
907
+ auth: options?.auth
908
+ }).json();
880
909
  }
881
- async getResourceEvents(resourceUri2) {
882
- return this.http.get(`${resourceUri2}/events`).json();
910
+ async getResourceEvents(resourceUri2, options) {
911
+ return this.http.get(`${resourceUri2}/events`, {
912
+ ...options,
913
+ auth: options?.auth
914
+ }).json();
883
915
  }
884
- async getResourceAnnotations(resourceUri2) {
885
- return this.http.get(`${resourceUri2}/annotations`).json();
916
+ async getResourceAnnotations(resourceUri2, options) {
917
+ return this.http.get(`${resourceUri2}/annotations`, {
918
+ ...options,
919
+ auth: options?.auth
920
+ }).json();
886
921
  }
887
922
  async getAnnotationLLMContext(resourceUri2, annotationId, options) {
888
923
  const searchParams = new URLSearchParams();
@@ -891,84 +926,149 @@ var SemiontApiClient = class {
891
926
  }
892
927
  return this.http.get(
893
928
  `${resourceUri2}/annotations/${annotationId}/llm-context`,
894
- { searchParams }
929
+ {
930
+ searchParams,
931
+ auth: options?.auth
932
+ }
895
933
  ).json();
896
934
  }
897
- async getResourceReferencedBy(resourceUri2) {
898
- return this.http.get(`${resourceUri2}/referenced-by`).json();
935
+ async getResourceReferencedBy(resourceUri2, options) {
936
+ return this.http.get(`${resourceUri2}/referenced-by`, {
937
+ ...options,
938
+ auth: options?.auth
939
+ }).json();
899
940
  }
900
- async generateCloneToken(resourceUri2) {
901
- return this.http.post(`${resourceUri2}/clone-with-token`).json();
941
+ async generateCloneToken(resourceUri2, options) {
942
+ return this.http.post(`${resourceUri2}/clone-with-token`, {
943
+ ...options,
944
+ auth: options?.auth
945
+ }).json();
902
946
  }
903
- async getResourceByToken(token) {
904
- return this.http.get(`${this.baseUrl}/api/resources/token/${token}`).json();
947
+ async getResourceByToken(token, options) {
948
+ return this.http.get(`${this.baseUrl}/api/resources/token/${token}`, {
949
+ ...options,
950
+ auth: options?.auth
951
+ }).json();
905
952
  }
906
- async createResourceFromToken(data) {
907
- return this.http.post(`${this.baseUrl}/api/resources/create-from-token`, { json: data }).json();
953
+ async createResourceFromToken(data, options) {
954
+ return this.http.post(`${this.baseUrl}/api/resources/create-from-token`, {
955
+ json: data,
956
+ ...options,
957
+ auth: options?.auth
958
+ }).json();
908
959
  }
909
960
  // ============================================================================
910
961
  // ANNOTATIONS
911
962
  // ============================================================================
912
- async createAnnotation(resourceUri2, data) {
913
- return this.http.post(`${resourceUri2}/annotations`, { json: data }).json();
963
+ async createAnnotation(resourceUri2, data, options) {
964
+ return this.http.post(`${resourceUri2}/annotations`, {
965
+ json: data,
966
+ ...options,
967
+ auth: options?.auth
968
+ }).json();
914
969
  }
915
- async getAnnotation(annotationUri2) {
916
- return this.http.get(annotationUri2).json();
970
+ async getAnnotation(annotationUri2, options) {
971
+ return this.http.get(annotationUri2, {
972
+ ...options,
973
+ auth: options?.auth
974
+ }).json();
917
975
  }
918
- async getResourceAnnotation(annotationUri2) {
919
- return this.http.get(annotationUri2).json();
976
+ async getResourceAnnotation(annotationUri2, options) {
977
+ return this.http.get(annotationUri2, {
978
+ ...options,
979
+ auth: options?.auth
980
+ }).json();
920
981
  }
921
- async listAnnotations(resourceUri2, motivation) {
982
+ async listAnnotations(resourceUri2, motivation, options) {
922
983
  const searchParams = new URLSearchParams();
923
984
  if (motivation) searchParams.append("motivation", motivation);
924
- return this.http.get(`${resourceUri2}/annotations`, { searchParams }).json();
985
+ return this.http.get(`${resourceUri2}/annotations`, {
986
+ searchParams,
987
+ ...options,
988
+ auth: options?.auth
989
+ }).json();
925
990
  }
926
- async deleteAnnotation(annotationUri2) {
927
- await this.http.delete(annotationUri2);
991
+ async deleteAnnotation(annotationUri2, options) {
992
+ await this.http.delete(annotationUri2, {
993
+ ...options,
994
+ auth: options?.auth
995
+ });
928
996
  }
929
- async updateAnnotationBody(annotationUri2, data) {
997
+ async updateAnnotationBody(annotationUri2, data, options) {
930
998
  return this.http.put(`${annotationUri2}/body`, {
931
- json: data
999
+ json: data,
1000
+ ...options,
1001
+ auth: options?.auth
932
1002
  }).json();
933
1003
  }
934
- async getAnnotationHistory(annotationUri2) {
1004
+ async getAnnotationHistory(annotationUri2, options) {
1005
+ if (options) {
1006
+ return this.http.get(`${annotationUri2}/history`, options).json();
1007
+ }
935
1008
  return this.http.get(`${annotationUri2}/history`).json();
936
1009
  }
937
1010
  // ============================================================================
938
1011
  // ENTITY TYPES
939
1012
  // ============================================================================
940
- async addEntityType(type) {
941
- return this.http.post(`${this.baseUrl}/api/entity-types`, { json: { type } }).json();
1013
+ async addEntityType(type, options) {
1014
+ return this.http.post(`${this.baseUrl}/api/entity-types`, {
1015
+ json: { type },
1016
+ ...options,
1017
+ auth: options?.auth
1018
+ }).json();
942
1019
  }
943
- async addEntityTypesBulk(types) {
944
- return this.http.post(`${this.baseUrl}/api/entity-types/bulk`, { json: { tags: types } }).json();
1020
+ async addEntityTypesBulk(types, options) {
1021
+ return this.http.post(`${this.baseUrl}/api/entity-types/bulk`, {
1022
+ json: { tags: types },
1023
+ ...options,
1024
+ auth: options?.auth
1025
+ }).json();
945
1026
  }
946
- async listEntityTypes() {
947
- return this.http.get(`${this.baseUrl}/api/entity-types`).json();
1027
+ async listEntityTypes(options) {
1028
+ return this.http.get(`${this.baseUrl}/api/entity-types`, {
1029
+ ...options,
1030
+ auth: options?.auth
1031
+ }).json();
948
1032
  }
949
1033
  // ============================================================================
950
1034
  // ADMIN
951
1035
  // ============================================================================
952
- async listUsers() {
953
- return this.http.get(`${this.baseUrl}/api/admin/users`).json();
1036
+ async listUsers(options) {
1037
+ return this.http.get(`${this.baseUrl}/api/admin/users`, {
1038
+ ...options,
1039
+ auth: options?.auth
1040
+ }).json();
954
1041
  }
955
- async getUserStats() {
956
- return this.http.get(`${this.baseUrl}/api/admin/users/stats`).json();
1042
+ async getUserStats(options) {
1043
+ return this.http.get(`${this.baseUrl}/api/admin/users/stats`, {
1044
+ ...options,
1045
+ auth: options?.auth
1046
+ }).json();
957
1047
  }
958
1048
  /**
959
1049
  * Update a user by ID
960
1050
  * Note: Users use DID identifiers (did:web:domain:users:id), not HTTP URIs.
961
1051
  */
962
- async updateUser(id, data) {
963
- return this.http.patch(`${this.baseUrl}/api/admin/users/${id}`, { json: data }).json();
1052
+ async updateUser(id, data, options) {
1053
+ return this.http.patch(`${this.baseUrl}/api/admin/users/${id}`, {
1054
+ json: data,
1055
+ ...options,
1056
+ auth: options?.auth
1057
+ }).json();
964
1058
  }
965
- async getOAuthConfig() {
966
- return this.http.get(`${this.baseUrl}/api/admin/oauth/config`).json();
1059
+ async getOAuthConfig(options) {
1060
+ return this.http.get(`${this.baseUrl}/api/admin/oauth/config`, {
1061
+ ...options,
1062
+ auth: options?.auth
1063
+ }).json();
967
1064
  }
968
1065
  // ============================================================================
969
1066
  // JOB STATUS
970
1067
  // ============================================================================
971
- async getJobStatus(id) {
1068
+ async getJobStatus(id, options) {
1069
+ if (options) {
1070
+ return this.http.get(`${this.baseUrl}/api/jobs/${id}`, options).json();
1071
+ }
972
1072
  return this.http.get(`${this.baseUrl}/api/jobs/${id}`).json();
973
1073
  }
974
1074
  /**
@@ -982,7 +1082,7 @@ var SemiontApiClient = class {
982
1082
  const timeout = options?.timeout ?? 6e4;
983
1083
  const startTime = Date.now();
984
1084
  while (true) {
985
- const status = await this.getJobStatus(id);
1085
+ const status = await this.getJobStatus(id, { auth: options?.auth });
986
1086
  if (options?.onProgress) {
987
1087
  options.onProgress(status);
988
1088
  }
@@ -1004,15 +1104,24 @@ var SemiontApiClient = class {
1004
1104
  if (options?.maxResources !== void 0) searchParams.append("maxResources", options.maxResources.toString());
1005
1105
  if (options?.includeContent !== void 0) searchParams.append("includeContent", options.includeContent.toString());
1006
1106
  if (options?.includeSummary !== void 0) searchParams.append("includeSummary", options.includeSummary.toString());
1007
- return this.http.get(`${resourceUri2}/llm-context`, { searchParams }).json();
1107
+ return this.http.get(`${resourceUri2}/llm-context`, {
1108
+ searchParams,
1109
+ auth: options?.auth
1110
+ }).json();
1008
1111
  }
1009
1112
  // ============================================================================
1010
1113
  // SYSTEM STATUS
1011
1114
  // ============================================================================
1012
- async healthCheck() {
1013
- return this.http.get(`${this.baseUrl}/api/health`).json();
1115
+ async healthCheck(options) {
1116
+ return this.http.get(`${this.baseUrl}/api/health`, {
1117
+ ...options,
1118
+ auth: options?.auth
1119
+ }).json();
1014
1120
  }
1015
- async getStatus() {
1121
+ async getStatus(options) {
1122
+ if (options) {
1123
+ return this.http.get(`${this.baseUrl}/api/status`, options).json();
1124
+ }
1016
1125
  return this.http.get(`${this.baseUrl}/api/status`).json();
1017
1126
  }
1018
1127
  };