| 1 | import { schema } from '@ghost/db'; |
| 2 | import { type Role, |
| 3 | import { ApiProperty, ApiPropertyOptional |
| 4 | import { |
| 5 | IsBoolean, |
| 6 | IsISO8601, |
| 7 | IsInt, |
| 8 | IsOptional, |
| 9 | IsString, |
| 10 | } from 'class-validator'; |
| 11 | |
| 12 | export class RepositoryParentEntity |
| 13 | @ApiProperty() |
| 14 | @IsString() |
| 15 | username: string; |
| 16 | |
| 17 | @ApiProperty() |
| 18 | @IsString() |
| 19 | slug: string; |
| 20 | |
| 21 | @ApiProperty() |
| 22 | @IsString() |
| 23 | name: string; |
| 24 | } |
| 25 | |
| 26 | export class RepositoryEntity |
| 27 | @ApiProperty() |
| 28 | @IsString() |
| 29 | id: string; |
| 30 | |
| 31 | @ApiProperty() |
| 32 | @IsString() |
| 33 | name: string; |
| 34 | |
| 35 | @ApiPropertyOptional() |
| 36 | @IsString() |
| 37 | @IsOptional() |
| 38 | description?: string |
| 39 | |
| 40 | @ApiProperty() |
| 41 | @IsString() |
| 42 | slug: string; |
| 43 | |
| 44 | @ApiProperty({ |
| 45 | description: |
| 46 | 'The owner it lives under now; differs from the requested one after a rename or transfer.', |
| 47 | }) |
| 48 | @IsString() |
| 49 | owner: string; |
| 50 | |
| 51 | @ApiProperty({ |
| 52 | enumName: 'RepositoryVisibility', |
| 53 | enum: schema.repositoryVisiblity |
| 54 | }) |
| 55 | @IsString() |
| 56 | visibility: (typeof |
| 57 | |
| 58 | @ApiProperty() |
| 59 | @IsISO8601() |
| 60 | lastPushedAt: string; |
| 61 | |
| 62 | @ApiProperty() |
| 63 | @IsISO8601() |
| 64 | createdAt: string; |
| 65 | |
| 66 | @ApiProperty() |
| 67 | @IsISO8601() |
| 68 | updatedAt: string; |
| 69 | |
| 70 | @ApiProperty() |
| 71 | @IsInt() |
| 72 | starCount: number; |
| 73 | |
| 74 | @ApiProperty() |
| 75 | @IsBoolean() |
| 76 | viewerHasStarred: boolean; |
| 77 | |
| 78 | @ApiProperty() |
| 79 | @IsInt() |
| 80 | forkCount: number; |
| 81 | |
| 82 | @ApiPropertyOptional({ |
| 83 | type: String, |
| 84 | nullable: true, |
| 85 | description: "Slug of the viewer's own fork of this repository, if any", |
| 86 | }) |
| 87 | @IsString() |
| 88 | @IsOptional() |
| 89 | viewerForkSlug: string |
| 90 | |
| 91 | @ApiProperty({ |
| 92 | enumName: 'ViewerRole', |
| 93 | enum: roleHierarchy, |
| 94 | nullable: true, |
| 95 | description: |
| 96 | "The viewer's role here: `owner`, a collaborator role, or null for anyone else.", |
| 97 | }) |
| 98 | @IsString() |
| 99 | @IsOptional() |
| 100 | viewerRole: Role |
| 101 | |
| 102 | @ApiPropertyOptional({ |
| 103 | type: RepositoryParentEntity, |
| 104 | nullable: true, |
| 105 | description: 'The repository this one was forked from', |
| 106 | }) |
| 107 | @IsOptional() |
| 108 | parent: RepositoryParentEntity |
| 109 | } |