integrations.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. import Alert from 'sentry/components/alert';
  2. import {PlatformKey} from 'sentry/data/platformCategories';
  3. import {
  4. DISABLED as DISABLED_STATUS,
  5. INSTALLED,
  6. NOT_INSTALLED,
  7. PENDING,
  8. } from 'sentry/views/organizationIntegrations/constants';
  9. import {Field} from 'sentry/views/settings/components/forms/type';
  10. import {Avatar, Choices, ObjectStatus, Scope} from './core';
  11. import {BaseRelease} from './release';
  12. import {User} from './user';
  13. export type PermissionValue = 'no-access' | 'read' | 'write' | 'admin';
  14. export type Permissions = {
  15. Event: PermissionValue;
  16. Member: PermissionValue;
  17. Organization: PermissionValue;
  18. Project: PermissionValue;
  19. Release: PermissionValue;
  20. Team: PermissionValue;
  21. };
  22. export type ExternalActorMapping = {
  23. id: string;
  24. externalName: string;
  25. userId?: string;
  26. teamId?: string;
  27. sentryName: string;
  28. };
  29. export type ExternalActorSuggestion = {
  30. externalName: string;
  31. userId?: string;
  32. teamId?: string;
  33. };
  34. export type ExternalActorMappingOrSuggestion =
  35. | ExternalActorMapping
  36. | ExternalActorSuggestion;
  37. export type ExternalUser = {
  38. id: string;
  39. memberId: string;
  40. externalName: string;
  41. provider: string;
  42. integrationId: string;
  43. };
  44. export type ExternalTeam = {
  45. id: string;
  46. teamId: string;
  47. externalName: string;
  48. provider: string;
  49. integrationId: string;
  50. };
  51. /**
  52. * Repositories, pull requests, and commits
  53. */
  54. export enum RepositoryStatus {
  55. ACTIVE = 'active',
  56. DISABLED = 'disabled',
  57. HIDDEN = 'hidden',
  58. PENDING_DELETION = 'pending_deletion',
  59. DELETION_IN_PROGRESS = 'deletion_in_progress',
  60. }
  61. export type Repository = {
  62. dateCreated: string;
  63. externalSlug: string;
  64. id: string;
  65. integrationId: string;
  66. name: string;
  67. provider: {id: string; name: string};
  68. status: RepositoryStatus;
  69. url: string;
  70. };
  71. export type Commit = {
  72. id: string;
  73. message: string | null;
  74. dateCreated: string;
  75. releases: BaseRelease[];
  76. repository?: Repository;
  77. author?: User;
  78. };
  79. export type Committer = {
  80. author: User;
  81. commits: Commit[];
  82. };
  83. export type CommitAuthor = {
  84. email?: string;
  85. name?: string;
  86. };
  87. export type CommitFile = {
  88. id: string;
  89. author: CommitAuthor;
  90. commitMessage: string;
  91. filename: string;
  92. orgId: number;
  93. repoName: string;
  94. type: string;
  95. };
  96. export type PullRequest = {
  97. id: string;
  98. title: string;
  99. externalUrl: string;
  100. repository: Repository;
  101. };
  102. /**
  103. * Sentry Apps
  104. */
  105. export type SentryAppStatus = 'unpublished' | 'published' | 'internal';
  106. export type SentryAppSchemaIssueLink = {
  107. type: 'issue-link';
  108. create: {
  109. uri: string;
  110. required_fields: any[];
  111. optional_fields?: any[];
  112. };
  113. link: {
  114. uri: string;
  115. required_fields: any[];
  116. optional_fields?: any[];
  117. };
  118. };
  119. export type SentryAppSchemaStacktraceLink = {
  120. type: 'stacktrace-link';
  121. uri: string;
  122. url: string;
  123. params?: Array<string>;
  124. };
  125. export type SentryAppSchemaElement =
  126. | SentryAppSchemaIssueLink
  127. | SentryAppSchemaStacktraceLink;
  128. export type SentryApp = {
  129. status: SentryAppStatus;
  130. scopes: Scope[];
  131. isAlertable: boolean;
  132. verifyInstall: boolean;
  133. slug: string;
  134. name: string;
  135. uuid: string;
  136. author: string;
  137. events: WebhookEvent[];
  138. schema: {
  139. elements?: SentryAppSchemaElement[];
  140. };
  141. // possible null params
  142. popularity: number | null;
  143. webhookUrl: string | null;
  144. redirectUrl: string | null;
  145. overview: string | null;
  146. // optional params below
  147. datePublished?: string;
  148. clientId?: string;
  149. clientSecret?: string;
  150. owner?: {
  151. id: number;
  152. slug: string;
  153. };
  154. featureData: IntegrationFeature[];
  155. avatars?: Avatar[];
  156. };
  157. // Minimal Sentry App representation for use with avatars
  158. export type AvatarSentryApp = {
  159. name: string;
  160. slug: string;
  161. uuid: string;
  162. avatars?: Avatar[];
  163. };
  164. export type SentryAppInstallation = {
  165. app: {
  166. uuid: string;
  167. slug: string;
  168. };
  169. organization: {
  170. slug: string;
  171. };
  172. uuid: string;
  173. status: 'installed' | 'pending';
  174. code?: string;
  175. };
  176. export type SentryAppComponent = {
  177. uuid: string;
  178. type: 'issue-link' | 'alert-rule-action' | 'issue-media' | 'stacktrace-link';
  179. schema: SentryAppSchemaStacktraceLink;
  180. sentryApp: {
  181. uuid: string;
  182. slug: string;
  183. name: string;
  184. avatars: Avatar[];
  185. };
  186. };
  187. export type SentryAppWebhookRequest = {
  188. webhookUrl: string;
  189. sentryAppSlug: string;
  190. eventType: string;
  191. date: string;
  192. organization?: {
  193. slug: string;
  194. name: string;
  195. };
  196. responseCode: number;
  197. errorUrl?: string;
  198. };
  199. /**
  200. * Organization Integrations
  201. */
  202. export type IntegrationType = 'document' | 'plugin' | 'first_party' | 'sentry_app';
  203. export type IntegrationFeature = {
  204. description: string;
  205. featureGate: string;
  206. featureId: number;
  207. };
  208. export type IntegrationInstallationStatus =
  209. | typeof INSTALLED
  210. | typeof NOT_INSTALLED
  211. | typeof PENDING
  212. | typeof DISABLED_STATUS;
  213. type IntegrationDialog = {
  214. actionText: string;
  215. body: string;
  216. };
  217. export type DocIntegration = {
  218. name: string;
  219. slug: string;
  220. author: string;
  221. url: string;
  222. popularity: number;
  223. description: string;
  224. isDraft: boolean;
  225. avatar?: Avatar;
  226. features?: IntegrationFeature[];
  227. resources?: Array<{title: string; url: string}>;
  228. };
  229. type IntegrationAspects = {
  230. alerts?: Array<React.ComponentProps<typeof Alert> & {text: string}>;
  231. disable_dialog?: IntegrationDialog;
  232. removal_dialog?: IntegrationDialog;
  233. externalInstall?: {
  234. url: string;
  235. buttonText: string;
  236. noticeText: string;
  237. };
  238. configure_integration?: {
  239. title: string;
  240. };
  241. };
  242. type BaseIntegrationProvider = {
  243. key: string;
  244. slug: string;
  245. name: string;
  246. canAdd: boolean;
  247. canDisable: boolean;
  248. features: string[];
  249. };
  250. export type IntegrationProvider = BaseIntegrationProvider & {
  251. setupDialog: {url: string; width: number; height: number};
  252. metadata: {
  253. description: string;
  254. features: IntegrationFeature[];
  255. author: string;
  256. noun: string;
  257. issue_url: string;
  258. source_url: string;
  259. aspects: IntegrationAspects;
  260. };
  261. };
  262. type OrganizationIntegrationProvider = BaseIntegrationProvider & {
  263. aspects: IntegrationAspects;
  264. };
  265. export type Integration = {
  266. id: string;
  267. name: string;
  268. icon: string;
  269. domainName: string;
  270. accountType: string;
  271. scopes?: string[];
  272. status: ObjectStatus;
  273. organizationIntegrationStatus: ObjectStatus;
  274. gracePeriodEnd: string;
  275. provider: OrganizationIntegrationProvider;
  276. dynamicDisplayInformation?: {
  277. configure_integration?: {
  278. instructions: string[];
  279. };
  280. integration_detail?: {
  281. uninstallationUrl?: string;
  282. };
  283. };
  284. };
  285. type ConfigData = {
  286. installationType?: string;
  287. };
  288. export type OrganizationIntegration = {
  289. id: string;
  290. name: string;
  291. status: ObjectStatus;
  292. organizationIntegrationStatus: ObjectStatus;
  293. gracePeriodEnd: string;
  294. provider: OrganizationIntegrationProvider;
  295. configOrganization: Field[];
  296. configData: ConfigData | null;
  297. organizationId: string;
  298. externalId: string;
  299. icon: string | null;
  300. domainName: string | null;
  301. accountType: string | null;
  302. };
  303. // we include the configOrganization when we need it
  304. export type IntegrationWithConfig = Integration & {
  305. configOrganization: Field[];
  306. configData: ConfigData;
  307. };
  308. /**
  309. * Integration & External issue links
  310. */
  311. export type IntegrationExternalIssue = {
  312. id: string;
  313. key: string;
  314. url: string;
  315. title: string;
  316. description: string;
  317. displayName: string;
  318. };
  319. export type GroupIntegration = Integration & {
  320. externalIssues: IntegrationExternalIssue[];
  321. };
  322. export type PlatformExternalIssue = {
  323. id: string;
  324. issueId: string;
  325. serviceType: string;
  326. displayName: string;
  327. webUrl: string;
  328. };
  329. /**
  330. * The issue config form fields we get are basically the form fields we use in
  331. * the UI but with some extra information. Some fields marked optional in the
  332. * form field are guaranteed to exist so we can mark them as required here
  333. */
  334. export type IssueConfigField = Field & {
  335. name: string;
  336. default?: string | number;
  337. choices?: Choices;
  338. url?: string;
  339. multiple?: boolean;
  340. };
  341. export type IntegrationIssueConfig = {
  342. status: ObjectStatus;
  343. name: string;
  344. domainName: string;
  345. linkIssueConfig?: IssueConfigField[];
  346. createIssueConfig?: IssueConfigField[];
  347. provider: IntegrationProvider;
  348. icon: string[];
  349. };
  350. /**
  351. * Project Plugins
  352. */
  353. export type PluginNoProject = {
  354. id: string;
  355. name: string;
  356. slug: string;
  357. shortName: string;
  358. type: string;
  359. canDisable: boolean;
  360. isTestable: boolean;
  361. hasConfiguration: boolean;
  362. metadata: any; // TODO(ts)
  363. contexts: any[]; // TODO(ts)
  364. status: string;
  365. assets: Array<{url: string}>;
  366. doc: string;
  367. features: string[];
  368. featureDescriptions: IntegrationFeature[];
  369. isHidden: boolean;
  370. isDeprecated: boolean;
  371. version?: string;
  372. author?: {name: string; url: string};
  373. description?: string;
  374. resourceLinks?: Array<{title: string; url: string}>;
  375. altIsSentryApp?: boolean;
  376. deprecationDate?: string;
  377. firstPartyAlternative?: string;
  378. };
  379. export type Plugin = PluginNoProject & {
  380. enabled: boolean;
  381. };
  382. export type PluginProjectItem = {
  383. projectId: string;
  384. projectSlug: string;
  385. projectName: string;
  386. projectPlatform: PlatformKey;
  387. enabled: boolean;
  388. configured: boolean;
  389. };
  390. export type PluginWithProjectList = PluginNoProject & {
  391. projectList: PluginProjectItem[];
  392. };
  393. export type AppOrProviderOrPlugin =
  394. | SentryApp
  395. | IntegrationProvider
  396. | PluginWithProjectList
  397. | DocIntegration;
  398. /**
  399. * Webhooks and servicehooks
  400. */
  401. export type WebhookEvent = 'issue' | 'error';
  402. export type ServiceHook = {
  403. id: string;
  404. events: string[];
  405. dateCreated: string;
  406. secret: string;
  407. status: string;
  408. url: string;
  409. };
  410. /**
  411. * Codeowners and repository path mappings.
  412. */
  413. export type CodeOwner = {
  414. id: string;
  415. raw: string;
  416. dateCreated: string;
  417. dateUpdated: string;
  418. provider: 'github' | 'gitlab';
  419. codeMapping?: RepositoryProjectPathConfig;
  420. codeMappingId: string;
  421. ownershipSyntax?: string;
  422. errors: {
  423. missing_external_teams: string[];
  424. missing_external_users: string[];
  425. missing_user_emails: string[];
  426. teams_without_access: string[];
  427. users_without_access: string[];
  428. };
  429. };
  430. export type CodeownersFile = {
  431. raw: string;
  432. filepath: string;
  433. html_url: string;
  434. };
  435. export type FilesByRepository = {
  436. [repoName: string]: {
  437. authors?: {[email: string]: CommitAuthor};
  438. types?: Set<string>;
  439. };
  440. };
  441. type BaseRepositoryProjectPathConfig = {
  442. id: string;
  443. projectId: string;
  444. projectSlug: string;
  445. repoId: string;
  446. repoName: string;
  447. stackRoot: string;
  448. sourceRoot: string;
  449. defaultBranch?: string;
  450. };
  451. export type RepositoryProjectPathConfig = BaseRepositoryProjectPathConfig & {
  452. integrationId: string | null;
  453. provider: BaseIntegrationProvider | null;
  454. };
  455. export type RepositoryProjectPathConfigWithIntegration =
  456. BaseRepositoryProjectPathConfig & {
  457. integrationId: string;
  458. provider: BaseIntegrationProvider;
  459. };
  460. export type ServerlessFunction = {
  461. name: string;
  462. runtime: string;
  463. version: number;
  464. outOfDate: boolean;
  465. enabled: boolean;
  466. };