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

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.
@@ -3267,9 +3267,9 @@ declare function resourceAnnotationUri(uri: string): ResourceAnnotationUri;
3267
3267
  * Target can be simple string IRI or object with source and optional selector
3268
3268
  */
3269
3269
 
3270
- type Annotation$1 = components['schemas']['Annotation'];
3271
- type HighlightAnnotation = Annotation$1;
3272
- type ReferenceAnnotation = Annotation$1;
3270
+ type Annotation = components['schemas']['Annotation'];
3271
+ type HighlightAnnotation = Annotation;
3272
+ type ReferenceAnnotation = Annotation;
3273
3273
  type TextPositionSelector = components['schemas']['TextPositionSelector'];
3274
3274
  type TextQuoteSelector = components['schemas']['TextQuoteSelector'];
3275
3275
  type SvgSelector = components['schemas']['SvgSelector'];
@@ -3280,24 +3280,24 @@ type Selector = TextPositionSelector | TextQuoteSelector | SvgSelector | Fragmen
3280
3280
  * Get the source from an annotation body (null if stub)
3281
3281
  * Search for SpecificResource in body array
3282
3282
  */
3283
- declare function getBodySource(body: Annotation$1['body']): ResourceUri | null;
3283
+ declare function getBodySource(body: Annotation['body']): ResourceUri | null;
3284
3284
  /**
3285
3285
  * Get the type from an annotation body (returns first body type in array)
3286
3286
  */
3287
- declare function getBodyType(body: Annotation$1['body']): 'TextualBody' | 'SpecificResource' | null;
3287
+ declare function getBodyType(body: Annotation['body']): 'TextualBody' | 'SpecificResource' | null;
3288
3288
  /**
3289
3289
  * Check if body is resolved (has a source)
3290
3290
  * Check for SpecificResource in body array
3291
3291
  */
3292
- declare function isBodyResolved(body: Annotation$1['body']): boolean;
3292
+ declare function isBodyResolved(body: Annotation['body']): boolean;
3293
3293
  /**
3294
3294
  * Get the source IRI from target (handles both string and object forms)
3295
3295
  */
3296
- declare function getTargetSource(target: Annotation$1['target']): ResourceUri;
3296
+ declare function getTargetSource(target: Annotation['target']): ResourceUri;
3297
3297
  /**
3298
3298
  * Get the selector from target (undefined if string or no selector)
3299
3299
  */
