@semiont/core 0.4.18 → 0.4.20

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
@@ -113,9 +113,7 @@ var PERSISTED_EVENT_TYPES = [
113
113
  "job:started",
114
114
  "job:progress",
115
115
  "job:completed",
116
- "job:failed",
117
- "embedding:computed",
118
- "embedding:deleted"
116
+ "job:failed"
119
117
  ];
120
118
 
121
119
  // src/bus-protocol.ts
@@ -374,32 +372,66 @@ function burstBuffer(options) {
374
372
  });
375
373
  }
376
374
 
375
+ // src/serialize-per-key.ts
376
+ async function serializePerKey(key, chains, work) {
377
+ const prev = chains.get(key) ?? Promise.resolve();
378
+ let result;
379
+ const next = prev.catch(() => {
380
+ }).then(async () => {
381
+ result = await work();
382
+ });
383
+ chains.set(key, next);
384
+ try {
385
+ await next;
386
+ return result;
387
+ } finally {
388
+ if (chains.get(key) === next) {
389
+ chains.delete(key);
390
+ }
391
+ }
392
+ }
393
+
394
+ // src/logger.ts
395
+ function errField(error) {
396
+ if (error instanceof Error) {
397
+ return {
398
+ name: error.name,
399
+ message: error.message,
400
+ stack: error.stack,
401
+ ...error.cause !== void 0 && { cause: errField(error.cause) }
402
+ };
403
+ }
404
+ return error;
405
+ }
406
+
377
407
  // src/annotation-utils.ts
378
- function findBodyItem(body, targetItem) {
408
+ function findBodyItem(body, identity) {
379
409
  if (!Array.isArray(body)) {
380
410
  return -1;
381
411
  }
382
412
  for (let i = 0; i < body.length; i++) {
383
413
  const item = body[i];
384
- if (typeof item === "object" && item !== null && "type" in item && "purpose" in item) {
385
- const itemType = item.type;
414
+ if (typeof item !== "object" || item === null || !("type" in item)) {
415
+ continue;
416
+ }
417
+ const itemType = item.type;
418
+ if (itemType !== identity.type) {
419
+ continue;
420
+ }
421
+ if (identity.type === "SpecificResource") {
422
+ if (!("source" in item)) continue;
423
+ const itemSource = item.source;
424
+ if (itemSource !== identity.source) continue;
425
+ } else {
426
+ if (!("value" in item)) continue;
427
+ const itemValue = item.value;
428
+ if (itemValue !== identity.value) continue;
429
+ }
430
+ if (identity.purpose !== void 0) {
386
431
  const itemPurpose = item.purpose;
387
- if (itemType !== targetItem.type || itemPurpose !== targetItem.purpose) {
388
- continue;
389
- }
390
- if (targetItem.type === "TextualBody" && "value" in item) {
391
- const itemValue = item.value;
392
- if (itemValue === targetItem.value) {
393
- return i;
394
- }
395
- }
396
- if (targetItem.type === "SpecificResource" && "source" in item) {
397
- const itemSource = item.source;
398
- if (itemSource === targetItem.source) {
399
- return i;
400
- }
401
- }
432
+ if (itemPurpose !== identity.purpose) continue;
402
433
  }
434
+ return i;
403
435
  }
404
436
  return -1;
405
437
  }
@@ -949,6 +981,6 @@ function getAllPlatformTypes() {
949
981
  var CORE_TYPES_VERSION = "0.1.0";
950
982
  var SDK_VERSION = "0.1.0";
951
983
 
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 };
984
+ 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, errField, 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, serializePerKey, userDID, userId, userToAgent, userToDid, validateEnvironment, validateSvgMarkup };
953
985
  //# sourceMappingURL=index.js.map
954
986
  //# sourceMappingURL=index.js.map