@immobiliarelabs/backstage-plugin-gitlab
Version:
245 lines (235 loc) • 11.9 kB
TypeScript
/// <reference types="react" />
import * as React from 'react';
import * as _backstage_core_components from '@backstage/core-components';
import { InfoCardVariants } from '@backstage/core-components';
import * as _backstage_catalog_model_index from '@backstage/catalog-model/index';
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
import { DiscoveryApi, IdentityApi, OAuthApi } from '@backstage/core-plugin-api';
import { RepositoryContributorSchema, UserSchema, SimpleMemberSchema, PipelineSchema, MergeRequestSchema, ProjectSchema, IssueSchema, ReleaseSchema, TagSchema } from '@gitbeaker/rest';
import { Entity } from '@backstage/catalog-model';
import * as _backstage_core_plugin_api_alpha from '@backstage/core-plugin-api/alpha';
type sortRule = 'releasedVersion' | 'releasedDate';
/**
* Properties for {@link ReleasesCard}
*
* @public
*/
interface ReleasesCardProps {
/**
* Title - The title of the card shown on ReleaseCard component
*/
title?: string;
/**
* Filter
*
* all - show all releases (default)
* patch - major, minor, patch - no pre-releases
*
*/
show?: string;
/**
* Limit - show only a maximum number of releases
*/
limit?: number;
/**
* Sort - Determines the order of releases
* @default 'releasedDate'
*/
sort?: sortRule;
/**
* Determines if the sort selector should be shown
*/
showSortSelector?: boolean;
/**
* Determines InfoCard variant
*/
variant?: InfoCardVariants;
}
type GitlabPageProps = {
release?: ReleasesCardProps;
};
declare const gitlabPlugin: _backstage_core_plugin_api.BackstagePlugin<{}, {}, {}>;
declare const EntityGitlabContent: (props: GitlabPageProps) => React.JSX.Element;
declare const EntityGitlabLanguageCard: (props: {
variant?: _backstage_core_components.InfoCardVariants | undefined;
}) => React.JSX.Element;
declare const EntityGitlabPeopleCard: (props: {
variant?: _backstage_core_components.InfoCardVariants | undefined;
disableMembersList?: boolean | undefined;
}) => React.JSX.Element;
declare const EntityGitlabMergeRequestsTable: ({}: {}) => React.JSX.Element;
declare const EntityGitlabMergeRequestStatsCard: (props: {
entity?: _backstage_catalog_model_index.Entity | undefined;
variant?: _backstage_core_components.InfoCardVariants | undefined;
}) => React.JSX.Element;
declare const EntityGitlabPipelinesTable: ({}: {}) => React.JSX.Element;
declare const EntityGitlabReleasesCard: (props: ReleasesCardProps) => React.JSX.Element;
declare const EntityGitlabCoverageCard: (props: {
variant?: _backstage_core_components.InfoCardVariants | undefined;
}) => React.JSX.Element;
declare const EntityGitlabIssuesTable: ({}: {}) => React.JSX.Element;
declare const EntityGitlabReadmeCard: (props: {
variant?: _backstage_core_components.InfoCardVariants | undefined;
markdownClasses?: string | undefined;
}) => React.JSX.Element;
type PeopleCardEntityData = {
name: string;
email?: string;
avatar_url?: string;
id?: number;
state?: string;
username?: string;
web_url?: string;
full_path?: string;
};
type Languages = {
[key: string]: number;
};
type ContributorsSummary = (RepositoryContributorSchema & Partial<UserSchema>)[];
type MembersSummary = (SimpleMemberSchema & Partial<UserSchema>)[];
type LanguagesSummary = Languages;
declare const GitlabCIApiRef: _backstage_core_plugin_api.ApiRef<GitlabCIBuilder>;
type GitlabCIBuilder = {
build(gitlabInstance: string): GitlabCIApi;
};
type GraphQLQuery = {
variables: Record<string, string>;
query: string;
};
type GitlabProjectCoverageResponse = {
data: {
project: {
pipelines: {
nodes: {
coverage: number;
createdAt: string;
}[];
};
};
};
};
type GitlabCIApi = {
getPipelineSummary(projectID: string | number): Promise<PipelineSchema[] | undefined>;
getContributorsSummary(projectID: string | number): Promise<ContributorsSummary | undefined>;
getMembersSummary(projectID: string | number): Promise<MembersSummary | undefined>;
getMergeRequestsSummary(projectID: string | number): Promise<MergeRequestSchema[] | undefined>;
getMergeRequestsStatusSummary(projectID: string | number, count: number): Promise<MergeRequestSchema[] | undefined>;
getProjectName(projectID: string | number): Promise<string | undefined>;
getLanguagesSummary(projectID: string | number): Promise<LanguagesSummary | undefined>;
getProjectDetails(projectSlug: string): Promise<ProjectSchema | undefined>;
getProjectCoverage(projectSlug: string, projectDefaultBranch: string): Promise<GitlabProjectCoverageResponse | undefined>;
getIssuesSummary(projectID: string | number): Promise<IssueSchema[] | undefined>;
getCodeOwners(projectID: string | number, branch?: string, filePath?: string): Promise<PeopleCardEntityData[]>;
getReleasesSummary(projectID: string | number): Promise<ReleaseSchema[] | undefined>;
getTags(projectID: string | number): Promise<TagSchema[] | undefined>;
getContributorsLink(projectWebUrl: string, projectDefaultBranch: string): string;
getMembersLink(projectWebUrl: string): string;
getOwnersLink(projectWebUrl: string, projectDefaultBranch: string, codeOwnersPath?: string): string;
getReadme(projectID: string | number, branch?: string, filePath?: string): Promise<string | undefined>;
};
type APIOptions = {
discoveryApi: DiscoveryApi;
identityApi: IdentityApi;
codeOwnersPath?: string;
readmePath?: string;
gitlabAuthApi: OAuthApi;
useOAuth?: boolean;
cache?: {
enabled?: boolean;
ttl?: number;
};
httpFetch?: typeof fetch;
};
declare class GitlabCIClient implements GitlabCIApi {
discoveryApi: DiscoveryApi;
identityApi: IdentityApi;
gitlabAuthApi: OAuthApi;
useOAth: boolean;
codeOwnersPath: string;
gitlabInstance: string;
readmePath: string;
cacheTTL?: number;
cacheEnabled: boolean;
httpFetch: typeof fetch;
constructor({ discoveryApi, identityApi, codeOwnersPath, readmePath, gitlabAuthApi, gitlabInstance, cache, useOAuth, httpFetch, }: APIOptions & {
gitlabInstance: string;
});
static setupAPI({ discoveryApi, identityApi, codeOwnersPath, readmePath, gitlabAuthApi, useOAuth, cache, }: APIOptions): {
build: (gitlabInstance: string) => GitlabCIClient;
};
private cleanupExpiredCache;
private getCacheKey;
private getCachedData;
private setCachedData;
protected callApi<T>(path: string, query: {
[key in string]: string;
}, APIkind?: 'rest' | 'graphql', options?: RequestInit): Promise<T | undefined>;
protected callGraphQLApi<T>(query: GraphQLQuery): Promise<T | undefined>;
getPipelineSummary(projectID?: string | number): Promise<PipelineSchema[] | undefined>;
getIssuesSummary(projectId: string | number): Promise<IssueSchema[] | undefined>;
getProjectName(projectID?: string | number): Promise<string | undefined>;
private getUserProfilesData;
private getUserMembersData;
private getUserDetail;
private getGroupDetail;
getMergeRequestsSummary(projectID?: string | number): Promise<MergeRequestSchema[] | undefined>;
getMergeRequestsStatusSummary(projectID?: string | number, count?: number): Promise<MergeRequestSchema[] | undefined>;
getContributorsSummary(projectID?: string | number): Promise<ContributorsSummary | undefined>;
getMembersSummary(projectID?: string | number): Promise<MembersSummary | undefined>;
getLanguagesSummary(projectID?: string | number): Promise<LanguagesSummary | undefined>;
getReleasesSummary(projectID: string | number): Promise<ReleaseSchema[] | undefined>;
getTags(projectID: string | number): Promise<TagSchema[] | undefined>;
getProjectDetails(projectSlug: string): Promise<ProjectSchema | undefined>;
getProjectCoverage(projectSlug: string, projectDefaultBranch: string): Promise<GitlabProjectCoverageResponse | undefined>;
getCodeOwners(projectID: string | number, branch?: string, filePath?: string): Promise<PeopleCardEntityData[]>;
getReadme(projectID: string | number, branch?: string, filePath?: string): Promise<string | undefined>;
getContributorsLink(projectWebUrl: string, projectDefaultBranch: string): string;
getMembersLink(projectWebUrl: string): string;
getOwnersLink(projectWebUrl: string, projectDefaultBranch: string, codeOwnersPath?: string): string;
}
declare const isGitlabAvailable: (entity: Entity) => boolean;
declare const gitlabTranslationRef: _backstage_core_plugin_api_alpha.TranslationRef<"Gitlab", {
readonly "coverageCard.title": "Coverage statistics";
readonly "coverageCard.deepLinkTitle": "go to Analytics";
readonly "coverageCard.lastCoverage": "Last Coverage: ";
readonly "coverageCard.noData": "No data";
readonly "issuesTable.title": "Gitlab Issues: {{projectName}}";
readonly "issuesTable.columnsTitle.title": "Title";
readonly "issuesTable.columnsTitle.issueId": "Issue ID";
readonly "issuesTable.columnsTitle.author": "Author";
readonly "issuesTable.columnsTitle.createdAt": "Created At";
readonly "issuesTable.columnsTitle.issueType": "Issue Type";
readonly "issuesTable.columnsTitle.issueStatus": "Issue Status";
readonly "issuesTable.status.open": "open";
readonly "issuesTable.status.close": "close";
readonly "languagesCard.title": "Languages";
readonly "mergeRequestsTable.title": "Gitlab Merge Request Status: {{projectName}}";
readonly "mergeRequestsTable.columnsTitle.state": "State";
readonly "mergeRequestsTable.columnsTitle.title": "Title";
readonly "mergeRequestsTable.columnsTitle.createdAt": "Created At";
readonly "mergeRequestsTable.columnsTitle.creator": "Creator";
readonly "mergeRequestsTable.columnsTitle.duration": "Duration";
readonly "mergeRequestStats.title": "Merge Request Statistics";
readonly "mergeRequestStats.helperText": "Number of MRs";
readonly "peopleCard.title": "People";
readonly "peopleCard.ownerList.title": "Owners";
readonly "peopleCard.ownerList.deepLinkTitle": "go to Owners File";
readonly "peopleCard.contributorList.title": "Contributors";
readonly "peopleCard.contributorList.deepLinkTitle": "go to Contributors";
readonly "peopleCard.memberList.title": "Members";
readonly "peopleCard.memberList.deepLinkTitle": "go to Members";
readonly "pipelinesTable.title": "Gitlab Pipelines: {{projectName}}";
readonly "pipelinesTable.columnsTitle.createdAt": "Created At";
readonly "pipelinesTable.columnsTitle.status": "Status";
readonly "pipelinesTable.columnsTitle.duration": "Duration";
readonly "pipelinesTable.columnsTitle.pipelineID": "Pipeline ID";
readonly "pipelinesTable.columnsTitle.branch": "Branch";
readonly "pipelinesTable.columnsTitle.webURL": "Web URL";
readonly "readmeCard.noReadme": "No README found";
readonly "releasesCard.title": "Releases";
readonly "releasesCard.deepLinkTitle": "go to Releases";
readonly "releasesCard.noReleases": "No releases have been made";
readonly "releasesCard.releasedDate": "Released Date";
readonly "releasesCard.releasedVersion": "Released Version";
}>;
export { type ContributorsSummary, EntityGitlabContent, EntityGitlabCoverageCard, EntityGitlabIssuesTable, EntityGitlabLanguageCard, EntityGitlabMergeRequestStatsCard, EntityGitlabMergeRequestsTable, EntityGitlabPeopleCard, EntityGitlabPipelinesTable, EntityGitlabReadmeCard, EntityGitlabReleasesCard, type GitlabCIApi, GitlabCIApiRef, GitlabCIClient, type LanguagesSummary, type MembersSummary, gitlabPlugin, gitlabTranslationRef, isGitlabAvailable };