import { SimpleLocalClient } from '../../core/index.js';
import type { IIronOsConfig, IIronOsSnapshot } from './iron_os.types.js';
import { ironOsProfile } from './iron_os.types.js';

export class IronOsClient extends SimpleLocalClient<IIronOsConfig> {
  constructor(private readonly configArg: IIronOsConfig) {
    super(ironOsProfile, configArg);
  }

  public async getSnapshot(forceRefreshArg = false): Promise<IIronOsSnapshot> {
    return new SimpleLocalClient<IIronOsConfig>(ironOsProfile, safeSnapshotConfig(this.configArg)).getSnapshot(forceRefreshArg) as Promise<IIronOsSnapshot>;
  }
}

const safeSnapshotConfig = (configArg: IIronOsConfig): IIronOsConfig => {
  const { host, port, path, transport, tcpCommand, useTls, url, ...safeConfig } = configArg;
  void host;
  void port;
  void path;
  void transport;
  void tcpCommand;
  void useTls;
  void url;
  return safeConfig;
};
