import * as plugins from '../../plugins.js';
import { DcRouterDb } from '../classes.dcrouter-db.js';
import type { IRemoteIngressPerformanceConfig } from '../../../ts_interfaces/data/remoteingress.js';

const getDb = () => DcRouterDb.getInstance().getDb();

@plugins.smartdata.Collection(() => getDb())
export class RemoteIngressHubSettingsDoc extends plugins.smartdata.SmartDataDbDoc<RemoteIngressHubSettingsDoc, RemoteIngressHubSettingsDoc> {
  @plugins.smartdata.unI()
  @plugins.smartdata.svDb()
  public settingsId: string = 'remote-ingress-hub-settings';

  @plugins.smartdata.svDb()
  public enabled?: boolean;

  @plugins.smartdata.svDb()
  public tunnelPort?: number;

  @plugins.smartdata.svDb()
  public hubDomain?: string;

  @plugins.smartdata.svDb()
  public performance?: IRemoteIngressPerformanceConfig;

  @plugins.smartdata.svDb()
  public updatedAt: number = 0;

  @plugins.smartdata.svDb()
  public updatedBy: string = '';

  constructor() {
    super();
  }

  public static async load(): Promise<RemoteIngressHubSettingsDoc | null> {
    return await RemoteIngressHubSettingsDoc.getInstance({ settingsId: 'remote-ingress-hub-settings' });
  }
}
