import type { ITransportAdapter } from '../engine/remoting/ITransportAdapter';
import { NatsTransport, type INatsLikeConnection } from './NatsTransport';

export interface ICreateTransportConfig {
  /** DNS root (e.g., 'com.nimbletec.richard.santomauro'). */
  readonly root?: string;
  /** @deprecated Use `root` instead. */
  readonly realm?: string;
  readonly logging?: boolean;
  readonly natsConnection: INatsLikeConnection;
  readonly natsCredentials?: {
    readonly user: string;
    readonly pass: string;
  };
}

export function createTransport(config: ICreateTransportConfig): ITransportAdapter {
  return new NatsTransport(config.natsConnection, {
    root: config.root ?? config.realm,
    credentials: config.natsCredentials,
  });
}
