@calimero-network/mero-js 12.0.0 → 13.0.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.d.ts CHANGED
@@ -11,7 +11,7 @@ export { RpcClient, RpcError } from './rpc/index.js';
11
11
  export type { MigrateMyEntriesSummary } from './rpc/index.js';
12
12
  export type { ExecuteParams } from './rpc/index.js';
13
13
  export { SseClient, WsClient } from './events/index.js';
14
- export type { SseEventData, WsEventData, AppVersionChangedEvent, GroupMembershipEventData } from './events/index.js';
14
+ export type { SseEventData, WsEventData, AppVersionChangedEvent, GroupMembershipEventData, GroupMigrationEventData, MigrationStartedData, MigrationProgressData, CascadeProgressData, MigrationCompletedData, } from './events/index.js';
15
15
  export * from './cloud/index.js';
16
16
  export * from './capabilities.js';
17
17
  export { DEFAULT_LOCAL_NODE_PORTS, localNodeUrl, nodeEndpoint, probeNodeHealth, discoverLocalNodes, } from './nodeDiscovery.js';
package/dist/index.mjs CHANGED
@@ -1517,6 +1517,17 @@ var RpcClient = class {
1517
1517
  }
1518
1518
  };
1519
1519
 
1520
+ // src/events/group.ts
1521
+ var MIGRATION_EVENT_TYPES = /* @__PURE__ */ new Set([
1522
+ "MigrationStarted",
1523
+ "MigrationProgress",
1524
+ "CascadeProgress",
1525
+ "MigrationCompleted"
1526
+ ]);
1527
+ function isGroupMigrationEvent(event) {
1528
+ return event.type !== void 0 && MIGRATION_EVENT_TYPES.has(event.type);
1529
+ }
1530
+
1520
1531
  // src/events/sse.ts
1521
1532
  var SseClient = class {
1522
1533
  constructor(opts) {
@@ -1560,6 +1571,22 @@ var SseClient = class {
1560
1571
  this.on("event", listener);
1561
1572
  return () => this.off("event", listener);
1562
1573
  }
1574
+ /**
1575
+ * Typed convenience over the generic `'event'` stream: invokes `handler` only
1576
+ * for group-migration events, narrowed on `type` so `data` is the matching
1577
+ * payload. Returns an unsubscribe closure.
1578
+ *
1579
+ * A non-admin subscriber sees `MigrationStarted`, `MigrationProgress` and
1580
+ * `MigrationCompleted` but never `CascadeProgress`, which core delivers to
1581
+ * namespace admins only.
1582
+ */
1583
+ onMigrationEvent(handler) {
1584
+ const listener = (ev) => {
1585
+ if (isGroupMigrationEvent(ev)) handler(ev);
1586
+ };
1587
+ this.on("event", listener);
1588
+ return () => this.off("event", listener);
1589
+ }
1563
1590
  emit(event, arg) {
1564
1591
  const key = event;
1565
1592
  if (key in this.listeners) {