@calimero-network/mero-js 11.1.0 → 12.1.0

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.cjs CHANGED
@@ -1583,6 +1583,17 @@ var RpcClient = class {
1583
1583
  }
1584
1584
  };
1585
1585
 
1586
+ // src/events/group.ts
1587
+ var MIGRATION_EVENT_TYPES = /* @__PURE__ */ new Set([
1588
+ "MigrationStarted",
1589
+ "MigrationProgress",
1590
+ "CascadeProgress",
1591
+ "MigrationCompleted"
1592
+ ]);
1593
+ function isGroupMigrationEvent(event) {
1594
+ return event.type !== void 0 && MIGRATION_EVENT_TYPES.has(event.type);
1595
+ }
1596
+
1586
1597
  // src/events/sse.ts
1587
1598
  var SseClient = class {
1588
1599
  constructor(opts) {
@@ -1626,6 +1637,22 @@ var SseClient = class {
1626
1637
  this.on("event", listener);
1627
1638
  return () => this.off("event", listener);
1628
1639
  }
1640
+ /**
1641
+ * Typed convenience over the generic `'event'` stream: invokes `handler` only
1642
+ * for group-migration events, narrowed on `type` so `data` is the matching
1643
+ * payload. Returns an unsubscribe closure.
1644
+ *
1645
+ * A non-admin subscriber sees `MigrationStarted`, `MigrationProgress` and
1646
+ * `MigrationCompleted` but never `CascadeProgress`, which core delivers to
1647
+ * namespace admins only.
1648
+ */
1649
+ onMigrationEvent(handler) {
1650
+ const listener = (ev) => {
1651
+ if (isGroupMigrationEvent(ev)) handler(ev);
1652
+ };
1653
+ this.on("event", listener);
1654
+ return () => this.off("event", listener);
1655
+ }
1629
1656
  emit(event, arg) {
1630
1657
  const key = event;
1631
1658
  if (key in this.listeners) {