integrations.tsx 11 KB

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