3300
- declare function getTargetSelector(target: Annotation$1['target']): {
3300
+ declare function getTargetSelector(target: Annotation['target']): {
3301
3301
  type: "TextPositionSelector";
3302
3302
  start: number;
3303
3303
  end: number;
@@ -3333,43 +3333,43 @@ declare function getTargetSelector(target: Annotation$1['target']): {
3333
3333
  /**
3334
3334
  * Check if target has a selector
3335
3335
  */
3336
- declare function hasTargetSelector(target: Annotation$1['target']): boolean;
3336
+ declare function hasTargetSelector(target: Annotation['target']): boolean;
3337
3337
  /**
3338
3338
  * Type guard to check if an annotation is a highlight
3339
3339
  */
3340
- declare function isHighlight(annotation: Annotation$1): annotation is HighlightAnnotation;
3340
+ declare function isHighlight(annotation: Annotation): annotation is HighlightAnnotation;
3341
3341
  /**
3342
3342
  * Type guard to check if an annotation is a reference (linking)
3343
3343
  */
3344
- declare function isReference(annotation: Annotation$1): annotation is ReferenceAnnotation;
3344
+ declare function isReference(annotation: Annotation): annotation is ReferenceAnnotation;
3345
3345
  /**
3346
3346
  * Type guard to check if an annotation is an assessment
3347
3347
  */
3348
- declare function isAssessment(annotation: Annotation$1): annotation is Annotation$1;
3348
+ declare function isAssessment(annotation: Annotation): annotation is Annotation;
3349
3349
  /**
3350
3350
  * Type guard to check if an annotation is a comment
3351
3351
  */
3352
- declare function isComment(annotation: Annotation$1): annotation is Annotation$1;
3352
+ declare function isComment(annotation: Annotation): annotation is Annotation;
3353
3353
  /**
3354
3354
  * Type guard to check if an annotation is a tag
3355
3355
  */
3356
- declare function isTag(annotation: Annotation$1): annotation is Annotation$1;
3356
+ declare function isTag(annotation: Annotation): annotation is Annotation;
3357
3357
  /**
3358
3358
  * Extract comment text from a comment annotation's body
3359
3359
  * @param annotation - The annotation to extract comment text from
3360
3360
  * @returns The comment text, or undefined if not a comment or no text found
3361
3361
  */
3362
- declare function getCommentText(annotation: Annotation$1): string | undefined;
3362
+ declare function getCommentText(annotation: Annotation): string | undefined;
3363
3363
  /**
3364
3364
  * Type guard to check if a reference annotation is a stub (unresolved)
3365
3365
  * Stub if no SpecificResource in body array
3366
3366
  */
3367
- declare function isStubReference(annotation: Annotation$1): boolean;
3367
+ declare function isStubReference(annotation: Annotation): boolean;
3368
3368
  /**
3369
3369
  * Type guard to check if a reference annotation is resolved
3370
3370
  * Resolved if SpecificResource exists in body array
3371
3371
  */
3372
- declare function isResolvedReference(annotation: Annotation$1): annotation is ReferenceAnnotation;
3372
+ declare function isResolvedReference(annotation: Annotation): annotation is ReferenceAnnotation;
3373
3373
  /**
3374
3374
  * Get the exact text from a selector (single or array)
3375
3375
  *
@@ -3382,7 +3382,7 @@ declare function getExactText(selector: Selector | Selector[] | undefined): stri
3382
3382
  * Get the exact text from an annotation's target selector
3383
3383
  * Uses getTargetSelector helper to safely get selector
3384
3384
  */
3385
- declare function getAnnotationExactText(annotation: Annotation$1): string;
3385
+ declare function getAnnotationExactText(annotation: Annotation): string;
3386
3386
  /**
3387
3387
  * Get the primary selector from a selector (single or array)
3388
3388
  *
@@ -3439,78 +3439,6 @@ declare function extractBoundingBox(svg: string): {
3439
3439
  height: number;
3440
3440
  } | null;
3441
3441
 
3442
- /**
3443
- * Event Utilities
3444
- *
3445
- * Pure TypeScript utilities for working with resource events.
3446
- * No React dependencies - safe to use in any JavaScript environment.
3447
- */
3448
-
3449
- type EventsResponse = paths['/resources/{id}/events']['get']['responses'][200]['content']['application/json'];
3450
- type StoredEvent = EventsResponse['events'][number];
3451
- type ResourceEvent = StoredEvent['event'];
3452
- type EventMetadata = StoredEvent['metadata'];
3453
- type Annotation = components['schemas']['Annotation'];
3454
- type ResourceEventType = 'resource.created' | 'resource.cloned' | 'resource.archived' | 'resource.unarchived' | 'annotation.added' | 'annotation.removed' | 'annotation.body.updated' | 'entitytag.added' | 'entitytag.removed' | 'entitytype.added' | 'job.started' | 'job.progress' | 'job.completed' | 'job.failed';
3455
- type TranslateFn = (key: string, params?: Record<string, string | number>) => string;
3456
- /**
3457
- * Extract annotation ID from event payload
3458
- * Returns null if event is not annotation-related
3459
- *
3460
- * For annotation.added: extracts full URI from payload.annotation.id
3461
- * For annotation.removed/body.updated: constructs full URI from payload.annotationId (UUID) + resourceId
3462
- */
3463
- declare function getAnnotationUriFromEvent(event: StoredEvent): AnnotationUri | null;
3464
- /**
3465
- * Check if an event is related to a specific annotation
3466
- */
3467
- declare function isEventRelatedToAnnotation(event: StoredEvent, annotationUri: AnnotationUri): boolean;
3468
- /**
3469
- * Type guard to check if event is a resource event
3470
- */
3471
- declare function isResourceEvent(event: any): event is StoredEvent;
3472
- /**
3473
- * Format event type for display with i18n support
3474
- */
3475
- declare function formatEventType(type: ResourceEventType, t: TranslateFn, payload?: any): string;
3476
- /**
3477
- * Get emoji for event type
3478
- * For unified annotation events, pass the payload to determine motivation
3479
- */
3480
- declare function getEventEmoji(type: ResourceEventType, payload?: any): string;
3481
- /**
3482
- * Format timestamp as relative time with i18n support
3483
- */
3484
- declare function formatRelativeTime(timestamp: string, t: TranslateFn): string;
3485
- /**
3486
- * Get display content from event payload - complete implementation
3487
- */
3488
- declare function getEventDisplayContent(event: StoredEvent, annotations: Annotation[], // Unified annotations array (all types)
3489
- allEvents: StoredEvent[]): {
3490
- exact: string;
3491
- isQuoted: boolean;
3492
- isTag: boolean;
3493
- } | null;
3494
- /**
3495
- * Get entity types from event payload
3496
- */
3497
- declare function getEventEntityTypes(event: StoredEvent): string[];
3498
- /**
3499
- * Resource creation details
3500
- */
3501
- interface ResourceCreationDetails {
3502
- type: 'created' | 'cloned';
3503
- method: string;
3504
- userId?: string;
3505
- sourceDocId?: string;
3506
- parentResourceId?: string;
3507
- metadata?: Record<string, any>;
3508
- }
3509
- /**
3510
- * Get resource creation details from event
3511
- */
3512
- declare function getResourceCreationDetails(event: StoredEvent): ResourceCreationDetails | null;
3513
-
3514
3442
  /**
3515
3443
  * Fuzzy Anchoring for W3C Web Annotation TextQuoteSelector
3516
3444
  *
@@ -3900,4 +3828,4 @@ declare function validateData<T>(schema: {
3900
3828
  */
3901
3829
  declare function isValidEmail(email: string): boolean;
3902
3830
 
3903
- export { type $defs as $, type AccessToken as A, type BaseUrl as B, type ContentFormat as C, getExactText as D, type EntityType as E, type FragmentSelector as F, type GoogleCredential as G, getAnnotationExactText as H, getPrimarySelector as I, type JobId as J, getTextPositionSelector as K, getTextQuoteSelector as L, type Motivation as M, getSvgSelector as N, getFragmentSelector as O, validateSvgMarkup as P, extractBoundingBox as Q, type ResourceUri as R, type SearchQuery as S, type TextPositionSelector as T, type UserDID as U, type StoredEvent as V, type EventMetadata as W, type ResourceEventType as X, getAnnotationUriFromEvent as Y, isEventRelatedToAnnotation as Z, isResourceEvent as _, type AnnotationUri as a, resourceUri as a$, formatEventType as a0, getEventEmoji as a1, formatRelativeTime as a2, getEventDisplayContent as a3, getEventEntityTypes as a4, type ResourceCreationDetails as a5, getResourceCreationDetails as a6, type TextPosition as a7, findTextWithContext as a8, verifyPosition as a9, normalizeCoordinates as aA, scaleSvgToNative as aB, extractContext as aC, type ValidatedAnnotation as aD, validateAndCorrectOffsets as aE, extractCharset as aF, decodeWithCharset as aG, type ValidationSuccess as aH, type ValidationFailure as aI, type ValidationResult as aJ, JWTTokenSchema as aK, validateData as aL, isValidEmail as aM, type AuthCode as aN, type MCPToken as aO, email as aP, authCode as aQ, googleCredential as aR, accessToken as aS, refreshToken as aT, mcpToken as aU, cloneToken as aV, jobId as aW, userDID as aX, entityType as aY, searchQuery as aZ, baseUrl as a_, type LocaleInfo as aa, LOCALES as ab, getLocaleInfo as ac, getLocaleNativeName as ad, getLocaleEnglishName as ae, formatLocaleDisplay as af, getAllLocaleCodes as ag, getResourceId as ah, getPrimaryRepresentation as ai, getPrimaryMediaType as aj, getChecksum as ak, getLanguage as al, getStorageUri as am, getCreator as an, getDerivedFrom as ao, isArchived as ap, getResourceEntityTypes as aq, isDraft as ar, getNodeEncoding as as, decodeRepresentation as at, type Point as au, type BoundingBox as av, createRectangleSvg as aw, createPolygonSvg as ax, createCircleSvg as ay, parseSvgSelector as az, type Email as b, annotationUri as b0, resourceAnnotationUri as b1, type ResourceEvent as b2, type components as c, type RefreshToken as d, type CloneToken as e, type ResourceAnnotationUri as f, type TextQuoteSelector as g, type SvgSelector as h, type Selector as i, getBodySource as j, getBodyType as k, isBodyResolved as l, getTargetSource as m, getTargetSelector as n, type operations as o, type paths as p, hasTargetSelector as q, isHighlight as r, isReference as s, isAssessment as t, isComment as u, isTag as v, type webhooks as w, getCommentText as x, isStubReference as y, isResolvedReference as z };
3831
+ export { type $defs as $, type AccessToken as A, type BaseUrl as B, type ContentFormat as C, getExactText as D, type EntityType as E, type FragmentSelector as F, type GoogleCredential as G, getAnnotationExactText as H, getPrimarySelector as I, type JobId as J, getTextPositionSelector as K, getTextQuoteSelector as L, type Motivation as M, getSvgSelector as N, getFragmentSelector as O, validateSvgMarkup as P, extractBoundingBox as Q, type ResourceUri as R, type SearchQuery as S, type TextPositionSelector as T, type UserDID as U, type TextPosition as V, findTextWithContext as W, verifyPosition as X, type LocaleInfo as Y, LOCALES as Z, getLocaleInfo as _, type AnnotationUri as a, getLocaleNativeName as a0, getLocaleEnglishName as a1, formatLocaleDisplay as a2, getAllLocaleCodes as a3, getResourceId as a4, getPrimaryRepresentation as a5, getPrimaryMediaType as a6, getChecksum as a7, getLanguage as a8, getStorageUri as a9, type AuthCode as aA, type MCPToken as aB, email as aC, authCode as aD, googleCredential as aE, accessToken as aF, refreshToken as aG, mcpToken as aH, cloneToken as aI, jobId as aJ, userDID as aK, entityType as aL, searchQuery as aM, baseUrl as aN, resourceUri as aO, annotationUri as aP, resourceAnnotationUri as aQ, getCreator as aa, getDerivedFrom as ab, isArchived as ac, getResourceEntityTypes as ad, isDraft as ae, getNodeEncoding as af, decodeRepresentation as ag, type Point as ah, type BoundingBox as ai, createRectangleSvg as aj, createPolygonSvg as ak, createCircleSvg as al, parseSvgSelector as am, normalizeCoordinates as an, scaleSvgToNative as ao, extractContext as ap, type ValidatedAnnotation as aq, validateAndCorrectOffsets as ar, extractCharset as as, decodeWithCharset as at, type ValidationSuccess as au, type ValidationFailure as av, type ValidationResult as aw, JWTTokenSchema as ax, validateData as ay, isValidEmail as az, type Email as b, type components as c, type RefreshToken as d, type CloneToken as e, type ResourceAnnotationUri as f, type TextQuoteSelector as g, type SvgSelector as h, type Selector as i, getBodySource as j, getBodyType as k, isBodyResolved as l, getTargetSource as m, getTargetSelector as n, type operations as o, type paths as p, hasTargetSelector as q, isHighlight as r, isReference as s, isAssessment as t, isComment as u, isTag as v, type webhooks as w, getCommentText as x, isStubReference as y, isResolvedReference as z };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BaseUrl, A as AccessToken, R as ResourceUri, E as EntityType, a as AnnotationUri, c as components, b as Email, p as paths, d as RefreshToken, G as GoogleCredential, C as ContentFormat, S as SearchQuery, e as CloneToken, f as ResourceAnnotationUri, M as Motivation, U as UserDID, J as JobId } from './index-BjpP_lGG.js';
2
- export { $ as $defs, aN as AuthCode, av as BoundingBox, W as EventMetadata, F as FragmentSelector, aK as JWTTokenSchema, ab as LOCALES, aa as LocaleInfo, aO as MCPToken, au as Point, a5 as ResourceCreationDetails, X as ResourceEventType, i as Selector, V as StoredEvent, h as SvgSelector, a7 as TextPosition, T as TextPositionSelector, g as TextQuoteSelector, aD as ValidatedAnnotation, aI as ValidationFailure, aJ as ValidationResult, aH as ValidationSuccess, aS as accessToken, b0 as annotationUri, aQ as authCode, a_ as baseUrl, aV as cloneToken, ay as createCircleSvg, ax as createPolygonSvg, aw as createRectangleSvg, at as decodeRepresentation, aG as decodeWithCharset, aP as email, aY as entityType, Q as extractBoundingBox, aF as extractCharset, aC as extractContext, a8 as findTextWithContext, a0 as formatEventType, af as formatLocaleDisplay, a2 as formatRelativeTime, ag as getAllLocaleCodes, H as getAnnotationExactText, Y as getAnnotationUriFromEvent, j as getBodySource, k as getBodyType, ak as getChecksum, x as getCommentText, an as getCreator, ao as getDerivedFrom, a3 as getEventDisplayContent, a1 as getEventEmoji, a4 as getEventEntityTypes, D as getExactText, O as getFragmentSelector, al as getLanguage, ae as getLocaleEnglishName, ac as getLocaleInfo, ad as getLocaleNativeName, as as getNodeEncoding, aj as getPrimaryMediaType, ai as getPrimaryRepresentation, I as getPrimarySelector, a6 as getResourceCreationDetails, aq as getResourceEntityTypes, ah as getResourceId, am as getStorageUri, N as getSvgSelector, n as getTargetSelector, m as getTargetSource, K as getTextPositionSelector, L as getTextQuoteSelector, aR as googleCredential, q as hasTargetSelector, ap as isArchived, t as isAssessment, l as isBodyResolved, u as isComment, ar as isDraft, Z as isEventRelatedToAnnotation, r as isHighlight, s as isReference, z as isResolvedReference, _ as isResourceEvent, y as isStubReference, v as isTag, aM as isValidEmail, aW as jobId, aU as mcpToken, aA as normalizeCoordinates, o as operations, az as parseSvgSelector, aT as refreshToken, b1 as resourceAnnotationUri, a$ as resourceUri, aB as scaleSvgToNative, aZ as searchQuery, aX as userDID, aE as validateAndCorrectOffsets, aL as validateData, P as validateSvgMarkup, a9 as verifyPosition, w as webhooks } from './index-BjpP_lGG.js';
1
+ import { B as BaseUrl, A as AccessToken, R as ResourceUri, E as EntityType, a as AnnotationUri, c as components, b as Email, p as paths, d as RefreshToken, G as GoogleCredential, C as ContentFormat, S as SearchQuery, e as CloneToken, f as ResourceAnnotationUri, M as Motivation, U as UserDID, J as JobId } from './index-BUlCf43K.js';
2
+ export { $ as $defs, aA as AuthCode, ai as BoundingBox, F as FragmentSelector, ax as JWTTokenSchema, Z as LOCALES, Y as LocaleInfo, aB as MCPToken, ah as Point, i as Selector, h as SvgSelector, V as TextPosition, T as TextPositionSelector, g as TextQuoteSelector, aq as ValidatedAnnotation, av as ValidationFailure, aw as ValidationResult, au as ValidationSuccess, aF as accessToken, aP as annotationUri, aD as authCode, aN as baseUrl, aI as cloneToken, al as createCircleSvg, ak as createPolygonSvg, aj as createRectangleSvg, ag as decodeRepresentation, at as decodeWithCharset, aC as email, aL as entityType, Q as extractBoundingBox, as as extractCharset, ap as extractContext, W as findTextWithContext, a2 as formatLocaleDisplay, a3 as getAllLocaleCodes, H as getAnnotationExactText, j as getBodySource, k as getBodyType, a7 as getChecksum, x as getCommentText, aa as getCreator, ab as getDerivedFrom, D as getExactText, O as getFragmentSelector, a8 as getLanguage, a1 as getLocaleEnglishName, _ as getLocaleInfo, a0 as getLocaleNativeName, af as getNodeEncoding, a6 as getPrimaryMediaType, a5 as getPrimaryRepresentation, I as getPrimarySelector, ad as getResourceEntityTypes, a4 as getResourceId, a9 as getStorageUri, N as getSvgSelector, n as getTargetSelector, m as getTargetSource, K as getTextPositionSelector, L as getTextQuoteSelector, aE as googleCredential, q as hasTargetSelector, ac as isArchived, t as isAssessment, l as isBodyResolved, u as isComment, ae as isDraft, r as isHighlight, s as isReference, z as isResolvedReference, y as isStubReference, v as isTag, az as isValidEmail, aJ as jobId, aH as mcpToken, an as normalizeCoordinates, o as operations, am as parseSvgSelector, aG as refreshToken, aQ as resourceAnnotationUri, aO as resourceUri, ao as scaleSvgToNative, aM as searchQuery, aK as userDID, ar as validateAndCorrectOffsets, ay as validateData, P as validateSvgMarkup, X as verifyPosition, w as webhooks } from './index-BUlCf43K.js';
3
3
 
4
4
  /**
5
5
  * TypeScript types for Server-Sent Events (SSE) streaming
@@ -205,39 +205,18 @@ interface TagDetectionProgress {
205
205
  * as it occurs. Used for real-time collaboration - multiple users see each
206
206
  * other's changes as they happen.
207
207
  *
208
+ * Re-exported from @semiont/core (authoritative source).
209
+ * The discriminated union type provides type-safe event handling.
210
+ *
208
211
  * @example
209
212
  * ```typescript
210
- * stream.onEvent((event: ResourceEvent) => {
213
+ * stream.onEvent((event) => {
211
214
  * console.log(`Event: ${event.type}`);
212
215
  * console.log(`User: ${event.userId}`);
213
216
  * console.log(`Payload:`, event.payload);
214
- * console.log(`Sequence: ${event.metadata.sequenceNumber}`);
215
217
  * });
216
218
  * ```
217
219
  */
218
- interface ResourceEvent {
219
- /** Event ID (unique) */
220
- id: string;
221
- /** Event type (e.g., 'resource.created', 'annotation.created', etc.) */
222
- type: string;
223
- /** ISO 8601 timestamp */
224
- timestamp: string;
225
- /** User ID who triggered the event */
226
- userId: string;
227
- /** Resource ID this event relates to */
228
- resourceId: string;
229
- /** Event-specific payload (varies by event type) */
230
- payload: any;
231
- /** Event store metadata */
232
- metadata: {
233
- /** Monotonically increasing sequence number */
234
- sequenceNumber: number;
235
- /** SHA-256 hash of previous event (for integrity) */
236
- prevEventHash: string;
237
- /** SHA-256 checksum of this event */
238
- checksum: string;
239
- };
240
- }
241
220
  /**
242
221
  * SSE stream controller interface
243
222
  *
@@ -664,7 +643,7 @@ declare class SSEClient {
664
643
  * stream.close();
665
644
  * ```
666
645
  */
667
- resourceEvents(resourceId: ResourceUri): SSEStream<ResourceEvent, never>;
646
+ resourceEvents(resourceId: ResourceUri): SSEStream<any, never>;
668
647
  }
669
648
 
670
649
  /**
@@ -980,4 +959,4 @@ declare function getMimeCategory(mimeType: string): MimeCategory;
980
959
  type GenerationContext = components['schemas']['GenerationContext'];
981
960
  type AnnotationLLMContextResponse = components['schemas']['AnnotationLLMContextResponse'];
982
961
 
983
- export { APIError, AccessToken, type AnnotationLLMContextResponse, AnnotationUri, BaseUrl, CloneToken, ContentFormat, type DetectAnnotationsStreamRequest, type DetectionProgress, Email, EntityType, type GenerateResourceStreamRequest, type GenerationContext, type GenerationProgress, GoogleCredential, JobId, type Logger, type MimeCategory, Motivation, RefreshToken, ResourceAnnotationUri, type ResourceEvent, ResourceUri, SSEClient, type SSEClientConfig, type SSEStream, SearchQuery, SemiontApiClient, type SemiontApiClientConfig, UserDID, components, getExtensionForMimeType, getMimeCategory, isImageMimeType, isPdfMimeType, isTextMimeType, paths };
962
+ export { APIError, AccessToken, type AnnotationLLMContextResponse, AnnotationUri, BaseUrl, CloneToken, ContentFormat, type DetectAnnotationsStreamRequest, type DetectionProgress, Email, EntityType, type GenerateResourceStreamRequest, type GenerationContext, type GenerationProgress, GoogleCredential, JobId, type Logger, type MimeCategory, Motivation, RefreshToken, ResourceAnnotationUri, ResourceUri, SSEClient, type SSEClientConfig, type SSEStream, SearchQuery, SemiontApiClient, type SemiontApiClientConfig, UserDID, components, getExtensionForMimeType, getMimeCategory, isImageMimeType, isPdfMimeType, isTextMimeType, paths };
package/dist/index.js CHANGED
@@ -1267,248 +1267,6 @@ function extractBoundingBox(svg) {
1267
1267
  return null;
1268
1268
  }
1269
1269
 
1270
- // src/utils/events.ts
1271
- function getAnnotationUriFromEvent(event) {
1272
- const eventData = event.event;
1273
- const payload = eventData.payload;
1274
- if (!payload) {
1275
- return null;
1276
- }
1277
- switch (eventData.type) {
1278
- case "annotation.added":
1279
- return payload.annotation?.id || null;
1280
- case "annotation.removed":
1281
- case "annotation.body.updated":
1282
- if (payload.annotationId && eventData.resourceId) {
1283
- try {
1284
- const resourceUri2 = eventData.resourceId;
1285
- const baseUrl2 = resourceUri2.substring(0, resourceUri2.lastIndexOf("/resources/"));
1286
- return `${baseUrl2}/annotations/${payload.annotationId}`;
1287
- } catch (e) {
1288
- return null;
1289
- }
1290
- }
1291
- return null;
1292
- default:
1293
- return null;
1294
- }
1295
- }
1296
- function isEventRelatedToAnnotation(event, annotationUri2) {
1297
- const eventAnnotationUri = getAnnotationUriFromEvent(event);
1298
- return eventAnnotationUri === annotationUri2;
1299
- }
1300
- function isResourceEvent(event) {
1301
- return event && typeof event.event === "object" && typeof event.event.id === "string" && typeof event.event.timestamp === "string" && typeof event.event.resourceId === "string" && typeof event.event.type === "string" && typeof event.metadata === "object" && typeof event.metadata.sequenceNumber === "number";
1302
- }
1303
- function formatEventType(type, t, payload) {
1304
- switch (type) {
1305
- case "resource.created":
1306
- return t("resourceCreated");
1307
- case "resource.cloned":
1308
- return t("resourceCloned");
1309
- case "resource.archived":
1310
- return t("resourceArchived");
1311
- case "resource.unarchived":
1312
- return t("resourceUnarchived");
1313
- case "annotation.added": {
1314
- const motivation = payload?.annotation?.motivation;
1315
- if (motivation === "highlighting") return t("highlightAdded");
1316
- if (motivation === "linking") return t("referenceCreated");
1317
- if (motivation === "assessing") return t("assessmentAdded");
1318
- return t("annotationAdded");
1319
- }
1320
- case "annotation.removed": {
1321
- return t("annotationRemoved");
1322
- }
1323
- case "annotation.body.updated": {
1324
- return t("annotationBodyUpdated");
1325
- }
1326
- case "entitytag.added":
1327
- return t("entitytagAdded");
1328
- case "entitytag.removed":
1329
- return t("entitytagRemoved");
1330
- case "entitytype.added":
1331
- return t("entitytypeAdded");
1332
- case "job.completed":
1333
- case "job.started":
1334
- case "job.progress":
1335
- case "job.failed":
1336
- return t("jobEvent");
1337
- default:
1338
- const _exhaustiveCheck = type;
1339
- return _exhaustiveCheck;
1340
- }
1341
- }
1342
- function getEventEmoji(type, payload) {
1343
- switch (type) {
1344
- case "resource.created":
1345
- case "resource.cloned":
1346
- case "resource.archived":
1347
- case "resource.unarchived":
1348
- return "\u{1F4C4}";
1349
- case "annotation.added": {
1350
- const motivation = payload?.annotation?.motivation;
1351
- if (motivation === "highlighting") return "\u{1F7E1}";
1352
- if (motivation === "linking") return "\u{1F535}";
1353
- if (motivation === "assessing") return "\u{1F534}";
1354
- return "\u{1F4DD}";
1355
- }
1356
- case "annotation.removed": {
1357
- return "\u{1F5D1}\uFE0F";
1358
- }
1359
- case "annotation.body.updated": {
1360
- return "\u270F\uFE0F";
1361
- }
1362
- case "entitytag.added":
1363
- case "entitytag.removed":
1364
- return "\u{1F3F7}\uFE0F";
1365
- case "entitytype.added":
1366
- return "\u{1F3F7}\uFE0F";
1367
- // Same emoji as entitytag (global entity type collection)
1368
- case "job.completed":
1369
- return "\u{1F517}";
1370
- // Link emoji for linked document creation
1371
- case "job.started":
1372
- case "job.progress":
1373
- return "\u2699\uFE0F";
1374
- // Gear for job processing
1375
- case "job.failed":
1376
- return "\u274C";
1377
- // X mark for failed jobs
1378
- default:
1379
- const _exhaustiveCheck = type;
1380
- return _exhaustiveCheck;
1381
- }
1382
- }
1383
- function formatRelativeTime(timestamp, t) {
1384
- const date = new Date(timestamp);
1385
- const now = /* @__PURE__ */ new Date();
1386
- const diffMs = now.getTime() - date.getTime();
1387
- const diffMins = Math.floor(diffMs / 6e4);
1388
- const diffHours = Math.floor(diffMs / 36e5);
1389
- const diffDays = Math.floor(diffMs / 864e5);
1390
- if (diffMins < 1) return t("justNow");
1391
- if (diffMins < 60) return t("minutesAgo", { count: diffMins });
1392
- if (diffHours < 24) return t("hoursAgo", { count: diffHours });
1393
- if (diffDays < 7) return t("daysAgo", { count: diffDays });
1394
- return date.toLocaleDateString();
1395
- }
1396
- function truncateText(text, maxLength = 50) {
1397
- const trimmed = text.trim();
1398
- return trimmed.length > maxLength ? trimmed.substring(0, maxLength) + "..." : trimmed;
1399
- }
1400
- function getEventDisplayContent(event, annotations, allEvents) {
1401
- const eventData = event.event;
1402
- const payload = eventData.payload;
1403
- switch (eventData.type) {
1404
- case "resource.created":
1405
- case "resource.cloned": {
1406
- return { exact: payload.name, isQuoted: false, isTag: false };
1407
- }
1408
- // Unified annotation events
1409
- case "annotation.body.updated": {
1410
- const annotation = annotations.find(
1411
- (a) => a.id.endsWith(`/annotations/${payload.annotationId}`)
1412
- );
1413
- if (annotation?.target) {
1414
- try {
1415
- const targetSelector = getTargetSelector(annotation.target);
1416
- const exact = getExactText(targetSelector);
1417
- if (exact) {
1418
- return { exact: truncateText(exact), isQuoted: true, isTag: false };
1419
- }
1420
- } catch {
1421
- }
1422
- }
1423
- return null;
1424
- }
1425
- case "annotation.removed": {
1426
- const addedEvent = allEvents.find(
1427
- (e) => e.event.type === "annotation.added" && e.event.payload.annotation?.id?.endsWith(`/annotations/${payload.annotationId}`)
1428
- );
1429
- if (addedEvent) {
1430
- const addedPayload = addedEvent.event.payload;
1431
- try {
1432
- const exact = getExactText(addedPayload.annotation.target.selector);
1433
- if (exact) {
1434
- return { exact: truncateText(exact), isQuoted: true, isTag: false };
1435
- }
1436
- } catch {
1437
- }
1438
- }
1439
- return null;
1440
- }
1441
- case "annotation.added": {
1442
- try {
1443
- const exact = getExactText(payload.annotation.target.selector);
1444
- if (exact) {
1445
- return { exact: truncateText(exact), isQuoted: true, isTag: false };
1446
- }
1447
- } catch {
1448
- }
1449
- return null;
1450
- }
1451
- case "entitytag.added":
1452
- case "entitytag.removed": {
1453
- return { exact: payload.entityType, isQuoted: false, isTag: true };
1454
- }
1455
- case "job.completed": {
1456
- if (payload.annotationUri) {
1457
- const annotation = annotations.find(
1458
- (a) => a.id === payload.annotationUri
1459
- );
1460
- if (annotation?.target) {
1461
- try {
1462
- const targetSelector = getTargetSelector(annotation.target);
1463
- const exact = getExactText(targetSelector);
1464
- if (exact) {
1465
- return { exact: truncateText(exact), isQuoted: true, isTag: false };
1466
- }
1467
- } catch {
1468
- }
1469
- }
1470
- }
1471
- return null;
1472
- }
1473
- default:
1474
- return null;
1475
- }
1476
- }
1477
- function getEventEntityTypes(event) {
1478
- const eventData = event.event;
1479
- if (eventData.type === "annotation.added") {
1480
- const payload = eventData.payload;
1481
- const motivation = payload?.annotation?.motivation;
1482
- if (motivation === "linking") {
1483
- return payload.annotation?.body?.entityTypes ?? [];
1484
- }
1485
- }
1486
- return [];
1487
- }
1488
- function getResourceCreationDetails(event) {
1489
- const eventData = event.event;
1490
- const payload = eventData.payload;
1491
- if (eventData.type === "resource.created") {
1492
- return {
1493
- type: "created",
1494
- method: payload.creationMethod || "unknown",
1495
- userId: eventData.userId,
1496
- metadata: payload.metadata
1497
- };
1498
- }
1499
- if (eventData.type === "resource.cloned") {
1500
- return {
1501
- type: "cloned",
1502
- method: payload.creationMethod || "clone",
1503
- userId: eventData.userId,
1504
- sourceDocId: payload.parentResourceId,
1505
- parentResourceId: payload.parentResourceId,
1506
- metadata: payload.metadata
1507
- };
1508
- }
1509
- return null;
1510
- }
1511
-
1512
1270
  // src/utils/fuzzy-anchor.ts
