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

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
215
  * const stream = sseClient.detectAnnotations(
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,14 +235,14 @@ var SSEClient = class {
247
235
  * stream.close();
248
236
  * ```
249
237
  */
250
- detectAnnotations(resourceId, request) {
238
+ detectAnnotations(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
  {
@@ -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
570
  return 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: ["*"],
@@ -593,7 +601,6 @@ var APIError = class extends Error {
593
601
  var SemiontApiClient = class {
594
602
  http;
595
603
  baseUrl;
596
- accessToken = null;
597
604
  logger;
598
605
  /**
599
606
  * SSE streaming client for real-time operations
@@ -605,7 +612,8 @@ var SemiontApiClient = class {
605
612
  * ```typescript
606
613
  * const stream = client.sse.detectAnnotations(
607
614
  * resourceId,
608
- * { entityTypes: ['Person', 'Organization'] }
615
+ * { entityTypes: ['Person', 'Organization'] },
616
+ * { auth: accessToken }
609
617
  * );
610
618
  *
611
619
  * stream.onProgress((p) => console.log(p.message));
@@ -615,7 +623,7 @@ var SemiontApiClient = class {
615
623
  */
616
624
  sse;
617
625
  constructor(config) {
618
- const { baseUrl: baseUrl2, accessToken: accessToken2, timeout = 3e4, retry = 2, logger } = config;
626
+ const { baseUrl: baseUrl2, timeout = 3e4, retry = 2, logger } = config;
619
627
  this.logger = logger;
620
628
  this.baseUrl = baseUrl2.endsWith("/") ? baseUrl2.slice(0, -1) : baseUrl2;
621
629
  this.http = ky.create({
@@ -623,9 +631,10 @@ var SemiontApiClient = class {
623
631
  retry,
624
632
  hooks: {
625
633
  beforeRequest: [
626
- (request) => {
627
- if (this.accessToken) {
628
- request.headers.set("Authorization", `Bearer ${this.accessToken}`);
634
+ (request, options) => {
635
+ const auth = options.auth;
636
+ if (auth) {
637
+ request.headers.set("Authorization", `Bearer ${auth}`);
629
638
  }
630
639
  if (this.logger) {
631
640
  this.logger.debug("HTTP Request", {
@@ -633,7 +642,7 @@ var SemiontApiClient = class {
633
642
  url: request.url,
634
643
  method: request.method,
635
644
  timestamp: Date.now(),
636
- hasAuth: !!this.accessToken
645
+ hasAuth: !!auth
637
646
  });
638
647
  }
639
648
  }
@@ -679,66 +688,60 @@ var SemiontApiClient = class {
679
688
  ]
680
689
  }
681
690
  });
682
- if (accessToken2) {
683
- this.accessToken = accessToken2;
684
- }
685
691
  this.sse = new SSEClient({
686
692
  baseUrl: this.baseUrl,
687
- accessToken: this.accessToken || void 0,
688
693
  logger: this.logger
689
694
  });
690
695
  }
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
696
  // ============================================================================
706
697
  // AUTHENTICATION
707
698
  // ============================================================================
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;
699
+ async authenticatePassword(email2, password, options) {
700
+ return this.http.post(`${this.baseUrl}/api/tokens/password`, {
701
+ json: { email: email2, password },
702
+ ...options,
703
+ auth: options?.auth
704
+ }).json();
714
705
  }
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;
706
+ async refreshToken(token, options) {
707
+ return this.http.post(`${this.baseUrl}/api/tokens/refresh`, {
708
+ json: { refreshToken: token },
709
+ ...options,
710
+ auth: options?.auth
711
+ }).json();
721
712
  }
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;
713
+ async authenticateGoogle(credential, options) {
714
+ return this.http.post(`${this.baseUrl}/api/tokens/google`, {
715
+ json: { credential },
716
+ ...options,
717
+ auth: options?.auth
718
+ }).json();
728
719
  }
729
- async generateMCPToken() {
730
- return this.http.post(`${this.baseUrl}/api/tokens/mcp-generate`).json();
720
+ async generateMCPToken(options) {
721
+ return this.http.post(`${this.baseUrl}/api/tokens/mcp-generate`, {
722
+ ...options,
723
+ auth: options?.auth
724
+ }).json();
731
725
  }
732
726
  // ============================================================================
733
727
  // USERS
734
728
  // ============================================================================
735
- async getMe() {
736
- return this.http.get(`${this.baseUrl}/api/users/me`).json();
729
+ async getMe(options) {
730
+ return this.http.get(`${this.baseUrl}/api/users/me`, {
731
+ ...options,
732
+ auth: options?.auth
733
+ }).json();
737
734
  }
738
- async acceptTerms() {
739
- return this.http.post(`${this.baseUrl}/api/users/accept-terms`).json();
735
+ async acceptTerms(options) {
736
+ return this.http.post(`${this.baseUrl}/api/users/accept-terms`, {
737
+ ...options,
738
+ auth: options?.auth
739
+ }).json();
740
740
  }
741
- async logout() {
741
+ async logout(options) {
742
+ if (options) {
743
+ return this.http.post(`${this.baseUrl}/api/users/logout`, options).json();
744
+ }
742
745
  return this.http.post(`${this.baseUrl}/api/users/logout`).json();
743
746
  }
744
747
  // ============================================================================
@@ -756,8 +759,9 @@ var SemiontApiClient = class {
756
759
  * @param data.creationMethod - Optional creation method
757
760
  * @param data.sourceAnnotationId - Optional source annotation ID
758
761
  * @param data.sourceResourceId - Optional source resource ID
762
+ * @param options - Request options including auth
759
763
  */
760
- async createResource(data) {
764
+ async createResource(data, options) {
761
765
  const formData = new FormData();
762
766
  formData.append("name", data.name);
763
767
  formData.append("format", data.format);
@@ -784,38 +788,46 @@ var SemiontApiClient = class {
784
788
  if (data.sourceResourceId) {
785
789
  formData.append("sourceResourceId", data.sourceResourceId);
786
790
  }
787
- return this.http.post(`${this.baseUrl}/resources`, { body: formData }).json();
791
+ return this.http.post(`${this.baseUrl}/resources`, {
792
+ body: formData,
793
+ ...options,
794
+ auth: options?.auth
795
+ }).json();
788
796
  }
789
- async getResource(resourceUri2) {
790
- return this.http.get(resourceUri2).json();
797
+ async getResource(resourceUri2, options) {
798
+ return this.http.get(resourceUri2, {
799
+ ...options,
800
+ auth: options?.auth
801
+ }).json();
791
802
  }
792
803
  /**
793
804
  * Get resource representation using W3C content negotiation
794
805
  * Returns raw binary content (images, PDFs, text, etc.) with content type
795
806
  *
796
807
  * @param resourceUri - Full resource URI
797
- * @param options - Options including Accept header for content negotiation
808
+ * @param options - Options including Accept header for content negotiation and auth
798
809
  * @returns Object with data (ArrayBuffer) and contentType (string)
799
810
  *
800
811
  * @example
801
812
  * ```typescript
802
813
  * // Get markdown representation
803
- * const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'text/markdown' });
814
+ * const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'text/markdown', auth: token });
804
815
  * const markdown = new TextDecoder().decode(data);
805
816
  *
806
817
  * // Get image representation
807
- * const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'image/png' });
818
+ * const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'image/png', auth: token });
808
819
  * const blob = new Blob([data], { type: contentType });
809
820
  *
810
821
  * // Get PDF representation
811
- * const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'application/pdf' });
822
+ * const { data, contentType } = await client.getResourceRepresentation(rUri, { accept: 'application/pdf', auth: token });
812
823
  * ```
813
824
  */
814
825
  async getResourceRepresentation(resourceUri2, options) {
815
826
  const response = await this.http.get(resourceUri2, {
816
827
  headers: {
817
828
  Accept: options?.accept || "text/plain"
818
- }
829
+ },
830
+ auth: options?.auth
819
831
  });
820
832
  const contentType = response.headers.get("content-type") || "application/octet-stream";
821
833
  const data = await response.arrayBuffer();
@@ -830,14 +842,15 @@ var SemiontApiClient = class {
830
842
  * until the stream is fully consumed or closed.
831
843
  *
832
844
  * @param resourceUri - Full resource URI
833
- * @param options - Options including Accept header for content negotiation
845
+ * @param options - Options including Accept header for content negotiation and auth
834
846
  * @returns Object with stream (ReadableStream) and contentType (string)
835
847
  *
836
848
  * @example
837
849
  * ```typescript
838
850
  * // Stream large file
839
851
  * const { stream, contentType } = await client.getResourceRepresentationStream(rUri, {
840
- * accept: 'video/mp4'
852
+ * accept: 'video/mp4',
853
+ * auth: token
841
854
  * });
842
855
  *
843
856
  * // Consume stream chunk by chunk (never loads entire file into memory)
@@ -860,7 +873,8 @@ var SemiontApiClient = class {
860
873
  const response = await this.http.get(resourceUri2, {
861
874
  headers: {
862
875
  Accept: options?.accept || "text/plain"
863
- }
876
+ },
877
+ auth: options?.auth
864
878
  });
865
879
  const contentType = response.headers.get("content-type") || "application/octet-stream";
866
880
  if (!response.body) {
@@ -868,21 +882,35 @@ var SemiontApiClient = class {
868
882
  }
869
883
  return { stream: response.body, contentType };
870
884
  }
871
- async listResources(limit, archived, query) {
885
+ async listResources(limit, archived, query, options) {
872
886
  const searchParams = new URLSearchParams();
873
887
  if (limit) searchParams.append("limit", limit.toString());
874
888
  if (archived !== void 0) searchParams.append("archived", archived.toString());
875
889
  if (query) searchParams.append("q", query);
876
- return this.http.get(`${this.baseUrl}/resources`, { searchParams }).json();
890
+ return this.http.get(`${this.baseUrl}/resources`, {
891
+ searchParams,
892
+ ...options,
893
+ auth: options?.auth
894
+ }).json();
877
895
  }
878
- async updateResource(resourceUri2, data) {
879
- return this.http.patch(resourceUri2, { json: data }).json();
896
+ async updateResource(resourceUri2, data, options) {
897
+ return this.http.patch(resourceUri2, {
898
+ json: data,
899
+ ...options,
900
+ auth: options?.auth
901
+ }).json();
880
902
  }
881
- async getResourceEvents(resourceUri2) {
882
- return this.http.get(`${resourceUri2}/events`).json();
903
+ async getResourceEvents(resourceUri2, options) {
904
+ return this.http.get(`${resourceUri2}/events`, {
905
+ ...options,
906
+ auth: options?.auth
907
+ }).json();
883
908
  }
884
- async getResourceAnnotations(resourceUri2) {
885
- return this.http.get(`${resourceUri2}/annotations`).json();
909
+ async getResourceAnnotations(resourceUri2, options) {
910
+ return this.http.get(`${resourceUri2}/annotations`, {
911
+ ...options,
912
+ auth: options?.auth
913
+ }).json();
886
914
  }
887
915
  async getAnnotationLLMContext(resourceUri2, annotationId, options) {
888
916
  const searchParams = new URLSearchParams();
@@ -891,84 +919,149 @@ var SemiontApiClient = class {
891
919
  }
892
920
  return this.http.get(
893
921
  `${resourceUri2}/annotations/${annotationId}/llm-context`,
894
- { searchParams }
922
+ {
923
+ searchParams,
924
+ auth: options?.auth
925
+ }
895
926
  ).json();
896
927
  }
897
- async getResourceReferencedBy(resourceUri2) {
898
- return this.http.get(`${resourceUri2}/referenced-by`).json();
928
+ async getResourceReferencedBy(resourceUri2, options) {
929
+ return this.http.get(`${resourceUri2}/referenced-by`, {
930
+ ...options,
931
+ auth: options?.auth
932
+ }).json();
899
933
  }
900
- async generateCloneToken(resourceUri2) {
901
- return this.http.post(`${resourceUri2}/clone-with-token`).json();
934
+ async generateCloneToken(resourceUri2, options) {
935
+ return this.http.post(`${resourceUri2}/clone-with-token`, {
936
+ ...options,
937
+ auth: options?.auth
938
+ }).json();
902
939
  }
903
- async getResourceByToken(token) {
904
- return this.http.get(`${this.baseUrl}/api/resources/token/${token}`).json();
940
+ async getResourceByToken(token, options) {
941
+ return this.http.get(`${this.baseUrl}/api/resources/token/${token}`, {
942
+ ...options,
943
+ auth: options?.auth
944
+ }).json();
905
945
  }
906
- async createResourceFromToken(data) {
907
- return this.http.post(`${this.baseUrl}/api/resources/create-from-token`, { json: data }).json();
946
+ async createResourceFromToken(data, options) {
947
+ return this.http.post(`${this.baseUrl}/api/resources/create-from-token`, {
948
+ json: data,
949
+ ...options,
950
+ auth: options?.auth
951
+ }).json();
908
952
  }
909
953
  // ============================================================================
910
954
  // ANNOTATIONS
911
955
  // ============================================================================
912
- async createAnnotation(resourceUri2, data) {
913
- return this.http.post(`${resourceUri2}/annotations`, { json: data }).json();
956
+ async createAnnotation(resourceUri2, data, options) {
957
+ return this.http.post(`${resourceUri2}/annotations`, {
958
+ json: data,
959
+ ...options,
960
+ auth: options?.auth
961
+ }).json();
914
962
  }
915
- async getAnnotation(annotationUri2) {
916
- return this.http.get(annotationUri2).json();
963
+ async getAnnotation(annotationUri2, options) {
964
+ return this.http.get(annotationUri2, {
965
+ ...options,
966
+ auth: options?.auth
967
+ }).json();
917
968
  }
918
- async getResourceAnnotation(annotationUri2) {
919
- return this.http.get(annotationUri2).json();
969
+ async getResourceAnnotation(annotationUri2, options) {
970
+ return this.http.get(annotationUri2, {
971
+ ...options,
972
+ auth: options?.auth
973
+ }).json();
920
974
  }
921
- async listAnnotations(resourceUri2, motivation) {
975
+ async listAnnotations(resourceUri2, motivation, options) {
922
976
  const searchParams = new URLSearchParams();
923
977
  if (motivation) searchParams.append("motivation", motivation);
924
- return this.http.get(`${resourceUri2}/annotations`, { searchParams }).json();
978
+ return this.http.get(`${resourceUri2}/annotations`, {
979
+ searchParams,
980
+ ...options,
981
+ auth: options?.auth
982
+ }).json();
925
983
  }
926
- async deleteAnnotation(annotationUri2) {
927
- await this.http.delete(annotationUri2);
984
+ async deleteAnnotation(annotationUri2, options) {
985
+ await this.http.delete(annotationUri2, {
986
+ ...options,
987
+ auth: options?.auth
988
+ });
928
989
  }
929
- async updateAnnotationBody(annotationUri2, data) {
990
+ async updateAnnotationBody(annotationUri2, data, options) {
930
991
  return this.http.put(`${annotationUri2}/body`, {
931
- json: data
992
+ json: data,
993
+ ...options,
994
+ auth: options?.auth
932
995
  }).json();
933
996
  }
934
- async getAnnotationHistory(annotationUri2) {
997
+ async getAnnotationHistory(annotationUri2, options) {
998
+ if (options) {
999
+ return this.http.get(`${annotationUri2}/history`, options).json();
1000
+ }
935
1001
  return this.http.get(`${annotationUri2}/history`).json();
936
1002
  }
937
1003
  // ============================================================================
938
1004
  // ENTITY TYPES
939
1005
  // ============================================================================
940
- async addEntityType(type) {
941
- return this.http.post(`${this.baseUrl}/api/entity-types`, { json: { type } }).json();
1006
+ async addEntityType(type, options) {
1007
+ return this.http.post(`${this.baseUrl}/api/entity-types`, {
1008
+ json: { type },
1009
+ ...options,
1010
+ auth: options?.auth
1011
+ }).json();
942
1012
  }
943
- async addEntityTypesBulk(types) {
944
- return this.http.post(`${this.baseUrl}/api/entity-types/bulk`, { json: { tags: types } }).json();
1013
+ async addEntityTypesBulk(types, options) {
1014
+ return this.http.post(`${this.baseUrl}/api/entity-types/bulk`, {
1015
+ json: { tags: types },
1016
+ ...options,
1017
+ auth: options?.auth
1018
+ }).json();
945
1019
  }
946
- async listEntityTypes() {
947
- return this.http.get(`${this.baseUrl}/api/entity-types`).json();
1020
+ async listEntityTypes(options) {
1021
+ return this.http.get(`${this.baseUrl}/api/entity-types`, {
1022
+ ...options,
1023
+ auth: options?.auth
1024
+ }).json();
948
1025
  }
949
1026
  // ============================================================================
950
1027
  // ADMIN
951
1028
  // ============================================================================
952
- async listUsers() {
953
- return this.http.get(`${this.baseUrl}/api/admin/users`).json();
1029
+ async listUsers(options) {
1030
+ return this.http.get(`${this.baseUrl}/api/admin/users`, {
1031
+ ...options,
1032
+ auth: options?.auth
1033
+ }).json();
954
1034
  }
955
- async getUserStats() {
956
- return this.http.get(`${this.baseUrl}/api/admin/users/stats`).json();
1035
+ async getUserStats(options) {
1036
+ return this.http.get(`${this.baseUrl}/api/admin/users/stats`, {
1037
+ ...options,
1038
+ auth: options?.auth
1039
+ }).json();
957
1040
  }
958
1041
  /**
959
1042
  * Update a user by ID
960
1043
  * Note: Users use DID identifiers (did:web:domain:users:id), not HTTP URIs.
961
1044
  */
962
- async updateUser(id, data) {
963
- return this.http.patch(`${this.baseUrl}/api/admin/users/${id}`, { json: data }).json();
1045
+ async updateUser(id, data, options) {
1046
+ return this.http.patch(`${this.baseUrl}/api/admin/users/${id}`, {
1047
+ json: data,
1048
+ ...options,
1049
+ auth: options?.auth
1050
+ }).json();
964
1051
  }
965
- async getOAuthConfig() {
966
- return this.http.get(`${this.baseUrl}/api/admin/oauth/config`).json();
1052
+ async getOAuthConfig(options) {
1053
+ return this.http.get(`${this.baseUrl}/api/admin/oauth/config`, {
1054
+ ...options,
1055
+ auth: options?.auth
1056
+ }).json();
967
1057
  }
968
1058
  // ============================================================================
969
1059
  // JOB STATUS
970
1060
  // ============================================================================
971
- async getJobStatus(id) {
1061
+ async getJobStatus(id, options) {
1062
+ if (options) {
1063
+ return this.http.get(`${this.baseUrl}/api/jobs/${id}`, options).json();
1064
+ }
972
1065
  return this.http.get(`${this.baseUrl}/api/jobs/${id}`).json();
973
1066
  }
974
1067
  /**
@@ -982,7 +1075,7 @@ var SemiontApiClient = class {
982
1075
  const timeout = options?.timeout ?? 6e4;
983
1076
  const startTime = Date.now();
984
1077
  while (true) {
985
- const status = await this.getJobStatus(id);
1078
+ const status = await this.getJobStatus(id, { auth: options?.auth });
986
1079
  if (options?.onProgress) {
987
1080
  options.onProgress(status);
988
1081
  }
@@ -1004,15 +1097,24 @@ var SemiontApiClient = class {
1004
1097
  if (options?.maxResources !== void 0) searchParams.append("maxResources", options.maxResources.toString());
1005
1098
  if (options?.includeContent !== void 0) searchParams.append("includeContent", options.includeContent.toString());
1006
1099
  if (options?.includeSummary !== void 0) searchParams.append("includeSummary", options.includeSummary.toString());
1007
- return this.http.get(`${resourceUri2}/llm-context`, { searchParams }).json();
1100
+ return this.http.get(`${resourceUri2}/llm-context`, {
1101
+ searchParams,
1102
+ auth: options?.auth
1103
+ }).json();
1008
1104
  }
1009
1105
  // ============================================================================
1010
1106
  // SYSTEM STATUS
1011
1107
  // ============================================================================
1012
- async healthCheck() {
1013
- return this.http.get(`${this.baseUrl}/api/health`).json();
1108
+ async healthCheck(options) {
1109
+ return this.http.get(`${this.baseUrl}/api/health`, {
1110
+ ...options,
1111
+ auth: options?.auth
1112
+ }).json();
1014
1113
  }
1015
- async getStatus() {
1114
+ async getStatus(options) {
1115
+ if (options) {
1116
+ return this.http.get(`${this.baseUrl}/api/status`, options).json();
1117
+ }
1016
1118
  return this.http.get(`${this.baseUrl}/api/status`).json();
1017
1119
  }
1018
1120
  };