aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/api
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2018-12-05 17:32:18 +0100
committerSonarTech <sonartech@sonarsource.com>2018-12-05 20:20:59 +0100
commit41c98779d38bda9fdfdca182a5f20c73fcff9a84 (patch)
treed895a9f8bfd0276aee5ffacf7bb33a0109436cbd /server/sonar-web/src/main/js/api
parenta9c22c1185c5fd8c8dc4c9388f4a3b967e3f463d (diff)
downloadsonarqube-41c98779d38bda9fdfdca182a5f20c73fcff9a84.tar.gz
sonarqube-41c98779d38bda9fdfdca182a5f20c73fcff9a84.zip
create global type definitions (#1017)
Diffstat (limited to 'server/sonar-web/src/main/js/api')
-rw-r--r--server/sonar-web/src/main/js/api/alm-integration.ts19
-rw-r--r--server/sonar-web/src/main/js/api/billing.ts3
-rw-r--r--server/sonar-web/src/main/js/api/branches.ts5
-rw-r--r--server/sonar-web/src/main/js/api/ce.ts7
-rw-r--r--server/sonar-web/src/main/js/api/components.ts57
-rw-r--r--server/sonar-web/src/main/js/api/issues.ts3
-rw-r--r--server/sonar-web/src/main/js/api/languages.ts3
-rw-r--r--server/sonar-web/src/main/js/api/measures.ts22
-rw-r--r--server/sonar-web/src/main/js/api/metrics.ts9
-rw-r--r--server/sonar-web/src/main/js/api/nav.ts5
-rw-r--r--server/sonar-web/src/main/js/api/notifications.ts3
-rw-r--r--server/sonar-web/src/main/js/api/organizations.ts29
-rw-r--r--server/sonar-web/src/main/js/api/permissions.ts21
-rw-r--r--server/sonar-web/src/main/js/api/projectActivity.ts5
-rw-r--r--server/sonar-web/src/main/js/api/projectLinks.ts5
-rw-r--r--server/sonar-web/src/main/js/api/quality-gates.ts21
-rw-r--r--server/sonar-web/src/main/js/api/quality-profiles.ts5
-rw-r--r--server/sonar-web/src/main/js/api/rules.ts11
-rw-r--r--server/sonar-web/src/main/js/api/security-reports.ts3
-rw-r--r--server/sonar-web/src/main/js/api/settings.ts21
-rw-r--r--server/sonar-web/src/main/js/api/tests.ts7
-rw-r--r--server/sonar-web/src/main/js/api/time-machine.ts7
-rw-r--r--server/sonar-web/src/main/js/api/user_groups.ts7
-rw-r--r--server/sonar-web/src/main/js/api/users.ts15
-rw-r--r--server/sonar-web/src/main/js/api/webhooks.ts11
25 files changed, 119 insertions, 185 deletions
diff --git a/server/sonar-web/src/main/js/api/alm-integration.ts b/server/sonar-web/src/main/js/api/alm-integration.ts
index 4ede88d3bff..dd5660065ae 100644
--- a/server/sonar-web/src/main/js/api/alm-integration.ts
+++ b/server/sonar-web/src/main/js/api/alm-integration.ts
@@ -18,20 +18,13 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { getJSON, postJSON, post } from '../helpers/request';
-import {
- AlmApplication,
- AlmOrganization,
- AlmRepository,
- AlmUnboundApplication,
- OrganizationBase
-} from '../app/types';
import throwGlobalError from '../app/utils/throwGlobalError';
export function bindAlmOrganization(data: { installationId: string; organization: string }) {
return post('/api/alm_integration/bind_organization', data).catch(throwGlobalError);
}
-export function getAlmAppInfo(): Promise<{ application: AlmApplication }> {
+export function getAlmAppInfo(): Promise<{ application: T.AlmApplication }> {
return getJSON('/api/alm_integration/show_app_info').catch(throwGlobalError);
}
@@ -53,8 +46,8 @@ function fetchAlmOrganization(data: { installationId: string }, remainingTries:
}
export interface GetAlmOrganizationResponse {
- almOrganization: AlmOrganization;
- boundOrganization?: OrganizationBase;
+ almOrganization: T.AlmOrganization;
+ boundOrganization?: T.OrganizationBase;
}
export function getAlmOrganization(data: {
@@ -71,14 +64,14 @@ export function getAlmOrganization(data: {
export function getRepositories(data: {
organization: string;
-}): Promise<{ repositories: AlmRepository[] }> {
+}): Promise<{ repositories: T.AlmRepository[] }> {
return getJSON('/api/alm_integration/list_repositories', data).catch(throwGlobalError);
}
-export function listUnboundApplications(): Promise<AlmUnboundApplication[]> {
+export function listUnboundApplications(): Promise<T.AlmUnboundApplication[]> {
return getJSON('/api/alm_integration/list_unbound_applications').then(
({ applications }) =>
- applications.map((app: AlmUnboundApplication) => ({ ...app, name: app.name || app.key })),
+ applications.map((app: T.AlmUnboundApplication) => ({ ...app, name: app.name || app.key })),
throwGlobalError
);
}
diff --git a/server/sonar-web/src/main/js/api/billing.ts b/server/sonar-web/src/main/js/api/billing.ts
index f0a20dca756..c8c2f7012ff 100644
--- a/server/sonar-web/src/main/js/api/billing.ts
+++ b/server/sonar-web/src/main/js/api/billing.ts
@@ -19,9 +19,8 @@
*/
import { getJSON } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-import { SubscriptionPlan } from '../app/types';
-export function getSubscriptionPlans(): Promise<SubscriptionPlan[]> {
+export function getSubscriptionPlans(): Promise<T.SubscriptionPlan[]> {
return getJSON('/api/billing/show_subscription_plans').then(
({ subscriptionPlans }) => subscriptionPlans,
throwGlobalError
diff --git a/server/sonar-web/src/main/js/api/branches.ts b/server/sonar-web/src/main/js/api/branches.ts
index 9cb5dbaec27..d89c7951acc 100644
--- a/server/sonar-web/src/main/js/api/branches.ts
+++ b/server/sonar-web/src/main/js/api/branches.ts
@@ -18,14 +18,13 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { getJSON, post } from '../helpers/request';
-import { Branch, PullRequest } from '../app/types';
import throwGlobalError from '../app/utils/throwGlobalError';
-export function getBranches(project: string): Promise<Branch[]> {
+export function getBranches(project: string): Promise<T.Branch[]> {
return getJSON('/api/project_branches/list', { project }).then(r => r.branches, throwGlobalError);
}
-export function getPullRequests(project: string): Promise<PullRequest[]> {
+export function getPullRequests(project: string): Promise<T.PullRequest[]> {
return getJSON('/api/project_pull_requests/list', { project }).then(
r => r.pullRequests,
throwGlobalError
diff --git a/server/sonar-web/src/main/js/api/ce.ts b/server/sonar-web/src/main/js/api/ce.ts
index 6b6476a2798..a159628a65f 100644
--- a/server/sonar-web/src/main/js/api/ce.ts
+++ b/server/sonar-web/src/main/js/api/ce.ts
@@ -19,7 +19,6 @@
*/
import { getJSON, post, RequestData } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-import { Task } from '../app/types';
export function getAnalysisStatus(data: {
component: string;
@@ -38,7 +37,7 @@ export function getAnalysisStatus(data: {
return getJSON('/api/ce/analysis_status', data).catch(throwGlobalError);
}
-export function getActivity(data: RequestData): Promise<{ tasks: Task[] }> {
+export function getActivity(data: RequestData): Promise<{ tasks: T.Task[] }> {
return getJSON('/api/ce/activity', data);
}
@@ -52,7 +51,7 @@ export function getStatus(
return getJSON('/api/ce/activity_status', data);
}
-export function getTask(id: string, additionalFields?: string[]): Promise<Task> {
+export function getTask(id: string, additionalFields?: string[]): Promise<T.Task> {
return getJSON('/api/ce/task', { id, additionalFields }).then(r => r.task);
}
@@ -66,7 +65,7 @@ export function cancelAllTasks(): Promise<any> {
export function getTasksForComponent(
componentKey: string
-): Promise<{ queue: Task[]; current: Task }> {
+): Promise<{ queue: T.Task[]; current: T.Task }> {
return getJSON('/api/ce/component', { componentKey }).catch(throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/components.ts b/server/sonar-web/src/main/js/api/components.ts
index ae01e608b7b..c2706de28ef 100644
--- a/server/sonar-web/src/main/js/api/components.ts
+++ b/server/sonar-web/src/main/js/api/components.ts
@@ -19,17 +19,6 @@
*/
import throwGlobalError from '../app/utils/throwGlobalError';
import { getJSON, postJSON, post, RequestData } from '../helpers/request';
-import {
- SourceLine,
- Paging,
- Visibility,
- BranchParameters,
- MyProject,
- Metric,
- ComponentMeasure,
- LightComponent,
- SourceViewerFile
-} from '../app/types';
export interface BaseSearchProjectsParameters {
analyzedBefore?: string;
@@ -38,14 +27,14 @@ export interface BaseSearchProjectsParameters {
projects?: string;
q?: string;
qualifiers?: string;
- visibility?: Visibility;
+ visibility?: T.Visibility;
}
export interface ProjectBase {
key: string;
name: string;
qualifier: string;
- visibility: Visibility;
+ visibility: T.Visibility;
}
export interface Project extends ProjectBase {
@@ -63,7 +52,7 @@ export function getComponents(
parameters: SearchProjectsParameters
): Promise<{
components: Project[];
- paging: Paging;
+ paging: T.Paging;
}> {
return getJSON('/api/projects/search', parameters);
}
@@ -104,9 +93,9 @@ export function getComponentTree(
metrics: string[] = [],
additional: RequestData = {}
): Promise<{
- components: ComponentMeasure[];
- metrics: Metric[];
- paging: Paging;
+ components: T.ComponentMeasure[];
+ metrics: T.Metric[];
+ paging: T.Paging;
}> {
const url = '/api/measures/component_tree';
const data = Object.assign({}, additional, {
@@ -134,19 +123,19 @@ export function getComponentLeaves(
}
export function getComponent(
- data: { componentKey: string; metricKeys: string } & BranchParameters
+ data: { componentKey: string; metricKeys: string } & T.BranchParameters
): Promise<any> {
return getJSON('/api/measures/component', data).then(r => r.component, throwGlobalError);
}
-export interface TreeComponent extends LightComponent {
+export interface TreeComponent extends T.LightComponent {
id: string;
name: string;
path?: string;
refId?: string;
refKey?: string;
tags?: string[];
- visibility: Visibility;
+ visibility: T.Visibility;
}
export function getTree(data: {
@@ -160,12 +149,12 @@ export function getTree(data: {
qualifiers?: string;
s?: string;
strategy?: 'all' | 'leaves' | 'children';
-}): Promise<{ baseComponent: TreeComponent; components: TreeComponent[]; paging: Paging }> {
+}): Promise<{ baseComponent: TreeComponent; components: TreeComponent[]; paging: T.Paging }> {
return getJSON('/api/components/tree', data).catch(throwGlobalError);
}
export function doesComponentExists(
- data: { component: string } & BranchParameters
+ data: { component: string } & T.BranchParameters
): Promise<boolean> {
return getJSON('/api/components/show', data).then(
({ component }) => component !== undefined,
@@ -173,7 +162,7 @@ export function doesComponentExists(
);
}
-export function getComponentShow(data: { component: string } & BranchParameters): Promise<any> {
+export function getComponentShow(data: { component: string } & T.BranchParameters): Promise<any> {
return getJSON('/api/components/show', data).catch(throwGlobalError);
}
@@ -181,21 +170,21 @@ export function getParents(component: string): Promise<any> {
return getComponentShow({ component }).then(r => r.ancestors);
}
-export function getBreadcrumbs(data: { component: string } & BranchParameters): Promise<any> {
+export function getBreadcrumbs(data: { component: string } & T.BranchParameters): Promise<any> {
return getComponentShow(data).then(r => {
const reversedAncestors = [...r.ancestors].reverse();
return [...reversedAncestors, r.component];
});
}
-export function getComponentData(data: { component: string } & BranchParameters): Promise<any> {
+export function getComponentData(data: { component: string } & T.BranchParameters): Promise<any> {
return getComponentShow(data).then(r => r.component);
}
export function getMyProjects(data: {
p?: number;
ps?: number;
-}): Promise<{ paging: Paging; projects: MyProject[] }> {
+}): Promise<{ paging: T.Paging; projects: T.MyProject[] }> {
return getJSON('/api/projects/search_my_projects', data);
}
@@ -207,7 +196,7 @@ export interface Component {
isFavorite?: boolean;
analysisDate?: string;
tags: string[];
- visibility: Visibility;
+ visibility: T.Visibility;
leakPeriodDate?: string;
}
@@ -222,7 +211,7 @@ export function searchProjects(
components: Component[];
facets: Facet[];
organizations: Array<{ key: string; name: string }>;
- paging: Paging;
+ paging: T.Paging;
}> {
const url = '/api/components/search_projects';
return getJSON(url, data);
@@ -297,23 +286,23 @@ export function getSuggestions(
}
export function getComponentForSourceViewer(
- data: { component: string } & BranchParameters
-): Promise<SourceViewerFile> {
+ data: { component: string } & T.BranchParameters
+): Promise<T.SourceViewerFile> {
return getJSON('/api/components/app', data);
}
export function getSources(
- data: { key: string; from?: number; to?: number } & BranchParameters
-): Promise<SourceLine[]> {
+ data: { key: string; from?: number; to?: number } & T.BranchParameters
+): Promise<T.SourceLine[]> {
return getJSON('/api/sources/lines', data).then(r => r.sources);
}
-export function getDuplications(data: { key: string } & BranchParameters): Promise<any> {
+export function getDuplications(data: { key: string } & T.BranchParameters): Promise<any> {
return getJSON('/api/duplications/show', data);
}
export function getTests(
- data: { sourceFileKey: string; sourceFileLineNumber: number | string } & BranchParameters
+ data: { sourceFileKey: string; sourceFileLineNumber: number | string } & T.BranchParameters
): Promise<any> {
return getJSON('/api/tests/list', data).then(r => r.tests);
}
diff --git a/server/sonar-web/src/main/js/api/issues.ts b/server/sonar-web/src/main/js/api/issues.ts
index fc49c0f7658..96163c169d9 100644
--- a/server/sonar-web/src/main/js/api/issues.ts
+++ b/server/sonar-web/src/main/js/api/issues.ts
@@ -17,7 +17,6 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { FacetValue } from '../app/types';
import { getJSON, post, postJSON, RequestData } from '../helpers/request';
import { RawIssue } from '../helpers/issues';
import throwGlobalError from '../app/utils/throwGlobalError';
@@ -75,7 +74,7 @@ export function getFacets(
query: RequestData,
facets: FacetName[]
): Promise<{
- facets: Array<{ property: string; values: FacetValue[] }>;
+ facets: Array<{ property: string; values: T.FacetValue[] }>;
response: IssuesResponse;
}> {
const data = {
diff --git a/server/sonar-web/src/main/js/api/languages.ts b/server/sonar-web/src/main/js/api/languages.ts
index ebf3efdb631..8f0f328fc2d 100644
--- a/server/sonar-web/src/main/js/api/languages.ts
+++ b/server/sonar-web/src/main/js/api/languages.ts
@@ -18,9 +18,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { getJSON } from '../helpers/request';
-import { Language } from '../app/types';
import throwGlobalError from '../app/utils/throwGlobalError';
-export function getLanguages(): Promise<Language[]> {
+export function getLanguages(): Promise<T.Language[]> {
return getJSON('/api/languages/list').then(r => r.languages, throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/measures.ts b/server/sonar-web/src/main/js/api/measures.ts
index 9a5357a174a..58d537385db 100644
--- a/server/sonar-web/src/main/js/api/measures.ts
+++ b/server/sonar-web/src/main/js/api/measures.ts
@@ -19,20 +19,10 @@
*/
import { getJSON, RequestData, postJSON, post } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-import {
- BranchParameters,
- ComponentMeasure,
- CustomMeasure,
- Measure,
- Metric,
- Paging,
- Period,
- PeriodMeasure
-} from '../app/types';
export function getMeasures(
- data: { componentKey: string; metricKeys: string } & BranchParameters
-): Promise<Measure[]> {
+ data: { componentKey: string; metricKeys: string } & T.BranchParameters
+): Promise<T.Measure[]> {
return getJSON('/api/measures/component', data).then(r => r.component.measures, throwGlobalError);
}
@@ -40,7 +30,7 @@ export function getMeasuresAndMeta(
componentKey: string,
metrics: string[],
additional: RequestData = {}
-): Promise<{ component: ComponentMeasure; metrics?: Metric[]; periods?: Period[] }> {
+): Promise<{ component: T.ComponentMeasure; metrics?: T.Metric[]; periods?: T.Period[] }> {
const data = { ...additional, componentKey, metricKeys: metrics.join(',') };
return getJSON('/api/measures/component', data);
}
@@ -48,7 +38,7 @@ export function getMeasuresAndMeta(
interface MeasuresForProjects {
component: string;
metric: string;
- periods?: PeriodMeasure[];
+ periods?: T.PeriodMeasure[];
value?: string;
}
@@ -67,7 +57,7 @@ export function getCustomMeasures(data: {
p?: number;
projectKey: string;
ps?: number;
-}): Promise<{ customMeasures: CustomMeasure[]; paging: Paging }> {
+}): Promise<{ customMeasures: T.CustomMeasure[]; paging: T.Paging }> {
return getJSON('/api/custom_measures/search', data).then(
r =>
({
@@ -83,7 +73,7 @@ export function createCustomMeasure(data: {
metricKey: string;
projectKey: string;
value: string;
-}): Promise<CustomMeasure> {
+}): Promise<T.CustomMeasure> {
return postJSON('/api/custom_measures/create', data).catch(throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/metrics.ts b/server/sonar-web/src/main/js/api/metrics.ts
index 25cbbf710bc..96a0ed32230 100644
--- a/server/sonar-web/src/main/js/api/metrics.ts
+++ b/server/sonar-web/src/main/js/api/metrics.ts
@@ -18,11 +18,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { getJSON, post, postJSON } from '../helpers/request';
-import { Metric } from '../app/types';
import throwGlobalError from '../app/utils/throwGlobalError';
export interface MetricsResponse {
- metrics: Metric[];
+ metrics: T.Metric[];
p: number;
ps: number;
total: number;
@@ -40,13 +39,13 @@ export function getAllMetrics(data?: {
isCustom?: boolean;
p?: number;
ps?: number;
-}): Promise<Metric[]> {
+}): Promise<T.Metric[]> {
return inner(data);
function inner(
data: { p?: number; ps?: number } = { ps: 500 },
prev?: MetricsResponse
- ): Promise<Metric[]> {
+ ): Promise<T.Metric[]> {
return getMetrics(data).then(r => {
const result = prev ? prev.metrics.concat(r.metrics) : r.metrics;
if (r.p * r.ps >= r.total) {
@@ -71,7 +70,7 @@ export function createMetric(data: {
key: string;
name: string;
type: string;
-}): Promise<Metric> {
+}): Promise<T.Metric> {
return postJSON('/api/metrics/create', data).catch(throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/nav.ts b/server/sonar-web/src/main/js/api/nav.ts
index e5af1bb7e91..66da48b10ab 100644
--- a/server/sonar-web/src/main/js/api/nav.ts
+++ b/server/sonar-web/src/main/js/api/nav.ts
@@ -18,15 +18,14 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { getJSON } from '../helpers/request';
-import { AppState, BranchParameters } from '../app/types';
import throwGlobalError from '../app/utils/throwGlobalError';
-export function getGlobalNavigation(): Promise<AppState> {
+export function getGlobalNavigation(): Promise<T.AppState> {
return getJSON('/api/navigation/global');
}
export function getComponentNavigation(
- data: { componentKey: string } & BranchParameters
+ data: { componentKey: string } & T.BranchParameters
): Promise<any> {
return getJSON('/api/navigation/component', data).catch(throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/notifications.ts b/server/sonar-web/src/main/js/api/notifications.ts
index d1f0db0e09c..025967c5583 100644
--- a/server/sonar-web/src/main/js/api/notifications.ts
+++ b/server/sonar-web/src/main/js/api/notifications.ts
@@ -17,14 +17,13 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { Notification } from '../app/types';
import throwGlobalError from '../app/utils/throwGlobalError';
import { getJSON, post } from '../helpers/request';
export function getNotifications(): Promise<{
channels: string[];
globalTypes: string[];
- notifications: Notification[];
+ notifications: T.Notification[];
perProjectTypes: string[];
}> {
return getJSON('/api/notifications/list').catch(throwGlobalError);
diff --git a/server/sonar-web/src/main/js/api/organizations.ts b/server/sonar-web/src/main/js/api/organizations.ts
index 79397d3b5a2..deae9b7b39b 100644
--- a/server/sonar-web/src/main/js/api/organizations.ts
+++ b/server/sonar-web/src/main/js/api/organizations.ts
@@ -19,36 +19,29 @@
*/
import { getJSON, post, postJSON } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-import {
- Organization,
- OrganizationBase,
- Paging,
- OrganizationMember,
- Extension
-} from '../app/types';
export function getOrganizations(data: {
organizations?: string;
member?: boolean;
}): Promise<{
- organizations: Organization[];
- paging: Paging;
+ organizations: T.Organization[];
+ paging: T.Paging;
}> {
return getJSON('/api/organizations/search', data).catch(throwGlobalError);
}
-export function getOrganization(key: string): Promise<Organization | undefined> {
+export function getOrganization(key: string): Promise<T.Organization | undefined> {
return getJSON('/api/organizations/search', { organizations: key }).then(
- r => r.organizations.find((o: Organization) => o.key === key),
+ r => r.organizations.find((o: T.Organization) => o.key === key),
throwGlobalError
);
}
interface GetOrganizationNavigation {
- adminPages: Extension[];
+ adminPages: T.Extension[];
canUpdateProjectsVisibilityToPrivate: boolean;
isDefault: boolean;
- pages: Extension[];
+ pages: T.Extension[];
}
export function getOrganizationNavigation(key: string): Promise<GetOrganizationNavigation> {
@@ -59,12 +52,12 @@ export function getOrganizationNavigation(key: string): Promise<GetOrganizationN
}
export function createOrganization(
- data: OrganizationBase & { installationId?: string }
-): Promise<Organization> {
+ data: T.OrganizationBase & { installationId?: string }
+): Promise<T.Organization> {
return postJSON('/api/organizations/create', data).then(r => r.organization, throwGlobalError);
}
-export function updateOrganization(key: string, changes: OrganizationBase) {
+export function updateOrganization(key: string, changes: T.OrganizationBase) {
return post('/api/organizations/update', { key, ...changes }).catch(throwGlobalError);
}
@@ -78,14 +71,14 @@ export function searchMembers(data: {
ps?: number;
q?: string;
selected?: string;
-}): Promise<{ paging: Paging; users: OrganizationMember[] }> {
+}): Promise<{ paging: T.Paging; users: T.OrganizationMember[] }> {
return getJSON('/api/organizations/search_members', data).catch(throwGlobalError);
}
export function addMember(data: {
login: string;
organization: string;
-}): Promise<OrganizationMember> {
+}): Promise<T.OrganizationMember> {
return postJSON('/api/organizations/add_member', data).then(r => r.user, throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/permissions.ts b/server/sonar-web/src/main/js/api/permissions.ts
index 235d5c5ef36..1ba67a885a3 100644
--- a/server/sonar-web/src/main/js/api/permissions.ts
+++ b/server/sonar-web/src/main/js/api/permissions.ts
@@ -18,13 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { BaseSearchProjectsParameters } from './components';
-import {
- Paging,
- PermissionGroup,
- PermissionTemplate,
- PermissionUser,
- Visibility
-} from '../app/types';
import { getJSON, post, postJSON, RequestData } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
@@ -67,7 +60,7 @@ export function revokePermissionFromGroup(data: {
}
interface GetPermissionTemplatesResponse {
- permissionTemplates: PermissionTemplate[];
+ permissionTemplates: T.PermissionTemplate[];
defaultTemplates: Array<{ templateId: string; qualifier: string }>;
permissions: Array<{ key: string; name: string; description: string }>;
}
@@ -150,7 +143,7 @@ export function getPermissionsUsersForComponent(data: {
organization?: string;
p?: number;
ps?: number;
-}): Promise<{ paging: Paging; users: PermissionUser[] }> {
+}): Promise<{ paging: T.Paging; users: T.PermissionUser[] }> {
if (!data.ps) {
data.ps = PAGE_SIZE;
}
@@ -164,7 +157,7 @@ export function getPermissionsGroupsForComponent(data: {
organization?: string;
p?: number;
ps?: number;
-}): Promise<{ paging: Paging; groups: PermissionGroup[] }> {
+}): Promise<{ paging: T.Paging; groups: T.PermissionGroup[] }> {
if (!data.ps) {
data.ps = PAGE_SIZE;
}
@@ -177,7 +170,7 @@ export function getGlobalPermissionsUsers(data: {
organization?: string;
p?: number;
ps?: number;
-}): Promise<{ paging: Paging; users: PermissionUser[] }> {
+}): Promise<{ paging: T.Paging; users: T.PermissionUser[] }> {
if (!data.ps) {
data.ps = PAGE_SIZE;
}
@@ -190,7 +183,7 @@ export function getGlobalPermissionsGroups(data: {
organization?: string;
p?: number;
ps?: number;
-}): Promise<{ paging: Paging; groups: PermissionGroup[] }> {
+}): Promise<{ paging: T.Paging; groups: T.PermissionGroup[] }> {
if (!data.ps) {
data.ps = PAGE_SIZE;
}
@@ -237,14 +230,14 @@ export function getPermissionTemplateGroups(
export function changeProjectVisibility(
project: string,
- visibility: Visibility
+ visibility: T.Visibility
): Promise<void | Response> {
return post('/api/projects/update_visibility', { project, visibility }).catch(throwGlobalError);
}
export function changeProjectDefaultVisibility(
organization: string,
- projectVisibility: Visibility
+ projectVisibility: T.Visibility
): Promise<void | Response> {
return post('/api/projects/update_default_visibility', { organization, projectVisibility }).catch(
throwGlobalError
diff --git a/server/sonar-web/src/main/js/api/projectActivity.ts b/server/sonar-web/src/main/js/api/projectActivity.ts
index d16733b5ebb..8d9af2debc1 100644
--- a/server/sonar-web/src/main/js/api/projectActivity.ts
+++ b/server/sonar-web/src/main/js/api/projectActivity.ts
@@ -19,11 +19,10 @@
*/
import { getJSON, postJSON, post, RequestData } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-import { Paging, BranchParameters, Analysis } from '../app/types';
export function getProjectActivity(
- data: { project: string; category?: string; p?: number; ps?: number } & BranchParameters
-): Promise<{ analyses: Analysis[]; paging: Paging }> {
+ data: { project: string; category?: string; p?: number; ps?: number } & T.BranchParameters
+): Promise<{ analyses: T.Analysis[]; paging: T.Paging }> {
return getJSON('/api/project_analyses/search', data).catch(throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/projectLinks.ts b/server/sonar-web/src/main/js/api/projectLinks.ts
index eec3d0f4a72..2e5e92e6c75 100644
--- a/server/sonar-web/src/main/js/api/projectLinks.ts
+++ b/server/sonar-web/src/main/js/api/projectLinks.ts
@@ -17,11 +17,10 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { ProjectLink } from '../app/types';
import throwGlobalError from '../app/utils/throwGlobalError';
import { getJSON, post, postJSON } from '../helpers/request';
-export function getProjectLinks(projectKey: string): Promise<ProjectLink[]> {
+export function getProjectLinks(projectKey: string): Promise<T.ProjectLink[]> {
return getJSON('/api/project_links/search', { projectKey }).then(r => r.links, throwGlobalError);
}
@@ -33,6 +32,6 @@ export function createLink(data: {
name: string;
projectKey: string;
url: string;
-}): Promise<ProjectLink> {
+}): Promise<T.ProjectLink> {
return postJSON('/api/project_links/create', data).then(r => r.link, throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/quality-gates.ts b/server/sonar-web/src/main/js/api/quality-gates.ts
index af49578283e..cd47f7709e3 100644
--- a/server/sonar-web/src/main/js/api/quality-gates.ts
+++ b/server/sonar-web/src/main/js/api/quality-gates.ts
@@ -19,13 +19,12 @@
*/
import { getJSON, post, postJSON } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-import { Condition, Metric, QualityGate, Omit } from '../app/types';
export function fetchQualityGates(data: {
organization?: string;
}): Promise<{
actions: { create: boolean };
- qualitygates: QualityGate[];
+ qualitygates: T.QualityGate[];
}> {
return getJSON('/api/qualitygates/list', data).catch(throwGlobalError);
}
@@ -33,14 +32,14 @@ export function fetchQualityGates(data: {
export function fetchQualityGate(data: {
id: number;
organization?: string;
-}): Promise<QualityGate> {
+}): Promise<T.QualityGate> {
return getJSON('/api/qualitygates/show', data).catch(throwGlobalError);
}
export function createQualityGate(data: {
name: string;
organization?: string;
-}): Promise<QualityGate> {
+}): Promise<T.QualityGate> {
return postJSON('/api/qualitygates/create', data).catch(throwGlobalError);
}
@@ -63,7 +62,7 @@ export function copyQualityGate(data: {
id: number;
name: string;
organization?: string;
-}): Promise<QualityGate> {
+}): Promise<T.QualityGate> {
return postJSON('/api/qualitygates/copy', data).catch(throwGlobalError);
}
@@ -78,12 +77,14 @@ export function createCondition(
data: {
gateId: number;
organization?: string;
- } & Omit<Condition, 'id'>
-): Promise<Condition> {
+ } & T.Omit<T.Condition, 'id'>
+): Promise<T.Condition> {
return postJSON('/api/qualitygates/create_condition', data);
}
-export function updateCondition(data: { organization?: string } & Condition): Promise<Condition> {
+export function updateCondition(
+ data: { organization?: string } & T.Condition
+): Promise<T.Condition> {
return postJSON('/api/qualitygates/update_condition', data);
}
@@ -94,7 +95,7 @@ export function deleteCondition(data: { id: number; organization?: string }): Pr
export function getGateForProject(data: {
organization?: string;
project: string;
-}): Promise<QualityGate | undefined> {
+}): Promise<T.QualityGate | undefined> {
return getJSON('/api/qualitygates/get_by_project', data).then(
({ qualityGate }) =>
qualityGate && {
@@ -153,7 +154,7 @@ export interface ApplicationProject {
}
export interface ApplicationQualityGate {
- metrics: Metric[];
+ metrics: T.Metric[];
projects: ApplicationProject[];
status: string;
}
diff --git a/server/sonar-web/src/main/js/api/quality-profiles.ts b/server/sonar-web/src/main/js/api/quality-profiles.ts
index d07a6194341..4f1b3bd364e 100644
--- a/server/sonar-web/src/main/js/api/quality-profiles.ts
+++ b/server/sonar-web/src/main/js/api/quality-profiles.ts
@@ -28,7 +28,6 @@ import {
postJSON,
RequestData
} from '../helpers/request';
-import { Paging } from '../app/types';
import throwGlobalError from '../app/utils/throwGlobalError';
export interface ProfileActions {
@@ -193,7 +192,7 @@ export interface SearchUsersResponse {
name: string;
selected?: boolean;
}>;
- paging: Paging;
+ paging: T.Paging;
}
export function searchUsers(parameters: SearchUsersGroupsParameters): Promise<SearchUsersResponse> {
@@ -202,7 +201,7 @@ export function searchUsers(parameters: SearchUsersGroupsParameters): Promise<Se
export interface SearchGroupsResponse {
groups: Array<{ name: string }>;
- paging: Paging;
+ paging: T.Paging;
}
export function searchGroups(
diff --git a/server/sonar-web/src/main/js/api/rules.ts b/server/sonar-web/src/main/js/api/rules.ts
index ea42bf0a1a7..329af4239a8 100644
--- a/server/sonar-web/src/main/js/api/rules.ts
+++ b/server/sonar-web/src/main/js/api/rules.ts
@@ -19,7 +19,6 @@
*/
import { post, getJSON, postJSON } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-import { Rule, RuleDetails, RuleActivation } from '../app/types';
export interface GetRulesAppResponse {
canWrite?: boolean;
@@ -33,11 +32,11 @@ export function getRulesApp(data: {
}
export interface SearchRulesResponse {
- actives?: { [rule: string]: RuleActivation[] };
+ actives?: { [rule: string]: T.RuleActivation[] };
facets?: { property: string; values: { count: number; val: string }[] }[];
p: number;
ps: number;
- rules: Rule[];
+ rules: T.Rule[];
total: number;
}
@@ -57,7 +56,7 @@ export function getRuleDetails(parameters: {
actives?: boolean;
key: string;
organization: string | undefined;
-}): Promise<{ actives?: RuleActivation[]; rule: RuleDetails }> {
+}): Promise<{ actives?: T.RuleActivation[]; rule: T.RuleDetails }> {
return getJSON('/api/rules/show', parameters).catch(throwGlobalError);
}
@@ -80,7 +79,7 @@ export function createRule(data: {
status?: string;
template_key: string;
type?: string;
-}): Promise<RuleDetails> {
+}): Promise<T.RuleDetails> {
return postJSON('/api/rules/create', data).then(
r => r.rule,
error => {
@@ -112,6 +111,6 @@ export function updateRule(data: {
severity?: string;
status?: string;
tags?: string;
-}): Promise<RuleDetails> {
+}): Promise<T.RuleDetails> {
return postJSON('/api/rules/update', data).then(r => r.rule, throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/security-reports.ts b/server/sonar-web/src/main/js/api/security-reports.ts
index 2747ea7536f..eba073fc227 100644
--- a/server/sonar-web/src/main/js/api/security-reports.ts
+++ b/server/sonar-web/src/main/js/api/security-reports.ts
@@ -17,7 +17,6 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { SecurityHotspot } from '../app/types';
import { getJSON } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
@@ -26,6 +25,6 @@ export function getSecurityHotspots(data: {
standard: 'owaspTop10' | 'sansTop25' | 'cwe';
includeDistribution?: boolean;
branch?: string;
-}): Promise<{ categories: Array<SecurityHotspot> }> {
+}): Promise<{ categories: T.SecurityHotspot[] }> {
return getJSON('/api/security_reports/show', data).catch(throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/settings.ts b/server/sonar-web/src/main/js/api/settings.ts
index 11b37f1d02f..ae7339db76c 100644
--- a/server/sonar-web/src/main/js/api/settings.ts
+++ b/server/sonar-web/src/main/js/api/settings.ts
@@ -19,17 +19,10 @@
*/
import { omitBy } from 'lodash';
import { getJSON, RequestData, post, postJSON } from '../helpers/request';
-import {
- BranchParameters,
- SettingCategoryDefinition,
- SettingValue,
- SettingType,
- SettingDefinition
-} from '../app/types';
import throwGlobalError from '../app/utils/throwGlobalError';
import { isCategoryDefinition } from '../apps/settings/utils';
-export function getDefinitions(component?: string): Promise<SettingCategoryDefinition[]> {
+export function getDefinitions(component?: string): Promise<T.SettingCategoryDefinition[]> {
return getJSON('/api/settings/list_definitions', { component }).then(
r => r.definitions,
throwGlobalError
@@ -37,13 +30,13 @@ export function getDefinitions(component?: string): Promise<SettingCategoryDefin
}
export function getValues(
- data: { keys: string; component?: string } & BranchParameters
-): Promise<SettingValue[]> {
+ data: { keys: string; component?: string } & T.BranchParameters
+): Promise<T.SettingValue[]> {
return getJSON('/api/settings/values', data).then(r => r.settings);
}
export function setSettingValue(
- definition: SettingDefinition,
+ definition: T.SettingDefinition,
value: any,
component?: string
): Promise<void> {
@@ -52,7 +45,7 @@ export function setSettingValue(
if (isCategoryDefinition(definition) && definition.multiValues) {
data.values = value;
- } else if (definition.type === SettingType.PropertySet) {
+ } else if (definition.type === 'PROPERTY_SET') {
data.fieldValues = value
.map((fields: any) => omitBy(fields, value => value == null))
.map(JSON.stringify);
@@ -64,13 +57,13 @@ export function setSettingValue(
}
export function setSimpleSettingValue(
- data: { component?: string; value: string; key: string } & BranchParameters
+ data: { component?: string; value: string; key: string } & T.BranchParameters
): Promise<void | Response> {
return post('/api/settings/set', data).catch(throwGlobalError);
}
export function resetSettingValue(
- data: { keys: string; component?: string } & BranchParameters
+ data: { keys: string; component?: string } & T.BranchParameters
): Promise<void> {
return post('/api/settings/reset', data);
}
diff --git a/server/sonar-web/src/main/js/api/tests.ts b/server/sonar-web/src/main/js/api/tests.ts
index 5b649d1d99b..7dbb75c19af 100644
--- a/server/sonar-web/src/main/js/api/tests.ts
+++ b/server/sonar-web/src/main/js/api/tests.ts
@@ -18,7 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import throwGlobalError from '../app/utils/throwGlobalError';
-import { Paging, TestCase, CoveredFile, BranchParameters } from '../app/types';
import { getJSON } from '../helpers/request';
export function getTests(
@@ -29,11 +28,11 @@ export function getTests(
sourceFileLineNumber?: number;
testFileKey: string;
testId?: string;
- } & BranchParameters
-): Promise<{ paging: Paging; tests: TestCase[] }> {
+ } & T.BranchParameters
+): Promise<{ paging: T.Paging; tests: T.TestCase[] }> {
return getJSON('/api/tests/list', parameters).catch(throwGlobalError);
}
-export function getCoveredFiles(data: { testId: string }): Promise<CoveredFile[]> {
+export function getCoveredFiles(data: { testId: string }): Promise<T.CoveredFile[]> {
return getJSON('/api/tests/covered_files', data).then(r => r.files, throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/time-machine.ts b/server/sonar-web/src/main/js/api/time-machine.ts
index d397c89345e..6e52132de85 100644
--- a/server/sonar-web/src/main/js/api/time-machine.ts
+++ b/server/sonar-web/src/main/js/api/time-machine.ts
@@ -18,7 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { getJSON } from '../helpers/request';
-import { Paging, BranchParameters } from '../app/types';
import throwGlobalError from '../app/utils/throwGlobalError';
interface TimeMachineResponse {
@@ -26,7 +25,7 @@ interface TimeMachineResponse {
metric: string;
history: Array<{ date: string; value?: string }>;
}[];
- paging: Paging;
+ paging: T.Paging;
}
export function getTimeMachineData(
@@ -37,7 +36,7 @@ export function getTimeMachineData(
p?: number;
ps?: number;
to?: string;
- } & BranchParameters
+ } & T.BranchParameters
): Promise<TimeMachineResponse> {
return getJSON('/api/measures/search_history', data).catch(throwGlobalError);
}
@@ -49,7 +48,7 @@ export function getAllTimeMachineData(
from?: string;
p?: number;
to?: string;
- } & BranchParameters,
+ } & T.BranchParameters,
prev?: TimeMachineResponse
): Promise<TimeMachineResponse> {
return getTimeMachineData({ ...data, ps: 1000 }).then(r => {
diff --git a/server/sonar-web/src/main/js/api/user_groups.ts b/server/sonar-web/src/main/js/api/user_groups.ts
index eadd920a5f0..d64fde6cf26 100644
--- a/server/sonar-web/src/main/js/api/user_groups.ts
+++ b/server/sonar-web/src/main/js/api/user_groups.ts
@@ -18,7 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { getJSON, post, postJSON } from '../helpers/request';
-import { Paging, Group } from '../app/types';
import throwGlobalError from '../app/utils/throwGlobalError';
export function searchUsersGroups(data: {
@@ -27,7 +26,7 @@ export function searchUsersGroups(data: {
p?: number;
ps?: number;
q?: string;
-}): Promise<{ groups: Group[]; paging: Paging }> {
+}): Promise<{ groups: T.Group[]; paging: T.Paging }> {
return getJSON('/api/user_groups/search', data).catch(throwGlobalError);
}
@@ -45,7 +44,7 @@ export function getUsersInGroup(data: {
ps?: number;
q?: string;
selected?: string;
-}): Promise<{ paging: Paging; users: GroupUser[] }> {
+}): Promise<{ paging: T.Paging; users: GroupUser[] }> {
return getJSON('/api/user_groups/users', data).catch(throwGlobalError);
}
@@ -71,7 +70,7 @@ export function createGroup(data: {
description?: string;
organization: string | undefined;
name: string;
-}): Promise<Group> {
+}): Promise<T.Group> {
return postJSON('/api/user_groups/create', data).then(r => r.group, throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/users.ts b/server/sonar-web/src/main/js/api/users.ts
index 1954f192c50..75405a9173f 100644
--- a/server/sonar-web/src/main/js/api/users.ts
+++ b/server/sonar-web/src/main/js/api/users.ts
@@ -19,9 +19,8 @@
*/
import { getJSON, post, postJSON, RequestData } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-import { Paging, HomePage, CurrentUser, IdentityProvider, User } from '../app/types';
-export function getCurrentUser(): Promise<CurrentUser> {
+export function getCurrentUser(): Promise<T.CurrentUser> {
return getJSON('/api/users/current');
}
@@ -46,7 +45,7 @@ export function getUserGroups(
organization?: string,
query?: string,
selected?: string
-): Promise<{ paging: Paging; groups: UserGroup[] }> {
+): Promise<{ paging: T.Paging; groups: UserGroup[] }> {
const data: RequestData = { login };
if (organization) {
data.organization = organization;
@@ -60,7 +59,7 @@ export function getUserGroups(
return getJSON('/api/users/groups', data);
}
-export function getIdentityProviders(): Promise<{ identityProviders: IdentityProvider[] }> {
+export function getIdentityProviders(): Promise<{ identityProviders: T.IdentityProvider[] }> {
return getJSON('/api/users/identity_providers').catch(throwGlobalError);
}
@@ -68,7 +67,7 @@ export function searchUsers(data: {
p?: number;
ps?: number;
q?: string;
-}): Promise<{ paging: Paging; users: User[] }> {
+}): Promise<{ paging: T.Paging; users: T.User[] }> {
data.q = data.q || undefined;
return getJSON('/api/users/search', data).catch(throwGlobalError);
}
@@ -89,14 +88,14 @@ export function updateUser(data: {
login: string;
name?: string;
scmAccount: string[];
-}): Promise<User> {
+}): Promise<T.User> {
return postJSON('/api/users/update', {
...data,
scmAccount: data.scmAccount.length > 0 ? data.scmAccount : ''
});
}
-export function deactivateUser(data: { login: string }): Promise<User> {
+export function deactivateUser(data: { login: string }): Promise<T.User> {
return postJSON('/api/users/deactivate', data).catch(throwGlobalError);
}
@@ -104,6 +103,6 @@ export function skipOnboarding(): Promise<void | Response> {
return post('/api/users/skip_onboarding_tutorial').catch(throwGlobalError);
}
-export function setHomePage(homepage: HomePage): Promise<void | Response> {
+export function setHomePage(homepage: T.HomePage): Promise<void | Response> {
return post('/api/users/set_homepage', homepage).catch(throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/webhooks.ts b/server/sonar-web/src/main/js/api/webhooks.ts
index a51a01c0948..b3327608c25 100644
--- a/server/sonar-web/src/main/js/api/webhooks.ts
+++ b/server/sonar-web/src/main/js/api/webhooks.ts
@@ -19,14 +19,13 @@
*/
import { getJSON, post, postJSON } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-import { Webhook, WebhookDelivery, Paging } from '../app/types';
export function createWebhook(data: {
name: string;
organization: string | undefined;
project?: string;
url: string;
-}): Promise<{ webhook: Webhook }> {
+}): Promise<{ webhook: T.Webhook }> {
return postJSON('/api/webhooks/create', data).catch(throwGlobalError);
}
@@ -37,7 +36,7 @@ export function deleteWebhook(data: { webhook: string }): Promise<void | Respons
export function searchWebhooks(data: {
organization: string | undefined;
project?: string;
-}): Promise<{ webhooks: Webhook[] }> {
+}): Promise<{ webhooks: T.Webhook[] }> {
return getJSON('/api/webhooks/list', data).catch(throwGlobalError);
}
@@ -56,14 +55,14 @@ export function searchDeliveries(data: {
p?: number;
ps?: number;
}): Promise<{
- deliveries: WebhookDelivery[];
- paging: Paging;
+ deliveries: T.WebhookDelivery[];
+ paging: T.Paging;
}> {
return getJSON('/api/webhooks/deliveries', data).catch(throwGlobalError);
}
export function getDelivery(data: {
deliveryId: string;
-}): Promise<{ delivery: WebhookDelivery & { payload: string } }> {
+}): Promise<{ delivery: T.WebhookDelivery & { payload: string } }> {
return getJSON('/api/webhooks/delivery', data).catch(throwGlobalError);
}