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

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