@semiont/core 0.5.1 → 0.5.3

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
@@ -109,7 +109,8 @@ var PERSISTED_EVENT_TYPES = [
109
109
  "mark:unarchived",
110
110
  "mark:entity-tag-added",
111
111
  "mark:entity-tag-removed",
112
- "mark:entity-type-added",
112
+ "frame:entity-type-added",
113
+ "frame:tag-schema-added",
113
114
  "job:started",
114
115
  "job:progress",
115
116
  "job:completed",
@@ -134,7 +135,6 @@ var CHANNEL_SCHEMAS = {
134
135
  "yield:moved": null,
135
136
  "yield:representation-added": null,
136
137
  "yield:representation-removed": null,
137
- "yield:request": "YieldRequestCommand",
138
138
  "yield:create": "YieldCreateCommand",
139
139
  "yield:update": "YieldUpdateCommand",
140
140
  "yield:mv": "YieldMvCommand",
@@ -169,7 +169,8 @@ var CHANNEL_SCHEMAS = {
169
169
  "mark:body-updated": null,
170
170
  "mark:entity-tag-added": null,
171
171
  "mark:entity-tag-removed": null,
172
- "mark:entity-type-added": null,
172
+ "frame:entity-type-added": null,
173
+ "frame:tag-schema-added": null,
173
174
  "mark:archived": null,
174
175
  "mark:unarchived": null,
175
176
  "mark:create-request": "MarkCreateRequest",
@@ -179,13 +180,15 @@ var CHANNEL_SCHEMAS = {
179
180
  "mark:archive": "MarkArchiveCommand",
180
181
  "mark:unarchive": "MarkUnarchiveCommand",
181
182
  "mark:update-entity-types": "MarkUpdateEntityTypesCommand",
182
- "mark:add-entity-type": "MarkAddEntityTypeCommand",
183
+ "frame:add-entity-type": "FrameAddEntityTypeCommand",
184
+ "frame:add-tag-schema": "FrameAddTagSchemaCommand",
183
185
  "mark:create-ok": "MarkCreateOk",
184
186
  "mark:create-failed": "CommandError",
185
187
  "mark:delete-ok": "MarkDeleteOk",
186
188
  "mark:delete-failed": "CommandError",
187
189
  "mark:body-update-failed": "CommandError",
188
- "mark:entity-type-add-failed": "CommandError",
190
+ "frame:entity-type-add-failed": "CommandError",
191
+ "frame:tag-schema-add-failed": "CommandError",
189
192
  "mark:select-comment": "SelectionData",
190
193
  "mark:select-tag": "SelectionData",
191
194
  "mark:select-assessment": "SelectionData",
@@ -261,6 +264,9 @@ var CHANNEL_SCHEMAS = {
261
264
  "browse:entity-types-requested": "BrowseEntityTypesRequest",
262
265
  "browse:entity-types-result": "BrowseEntityTypesResult",
263
266
  "browse:entity-types-failed": null,
267
+ "browse:tag-schemas-requested": "BrowseTagSchemasRequest",
268
+ "browse:tag-schemas-result": "BrowseTagSchemasResult",
269
+ "browse:tag-schemas-failed": null,
264
270
  "browse:directory-requested": "BrowseDirectoryRequest",
265
271
  "browse:directory-result": "BrowseDirectoryResult",
266
272
  "browse:directory-failed": null,
@@ -349,6 +355,34 @@ function isEventRelatedToAnnotation(event, annotationUri2) {
349
355
  function isStoredEvent(event) {
350
356
  return event && typeof event.id === "string" && typeof event.timestamp === "string" && typeof event.type === "string" && typeof event.metadata === "object" && typeof event.metadata.sequenceNumber === "number";
351
357
  }
358
+
359
+ // src/bus-log.ts
360
+ var NODE_BUS_LOG = typeof process !== "undefined" && !!process.env?.SEMIONT_BUS_LOG;
361
+ function busLogEnabled() {
362
+ const g = globalThis;
363
+ if (g.__SEMIONT_BUS_LOG__) return true;
364
+ return NODE_BUS_LOG;
365
+ }
366
+ var traceIdProvider;
367
+ function setBusLogTraceIdProvider(fn) {
368
+ traceIdProvider = fn;
369
+ }
370
+ function busLog(op, channel, payload, scope) {
371
+ if (!busLogEnabled()) return;
372
+ const cidRaw = payload?.correlationId;
373
+ const cid = typeof cidRaw === "string" ? cidRaw.slice(0, 8) : void 0;
374
+ let traceId;
375
+ if (traceIdProvider) {
376
+ try {
377
+ traceId = traceIdProvider();
378
+ } catch {
379
+ }
380
+ }
381
+ const tag = `[bus ${op}] ${channel}` + (scope ? ` scope=${scope}` : "") + (cid ? ` cid=${cid}` : "") + (traceId ? ` trace=${traceId.slice(0, 8)}` : "");
382
+ console.debug(tag, payload);
383
+ }
384
+
385
+ // src/event-bus.ts
352
386
  var EventBus = class {
353
387
  subjects;
354
388
  isDestroyed;
@@ -384,7 +418,15 @@ var EventBus = class {
384
418
  throw new Error(`Cannot access event '${String(eventName)}' on destroyed bus`);
385
419
  }
386
420
  if (!this.subjects.has(eventName)) {
387
- this.subjects.set(eventName, new Subject());
421
+ const subject = new Subject();
422
+ if (busLogEnabled()) {
423
+ const originalNext = subject.next.bind(subject);
424
+ subject.next = (value) => {
425
+ busLog("EMIT", String(eventName), value);
426
+ originalNext(value);
427
+ };
428
+ }
429
+ this.subjects.set(eventName, subject);
388
430
  }
389
431
  return this.subjects.get(eventName);
390
432
  }
@@ -592,32 +634,6 @@ function errField(error) {
592
634
  return error;
593
635
  }
594
636
 
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
637
  // src/annotation-utils.ts
622
638
  function findBodyItem(body, identity) {
623
639
  if (!Array.isArray(body)) {
@@ -989,6 +1005,8 @@ var BRIDGED_CHANNELS = [
989
1005
  "browse:referenced-by-failed",
990
1006
  "browse:entity-types-result",
991
1007
  "browse:entity-types-failed",
1008
+ "browse:tag-schemas-result",
1009
+ "browse:tag-schemas-failed",
992
1010
  "browse:directory-result",
993
1011
  "browse:directory-failed",
994
1012
  "browse:annotation-context-result",
@@ -1016,13 +1034,18 @@ var BRIDGED_CHANNELS = [
1016
1034
  "job:create-failed",
1017
1035
  "job:claimed",
1018
1036
  "job:claim-failed",
1037
+ "yield:create-ok",
1038
+ "yield:create-failed",
1039
+ "yield:update-ok",
1040
+ "yield:update-failed",
1019
1041
  "yield:clone-token-generated",
1020
1042
  "yield:clone-token-failed",
1021
1043
  "yield:clone-resource-result",
1022
1044
  "yield:clone-resource-failed",
1023
1045
  "yield:clone-created",
1024
1046
  "yield:clone-create-failed",
1025
- "mark:entity-type-added",
1047
+ "frame:entity-type-added",
1048
+ "frame:tag-schema-added",
1026
1049
  "beckon:focus",
1027
1050
  "beckon:sparkle",
1028
1051
  "bus:resume-gap"