mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
42 lines
1 KiB
TypeScript
42 lines
1 KiB
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
import { ArrayMinSize, IsEnum, IsNotEmpty, IsString } from 'class-validator';
|
|
import { Permission } from 'src/enum';
|
|
import { Optional } from 'src/validation';
|
|
export class APIKeyCreateDto {
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
@Optional()
|
|
name?: string;
|
|
|
|
@IsEnum(Permission, { each: true })
|
|
@ApiProperty({ enum: Permission, enumName: 'Permission', isArray: true })
|
|
@ArrayMinSize(1)
|
|
permissions!: Permission[];
|
|
}
|
|
|
|
export class APIKeyUpdateDto {
|
|
@Optional()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
name?: string;
|
|
|
|
@Optional()
|
|
@IsEnum(Permission, { each: true })
|
|
@ApiProperty({ enum: Permission, enumName: 'Permission', isArray: true })
|
|
@ArrayMinSize(1)
|
|
permissions?: Permission[];
|
|
}
|
|
|
|
export class APIKeyCreateResponseDto {
|
|
secret!: string;
|
|
apiKey!: APIKeyResponseDto;
|
|
}
|
|
|
|
export class APIKeyResponseDto {
|
|
id!: string;
|
|
name!: string;
|
|
createdAt!: Date;
|
|
updatedAt!: Date;
|
|
@ApiProperty({ enum: Permission, enumName: 'Permission', isArray: true })
|
|
permissions!: Permission[];
|
|
}
|