@semiont/core 0.4.13 → 0.4.15
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.d.ts +1357 -1155
- package/dist/index.js +65 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -66,6 +66,7 @@ var CREATION_METHODS = {
|
|
|
66
66
|
UPLOAD: "upload",
|
|
67
67
|
UI: "ui",
|
|
68
68
|
REFERENCE: "reference",
|
|
69
|
+
CLI: "cli",
|
|
69
70
|
CLONE: "clone",
|
|
70
71
|
GENERATED: "generated"
|
|
71
72
|
};
|
|
@@ -93,32 +94,59 @@ function userId(id) {
|
|
|
93
94
|
return id;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
// src/events.ts
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
97
|
+
// src/persisted-events.ts
|
|
98
|
+
var PERSISTED_EVENT_TYPES = [
|
|
99
|
+
"yield:created",
|
|
100
|
+
"yield:cloned",
|
|
101
|
+
"yield:updated",
|
|
102
|
+
"yield:moved",
|
|
103
|
+
"yield:representation-added",
|
|
104
|
+
"yield:representation-removed",
|
|
105
|
+
"mark:added",
|
|
106
|
+
"mark:removed",
|
|
107
|
+
"mark:body-updated",
|
|
108
|
+
"mark:archived",
|
|
109
|
+
"mark:unarchived",
|
|
110
|
+
"mark:entity-tag-added",
|
|
111
|
+
"mark:entity-tag-removed",
|
|
112
|
+
"mark:entity-type-added",
|
|
113
|
+
"job:started",
|
|
114
|
+
"job:progress",
|
|
115
|
+
"job:completed",
|
|
116
|
+
"job:failed",
|
|
117
|
+
"embedding:computed",
|
|
118
|
+
"embedding:deleted"
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
// src/bus-protocol.ts
|
|
122
|
+
var STREAM_COMMAND_RESULT_TYPES = [
|
|
123
|
+
// Match flow — search results for binding candidates
|
|
124
|
+
"match:search-results",
|
|
125
|
+
"match:search-failed",
|
|
126
|
+
// Gather flow — assembled context for reference resolution
|
|
127
|
+
"gather:complete",
|
|
128
|
+
"gather:failed",
|
|
129
|
+
"gather:annotation-progress",
|
|
130
|
+
// Mark flow — AI-assisted annotation progress
|
|
131
|
+
"mark:progress",
|
|
132
|
+
"mark:assist-finished",
|
|
133
|
+
"mark:assist-failed",
|
|
134
|
+
// Yield flow — resource generation progress
|
|
135
|
+
"yield:progress",
|
|
136
|
+
"yield:finished",
|
|
137
|
+
"yield:failed"
|
|
138
|
+
];
|
|
110
139
|
|
|
111
140
|
// src/event-utils.ts
|
|
112
141
|
function getAnnotationUriFromEvent(event) {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
if (eventData.type === "annotation.added") {
|
|
142
|
+
const payload = event.payload;
|
|
143
|
+
if (event.type === "mark:added") {
|
|
116
144
|
return payload?.annotation?.id || null;
|
|
117
145
|
}
|
|
118
|
-
if (
|
|
119
|
-
if (payload?.annotationId &&
|
|
146
|
+
if (event.type === "mark:removed" || event.type === "mark:body-updated") {
|
|
147
|
+
if (payload?.annotationId && event.resourceId) {
|
|
120
148
|
try {
|
|
121
|
-
const resourceUri2 =
|
|
149
|
+
const resourceUri2 = event.resourceId;
|
|
122
150
|
const baseUrl2 = resourceUri2.substring(0, resourceUri2.lastIndexOf("/resources/"));
|
|
123
151
|
return `${baseUrl2}/annotations/${payload.annotationId}`;
|
|
124
152
|
} catch (e) {
|
|
@@ -132,8 +160,8 @@ function isEventRelatedToAnnotation(event, annotationUri2) {
|
|
|
132
160
|
const eventAnnotationUri = getAnnotationUriFromEvent(event);
|
|
133
161
|
return eventAnnotationUri === annotationUri2;
|
|
134
162
|
}
|
|
135
|
-
function
|
|
136
|
-
return event && typeof event.
|
|
163
|
+
function isStoredEvent(event) {
|
|
164
|
+
return event && typeof event.id === "string" && typeof event.timestamp === "string" && typeof event.type === "string" && typeof event.metadata === "object" && typeof event.metadata.sequenceNumber === "number";
|
|
137
165
|
}
|
|
138
166
|
var EventBus = class {
|
|
139
167
|
subjects;
|
|
@@ -174,6 +202,16 @@ var EventBus = class {
|
|
|
174
202
|
}
|
|
175
203
|
return this.subjects.get(eventName);
|
|
176
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Get the RxJS Subject for a domain event type (PersistedEventType).
|
|
207
|
+
*
|
|
208
|
+
* Domain event channels carry `StoredEvent`. This method avoids the need
|
|
209
|
+
* for `as keyof EventMap` casts when subscribing to domain event channels
|
|
210
|
+
* using runtime `PersistedEventType` strings.
|
|
211
|
+
*/
|
|
212
|
+
getDomainEvent(eventType) {
|
|
213
|
+
return this.get(eventType);
|
|
214
|
+
}
|
|
177
215
|
/**
|
|
178
216
|
* Destroy the event bus and complete all subjects
|
|
179
217
|
*
|
|
@@ -241,6 +279,10 @@ var ScopedEventBus = class _ScopedEventBus {
|
|
|
241
279
|
}
|
|
242
280
|
return parentSubjects.get(scopedKey);
|
|
243
281
|
}
|
|
282
|
+
/** Get the RxJS Subject for a domain event type on this scoped bus. */
|
|
283
|
+
getDomainEvent(eventType) {
|
|
284
|
+
return this.get(eventType);
|
|
285
|
+
}
|
|
244
286
|
/**
|
|
245
287
|
* Create a nested scope
|
|
246
288
|
*
|
|
@@ -907,6 +949,6 @@ function getAllPlatformTypes() {
|
|
|
907
949
|
var CORE_TYPES_VERSION = "0.1.0";
|
|
908
950
|
var SDK_VERSION = "0.1.0";
|
|
909
951
|
|
|
910
|
-
export { APIError, CORE_TYPES_VERSION, CREATION_METHODS, ConfigurationError, ConflictError, EventBus, NotFoundError, SDK_VERSION, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseUrl, burstBuffer, cloneToken, createTomlConfigLoader, didToAgent, email, entityType, findBodyItem, generateUuid, getAllPlatformTypes, getAnnotationUriFromEvent,
|
|
952
|
+
export { APIError, CORE_TYPES_VERSION, CREATION_METHODS, ConfigurationError, ConflictError, EventBus, NotFoundError, PERSISTED_EVENT_TYPES, SDK_VERSION, STREAM_COMMAND_RESULT_TYPES, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseUrl, burstBuffer, cloneToken, createTomlConfigLoader, didToAgent, email, entityType, findBodyItem, generateUuid, getAllPlatformTypes, getAnnotationUriFromEvent, getFragmentSelector, getSvgSelector, getTextPositionSelector, googleCredential, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceId, isStoredEvent, isString, isUndefined, isValidPlatformType, jobId, loadTomlConfig, mcpToken, parseEnvironment, refreshToken, resourceAnnotationUri, resourceId, resourceUri, searchQuery, userDID, userId, userToAgent, userToDid, validateEnvironment, validateSvgMarkup };
|
|
911
953
|
//# sourceMappingURL=index.js.map
|
|
912
954
|
//# sourceMappingURL=index.js.map
|