64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { IsDateString, IsNotEmpty, IsOptional, IsString, MaxLength } from 'class-validator';
|
|
|
|
export class CreateApiKeyDto {
|
|
@ApiProperty({
|
|
description: 'Nom de la clé API (pour identification)',
|
|
example: 'Intégration ERP Production',
|
|
maxLength: 100,
|
|
})
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
@MaxLength(100)
|
|
name: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: "Date d'expiration de la clé (ISO 8601). Si absent, la clé n'expire pas.",
|
|
example: '2027-01-01T00:00:00.000Z',
|
|
})
|
|
@IsOptional()
|
|
@IsDateString()
|
|
expiresAt?: string;
|
|
}
|
|
|
|
export class ApiKeyDto {
|
|
@ApiProperty({ description: 'Identifiant unique de la clé', example: 'uuid-here' })
|
|
id: string;
|
|
|
|
@ApiProperty({ description: 'Nom de la clé', example: 'Intégration ERP Production' })
|
|
name: string;
|
|
|
|
@ApiProperty({
|
|
description: 'Préfixe de la clé (pour identification visuelle)',
|
|
example: 'xped_live_a1b2c3d4',
|
|
})
|
|
keyPrefix: string;
|
|
|
|
@ApiProperty({ description: 'La clé est-elle active', example: true })
|
|
isActive: boolean;
|
|
|
|
@ApiPropertyOptional({
|
|
description: 'Dernière utilisation de la clé',
|
|
example: '2025-03-20T14:30:00.000Z',
|
|
})
|
|
lastUsedAt: Date | null;
|
|
|
|
@ApiPropertyOptional({
|
|
description: "Date d'expiration",
|
|
example: '2027-01-01T00:00:00.000Z',
|
|
})
|
|
expiresAt: Date | null;
|
|
|
|
@ApiProperty({ description: 'Date de création', example: '2025-03-26T10:00:00.000Z' })
|
|
createdAt: Date;
|
|
}
|
|
|
|
export class CreateApiKeyResultDto extends ApiKeyDto {
|
|
@ApiProperty({
|
|
description:
|
|
'Clé API complète — affichée UNE SEULE FOIS. Conservez-la en lieu sûr, elle ne sera plus visible.',
|
|
example: 'xped_live_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2',
|
|
})
|
|
fullKey: string;
|
|
}
|