import { Injectable } from '@nestjs/common';
import { MonitorLogEventEntity } from './monitor-log-event.entity';

type FetchLogsInput = {
  serviceKey: string;
  nodeKey?: string;
  limit?: number;
};

@Injectable()
export class OpenObserveLogAdapter {
  readonly mode: 'configured' | 'fallback';

  constructor() {
    this.mode = process.env.OPENOBSERVE_BASE_URL?.trim()
      ? 'configured'
      : 'fallback';
  }

  async fetchRecentLogs(
    input: FetchLogsInput,
    fallback: () => Promise<MonitorLogEventEntity[]>,
  ) {
    // Phase 1 keeps the real integration boundary here.
    // If OpenObserve is not wired yet, we fall back to the local log store
    // so the analysis layer remains demonstrable.
    void input;
    return fallback();
  }
}