1513
1271
  function findTextWithContext(content, exact, prefix, suffix) {
1514
1272
  if (!exact) return null;
@@ -2044,6 +1802,6 @@ function getMimeCategory(mimeType) {
2044
1802
  return "unsupported";
2045
1803
  }
2046
1804
 
2047
- export { APIError, JWTTokenSchema, LOCALES, SSEClient, SemiontApiClient, accessToken, annotationUri, authCode, baseUrl, cloneToken, createCircleSvg, createPolygonSvg, createRectangleSvg, decodeRepresentation, decodeWithCharset, email, entityType, extractBoundingBox, extractCharset, extractContext, findTextWithContext, formatEventType, formatLocaleDisplay, formatRelativeTime, getAllLocaleCodes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getEventDisplayContent, getEventEmoji, getEventEntityTypes, getExactText, getExtensionForMimeType, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getMimeCategory, getNodeEncoding, getPrimaryMediaType, getPrimaryRepresentation, getPrimarySelector, getResourceCreationDetails, getResourceEntityTypes, getResourceId, getStorageUri, getSvgSelector, getTargetSelector, getTargetSource, getTextPositionSelector, getTextQuoteSelector, googleCredential, hasTargetSelector, isArchived, isAssessment, isBodyResolved, isComment, isDraft, isEventRelatedToAnnotation, isHighlight, isImageMimeType, isPdfMimeType, isReference, isResolvedReference, isResourceEvent, isStubReference, isTag, isTextMimeType, isValidEmail, jobId, mcpToken, normalizeCoordinates, parseSvgSelector, refreshToken, resourceAnnotationUri, resourceUri, scaleSvgToNative, searchQuery, userDID, validateAndCorrectOffsets, validateData, validateSvgMarkup, verifyPosition };
1805
+ export { APIError, JWTTokenSchema, LOCALES, SSEClient, SemiontApiClient, accessToken, annotationUri, authCode, baseUrl, cloneToken, createCircleSvg, createPolygonSvg, createRectangleSvg, decodeRepresentation, decodeWithCharset, email, entityType, extractBoundingBox, extractCharset, extractContext, findTextWithContext, formatLocaleDisplay, getAllLocaleCodes, getAnnotationExactText, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getExtensionForMimeType, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getMimeCategory, getNodeEncoding, getPrimaryMediaType, getPrimaryRepresentation, getPrimarySelector, getResourceEntityTypes, getResourceId, getStorageUri, getSvgSelector, getTargetSelector, getTargetSource, getTextPositionSelector, getTextQuoteSelector, googleCredential, hasTargetSelector, isArchived, isAssessment, isBodyResolved, isComment, isDraft, isHighlight, isImageMimeType, isPdfMimeType, isReference, isResolvedReference, isStubReference, isTag, isTextMimeType, isValidEmail, jobId, mcpToken, normalizeCoordinates, parseSvgSelector, refreshToken, resourceAnnotationUri, resourceUri, scaleSvgToNative, searchQuery, userDID, validateAndCorrectOffsets, validateData, validateSvgMarkup, verifyPosition };
2048
1806
  //# sourceMappingURL=index.js.map
2049
1807
  //# sourceMappingURL=index.js.map