| 1 | import { schema } from '@ghost/db'; |
| 2 | import { ApiProperty } |
| 3 | import { IsIn } |
| 4 | |
| 5 | type OauthAppAccessState |
| 6 | (typeof schema |
| 7 | |
| 8 | export class OauthAppAccessDTO |
| 9 | @ApiProperty() |
| 10 | clientId: string; |
| 11 | |
| 12 | @ApiProperty() |
| 13 | name: string; |
| 14 | |
| 15 | @ApiProperty({ type |
| 16 | logoUrl: string |
| 17 | |
| 18 | @ApiProperty({ type |
| 19 | description: string |
| 20 | |
| 21 | @ApiProperty() |
| 22 | homepageUrl: string; |
| 23 | |
| 24 | @ApiProperty({ |
| 25 | type: String, |
| 26 | nullable: true, |
| 27 | description: |
| 28 | 'The user or organization that registered it; null for an app built into Ghost.', |
| 29 | }) |
| 30 | owner: string |
| 31 | |
| 32 | @ApiProperty({ |
| 33 | type: [String], |
| 34 | description: |
| 35 | 'Every scope members of this organization granted the app, so admins see what approving it lets it do.', |
| 36 | }) |
| 37 | scopes: string[] |
| 38 | |
| 39 | @ApiProperty({ enum |
| 40 | state: OauthAppAccessState |
| 41 | |
| 42 | @ApiProperty({ |
| 43 | type: String, |
| 44 | nullable: true, |
| 45 | description: 'Who asked for the app; null when an admin decided first.', |
| 46 | }) |
| 47 | requestedBy: string |
| 48 | |
| 49 | @ApiProperty() |
| 50 | requestedAt: string; |
| 51 | |
| 52 | @ApiProperty({ type |
| 53 | decidedBy: string |
| 54 | |
| 55 | @ApiProperty({ type |
| 56 | decidedAt: string |
| 57 | } |
| 58 | |
| 59 | export class ListOauthAppAccessResponseDTO |
| 60 | @ApiProperty({ |
| 61 | description: |
| 62 | 'Whether the organization restricts OAuth apps at all; the answers below matter only while it does.', |
| 63 | }) |
| 64 | restricted: boolean; |
| 65 | |
| 66 | @ApiProperty({ |
| 67 | type: [OauthAppAccessDTO], |
| 68 | description: 'Newest request first.', |
| 69 | }) |
| 70 | apps: OauthAppAccessDTO |
| 71 | } |
| 72 | |
| 73 | export class DecideOauthAppAccessDTO |
| 74 | @ApiProperty({ enum |
| 75 | @IsIn(['approved' |
| 76 | state: 'approved |
| 77 | } |
| 78 | |
| 79 | export class OauthAppOrganizationAccessDTO |
| 80 | @ApiProperty() |
| 81 | slug: string; |
| 82 | |
| 83 | @ApiProperty() |
| 84 | name: string; |
| 85 | |
| 86 | @ApiProperty() |
| 87 | restricted: boolean; |
| 88 | |
| 89 | @ApiProperty({ |
| 90 | description: |
| 91 | "Whether the app's keys reach the organization's repositories now.", |
| 92 | }) |
| 93 | allowed: boolean; |
| 94 | |
| 95 | @ApiProperty({ |
| 96 | enum: schema.organizationOauthAppState |
| 97 | nullable: true, |
| 98 | description: 'Null when nobody has asked for the app yet.', |
| 99 | }) |
| 100 | state: OauthAppAccessState |
| 101 | } |
| 102 | |
| 103 | export class ListOauthAppOrganizationAccessResponseDTO |
| 104 | @ApiProperty({ type |
| 105 | organizations: OauthAppOrganizationAccessDTO |
| 106 | } |