/**
 * Performance 模块 — 契约校验专属配置
 *
 * 包含已知的字段名差异白名单和前后端类型映射表。
 * 新模块不需要此文件，脚本会以空配置运行。
 */

export interface KnownFieldDiff {
  endpoint: string;
  feFields: string[];
  beFields: string[];
  status: 'match' | 'warning' | 'mismatch' | 'info';
  note: string;
}

/** 已知的前后端字段名差异（已确认兼容，作为白名单） */
export const knownFieldDiffs: KnownFieldDiff[] = [
  {
    endpoint: 'POST /360/evaluations',
    feFields: ['evaluateeId'],
    beFields: ['targetId', 'evaluateeId'],
    status: 'info',
    note: '前端用 evaluateeId，后端内部用 targetId，Controller 做了兼容映射 (dto.targetId || dto.evaluateeId)',
  },
  {
    endpoint: 'POST /calibration/sessions/:id/adjust-grade',
    feFields: ['participantId', 'newGrade', 'reason'],
    beFields: ['assessmentId', 'newGradeCode', 'reason'],
    status: 'info',
    note: '前端用 participantId/newGrade，后端用 assessmentId/newGradeCode，Controller 做了兼容映射',
  },
  {
    endpoint: 'POST /calibration/sessions',
    feFields: ['departmentIds'],
    beFields: ['departmentId'],
    status: 'info',
    note: '前端用 departmentIds (数组)，后端用 departmentId (单个)，Controller 取 departmentIds[0]',
  },
  {
    endpoint: 'POST /360/evaluations/:id/evaluators',
    feFields: ['evaluators[].relationship'],
    beFields: ['evaluators[].relationType'],
    status: 'info',
    note: '前端用 relationship，后端用 relationType，Controller 做了 relationship -> relationType 映射',
  },
  {
    endpoint: 'POST /kpi/assessments/:id/self-evaluate',
    feFields: ['selfScore', 'selfComment'],
    beFields: ['score', 'selfScore', 'comment', 'selfComment', 'completionNote'],
    status: 'info',
    note: 'DTO 同时接受 score/selfScore 和 comment/selfComment 两种字段名（已兼容）',
  },
  {
    endpoint: 'POST /kpi/assessments/:id/manager-evaluate',
    feFields: ['managerScore', 'managerComment'],
    beFields: ['score', 'managerScore', 'comment', 'managerComment', 'proposedGradeCode'],
    status: 'info',
    note: 'DTO 同时接受 score/managerScore 和 comment/managerComment 两种字段名（已兼容）',
  },
  {
    endpoint: 'POST /interviews (create)',
    feFields: ['cycleId', 'employeeId', 'scheduledAt', 'type', 'topics', 'location'],
    beFields: ['cycleId', 'employeeId', 'type', 'scheduledAt', 'duration', 'topics'],
    status: 'info',
    note: '前端发 location 但后端 CreateInterviewDto 无 location 字段；前端未发 duration 但后端支持',
  },
  {
    endpoint: 'PATCH /interviews/:id (update)',
    feFields: ['scheduledAt', 'location', 'duration', 'topics'],
    beFields: ['scheduledAt', 'duration', 'topics'],
    status: 'info',
    note: '前端 UpdateInterviewParams 有 location 字段，但后端 UpdateInterviewDto 无 location',
  },
  {
    endpoint: 'POST /interviews/:id/reschedule',
    feFields: ['scheduledAt'],
    beFields: ['scheduledAt', 'reason'],
    status: 'info',
    note: '前端仅发 scheduledAt，后端 DTO 还支持 reason 字段（可选）',
  },
];

/** 前端 interface ↔ 后端 DTO 的已知对应关系（用于类型映射表输出） */
export const typePairs: Array<[string, string]> = [
  ['CreateCycleParams', 'CreateCycleDto'],
  ['UpdateCycleParams', 'UpdateCycleDto'],
  ['QueryCycleParams', 'QueryCycleDto'],
  ['CreateGradeConfigParams', 'CreateGradeConfigDto'],
  ['CreateKpiIndicatorParams', 'CreateIndicatorDto'],
  ['QueryKpiIndicatorParams', 'QueryIndicatorDto'],
  ['QueryKpiAssignmentParams', 'QueryAssignmentDto'],
  ['AssignKpiParams', 'CreateAssignmentDto'],
  ['SelfEvaluateParams', 'SelfEvaluateDto'],
  ['ManagerEvaluateParams', 'ManagerEvaluateDto'],
  ['UpdateQuarterTargetsParams', 'UpdateQuarterTargetsDto'],
  ['CreateEvaluation360Params', 'CreateEvaluation360Dto'],
  ['QueryEvaluation360Params', 'QueryEvaluation360Dto'],
  ['SubmitFeedbackParams', 'SubmitFeedbackDto'],
  ['AddEvaluatorsParams', 'AddEvaluatorsDto'],
  ['CreateCalibrationSessionParams', 'CreateCalibrationSessionDto'],
  ['QueryCalibrationParams', 'QueryCalibrationSessionDto'],
  ['AdjustGradeParams', 'CalibrationAdjustGradeDto'],
  ['CreateInterviewParams', 'CreateInterviewDto'],
  ['UpdateInterviewParams', 'UpdateInterviewDto'],
  ['QueryInterviewParams', 'QueryInterviewDto'],
  ['CompleteInterviewParams', 'CompleteInterviewDto'],
  ['QueryResultParams', 'QueryResultDto'],
  ['CalculateResultsPayload', 'CalculateResultsDto'],
  ['PublishResultsPayload', 'PublishResultsDto'],
  ['ExportResultsPayload', 'ExportResultsDto'],
  ['CreateFeedbackParams', 'CreateFeedbackDto'],
  ['QueryFeedbackParams', 'QueryFeedbackDto'],
  ['CreateStrategicObjectiveParams', 'CreateStrategicObjectiveDto'],
  ['UpdateStrategicObjectiveParams', 'UpdateStrategicObjectiveDto'],
  ['QueryStrategicObjectiveParams', 'QueryStrategicObjectiveDto'],
];
