@semiont/core 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +164 -85
- package/dist/index.js +47 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -336,4 +336,4 @@ Apache-2.0
|
|
|
336
336
|
|
|
337
337
|
- [W3C Web Annotation Model](https://www.w3.org/TR/annotation-model/) - Annotation standard
|
|
338
338
|
- [DID:WEB Specification](https://w3c-ccg.github.io/did-method-web/) - Decentralized identifiers
|
|
339
|
-
- [W3C Selectors](../../
|
|
339
|
+
- [W3C Selectors](../../docs/protocol/W3C-SELECTORS.md) - Selector implementation details
|
package/dist/index.d.ts
CHANGED
|
@@ -2223,7 +2223,7 @@ interface components {
|
|
|
2223
2223
|
annotationId: string;
|
|
2224
2224
|
operations: (components["schemas"]["BodyOperationAdd"] | components["schemas"]["BodyOperationRemove"] | components["schemas"]["BodyOperationReplace"])[];
|
|
2225
2225
|
};
|
|
2226
|
-
/** @description Payload for
|
|
2226
|
+
/** @description Payload for frame:entity-type-added domain event (system-level, no resourceId — fan-out is global) */
|
|
2227
2227
|
EntityTypeAddedPayload: {
|
|
2228
2228
|
entityType: string;
|
|
2229
2229
|
};
|
|
@@ -3198,8 +3198,8 @@ interface components {
|
|
|
3198
3198
|
[key: string]: number;
|
|
3199
3199
|
};
|
|
3200
3200
|
};
|
|
3201
|
-
/** @description Bus command to add a new entity type
|
|
3202
|
-
|
|
3201
|
+
/** @description Bus command to add a new entity type to the KB's vocabulary. Carried on the `frame:add-entity-type` channel — Frame is the schema-layer flow that owns vocabulary writes. */
|
|
3202
|
+
FrameAddEntityTypeCommand: {
|
|
3203
3203
|
tag: string;
|
|
3204
3204
|
/** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
|
|
3205
3205
|
_userId?: string;
|
|
@@ -3356,10 +3356,11 @@ interface components {
|
|
|
3356
3356
|
/** @description Bus command to create a cloned resource from a clone token. */
|
|
3357
3357
|
YieldCloneCreateCommand: {
|
|
3358
3358
|
correlationId: string;
|
|
3359
|
+
/** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
|
|
3360
|
+
_userId?: string;
|
|
3359
3361
|
token: string;
|
|
3360
3362
|
name: string;
|
|
3361
3363
|
content: string;
|
|
3362
|
-
userId: string;
|
|
3363
3364
|
archiveOriginal?: boolean;
|
|
3364
3365
|
};
|
|
3365
3366
|
/** @description Success response after creating a cloned resource. */
|
|
@@ -3674,14 +3675,14 @@ type PersistedEventCatalog = {
|
|
|
3674
3675
|
'mark:unarchived': components['schemas']['ResourceUnarchivedPayload'];
|
|
3675
3676
|
'mark:entity-tag-added': components['schemas']['EntityTagChangedPayload'];
|
|
3676
3677
|
'mark:entity-tag-removed': components['schemas']['EntityTagChangedPayload'];
|
|
3677
|
-
'
|
|
3678
|
+
'frame:entity-type-added': components['schemas']['EntityTypeAddedPayload'];
|
|
3678
3679
|
'job:started': components['schemas']['JobStartedPayload'];
|
|
3679
3680
|
'job:progress': components['schemas']['JobProgressPayload'];
|
|
3680
3681
|
'job:completed': components['schemas']['JobCompletedPayload'];
|
|
3681
3682
|
'job:failed': components['schemas']['JobFailedPayload'];
|
|
3682
3683
|
};
|
|
3683
3684
|
/** System event types — persisted events that have no resourceId. */
|
|
3684
|
-
type SystemEventType = '
|
|
3685
|
+
type SystemEventType = 'frame:entity-type-added';
|
|
3685
3686
|
/** Extract the concrete persisted event type for a given type string. */
|
|
3686
3687
|
type EventOfType<K extends keyof PersistedEventCatalog> = K extends SystemEventType ? EventBase & {
|
|
3687
3688
|
type: K;
|
|
@@ -3706,7 +3707,7 @@ type PersistedEventType = PersistedEvent['type'];
|
|
|
3706
3707
|
* also adding it here: forgetting fails to typecheck rather than silently
|
|
3707
3708
|
* dropping the event from the events-stream.
|
|
3708
3709
|
*/
|
|
3709
|
-
declare const PERSISTED_EVENT_TYPES: readonly ["yield:created", "yield:cloned", "yield:updated", "yield:moved", "yield:representation-added", "yield:representation-removed", "mark:added", "mark:removed", "mark:body-updated", "mark:archived", "mark:unarchived", "mark:entity-tag-added", "mark:entity-tag-removed", "
|
|
3710
|
+
declare const PERSISTED_EVENT_TYPES: readonly ["yield:created", "yield:cloned", "yield:updated", "yield:moved", "yield:representation-added", "yield:representation-removed", "mark:added", "mark:removed", "mark:body-updated", "mark:archived", "mark:unarchived", "mark:entity-tag-added", "mark:entity-tag-removed", "frame:entity-type-added", "job:started", "job:progress", "job:completed", "job:failed"];
|
|
3710
3711
|
/** Input type for appendEvent — PersistedEvent without id/timestamp (assigned at persistence time). */
|
|
3711
3712
|
type EventInput = Omit<PersistedEvent, 'id' | 'timestamp'>;
|
|
3712
3713
|
|
|
@@ -3867,7 +3868,6 @@ type EventMap = {
|
|
|
3867
3868
|
'mark:body-updated': StoredEvent<EventOfType<'mark:body-updated'>>;
|
|
3868
3869
|
'mark:entity-tag-added': StoredEvent<EventOfType<'mark:entity-tag-added'>>;
|
|
3869
3870
|
'mark:entity-tag-removed': StoredEvent<EventOfType<'mark:entity-tag-removed'>>;
|
|
3870
|
-
'mark:entity-type-added': StoredEvent<EventOfType<'mark:entity-type-added'>>;
|
|
3871
3871
|
'mark:archived': StoredEvent<EventOfType<'mark:archived'>>;
|
|
3872
3872
|
'mark:unarchived': StoredEvent<EventOfType<'mark:unarchived'>>;
|
|
3873
3873
|
'mark:create-request': components['schemas']['MarkCreateRequest'];
|
|
@@ -3877,13 +3877,11 @@ type EventMap = {
|
|
|
3877
3877
|
'mark:archive': components['schemas']['MarkArchiveCommand'];
|
|
3878
3878
|
'mark:unarchive': components['schemas']['MarkUnarchiveCommand'];
|
|
3879
3879
|
'mark:update-entity-types': components['schemas']['MarkUpdateEntityTypesCommand'];
|
|
3880
|
-
'mark:add-entity-type': components['schemas']['MarkAddEntityTypeCommand'];
|
|
3881
3880
|
'mark:create-ok': components['schemas']['MarkCreateOk'];
|
|
3882
3881
|
'mark:create-failed': components['schemas']['CommandError'];
|
|
3883
3882
|
'mark:delete-ok': components['schemas']['MarkDeleteOk'];
|
|
3884
3883
|
'mark:delete-failed': components['schemas']['CommandError'];
|
|
3885
3884
|
'mark:body-update-failed': components['schemas']['CommandError'];
|
|
3886
|
-
'mark:entity-type-add-failed': components['schemas']['CommandError'];
|
|
3887
3885
|
'mark:select-comment': components['schemas']['SelectionData'];
|
|
3888
3886
|
'mark:select-tag': components['schemas']['SelectionData'];
|
|
3889
3887
|
'mark:select-assessment': components['schemas']['SelectionData'];
|
|
@@ -3898,6 +3896,9 @@ type EventMap = {
|
|
|
3898
3896
|
'mark:selection-changed': components['schemas']['MarkSelectionChangedEvent'];
|
|
3899
3897
|
'mark:click-changed': components['schemas']['MarkClickChangedEvent'];
|
|
3900
3898
|
'mark:shape-changed': components['schemas']['MarkShapeChangedEvent'];
|
|
3899
|
+
'frame:entity-type-added': StoredEvent<EventOfType<'frame:entity-type-added'>>;
|
|
3900
|
+
'frame:add-entity-type': components['schemas']['FrameAddEntityTypeCommand'];
|
|
3901
|
+
'frame:entity-type-add-failed': components['schemas']['CommandError'];
|
|
3901
3902
|
'bind:initiate': BindInitiateCommand;
|
|
3902
3903
|
'bind:update-body': BindUpdateBodyCommand;
|
|
3903
3904
|
'bind:body-updated': components['schemas']['BindBodyUpdated'];
|
|
@@ -4078,7 +4079,7 @@ type EventName = keyof EventMap;
|
|
|
4078
4079
|
*
|
|
4079
4080
|
* The frontend's `subscribeToResource(id)` wires these channels via
|
|
4080
4081
|
* `scope=id&scoped=<channel>` so the SSE route delivers them to that
|
|
4081
|
-
* participant.
|
|
4082
|
+
* participant. WorkerStateUnit uses this list to decide which emitted events to
|
|
4082
4083
|
* scope to their resource.
|
|
4083
4084
|
*/
|
|
4084
4085
|
/**
|
|
@@ -4144,7 +4145,7 @@ declare const CHANNEL_SCHEMAS: {
|
|
|
4144
4145
|
readonly 'mark:body-updated': null;
|
|
4145
4146
|
readonly 'mark:entity-tag-added': null;
|
|
4146
4147
|
readonly 'mark:entity-tag-removed': null;
|
|
4147
|
-
readonly '
|
|
4148
|
+
readonly 'frame:entity-type-added': null;
|
|
4148
4149
|
readonly 'mark:archived': null;
|
|
4149
4150
|
readonly 'mark:unarchived': null;
|
|
4150
4151
|
readonly 'mark:create-request': "MarkCreateRequest";
|
|
@@ -4154,13 +4155,13 @@ declare const CHANNEL_SCHEMAS: {
|
|
|
4154
4155
|
readonly 'mark:archive': "MarkArchiveCommand";
|
|
4155
4156
|
readonly 'mark:unarchive': "MarkUnarchiveCommand";
|
|
4156
4157
|
readonly 'mark:update-entity-types': "MarkUpdateEntityTypesCommand";
|
|
4157
|
-
readonly '
|
|
4158
|
+
readonly 'frame:add-entity-type': "FrameAddEntityTypeCommand";
|
|
4158
4159
|
readonly 'mark:create-ok': "MarkCreateOk";
|
|
4159
4160
|
readonly 'mark:create-failed': "CommandError";
|
|
4160
4161
|
readonly 'mark:delete-ok': "MarkDeleteOk";
|
|
4161
4162
|
readonly 'mark:delete-failed': "CommandError";
|
|
4162
4163
|
readonly 'mark:body-update-failed': "CommandError";
|
|
4163
|
-
readonly '
|
|
4164
|
+
readonly 'frame:entity-type-add-failed': "CommandError";
|
|
4164
4165
|
readonly 'mark:select-comment': "SelectionData";
|
|
4165
4166
|
readonly 'mark:select-tag': "SelectionData";
|
|
4166
4167
|
readonly 'mark:select-assessment': "SelectionData";
|
|
@@ -4999,6 +5000,54 @@ declare function getNodeEncoding(charset: string): BufferEncoding;
|
|
|
4999
5000
|
*/
|
|
5000
5001
|
declare function decodeRepresentation(buffer: Buffer, mediaType: string): string;
|
|
5001
5002
|
|
|
5003
|
+
/**
|
|
5004
|
+
* Common error classes — the unified Semiont error hierarchy.
|
|
5005
|
+
*
|
|
5006
|
+
* `SemiontError` is the base every other Semiont error class extends:
|
|
5007
|
+
* `APIError` (api-client), `BusRequestError` and `SemiontSessionError` (sdk),
|
|
5008
|
+
* `ValidationError`, `ScriptError`, `NotFoundError`, `UnauthorizedError`,
|
|
5009
|
+
* `ConflictError` (here), and `AWSError` (cli). Subclasses tighten the
|
|
5010
|
+
* `code` field to a literal-union for discriminated handling.
|
|
5011
|
+
*/
|
|
5012
|
+
/**
|
|
5013
|
+
* Transport-neutral error vocabulary. Every transport that surfaces
|
|
5014
|
+
* errors over `ITransport.errors$` maps its native failure modes to one
|
|
5015
|
+
* of these codes — HTTP `APIError` maps from status code, in-process
|
|
5016
|
+
* transports map from local failure shape, gRPC would map from status
|
|
5017
|
+
* code, etc. Routing layers (e.g. `SemiontBrowser`'s session-expired /
|
|
5018
|
+
* permission-denied modal routing) match on this vocabulary so they
|
|
5019
|
+
* stay transport-agnostic.
|
|
5020
|
+
*
|
|
5021
|
+
* - `unauthorized` — auth required / token missing or expired (HTTP 401)
|
|
5022
|
+
* - `forbidden` — auth ok but lacks permission (HTTP 403)
|
|
5023
|
+
* - `not-found` — resource missing (HTTP 404)
|
|
5024
|
+
* - `conflict` — concurrent modification, duplicate, etc. (HTTP 409)
|
|
5025
|
+
* - `bad-request` — request malformed (HTTP 400)
|
|
5026
|
+
* - `unavailable` — backend unreachable, network error, 5xx
|
|
5027
|
+
* - `error` — unclassified fallback
|
|
5028
|
+
*/
|
|
5029
|
+
type TransportErrorCode = 'unauthorized' | 'forbidden' | 'not-found' | 'conflict' | 'bad-request' | 'unavailable' | 'error';
|
|
5030
|
+
declare class SemiontError extends Error {
|
|
5031
|
+
code: string;
|
|
5032
|
+
details?: Record<string, unknown> | undefined;
|
|
5033
|
+
constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
|
|
5034
|
+
}
|
|
5035
|
+
declare class ValidationError extends SemiontError {
|
|
5036
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
5037
|
+
}
|
|
5038
|
+
declare class ScriptError extends SemiontError {
|
|
5039
|
+
constructor(message: string, code?: string, details?: Record<string, unknown>);
|
|
5040
|
+
}
|
|
5041
|
+
declare class NotFoundError extends SemiontError {
|
|
5042
|
+
constructor(resource: string, id?: string);
|
|
5043
|
+
}
|
|
5044
|
+
declare class UnauthorizedError extends SemiontError {
|
|
5045
|
+
constructor(message?: string, details?: Record<string, unknown>);
|
|
5046
|
+
}
|
|
5047
|
+
declare class ConflictError extends SemiontError {
|
|
5048
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
5049
|
+
}
|
|
5050
|
+
|
|
5002
5051
|
/**
|
|
5003
5052
|
* Transport interfaces — the shared contract for any wire-or-local
|
|
5004
5053
|
* communication path consumed by `SemiontClient`. Concrete implementations
|
|
@@ -5006,16 +5055,21 @@ declare function decodeRepresentation(buffer: Buffer, mediaType: string): string
|
|
|
5006
5055
|
* `@semiont/api-client`, in-process variants in `@semiont/make-meaning`,
|
|
5007
5056
|
* etc.).
|
|
5008
5057
|
*
|
|
5009
|
-
*
|
|
5058
|
+
* Three interfaces:
|
|
5010
5059
|
*
|
|
5011
|
-
* ITransport —
|
|
5012
|
-
*
|
|
5060
|
+
* ITransport — bus primitives + lifecycle. Universal: every
|
|
5061
|
+
* concrete transport implements this.
|
|
5062
|
+
* IBackendOperations — auth, admin, exchange, system endpoints.
|
|
5063
|
+
* HTTP-shaped today; an in-process transport may
|
|
5064
|
+
* implement none, some, or a different set.
|
|
5065
|
+
* Optional on `SemiontClient` — passed only when
|
|
5066
|
+
* the host has a backend that supports them.
|
|
5013
5067
|
* IContentTransport — binary I/O (putBinary / getBinary). Narrow by
|
|
5014
5068
|
* design because binary has different backpressure
|
|
5015
5069
|
* and streaming characteristics.
|
|
5016
5070
|
*
|
|
5017
5071
|
* The behavioral guarantees every implementation must honor are documented
|
|
5018
|
-
* in `
|
|
5072
|
+
* in `docs/protocol/TRANSPORT-CONTRACT.md`.
|
|
5019
5073
|
*/
|
|
5020
5074
|
|
|
5021
5075
|
type Agent$1 = components['schemas']['Agent'];
|
|
@@ -5083,6 +5137,21 @@ type ProgressEvent = {
|
|
|
5083
5137
|
result?: Record<string, unknown>;
|
|
5084
5138
|
};
|
|
5085
5139
|
type ProgressCallback = (event: ProgressEvent) => void;
|
|
5140
|
+
/**
|
|
5141
|
+
* Stream-shaped return type for backend download operations
|
|
5142
|
+
* (`backupKnowledgeBase`, `exportKnowledgeBase`). Transport-neutral —
|
|
5143
|
+
* any implementation can produce a `ReadableStream<Uint8Array>` without
|
|
5144
|
+
* fabricating a fetch `Response`. HTTP wraps `response.body` and
|
|
5145
|
+
* `response.headers`; in-process implementations return their own stream.
|
|
5146
|
+
*
|
|
5147
|
+
* The same shape `IContentTransport.getBinaryStream` already uses for
|
|
5148
|
+
* binary downloads.
|
|
5149
|
+
*/
|
|
5150
|
+
interface BackendDownload {
|
|
5151
|
+
stream: ReadableStream<Uint8Array>;
|
|
5152
|
+
contentType: string;
|
|
5153
|
+
filename?: string;
|
|
5154
|
+
}
|
|
5086
5155
|
interface ITransport {
|
|
5087
5156
|
/**
|
|
5088
5157
|
* Base URL the transport speaks to. For HTTP this is `https://host[:port]`;
|
|
@@ -5117,6 +5186,38 @@ interface ITransport {
|
|
|
5117
5186
|
* an in-process transport bridges from the local actor bus.
|
|
5118
5187
|
*/
|
|
5119
5188
|
bridgeInto(bus: EventBus): void;
|
|
5189
|
+
/**
|
|
5190
|
+
* Transport-level connection state. For HTTP, reflects the SSE
|
|
5191
|
+
* connection's health; for in-process transports, typically `'open'`
|
|
5192
|
+
* from construction onward (no connection to lose).
|
|
5193
|
+
*/
|
|
5194
|
+
readonly state$: Observable<ConnectionState>;
|
|
5195
|
+
/**
|
|
5196
|
+
* Stream of transport-level errors surfaced from typed-wire methods or
|
|
5197
|
+
* other transport-mediated round-trips, just before they're thrown to
|
|
5198
|
+
* the caller. Each emission is a `SemiontError` (or subclass — HTTP
|
|
5199
|
+
* emits `APIError`, in-process transports emit whatever subclass is
|
|
5200
|
+
* appropriate). Consumers can subscribe for global error handling
|
|
5201
|
+
* (e.g. surfacing 401/403 as modals, logging) without wrapping every
|
|
5202
|
+
* call site in try/catch. Distinct from bus-level errors, which are
|
|
5203
|
+
* surfaced via the channel-correlation pattern in `busRequest`.
|
|
5204
|
+
*/
|
|
5205
|
+
readonly errors$: Observable<SemiontError>;
|
|
5206
|
+
dispose(): void;
|
|
5207
|
+
}
|
|
5208
|
+
/**
|
|
5209
|
+
* Auth, admin, exchange, and system endpoints. HTTP-shaped today —
|
|
5210
|
+
* `HttpTransport` implements both this and `ITransport`; the
|
|
5211
|
+
* `SemiontClient` constructor takes a `IBackendOperations` argument
|
|
5212
|
+
* separately from the bus transport so non-HTTP transports
|
|
5213
|
+
* (`LocalTransport`) can implement just the bus surface and the
|
|
5214
|
+
* SemiontClient cleanly omits `client.auth` / `client.admin`.
|
|
5215
|
+
*
|
|
5216
|
+
* Implementations should map their native error codes to
|
|
5217
|
+
* `TransportErrorCode` (see `errors.ts`) so the routing layer
|
|
5218
|
+
* (`SemiontBrowser`) stays transport-neutral.
|
|
5219
|
+
*/
|
|
5220
|
+
interface IBackendOperations {
|
|
5120
5221
|
authenticatePassword(email: Email, password: string): Promise<AuthResponse>;
|
|
5121
5222
|
authenticateGoogle(credential: GoogleCredential): Promise<AuthResponse>;
|
|
5122
5223
|
refreshAccessToken(token: RefreshToken): Promise<TokenRefreshResponse>;
|
|
@@ -5133,21 +5234,24 @@ interface ITransport {
|
|
|
5133
5234
|
getUserStats(): Promise<AdminUserStatsResponse>;
|
|
5134
5235
|
updateUser(id: UserDID, data: UpdateUserRequest): Promise<UpdateUserResponse>;
|
|
5135
5236
|
getOAuthConfig(): Promise<OAuthConfigResponse>;
|
|
5136
|
-
backupKnowledgeBase(): Promise<
|
|
5137
|
-
|
|
5237
|
+
backupKnowledgeBase(): Promise<BackendDownload>;
|
|
5238
|
+
/**
|
|
5239
|
+
* Stream of `ProgressEvent`s for a restore/import operation. The
|
|
5240
|
+
* Observable emits each progress event in order and completes when
|
|
5241
|
+
* the operation is done; the final event carries `phase: 'complete'`
|
|
5242
|
+
* (or `'error'` / `'failed'` followed by an Observable error).
|
|
5243
|
+
*
|
|
5244
|
+
* The SDK wraps the contract's `Observable<ProgressEvent>` as a
|
|
5245
|
+
* `StreamObservable<ProgressEvent>` so consumers can `await` for the
|
|
5246
|
+
* final event or `.subscribe(...)` to render every step.
|
|
5247
|
+
*/
|
|
5248
|
+
restoreKnowledgeBase(file: File): Observable<ProgressEvent>;
|
|
5138
5249
|
exportKnowledgeBase(params?: {
|
|
5139
5250
|
includeArchived?: boolean;
|
|
5140
|
-
}): Promise<
|
|
5141
|
-
importKnowledgeBase(file: File
|
|
5251
|
+
}): Promise<BackendDownload>;
|
|
5252
|
+
importKnowledgeBase(file: File): Observable<ProgressEvent>;
|
|
5142
5253
|
healthCheck(): Promise<HealthCheckResponse>;
|
|
5143
5254
|
getStatus(): Promise<StatusResponse>;
|
|
5144
|
-
/**
|
|
5145
|
-
* Transport-level connection state. For HTTP, reflects the SSE
|
|
5146
|
-
* connection's health; for in-process transports, typically `'open'`
|
|
5147
|
-
* from construction onward (no connection to lose).
|
|
5148
|
-
*/
|
|
5149
|
-
readonly state$: Observable<ConnectionState>;
|
|
5150
|
-
dispose(): void;
|
|
5151
5255
|
}
|
|
5152
5256
|
interface PutBinaryRequest {
|
|
5153
5257
|
name: string;
|
|
@@ -5163,10 +5267,36 @@ interface PutBinaryRequest {
|
|
|
5163
5267
|
generator?: Agent$1 | Agent$1[];
|
|
5164
5268
|
isDraft?: boolean;
|
|
5165
5269
|
}
|
|
5270
|
+
/**
|
|
5271
|
+
* Optional byte-progress hook for `putBinary`. Receives raw byte counts;
|
|
5272
|
+
* derived shapes (percentage, ETA) are the caller's responsibility.
|
|
5273
|
+
*
|
|
5274
|
+
* `totalBytes` may be 0 when the underlying transport can't determine it
|
|
5275
|
+
* (chunked encoding, indeterminate streams). Consumers should render an
|
|
5276
|
+
* indeterminate state in that case.
|
|
5277
|
+
*/
|
|
5278
|
+
type PutBinaryProgress = (event: {
|
|
5279
|
+
bytesUploaded: number;
|
|
5280
|
+
totalBytes: number;
|
|
5281
|
+
}) => void;
|
|
5282
|
+
interface PutBinaryOptions {
|
|
5283
|
+
auth?: AccessToken;
|
|
5284
|
+
/**
|
|
5285
|
+
* Called as bytes flow over the wire. Honored by transports that can
|
|
5286
|
+
* observe upload progress (HTTP via XHR). Transports that can't
|
|
5287
|
+
* (in-process LocalContentTransport, current `ky`-based fetch path
|
|
5288
|
+
* with no `onProgress`) simply ignore it.
|
|
5289
|
+
*/
|
|
5290
|
+
onProgress?: PutBinaryProgress;
|
|
5291
|
+
/**
|
|
5292
|
+
* Signal that aborts the in-flight request. The XHR-based HTTP path
|
|
5293
|
+
* calls `xhr.abort()` when the signal fires; in-process and
|
|
5294
|
+
* non-XHR HTTP paths complete in the background after abort.
|
|
5295
|
+
*/
|
|
5296
|
+
signal?: AbortSignal;
|
|
5297
|
+
}
|
|
5166
5298
|
interface IContentTransport {
|
|
5167
|
-
putBinary(request: PutBinaryRequest, options?: {
|
|
5168
|
-
auth?: AccessToken;
|
|
5169
|
-
}): Promise<{
|
|
5299
|
+
putBinary(request: PutBinaryRequest, options?: PutBinaryOptions): Promise<{
|
|
5170
5300
|
resourceId: ResourceId;
|
|
5171
5301
|
}>;
|
|
5172
5302
|
getBinary(resourceId: ResourceId, options?: {
|
|
@@ -5201,7 +5331,7 @@ interface IContentTransport {
|
|
|
5201
5331
|
* Resource-scoped channels (joined/left via `subscribeToResource`) are
|
|
5202
5332
|
* tracked separately by transports that care about scope (HTTP).
|
|
5203
5333
|
*/
|
|
5204
|
-
declare const BRIDGED_CHANNELS: readonly ["browse:resources-result", "browse:resources-failed", "browse:resource-result", "browse:resource-failed", "browse:annotations-result", "browse:annotations-failed", "browse:annotation-result", "browse:annotation-failed", "browse:annotation-history-result", "browse:annotation-history-failed", "browse:events-result", "browse:events-failed", "browse:referenced-by-result", "browse:referenced-by-failed", "browse:entity-types-result", "browse:entity-types-failed", "browse:directory-result", "browse:directory-failed", "browse:annotation-context-result", "browse:annotation-context-failed", "mark:delete-ok", "mark:delete-failed", "mark:create-ok", "mark:create-failed", "match:search-results", "match:search-failed", "gather:complete", "gather:failed", "gather:annotation-progress", "gather:annotation-finished", "gather:summary-result", "gather:summary-failed", "bind:body-updated", "bind:body-update-failed", "job:report-progress", "job:complete", "job:fail", "job:status-result", "job:status-failed", "job:created", "job:create-failed", "job:claimed", "job:claim-failed", "yield:clone-token-generated", "yield:clone-token-failed", "yield:clone-resource-result", "yield:clone-resource-failed", "yield:clone-created", "yield:clone-create-failed", "
|
|
5334
|
+
declare const BRIDGED_CHANNELS: readonly ["browse:resources-result", "browse:resources-failed", "browse:resource-result", "browse:resource-failed", "browse:annotations-result", "browse:annotations-failed", "browse:annotation-result", "browse:annotation-failed", "browse:annotation-history-result", "browse:annotation-history-failed", "browse:events-result", "browse:events-failed", "browse:referenced-by-result", "browse:referenced-by-failed", "browse:entity-types-result", "browse:entity-types-failed", "browse:directory-result", "browse:directory-failed", "browse:annotation-context-result", "browse:annotation-context-failed", "mark:delete-ok", "mark:delete-failed", "mark:create-ok", "mark:create-failed", "match:search-results", "match:search-failed", "gather:complete", "gather:failed", "gather:annotation-progress", "gather:annotation-finished", "gather:summary-result", "gather:summary-failed", "bind:body-updated", "bind:body-update-failed", "job:report-progress", "job:complete", "job:fail", "job:status-result", "job:status-failed", "job:created", "job:create-failed", "job:claimed", "job:claim-failed", "yield:create-ok", "yield:create-failed", "yield:update-ok", "yield:update-failed", "yield:clone-token-generated", "yield:clone-token-failed", "yield:clone-resource-result", "yield:clone-resource-failed", "yield:clone-created", "yield:clone-create-failed", "frame:entity-type-added", "beckon:focus", "beckon:sparkle", "bus:resume-gap"];
|
|
5205
5335
|
type BridgedChannel = typeof BRIDGED_CHANNELS[number];
|
|
5206
5336
|
|
|
5207
5337
|
/**
|
|
@@ -5649,57 +5779,6 @@ declare function isNullish(value: unknown): value is null | undefined;
|
|
|
5649
5779
|
*/
|
|
5650
5780
|
declare function isDefined<T>(value: T | null | undefined): value is T;
|
|
5651
5781
|
|
|
5652
|
-
/**
|
|
5653
|
-
* Common error classes
|
|
5654
|
-
*/
|
|
5655
|
-
/**
|
|
5656
|
-
* Base error class for Semiont applications
|
|
5657
|
-
*/
|
|
5658
|
-
declare class SemiontError extends Error {
|
|
5659
|
-
code: string;
|
|
5660
|
-
details?: Record<string, any> | undefined;
|
|
5661
|
-
constructor(message: string, code: string, details?: Record<string, any> | undefined);
|
|
5662
|
-
}
|
|
5663
|
-
/**
|
|
5664
|
-
* Error thrown when validation fails
|
|
5665
|
-
*/
|
|
5666
|
-
declare class ValidationError extends SemiontError {
|
|
5667
|
-
constructor(message: string, details?: Record<string, any>);
|
|
5668
|
-
}
|
|
5669
|
-
/**
|
|
5670
|
-
* Error thrown by scripts
|
|
5671
|
-
*/
|
|
5672
|
-
declare class ScriptError extends SemiontError {
|
|
5673
|
-
constructor(message: string, code?: string, details?: Record<string, any>);
|
|
5674
|
-
}
|
|
5675
|
-
/**
|
|
5676
|
-
* Error thrown when a resource is not found
|
|
5677
|
-
*/
|
|
5678
|
-
declare class NotFoundError extends SemiontError {
|
|
5679
|
-
constructor(resource: string, id?: string);
|
|
5680
|
-
}
|
|
5681
|
-
/**
|
|
5682
|
-
* Error thrown when user is not authorized
|
|
5683
|
-
*/
|
|
5684
|
-
declare class UnauthorizedError extends SemiontError {
|
|
5685
|
-
constructor(message?: string, details?: Record<string, any>);
|
|
5686
|
-
}
|
|
5687
|
-
/**
|
|
5688
|
-
* Error thrown when operation would conflict with existing data
|
|
5689
|
-
*/
|
|
5690
|
-
declare class ConflictError extends SemiontError {
|
|
5691
|
-
constructor(message: string, details?: Record<string, any>);
|
|
5692
|
-
}
|
|
5693
|
-
/**
|
|
5694
|
-
* API Error class for handling HTTP errors
|
|
5695
|
-
* Used by API clients to represent failed HTTP requests
|
|
5696
|
-
*/
|
|
5697
|
-
declare class APIError extends Error {
|
|
5698
|
-
status: number;
|
|
5699
|
-
data: any;
|
|
5700
|
-
constructor(status: number, data: any, message?: string);
|
|
5701
|
-
}
|
|
5702
|
-
|
|
5703
5782
|
/**
|
|
5704
5783
|
* DID (Decentralized Identifier) and W3C Agent utilities
|
|
5705
5784
|
*
|
|
@@ -5885,4 +5964,4 @@ declare function getAllPlatformTypes(): PlatformType[];
|
|
|
5885
5964
|
declare const CORE_TYPES_VERSION = "0.1.0";
|
|
5886
5965
|
declare const SDK_VERSION = "0.1.0";
|
|
5887
5966
|
|
|
5888
|
-
export {
|
|
5967
|
+
export { type AccessToken, type Annotation, type AnnotationCategory, type AnnotationId, type AnnotationUri, type AssembledAnnotation, type AuthCode, BRIDGED_CHANNELS, type BackendDownload, type BaseUrl, type BodyItem, type BodyItemIdentity, type BodyOperation, type BoundingBox, type Brand, type BridgedChannel, type BurstBufferOptions, type BusOp, CHANNEL_SCHEMAS, CORE_TYPES_VERSION, CREATION_METHODS, type CloneToken, ConfigurationError, ConflictError, type ConnectionState, type ContentCache, type ContentFormat, type CreateAnnotationInternal, type CreationMethod, type Email, type EmittableChannel, type EntityType, type EntityTypeStats, type Environment, EnvironmentConfig, type EventBase, EventBus, type EventInput, type EventMap, type EventMetadata, type EventName, type EventOfType, type EventQuery, type EventSignature, type FragmentSelector, type GatheredContext, type GoogleAuthRequest, type GoogleCredential, type GraphConnection, type GraphPath, type HealthCheckResponse, type IBackendOperations, type IContentTransport, type ITransport, JWTTokenSchema, type JobId, LOCALES, type ListUsersResponse, type LocaleInfo, type Logger, type MCPToken, type MatchQuality, type MimeCategory, type Motivation, NotFoundError, PERSISTED_EVENT_TYPES, type PersistedEvent, type PersistedEventType, type PlatformType, type Point, type ProgressCallback, type ProgressEvent, type PutBinaryOptions, type PutBinaryProgress, type PutBinaryRequest, RESOURCE_BROADCAST_TYPES, type RefreshToken, type ResourceAnnotationUri, type ResourceAnnotations, type ResourceBroadcastType, type ResourceDescriptor, type ResourceFilter, type ResourceId, type ResourceUri, SDK_VERSION, ScopedEventBus, ScriptError, type SearchQuery, type SelectionData, type Selector, SemiontError, type StatusResponse, type StoredEvent, type StoredEventLike, type SvgSelector, type TextPosition, type TextPositionSelector, type TextQuoteSelector, type ActorInferenceConfig as TomlActorInferenceConfig, type TomlFileReader, type InferenceConfig as TomlInferenceConfig, type WorkerInferenceConfig as TomlWorkerInferenceConfig, type TransportErrorCode, UnauthorizedError, type UpdateResourceInput, type UpdateUserRequest, type UpdateUserResponse, type UserDID, type UserId, type UserResponse, type ValidatedAnnotation, ValidationError, type ValidationFailure, type ValidationResult, type ValidationSuccess, accessToken, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, cloneToken, type components, createCircleSvg, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, didToAgent, email, entityType, errField, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, findTextWithContext, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, 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, isAnnotationId, isArchived, isArray, isAssessment, isBodyResolved, isBoolean, isComment, isDefined, isDraft, isEventRelatedToAnnotation, isFunction, isHighlight, isImageMimeType, isNull, isNullish, isNumber, isObject, isPdfMimeType, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isTag, isTextMimeType, isUndefined, isValidEmail, isValidPlatformType, jobId, loadTomlConfig, mcpToken, normalizeCoordinates, normalizeText, type operations, parseEnvironment, parseSvgSelector, type paths, refreshToken, resourceAnnotationUri, resourceId, resourceUri, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, userDID, userId, userToAgent, userToDid, validateAndCorrectOffsets, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
|
package/dist/index.js
CHANGED
|
@@ -109,7 +109,7 @@ var PERSISTED_EVENT_TYPES = [
|
|
|
109
109
|
"mark:unarchived",
|
|
110
110
|
"mark:entity-tag-added",
|
|
111
111
|
"mark:entity-tag-removed",
|
|
112
|
-
"
|
|
112
|
+
"frame:entity-type-added",
|
|
113
113
|
"job:started",
|
|
114
114
|
"job:progress",
|
|
115
115
|
"job:completed",
|
|
@@ -169,7 +169,7 @@ var CHANNEL_SCHEMAS = {
|
|
|
169
169
|
"mark:body-updated": null,
|
|
170
170
|
"mark:entity-tag-added": null,
|
|
171
171
|
"mark:entity-tag-removed": null,
|
|
172
|
-
"
|
|
172
|
+
"frame:entity-type-added": null,
|
|
173
173
|
"mark:archived": null,
|
|
174
174
|
"mark:unarchived": null,
|
|
175
175
|
"mark:create-request": "MarkCreateRequest",
|
|
@@ -179,13 +179,13 @@ var CHANNEL_SCHEMAS = {
|
|
|
179
179
|
"mark:archive": "MarkArchiveCommand",
|
|
180
180
|
"mark:unarchive": "MarkUnarchiveCommand",
|
|
181
181
|
"mark:update-entity-types": "MarkUpdateEntityTypesCommand",
|
|
182
|
-
"
|
|
182
|
+
"frame:add-entity-type": "FrameAddEntityTypeCommand",
|
|
183
183
|
"mark:create-ok": "MarkCreateOk",
|
|
184
184
|
"mark:create-failed": "CommandError",
|
|
185
185
|
"mark:delete-ok": "MarkDeleteOk",
|
|
186
186
|
"mark:delete-failed": "CommandError",
|
|
187
187
|
"mark:body-update-failed": "CommandError",
|
|
188
|
-
"
|
|
188
|
+
"frame:entity-type-add-failed": "CommandError",
|
|
189
189
|
"mark:select-comment": "SelectionData",
|
|
190
190
|
"mark:select-tag": "SelectionData",
|
|
191
191
|
"mark:select-assessment": "SelectionData",
|
|
@@ -349,6 +349,34 @@ function isEventRelatedToAnnotation(event, annotationUri2) {
|
|
|
349
349
|
function isStoredEvent(event) {
|
|
350
350
|
return event && typeof event.id === "string" && typeof event.timestamp === "string" && typeof event.type === "string" && typeof event.metadata === "object" && typeof event.metadata.sequenceNumber === "number";
|
|
351
351
|
}
|
|
352
|
+
|
|
353
|
+
// src/bus-log.ts
|
|
354
|
+
var NODE_BUS_LOG = typeof process !== "undefined" && !!process.env?.SEMIONT_BUS_LOG;
|
|
355
|
+
function busLogEnabled() {
|
|
356
|
+
const g = globalThis;
|
|
357
|
+
if (g.__SEMIONT_BUS_LOG__) return true;
|
|
358
|
+
return NODE_BUS_LOG;
|
|
359
|
+
}
|
|
360
|
+
var traceIdProvider;
|
|
361
|
+
function setBusLogTraceIdProvider(fn) {
|
|
362
|
+
traceIdProvider = fn;
|
|
363
|
+
}
|
|
364
|
+
function busLog(op, channel, payload, scope) {
|
|
365
|
+
if (!busLogEnabled()) return;
|
|
366
|
+
const cidRaw = payload?.correlationId;
|
|
367
|
+
const cid = typeof cidRaw === "string" ? cidRaw.slice(0, 8) : void 0;
|
|
368
|
+
let traceId;
|
|
369
|
+
if (traceIdProvider) {
|
|
370
|
+
try {
|
|
371
|
+
traceId = traceIdProvider();
|
|
372
|
+
} catch {
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
const tag = `[bus ${op}] ${channel}` + (scope ? ` scope=${scope}` : "") + (cid ? ` cid=${cid}` : "") + (traceId ? ` trace=${traceId.slice(0, 8)}` : "");
|
|
376
|
+
console.debug(tag, payload);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/event-bus.ts
|
|
352
380
|
var EventBus = class {
|
|
353
381
|
subjects;
|
|
354
382
|
isDestroyed;
|
|
@@ -384,7 +412,15 @@ var EventBus = class {
|
|
|
384
412
|
throw new Error(`Cannot access event '${String(eventName)}' on destroyed bus`);
|
|
385
413
|
}
|
|
386
414
|
if (!this.subjects.has(eventName)) {
|
|
387
|
-
|
|
415
|
+
const subject = new Subject();
|
|
416
|
+
if (busLogEnabled()) {
|
|
417
|
+
const originalNext = subject.next.bind(subject);
|
|
418
|
+
subject.next = (value) => {
|
|
419
|
+
busLog("EMIT", String(eventName), value);
|
|
420
|
+
originalNext(value);
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
this.subjects.set(eventName, subject);
|
|
388
424
|
}
|
|
389
425
|
return this.subjects.get(eventName);
|
|
390
426
|
}
|
|
@@ -592,32 +628,6 @@ function errField(error) {
|
|
|
592
628
|
return error;
|
|
593
629
|
}
|
|
594
630
|
|
|
595
|
-
// src/bus-log.ts
|
|
596
|
-
var NODE_BUS_LOG = typeof process !== "undefined" && !!process.env?.SEMIONT_BUS_LOG;
|
|
597
|
-
function busLogEnabled() {
|
|
598
|
-
const g = globalThis;
|
|
599
|
-
if (g.__SEMIONT_BUS_LOG__) return true;
|
|
600
|
-
return NODE_BUS_LOG;
|
|
601
|
-
}
|
|
602
|
-
var traceIdProvider;
|
|
603
|
-
function setBusLogTraceIdProvider(fn) {
|
|
604
|
-
traceIdProvider = fn;
|
|
605
|
-
}
|
|
606
|
-
function busLog(op, channel, payload, scope) {
|
|
607
|
-
if (!busLogEnabled()) return;
|
|
608
|
-
const cidRaw = payload?.correlationId;
|
|
609
|
-
const cid = typeof cidRaw === "string" ? cidRaw.slice(0, 8) : void 0;
|
|
610
|
-
let traceId;
|
|
611
|
-
if (traceIdProvider) {
|
|
612
|
-
try {
|
|
613
|
-
traceId = traceIdProvider();
|
|
614
|
-
} catch {
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
const tag = `[bus ${op}] ${channel}` + (scope ? ` scope=${scope}` : "") + (cid ? ` cid=${cid}` : "") + (traceId ? ` trace=${traceId.slice(0, 8)}` : "");
|
|
618
|
-
console.debug(tag, payload);
|
|
619
|
-
}
|
|
620
|
-
|
|
621
631
|
// src/annotation-utils.ts
|
|
622
632
|
function findBodyItem(body, identity) {
|
|
623
633
|
if (!Array.isArray(body)) {
|
|
@@ -1016,13 +1026,17 @@ var BRIDGED_CHANNELS = [
|
|
|
1016
1026
|
"job:create-failed",
|
|
1017
1027
|
"job:claimed",
|
|
1018
1028
|
"job:claim-failed",
|
|
1029
|
+
"yield:create-ok",
|
|
1030
|
+
"yield:create-failed",
|
|
1031
|
+
"yield:update-ok",
|
|
1032
|
+
"yield:update-failed",
|
|
1019
1033
|
"yield:clone-token-generated",
|
|
1020
1034
|
"yield:clone-token-failed",
|
|
1021
1035
|
"yield:clone-resource-result",
|
|
1022
1036
|
"yield:clone-resource-failed",
|
|
1023
1037
|
"yield:clone-created",
|
|
1024
1038
|
"yield:clone-create-failed",
|
|
1025
|
-
"
|
|
1039
|
+
"frame:entity-type-added",
|
|
1026
1040
|
"beckon:focus",
|
|
1027
1041
|
"beckon:sparkle",
|
|
1028
1042
|
"bus:resume-gap"
|
|
@@ -1555,15 +1569,6 @@ var ConflictError = class extends SemiontError {
|
|
|
1555
1569
|
this.name = "ConflictError";
|
|
1556
1570
|
}
|
|
1557
1571
|
};
|
|
1558
|
-
var APIError = class extends Error {
|
|
1559
|
-
constructor(status, data, message) {
|
|
1560
|
-
super(message || `API Error: ${status}`);
|
|
1561
|
-
this.status = status;
|
|
1562
|
-
this.data = data;
|
|
1563
|
-
this.name = "APIError";
|
|
1564
|
-
Error.captureStackTrace(this, this.constructor);
|
|
1565
|
-
}
|
|
1566
|
-
};
|
|
1567
1572
|
|
|
1568
1573
|
// src/did-utils.ts
|
|
1569
1574
|
function userToDid(user) {
|
|
@@ -1929,6 +1934,6 @@ function getAllPlatformTypes() {
|
|
|
1929
1934
|
var CORE_TYPES_VERSION = "0.1.0";
|
|
1930
1935
|
var SDK_VERSION = "0.1.0";
|
|
1931
1936
|
|
|
1932
|
-
export {
|
|
1937
|
+
export { BRIDGED_CHANNELS, CHANNEL_SCHEMAS, CORE_TYPES_VERSION, CREATION_METHODS, ConfigurationError, ConflictError, EventBus, JWTTokenSchema, LOCALES, NotFoundError, PERSISTED_EVENT_TYPES, RESOURCE_BROADCAST_TYPES, SDK_VERSION, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, cloneToken, createCircleSvg, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, didToAgent, email, entityType, errField, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, findTextWithContext, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, 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, isAnnotationId, isArchived, isArray, isAssessment, isBodyResolved, isBoolean, isComment, isDefined, isDraft, isEventRelatedToAnnotation, isFunction, isHighlight, isImageMimeType, isNull, isNullish, isNumber, isObject, isPdfMimeType, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isTag, isTextMimeType, isUndefined, isValidEmail, isValidPlatformType, jobId, loadTomlConfig, mcpToken, normalizeCoordinates, normalizeText, parseEnvironment, parseSvgSelector, refreshToken, resourceAnnotationUri, resourceId, resourceUri, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, userDID, userId, userToAgent, userToDid, validateAndCorrectOffsets, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
|
|
1933
1938
|
//# sourceMappingURL=index.js.map
|
|
1934
1939
|
//# sourceMappingURL=index.js.map
|