| 1 | import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; |
| 2 | import { Type } |
| 3 | import { |
| 4 | IsBoolean, |
| 5 | IsInt, |
| 6 | IsOptional, |
| 7 | IsString, |
| 8 | Max, |
| 9 | MaxLength, |
| 10 | Min, |
| 11 | } from 'class-validator'; |
| 12 | |
| 13 | import { RepositoryEntity } |
| 14 | |
| 15 | export class GetRepositoriesQueryDTO |
| 16 | @ApiPropertyOptional({ |
| 17 | description: |
| 18 | "Keep repositories whose name or description contains this text, ignoring case. `org:<name>` or `user:<name>` keeps one owner's repositories, where the listing spans several owners.", |
| 19 | example: 'ghost', |
| 20 | }) |
| 21 | @IsString() |
| 22 | @IsOptional() |
| 23 | @MaxLength(200) |
| 24 | q?: string |
| 25 | |
| 26 | @ApiPropertyOptional({ |
| 27 | description: |
| 28 | 'Opaque cursor returned as `nextCursor` by the previous page. Omit for the first page.', |
| 29 | }) |
| 30 | @IsString() |
| 31 | @IsOptional() |
| 32 | cursor?: string |
| 33 | |
| 34 | @ApiPropertyOptional({ |
| 35 | description: 'Page size.', |
| 36 | minimum: 1, |
| 37 | maximum: 100, |
| 38 | default: 20, |
| 39 | }) |
| 40 | @Type(() => |
| 41 | @IsInt() |
| 42 | @Min(1) |
| 43 | @Max(100) |
| 44 | @IsOptional() |
| 45 | limit?: number |
| 46 | } |
| 47 | |
| 48 | export class GetRepositoriesResponseDTO |
| 49 | @ApiProperty({ type |
| 50 | repositories: RepositoryEntity |
| 51 | |
| 52 | @ApiProperty({ |
| 53 | type: String, |
| 54 | nullable: true, |
| 55 | description: |
| 56 | 'Pass back as `cursor` for the next page. `null` on the last page.', |
| 57 | }) |
| 58 | @IsString() |
| 59 | @IsOptional() |
| 60 | nextCursor: string |
| 61 | |
| 62 | @ApiProperty() |
| 63 | @IsBoolean() |
| 64 | hasMore: boolean; |
| 65 | } |