| 1 | import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; |
| 2 | import { |
| 3 | Allow, |
| 4 | IsBoolean, |
| 5 | IsIn, |
| 6 | IsOptional, |
| 7 | IsString, |
| 8 | MaxLength, |
| 9 | MinLength, |
| 10 | } from 'class-validator'; |
| 11 | |
| 12 | /** GitHub's pull request list query; `popularity` and `long-running` sort as `created`. */ |
| 13 | export class GithubListPullsQueryDTO |
| 14 | @ApiPropertyOptional({ enum |
| 15 | @IsOptional() |
| 16 | @IsIn(['open' |
| 17 | state?: 'open |
| 18 | |
| 19 | @ApiPropertyOptional({ description |
| 20 | @IsOptional() |
| 21 | @IsString() |
| 22 | head?: string |
| 23 | |
| 24 | @ApiPropertyOptional() |
| 25 | @IsOptional() |
| 26 | @IsString() |
| 27 | base?: string |
| 28 | |
| 29 | @ApiPropertyOptional({ |
| 30 | enum: ['created', |
| 31 | default: 'created', |
| 32 | }) |
| 33 | @IsOptional() |
| 34 | @IsIn(['created' |
| 35 | sort?: 'created |
| 36 | |
| 37 | @ApiPropertyOptional({ enum |
| 38 | @IsOptional() |
| 39 | @IsIn(['asc' |
| 40 | direction?: 'asc |
| 41 | |
| 42 | @ApiPropertyOptional({ default |
| 43 | @Allow() |
| 44 | page?: string |
| 45 | |
| 46 | @ApiPropertyOptional({ default |
| 47 | @Allow() |
| 48 | per_page?: string |
| 49 | } |
| 50 | |
| 51 | /** GitHub's create-pull-request body. Opening a pull request from an existing issue (`issue`) is not supported, so it is dropped by the whitelist. */ |
| 52 | export class GithubCreatePullDTO |
| 53 | @ApiProperty() |
| 54 | @IsString() |
| 55 | @MinLength(1) |
| 56 | @MaxLength(200) |
| 57 | title: string; |
| 58 | |
| 59 | @ApiProperty({ description |
| 60 | @IsString() |
| 61 | head: string; |
| 62 | |
| 63 | @ApiPropertyOptional({ description |
| 64 | @IsOptional() |
| 65 | @IsString() |
| 66 | head_repo?: string |
| 67 | |
| 68 | @ApiProperty() |
| 69 | @IsString() |
| 70 | base: string; |
| 71 | |
| 72 | @ApiPropertyOptional() |
| 73 | @IsOptional() |
| 74 | @IsString() |
| 75 | @MaxLength(20000) |
| 76 | body?: string |
| 77 | |
| 78 | @ApiPropertyOptional() |
| 79 | @IsOptional() |
| 80 | @IsBoolean() |
| 81 | draft?: boolean |
| 82 | |
| 83 | @ApiPropertyOptional({ description |
| 84 | @IsOptional() |
| 85 | @IsBoolean() |
| 86 | maintainer_can_modify?: boolean |
| 87 | } |
| 88 | |
| 89 | export class GithubUpdatePullDTO |
| 90 | @ApiPropertyOptional() |
| 91 | @IsOptional() |
| 92 | @IsString() |
| 93 | @MinLength(1) |
| 94 | @MaxLength(200) |
| 95 | title?: string |
| 96 | |
| 97 | @ApiPropertyOptional() |
| 98 | @IsOptional() |
| 99 | @IsString() |
| 100 | @MaxLength(20000) |
| 101 | body?: string |
| 102 | |
| 103 | @ApiPropertyOptional({ enum |
| 104 | @IsOptional() |
| 105 | @IsIn(['open' |
| 106 | state?: 'open |
| 107 | |
| 108 | @ApiPropertyOptional({ |
| 109 | description: 'Only the current base: Ghost cannot retarget a request.', |
| 110 | }) |
| 111 | @IsOptional() |
| 112 | @IsString() |
| 113 | base?: string |
| 114 | |
| 115 | @ApiPropertyOptional({ description |
| 116 | @IsOptional() |
| 117 | @IsBoolean() |
| 118 | maintainer_can_modify?: boolean |
| 119 | } |
| 120 | |
| 121 | export class GithubMergePullDTO |
| 122 | @ApiPropertyOptional() |
| 123 | @IsOptional() |
| 124 | @IsString() |
| 125 | @MaxLength(200) |
| 126 | commit_title?: string |
| 127 | |
| 128 | @ApiPropertyOptional() |
| 129 | @IsOptional() |
| 130 | @IsString() |
| 131 | @MaxLength(65536) |
| 132 | commit_message?: string |
| 133 | |
| 134 | @ApiPropertyOptional({ |
| 135 | description: 'The head the merge must still be at.', |
| 136 | }) |
| 137 | @IsOptional() |
| 138 | @IsString() |
| 139 | sha?: string |
| 140 | |
| 141 | @ApiPropertyOptional({ |
| 142 | enum: ['merge', |
| 143 | default: 'merge', |
| 144 | }) |
| 145 | @IsOptional() |
| 146 | @IsIn(['merge' |
| 147 | merge_method?: 'merge |
| 148 | } |