/**
 * Minimal protocol surfaces used by feature binders to interact with optional
 * cross-cutting infrastructure (event bus, realtime broadcaster, realtime
 * handler registry). Lives in `core-shared` so `BindContext` can reference
 * these unconditionally — features depend on `core-shared`, never on the
 * optional packages directly.
 *
 * The optional packages' full interfaces (`IEventBus`, `IRealtimeBroadcaster`,
 * `IRealtimeHandlerRegistry`) `extends` these — typechecks fail if a refactor
 * narrows the protocol surface in a way the full interface would lose.
 */

export type EventBusProtocol = {
  publish<T>(event: { name: string }, payload: T): Promise<void>;
  subscribe<T>(
    event: { name: string },
    consumer: string,
    handler: (payload: T) => Promise<void>,
  ): void;
};

export type RealtimeBroadcasterProtocol = {
  broadcast<T>(
    channel: { name: string; key?: unknown },
    payload: T,
  ): Promise<void>;
};

export type RealtimeRegistryProtocol = {
  register(entry: { descriptor: unknown; handler: unknown }): void;
  registerChannel(descriptor: unknown): void;
  listChannels(): unknown[];
};
