first commit
This commit is contained in:
79
apps/api-gateway/src/dto/rbac.dto.ts
Normal file
79
apps/api-gateway/src/dto/rbac.dto.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { IsArray, IsBoolean, IsEnum, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export enum GatewayOAuthClientType {
|
||||
CONFIDENTIAL = 'CONFIDENTIAL',
|
||||
PUBLIC = 'PUBLIC'
|
||||
}
|
||||
|
||||
export class CreateRoleDto {
|
||||
@ApiProperty({ description: 'Уникальный slug роли', example: 'support' })
|
||||
@IsString({ message: 'Slug роли должен быть строкой' })
|
||||
slug!: string;
|
||||
|
||||
@ApiProperty({ description: 'Название роли', example: 'Поддержка' })
|
||||
@IsString({ message: 'Название роли должно быть строкой' })
|
||||
name!: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Описание роли' })
|
||||
@IsOptional()
|
||||
@IsString({ message: 'Описание должно быть строкой' })
|
||||
description?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Список slug прав', type: [String] })
|
||||
@IsOptional()
|
||||
@IsArray({ message: 'Права должны быть массивом' })
|
||||
@IsString({ each: true, message: 'Каждое право должно быть строкой' })
|
||||
permissionSlugs?: string[];
|
||||
}
|
||||
|
||||
export class AssignUserRoleDto {
|
||||
@ApiProperty({ description: 'Slug роли', example: 'admin' })
|
||||
@IsString({ message: 'Slug роли должен быть строкой' })
|
||||
roleSlug!: string;
|
||||
}
|
||||
|
||||
export class CreateOAuthClientDto {
|
||||
@ApiProperty({ description: 'Название приложения', example: 'Lendry Docs' })
|
||||
@IsString({ message: 'Название должно быть строкой' })
|
||||
name!: string;
|
||||
|
||||
@ApiProperty({ description: 'Redirect URI', type: [String], example: ['https://app.example.com/oauth/callback'] })
|
||||
@IsArray({ message: 'Redirect URI должны быть массивом' })
|
||||
@IsString({ each: true, message: 'Каждый redirect URI должен быть строкой' })
|
||||
redirectUris!: string[];
|
||||
|
||||
@ApiProperty({ description: 'Scopes', type: [String], example: ['openid', 'profile', 'email'] })
|
||||
@IsArray({ message: 'Scopes должны быть массивом' })
|
||||
@IsString({ each: true, message: 'Каждый scope должен быть строкой' })
|
||||
scopes!: string[];
|
||||
|
||||
@ApiPropertyOptional({ description: 'Тип клиента', enum: GatewayOAuthClientType })
|
||||
@IsOptional()
|
||||
@IsEnum(GatewayOAuthClientType, { message: 'Укажите корректный тип клиента' })
|
||||
type?: GatewayOAuthClientType;
|
||||
}
|
||||
|
||||
export class UpdateOAuthClientDto {
|
||||
@ApiPropertyOptional({ description: 'Название приложения' })
|
||||
@IsOptional()
|
||||
@IsString({ message: 'Название должно быть строкой' })
|
||||
name?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Redirect URI', type: [String] })
|
||||
@IsOptional()
|
||||
@IsArray({ message: 'Redirect URI должны быть массивом' })
|
||||
@IsString({ each: true, message: 'Каждый redirect URI должен быть строкой' })
|
||||
redirectUris?: string[];
|
||||
|
||||
@ApiPropertyOptional({ description: 'Scopes', type: [String] })
|
||||
@IsOptional()
|
||||
@IsArray({ message: 'Scopes должны быть массивом' })
|
||||
@IsString({ each: true, message: 'Каждый scope должен быть строкой' })
|
||||
scopes?: string[];
|
||||
|
||||
@ApiPropertyOptional({ description: 'Активность приложения' })
|
||||
@IsOptional()
|
||||
@IsBoolean({ message: 'isActive должно быть boolean' })
|
||||
isActive?: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user