import { BaseApiClient } from '../base/BaseApiClient';
import type { ErrorReporter } from '../../interfaces/ErrorReporter';
import type { Logger } from '../../interfaces/Logger';

export type OperationalMode = 'normal' | 'maintenance' | 'test';
export type FeatureState = 'enabled' | 'disabled' | 'coming_soon' | 'hidden';

export type PolicySnapshotDto = {
  policyVersion: number;
  operationalMode: OperationalMode;
  maintenanceAllowlist: {
    view: string[];
    mutate: string[];
  };
  capabilities: Record<string, FeatureState>;
  loadedFrom: 'env' | 'file' | 'defaults';
  loadedAtIso: string;
};

export class PolicyApiClient extends BaseApiClient {
  constructor(baseUrl: string, errorReporter: ErrorReporter, logger: Logger) {
    super(baseUrl, errorReporter, logger);
  }

  getSnapshot(): Promise<PolicySnapshotDto> {
    return this.get<PolicySnapshotDto>('/policy/snapshot');
  }
}