You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

types.ts 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2023 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import { RuleDescriptionSection } from '../apps/coding-rules/rule';
  21. import {
  22. CleanCodeAttribute,
  23. CleanCodeAttributeCategory,
  24. SoftwareImpactSeverity,
  25. SoftwareQuality,
  26. } from './clean-code-taxonomy';
  27. import { ComponentQualifier, Visibility } from './component';
  28. import { IssueStatus, IssueTransition, MessageFormatting } from './issues';
  29. import { NewCodeDefinitionType } from './new-code-definition';
  30. import { UserActive, UserBase } from './users';
  31. export type Dict<T> = { [key: string]: T };
  32. export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
  33. export interface A11ySkipLink {
  34. key: string;
  35. label: string;
  36. weight?: number;
  37. }
  38. export interface AlmApplication extends IdentityProvider {
  39. installationUrl: string;
  40. }
  41. export interface AlmRepository {
  42. label: string;
  43. installationKey: string;
  44. linkedProjectKey?: string;
  45. linkedProjectName?: string;
  46. private?: boolean;
  47. }
  48. export interface AlmUnboundApplication {
  49. installationId: string;
  50. key: string;
  51. name: string;
  52. }
  53. export interface Breadcrumb {
  54. key: string;
  55. name: string;
  56. qualifier: string;
  57. }
  58. export namespace Chart {
  59. export interface Point {
  60. x: Date;
  61. y: number | string | undefined;
  62. }
  63. export interface Serie {
  64. data: Point[];
  65. name: string;
  66. translatedName: string;
  67. type: string;
  68. }
  69. }
  70. export interface Component extends LightComponent {
  71. alm?: { key: string; url: string };
  72. analysisDate?: string;
  73. breadcrumbs: Breadcrumb[];
  74. canBrowseAllChildProjects?: boolean;
  75. configuration?: ComponentConfiguration;
  76. description?: string;
  77. extensions?: Extension[];
  78. isFavorite?: boolean;
  79. leakPeriodDate?: string;
  80. name: string;
  81. needIssueSync?: boolean;
  82. path?: string;
  83. refKey?: string;
  84. qualityProfiles?: ComponentQualityProfile[];
  85. qualityGate?: { isDefault?: boolean; key: string; name: string };
  86. tags?: string[];
  87. version?: string;
  88. visibility?: Visibility;
  89. }
  90. export interface NavigationComponent
  91. extends Omit<Component, 'alm' | 'qualifier' | 'leakPeriodDate' | 'path' | 'tags'> {}
  92. interface ComponentConfiguration {
  93. canApplyPermissionTemplate?: boolean;
  94. canBrowseProject?: boolean;
  95. canUpdateProjectVisibilityToPrivate?: boolean;
  96. extensions?: Extension[];
  97. showBackgroundTasks?: boolean;
  98. showHistory?: boolean;
  99. showLinks?: boolean;
  100. showQualityGates?: boolean;
  101. showQualityProfiles?: boolean;
  102. showPermissions?: boolean;
  103. showSettings?: boolean;
  104. showUpdateKey?: boolean;
  105. }
  106. export interface ComponentQualityProfile {
  107. deleted?: boolean;
  108. key: string;
  109. language: string;
  110. name: string;
  111. }
  112. export interface ComponentMeasureIntern {
  113. analysisDate?: string;
  114. branch?: string;
  115. description?: string;
  116. isFavorite?: boolean;
  117. isRecentlyBrowsed?: boolean;
  118. canBrowseAllChildProjects?: boolean;
  119. key: string;
  120. match?: string;
  121. name: string;
  122. path?: string;
  123. project?: string;
  124. qualifier: string;
  125. refKey?: string;
  126. }
  127. export interface ComponentMeasure extends ComponentMeasureIntern {
  128. measures?: Measure[];
  129. }
  130. export interface ComponentMeasureEnhanced extends ComponentMeasureIntern {
  131. value?: string;
  132. leak?: string;
  133. measures: MeasureEnhanced[];
  134. }
  135. export interface Condition {
  136. error: string;
  137. id: string;
  138. metric: string;
  139. op?: string;
  140. isCaycCondition?: boolean;
  141. }
  142. export interface CustomMeasure {
  143. createdAt?: string;
  144. description?: string;
  145. id: string;
  146. metric: {
  147. key: string;
  148. name: string;
  149. domain?: string;
  150. type: string;
  151. };
  152. projectKey: string;
  153. pending?: boolean;
  154. user: UserBase;
  155. value: string;
  156. updatedAt?: string;
  157. }
  158. export interface Duplication {
  159. blocks: DuplicationBlock[];
  160. }
  161. export interface DuplicationBlock {
  162. _ref?: string;
  163. from: number;
  164. size: number;
  165. }
  166. export interface DuplicatedFile {
  167. key: string;
  168. name: string;
  169. project: string;
  170. projectName: string;
  171. }
  172. export type ExpandDirection = 'up' | 'down';
  173. export interface Extension {
  174. key: string;
  175. name: string;
  176. }
  177. export interface FacetValue<T = string> {
  178. count: number;
  179. val: T;
  180. }
  181. export enum FlowType {
  182. DATA = 'DATA',
  183. EXECUTION = 'EXECUTION',
  184. }
  185. export interface Flow {
  186. type: FlowType;
  187. description?: string;
  188. locations: FlowLocation[];
  189. }
  190. export interface FlowLocation {
  191. component: string;
  192. componentName?: string;
  193. index?: number;
  194. msg?: string;
  195. msgFormattings?: MessageFormatting[];
  196. textRange: TextRange;
  197. }
  198. export interface Group {
  199. default?: boolean;
  200. description?: string;
  201. membersCount: number;
  202. name: string;
  203. managed: boolean;
  204. }
  205. export enum HealthTypes {
  206. RED = 'RED',
  207. YELLOW = 'YELLOW',
  208. GREEN = 'GREEN',
  209. }
  210. export interface IdentityProvider {
  211. backgroundColor: string;
  212. helpMessage?: string;
  213. iconPath: string;
  214. key: string;
  215. name: string;
  216. manage?: boolean;
  217. }
  218. export interface Issue {
  219. actions: string[];
  220. assignee?: string;
  221. assigneeActive?: boolean;
  222. assigneeAvatar?: string;
  223. assigneeLogin?: string;
  224. assigneeName?: string;
  225. author?: string;
  226. branch?: string;
  227. cleanCodeAttributeCategory: CleanCodeAttributeCategory;
  228. cleanCodeAttribute: CleanCodeAttribute;
  229. impacts: Array<{
  230. softwareQuality: SoftwareQuality;
  231. severity: SoftwareImpactSeverity;
  232. }>;
  233. codeVariants?: string[];
  234. comments?: IssueComment[];
  235. component: string;
  236. componentEnabled?: boolean;
  237. componentLongName: string;
  238. componentQualifier: string;
  239. componentUuid: string;
  240. creationDate: string;
  241. effort?: string;
  242. externalRuleEngine?: string;
  243. fromExternalRule?: boolean;
  244. quickFixAvailable?: boolean;
  245. key: string;
  246. flows: FlowLocation[][];
  247. flowsWithType: Flow[];
  248. line?: number;
  249. message: string;
  250. messageFormattings?: MessageFormatting[];
  251. project: string;
  252. projectName: string;
  253. projectKey: string;
  254. pullRequest?: string;
  255. resolution?: string;
  256. rule: string;
  257. ruleDescriptionContextKey?: string;
  258. ruleName: string;
  259. ruleStatus?: string;
  260. scope: string;
  261. secondaryLocations: FlowLocation[];
  262. severity: string;
  263. status: string;
  264. issueStatus: IssueStatus;
  265. tags?: string[];
  266. textRange?: TextRange;
  267. transitions: IssueTransition[];
  268. type: IssueType;
  269. }
  270. export interface IssueChangelog {
  271. avatar?: string;
  272. creationDate: string;
  273. diffs: IssueChangelogDiff[];
  274. user: string;
  275. isUserActive: boolean;
  276. userName: string;
  277. externalUser?: string;
  278. webhookSource?: string;
  279. }
  280. export interface IssueChangelogDiff {
  281. key: string;
  282. newValue?: string;
  283. oldValue?: string;
  284. }
  285. export interface IssueComment {
  286. author?: string;
  287. authorActive?: boolean;
  288. authorAvatar?: string;
  289. authorLogin?: string;
  290. authorName?: string;
  291. createdAt: string;
  292. htmlText: string;
  293. key: string;
  294. markdown: string;
  295. updatable: boolean;
  296. }
  297. export interface IssuesByLine {
  298. [key: number]: Issue[];
  299. }
  300. export type IssueType = 'BUG' | 'VULNERABILITY' | 'CODE_SMELL' | 'SECURITY_HOTSPOT';
  301. export interface Language {
  302. key: string;
  303. name: string;
  304. }
  305. export type Languages = Dict<Language>;
  306. export interface LightComponent {
  307. key: string;
  308. qualifier: string;
  309. }
  310. export interface LinearIssueLocation {
  311. from: number;
  312. index?: number;
  313. line: number;
  314. startLine?: number;
  315. text?: string;
  316. textFormatting?: MessageFormatting[];
  317. to: number;
  318. }
  319. export interface LineMap {
  320. [line: number]: SourceLine;
  321. }
  322. export interface LinePopup {
  323. index?: number;
  324. line: number;
  325. name: string;
  326. open?: boolean;
  327. }
  328. export interface Measure extends MeasureIntern {
  329. metric: string;
  330. }
  331. export interface MeasureEnhanced extends MeasureIntern {
  332. metric: Metric;
  333. leak?: string;
  334. }
  335. export interface MeasureIntern {
  336. bestValue?: boolean;
  337. period?: PeriodMeasure;
  338. value?: string;
  339. }
  340. export interface Metric {
  341. bestValue?: string;
  342. custom?: boolean;
  343. decimalScale?: number;
  344. description?: string;
  345. direction?: number;
  346. domain?: string;
  347. hidden?: boolean;
  348. higherValuesAreBetter?: boolean;
  349. id: string;
  350. key: string;
  351. name: string;
  352. qualitative?: boolean;
  353. type: string;
  354. worstValue?: string;
  355. }
  356. export interface MyProject {
  357. description?: string;
  358. key: string;
  359. lastAnalysisDate?: string;
  360. links: Array<{
  361. name: string;
  362. type: string;
  363. href: string;
  364. }>;
  365. name: string;
  366. qualityGate?: string;
  367. }
  368. export interface Paging {
  369. pageIndex: number;
  370. pageSize: number;
  371. total: number;
  372. }
  373. export interface Period {
  374. date: string;
  375. index?: number;
  376. mode: PeriodMode | NewCodeDefinitionType;
  377. modeParam?: string;
  378. parameter?: string;
  379. }
  380. export interface PeriodMeasure {
  381. bestValue?: boolean;
  382. index: number;
  383. value: string;
  384. }
  385. /*
  386. * These are old baseline setting types, necessary for
  387. * backward compatibility.
  388. */
  389. export type PeriodMode =
  390. | 'days'
  391. | 'date'
  392. | 'version'
  393. | 'previous_analysis'
  394. | 'previous_version'
  395. | 'manual_baseline';
  396. export interface Permission {
  397. description: string;
  398. key: string;
  399. name: string;
  400. }
  401. export interface PermissionDefinition {
  402. key: string;
  403. name: string;
  404. description: string;
  405. }
  406. export type PermissionDefinitions = Array<PermissionDefinition | PermissionDefinitionGroup>;
  407. export interface PermissionDefinitionGroup {
  408. category: string;
  409. permissions: PermissionDefinition[];
  410. }
  411. export interface PermissionGroup {
  412. description?: string;
  413. id?: string;
  414. name: string;
  415. permissions: string[];
  416. managed?: boolean;
  417. }
  418. export interface PermissionUser extends UserActive {
  419. permissions: string[];
  420. managed?: boolean;
  421. }
  422. export interface PermissionTemplateGroup {
  423. key: string;
  424. usersCount: number;
  425. groupsCount: number;
  426. withProjectCreator?: boolean;
  427. }
  428. export interface PermissionTemplate {
  429. defaultFor: string[];
  430. id: string;
  431. name: string;
  432. description?: string;
  433. projectKeyPattern?: string;
  434. createdAt: string;
  435. updatedAt?: string;
  436. permissions: Array<PermissionTemplateGroup>;
  437. }
  438. export interface ProfileInheritanceDetails {
  439. activeRuleCount: number;
  440. inactiveRuleCount: number;
  441. isBuiltIn: boolean;
  442. key: string;
  443. name: string;
  444. overridingRuleCount?: number;
  445. }
  446. export interface ProjectLink {
  447. id: string;
  448. name?: string;
  449. type: string;
  450. url: string;
  451. }
  452. export enum CaycStatus {
  453. Compliant = 'compliant',
  454. NonCompliant = 'non-compliant',
  455. OverCompliant = 'over-compliant',
  456. }
  457. export interface QualityGate {
  458. actions?: {
  459. associateProjects?: boolean;
  460. copy?: boolean;
  461. delegate?: boolean;
  462. delete?: boolean;
  463. manageConditions?: boolean;
  464. rename?: boolean;
  465. setAsDefault?: boolean;
  466. };
  467. conditions?: Condition[];
  468. isBuiltIn?: boolean;
  469. caycStatus?: CaycStatus;
  470. isDefault?: boolean;
  471. name: string;
  472. }
  473. export type RawQuery = Dict<any>;
  474. export interface Rule {
  475. cleanCodeAttributeCategory?: CleanCodeAttributeCategory;
  476. cleanCodeAttribute?: CleanCodeAttribute;
  477. impacts: Array<{
  478. softwareQuality: SoftwareQuality;
  479. severity: SoftwareImpactSeverity;
  480. }>;
  481. isTemplate?: boolean;
  482. key: string;
  483. lang?: string;
  484. langName?: string;
  485. name: string;
  486. params?: RuleParameter[];
  487. severity: string;
  488. status: string;
  489. sysTags?: string[];
  490. tags?: string[];
  491. type: RuleType;
  492. }
  493. export interface RuleActivation {
  494. createdAt: string;
  495. inherit: RuleInheritance;
  496. params: { key: string; value: string }[];
  497. qProfile: string;
  498. severity: string;
  499. }
  500. export interface RulesUpdateRequest {
  501. key: string;
  502. markdown_description?: string;
  503. markdown_note?: string;
  504. name?: string;
  505. params?: string;
  506. remediation_fn_base_effort?: string;
  507. remediation_fn_type?: string;
  508. remediation_fy_gap_multiplier?: string;
  509. severity?: string;
  510. status?: string;
  511. tags?: string;
  512. }
  513. export interface RuleDetails extends Rule {
  514. createdAt: string;
  515. defaultRemFnBaseEffort?: string;
  516. defaultRemFnType?: string;
  517. descriptionSections?: RuleDescriptionSection[];
  518. educationPrinciples?: string[];
  519. gapDescription?: string;
  520. htmlDesc?: string;
  521. htmlNote?: string;
  522. internalKey?: string;
  523. isExternal?: boolean;
  524. mdDesc?: string;
  525. mdNote?: string;
  526. remFnBaseEffort?: string;
  527. remFnGapMultiplier?: string;
  528. remFnOverloaded?: boolean;
  529. remFnType?: string;
  530. repo: string;
  531. scope?: RuleScope;
  532. templateKey?: string;
  533. }
  534. export type RuleInheritance = 'NONE' | 'INHERITED' | 'OVERRIDES';
  535. export interface RuleParameter {
  536. defaultValue?: string;
  537. htmlDesc?: string;
  538. key: string;
  539. type: string;
  540. }
  541. export type RuleScope = 'MAIN' | 'TEST' | 'ALL';
  542. export type RuleType = 'BUG' | 'VULNERABILITY' | 'CODE_SMELL' | 'SECURITY_HOTSPOT' | 'UNKNOWN';
  543. export interface Snippet {
  544. start: number;
  545. end: number;
  546. index: number;
  547. toDelete?: boolean;
  548. }
  549. export interface SnippetGroup extends SnippetsByComponent {
  550. locations: FlowLocation[];
  551. }
  552. export interface SnippetsByComponent {
  553. component: SourceViewerFile;
  554. sources: { [line: number]: SourceLine };
  555. }
  556. export interface SourceLine {
  557. code?: string;
  558. conditions?: number;
  559. coverageBlock?: number;
  560. coverageStatus?: SourceLineCoverageStatus;
  561. coveredConditions?: number;
  562. duplicated?: boolean;
  563. isNew?: boolean;
  564. line: number;
  565. lineHits?: number;
  566. newCodeBlock?: number;
  567. scmAuthor?: string;
  568. scmDate?: string;
  569. scmRevision?: string;
  570. }
  571. export type SourceLineCoverageStatus = 'uncovered' | 'partially-covered' | 'covered';
  572. export interface SourceViewerFile {
  573. fav?: boolean;
  574. key: string;
  575. leakPeriodDate?: string;
  576. measures: {
  577. coverage?: string;
  578. duplicationDensity?: string;
  579. issues?: string;
  580. lines?: string;
  581. tests?: string;
  582. };
  583. canMarkAsFavorite?: boolean;
  584. path: string;
  585. name?: string;
  586. longName?: string;
  587. project: string;
  588. projectName: string;
  589. q: ComponentQualifier;
  590. uuid: string;
  591. }
  592. export type StandardSecurityCategories = Dict<{ title: string; description?: string }>;
  593. export type Status = 'ERROR' | 'OK';
  594. export interface SubscriptionPlan {
  595. maxNcloc: number;
  596. price: number;
  597. }
  598. export interface SuggestionLink {
  599. link: string;
  600. scope?: 'sonarcloud';
  601. text: string;
  602. }
  603. export interface SysInfoAppNode extends SysInfoBase {
  604. 'Compute Engine Logging': SysInfoLogging;
  605. Name: string;
  606. 'Web Logging': SysInfoLogging;
  607. }
  608. export interface SysInfoBase extends SysInfoValueObject {
  609. Health: HealthTypes;
  610. 'Health Causes': string[];
  611. Plugins?: Dict<string>;
  612. System: {
  613. Version: string;
  614. };
  615. }
  616. export interface SysInfoCluster extends SysInfoBase {
  617. 'Application Nodes': SysInfoAppNode[];
  618. 'Search Nodes': SysInfoSearchNode[];
  619. Settings: Dict<string>;
  620. Statistics?: {
  621. ncloc: number;
  622. };
  623. System: {
  624. 'High Availability': true;
  625. 'Server ID': string;
  626. Version: string;
  627. 'External Users and Groups Provisioning'?: string;
  628. };
  629. }
  630. export interface SysInfoLogging extends Dict<string> {
  631. 'Logs Level': string;
  632. }
  633. export interface SysInfoSearchNode extends SysInfoValueObject {
  634. Name: string;
  635. }
  636. export interface SysInfoSection extends Dict<SysInfoValueObject> {}
  637. export interface SysInfoStandalone extends SysInfoBase {
  638. 'Compute Engine Logging': SysInfoLogging;
  639. Settings: Dict<string>;
  640. Statistics?: {
  641. ncloc: number;
  642. } & Dict<string | number>;
  643. System: {
  644. 'High Availability': false;
  645. 'Server ID': string;
  646. Version: string;
  647. };
  648. 'Web Logging': SysInfoLogging;
  649. }
  650. export type SysInfoValue =
  651. | boolean
  652. | string
  653. | number
  654. | undefined
  655. | HealthTypes
  656. | SysInfoValueObject
  657. | SysInfoValueArray;
  658. export interface SysInfoValueArray extends Array<SysInfoValue> {}
  659. export interface SysInfoValueObject extends Dict<SysInfoValue> {}
  660. export type SysStatus =
  661. | 'STARTING'
  662. | 'UP'
  663. | 'DOWN'
  664. | 'RESTARTING'
  665. | 'DB_MIGRATION_NEEDED'
  666. | 'DB_MIGRATION_RUNNING';
  667. export interface TestCase {
  668. coveredLines: number;
  669. durationInMs: number;
  670. fileId: string;
  671. fileKey: string;
  672. fileName: string;
  673. id: string;
  674. message?: string;
  675. name: string;
  676. stacktrace?: string;
  677. status: string;
  678. }
  679. export interface TextRange {
  680. startLine: number;
  681. startOffset: number;
  682. endLine: number;
  683. endOffset: number;
  684. }
  685. export interface UserSelected extends UserActive {
  686. selected: boolean;
  687. }
  688. export interface UserGroupMember {
  689. selected: boolean;
  690. login: string;
  691. name: string;
  692. managed: boolean;
  693. }
  694. export namespace WebApi {
  695. export interface Action {
  696. key: string;
  697. changelog: Changelog[];
  698. description: string;
  699. deprecatedSince?: string;
  700. hasResponseExample: boolean;
  701. internal: boolean;
  702. params?: Param[];
  703. post: boolean;
  704. since?: string;
  705. }
  706. export interface Changelog {
  707. description: string;
  708. version: string;
  709. }
  710. export interface Domain {
  711. actions: Action[];
  712. deprecatedSince?: string;
  713. description: string;
  714. internal?: boolean;
  715. path: string;
  716. since?: string;
  717. }
  718. export interface Example {
  719. example: string;
  720. format: string;
  721. }
  722. export interface Param {
  723. defaultValue?: string;
  724. deprecatedKey?: string;
  725. deprecatedKeySince?: string;
  726. deprecatedSince?: string;
  727. description: string;
  728. exampleValue?: string;
  729. internal: boolean;
  730. key: string;
  731. maximumLength?: number;
  732. maximumValue?: number;
  733. maxValuesAllowed?: number;
  734. minimumLength?: number;
  735. minimumValue?: number;
  736. possibleValues?: string[];
  737. required: boolean;
  738. since?: string;
  739. }
  740. }