import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsOptional, IsString } from 'class-validator';

export class OAuthAuthorizeIncomingDto {
  @ApiPropertyOptional({ description: 'ID пользователя (legacy camelCase)' })
  @IsOptional()
  @IsString()
  userId?: string;

  @ApiPropertyOptional({ description: 'ID пользователя (OIDC legacy alias)' })
  @IsOptional()
  @IsString()
  user_id?: string;

  @ApiPropertyOptional({ description: 'OAuth client_id (legacy camelCase)' })
  @IsOptional()
  @IsString()
  clientId?: string;

  @ApiPropertyOptional({ description: 'OAuth client_id (RFC 6749)' })
  @IsOptional()
  @IsString()
  client_id?: string;

  @ApiPropertyOptional({ description: 'redirect_uri (legacy camelCase)' })
  @IsOptional()
  @IsString()
  redirectUri?: string;

  @ApiPropertyOptional({ description: 'redirect_uri (RFC 6749)' })
  @IsOptional()
  @IsString()
  redirect_uri?: string;

  @ApiPropertyOptional({ description: 'Scopes через пробел', example: 'openid profile email' })
  @IsOptional()
  @IsString()
  scope?: string;

  @ApiPropertyOptional({ description: 'OAuth state' })
  @IsOptional()
  @IsString()
  state?: string;

  @ApiPropertyOptional({ description: 'OAuth response_type', example: 'code' })
  @IsOptional()
  @IsString()
  response_type?: string;

  @ApiPropertyOptional({ description: 'Legacy camelCase alias response_type' })
  @IsOptional()
  @IsString()
  responseType?: string;

  @ApiPropertyOptional({ description: 'PKCE code_challenge' })
  @IsOptional()
  @IsString()
  code_challenge?: string;

  @ApiPropertyOptional({ description: 'Legacy camelCase alias code_challenge' })
  @IsOptional()
  @IsString()
  codeChallenge?: string;

  @ApiPropertyOptional({ description: 'PKCE code_challenge_method', example: 'S256' })
  @IsOptional()
  @IsString()
  code_challenge_method?: string;

  @ApiPropertyOptional({ description: 'Legacy camelCase alias code_challenge_method' })
  @IsOptional()
  @IsString()
  codeChallengeMethod?: string;

  @ApiPropertyOptional({ description: 'OpenID Connect nonce' })
  @IsOptional()
  @IsString()
  nonce?: string;
}

export class OAuthTokenIncomingDto {
  @IsOptional()
  @IsString()
  grantType?: string;

  @IsOptional()
  @IsString()
  grant_type?: string;

  @IsOptional()
  @IsString()
  code?: string;

  @IsOptional()
  @IsString()
  refreshToken?: string;

  @IsOptional()
  @IsString()
  refresh_token?: string;

  @IsOptional()
  @IsString()
  clientId?: string;

  @IsOptional()
  @IsString()
  client_id?: string;

  @IsOptional()
  @IsString()
  clientSecret?: string;

  @IsOptional()
  @IsString()
  client_secret?: string;

  @IsOptional()
  @IsString()
  redirectUri?: string;

  @IsOptional()
  @IsString()
  redirect_uri?: string;

  @IsOptional()
  @IsString()
  codeVerifier?: string;

  @IsOptional()
  @IsString()
  code_verifier?: string;
}

export class OAuthConsentActionDto {
  @ApiPropertyOptional({ description: 'OAuth client_id (RFC 6749)' })
  @IsOptional()
  @IsString()
  clientId?: string;

  @ApiPropertyOptional({ description: 'OAuth client_id (legacy camelCase)' })
  @IsOptional()
  @IsString()
  client_id?: string;

  @ApiPropertyOptional({ description: 'Scopes через пробел', example: 'openid profile email' })
  @IsOptional()
  @IsString()
  scope?: string;

  @ApiPropertyOptional({ description: 'redirect_uri (RFC 6749)' })
  @IsOptional()
  @IsString()
  redirectUri?: string;

  @ApiPropertyOptional({ description: 'redirect_uri (legacy camelCase)' })
  @IsOptional()
  @IsString()
  redirect_uri?: string;

  @ApiPropertyOptional({ description: 'OAuth state' })
  @IsOptional()
  @IsString()
  state?: string;

  @ApiPropertyOptional({ description: 'OpenID Connect nonce' })
  @IsOptional()
  @IsString()
  nonce?: string;
}
