import type * as shxInterfaces from '@smarthome.exchange/interfaces';
import { SimpleLocalMapper, type IIntegrationEntity, type ISimpleLocalSnapshot, type ISimpleLocalSnapshotOptions } from '../../core/index.js';
import type { IInfluxdbConfig, TInfluxdbRawData } from './influxdb.types.js';
import { influxdbProfile } from './influxdb.types.js';

export class InfluxdbMapper {
  public static toSnapshot(optionsArg: Omit<ISimpleLocalSnapshotOptions<IInfluxdbConfig>, 'profile'>): ISimpleLocalSnapshot {
    return SimpleLocalMapper.toSnapshot({ ...optionsArg, profile: influxdbProfile });
  }

  public static toSnapshotFromRaw(configArg: IInfluxdbConfig, rawDataArg: TInfluxdbRawData): ISimpleLocalSnapshot {
    return SimpleLocalMapper.toSnapshot({ profile: influxdbProfile, config: configArg, rawData: rawDataArg, online: true, source: 'manual' });
  }

  public static toDevices(snapshotArg: ISimpleLocalSnapshot): shxInterfaces.data.IDeviceDefinition[] {
    return SimpleLocalMapper.toDevices(influxdbProfile, snapshotArg);
  }

  public static toEntities(snapshotArg: ISimpleLocalSnapshot): IIntegrationEntity[] {
    return SimpleLocalMapper.toEntities(influxdbProfile, snapshotArg);
  }

  public static slug(valueArg: unknown): string {
    return SimpleLocalMapper.slug(valueArg);
  }
}
