| 1 | import { schema } from '@ghost/db'; |
| 2 | import { ApiProperty, ApiPropertyOptional |
| 3 | import { Type } |
| 4 | import { |
| 5 | IsBoolean, |
| 6 | IsIn, |
| 7 | IsInt, |
| 8 | IsOptional, |
| 9 | IsString, |
| 10 | MaxLength, |
| 11 | ValidateNested, |
| 12 | } from 'class-validator'; |
| 13 | |
| 14 | export class SuggestionQueryDTO |
| 15 | @ApiPropertyOptional({ |
| 16 | description: |
| 17 | 'What has been typed so far. Empty suggests the people or issues most likely meant.', |
| 18 | }) |
| 19 | @IsString() |
| 20 | @IsOptional() |
| 21 | @MaxLength(100) |
| 22 | q?: string |
| 23 | } |
| 24 | |
| 25 | export class SuggestedUserDTO |
| 26 | @ApiProperty() |
| 27 | @IsString() |
| 28 | username: string; |
| 29 | |
| 30 | @ApiProperty() |
| 31 | @IsString() |
| 32 | name: string; |
| 33 | |
| 34 | @ApiProperty({ type |
| 35 | @IsString() |
| 36 | @IsOptional() |
| 37 | image: string |
| 38 | } |
| 39 | |
| 40 | export class SuggestedUsersResponseDTO |
| 41 | @ApiProperty({ type |
| 42 | @ValidateNested({ each |
| 43 | @Type(() => |
| 44 | users: SuggestedUserDTO |
| 45 | } |
| 46 | |
| 47 | export class SuggestedIssueDTO |
| 48 | @ApiProperty() |
| 49 | @IsInt() |
| 50 | number: number; |
| 51 | |
| 52 | @ApiProperty() |
| 53 | @IsString() |
| 54 | title: string; |
| 55 | |
| 56 | @ApiProperty({ enumName |
| 57 | @IsIn(schema. |
| 58 | state: (typeof |
| 59 | |
| 60 | @ApiProperty() |
| 61 | @IsBoolean() |
| 62 | isPullRequest: boolean; |
| 63 | } |
| 64 | |
| 65 | export class SuggestedIssuesResponseDTO |
| 66 | @ApiProperty({ type |
| 67 | @ValidateNested({ each |
| 68 | @Type(() => |
| 69 | issues: SuggestedIssueDTO |
| 70 | } |