@roadiehq/backstage-plugin-github-pull-requests
Version:
191 lines (181 loc) • 6.91 kB
TypeScript
import * as _backstage_plugin_home_react from '@backstage/plugin-home-react';
import * as _backstage_core_components from '@backstage/core-components';
import { InfoCardVariants } from '@backstage/core-components';
import * as _backstage_catalog_model from '@backstage/catalog-model';
import { Entity } from '@backstage/catalog-model';
import * as react_jsx_runtime from 'react/jsx-runtime';
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
import { ConfigApi } from '@backstage/core-plugin-api';
import { Octokit } from '@octokit/rest';
import { GetResponseTypeFromEndpointMethod } from '@octokit/types';
import { ScmAuthApi } from '@backstage/integration-react';
import { FC } from 'react';
declare const githubPullRequestsPlugin: _backstage_core_plugin_api.BackstagePlugin<{
entityContent: _backstage_core_plugin_api.RouteRef<undefined>;
}, {}, {}>;
declare const EntityGithubPullRequestsContent: () => react_jsx_runtime.JSX.Element;
declare const EntityGithubPullRequestsOverviewCard: (props: {
entity?: _backstage_catalog_model.Entity;
variant?: _backstage_core_components.InfoCardVariants;
}) => react_jsx_runtime.JSX.Element;
declare const EntityGithubPullRequestsTable: (__props: {
entity?: _backstage_catalog_model.Entity;
branch?: string;
}) => react_jsx_runtime.JSX.Element;
declare const HomePageRequestedReviewsCard: (props: _backstage_plugin_home_react.CardExtensionProps<{
query?: string;
hostname?: string;
}>) => react_jsx_runtime.JSX.Element;
declare const HomePageYourOpenPullRequestsCard: (props: _backstage_plugin_home_react.CardExtensionProps<{
query?: string;
hostname?: string;
}>) => react_jsx_runtime.JSX.Element;
declare const EntityGithubGroupPullRequestsCard: (props: _backstage_plugin_home_react.CardExtensionProps<unknown>) => react_jsx_runtime.JSX.Element;
declare const octokit: Octokit;
type GetSearchPullRequestsResponseType = GetResponseTypeFromEndpointMethod<typeof octokit.search.issuesAndPullRequests>;
type SearchPullRequestsResponseDataItems = {
items: Array<Omit<GetSearchPullRequestsResponseType['data']['items'][number], 'pull_request'> & {
draft: boolean;
pull_request: {
html_url: string;
diff_url: string;
patch_url: string;
merged_at: string | null;
url: string;
};
user: {
login: string | null;
html_url: string;
} | null;
}>;
};
type SearchPullRequestsResponseData = Omit<GetSearchPullRequestsResponseType['data'], 'items'> & SearchPullRequestsResponseDataItems;
type GithubSearchPullRequestsDataItem = {
id: number;
state: string;
draft: boolean;
merged?: string;
repositoryUrl: string;
pullRequest: {
htmlUrl?: string;
created_at?: string;
};
title: string;
number: number;
user: {
login?: string;
htmlUrl?: string;
};
comments: number;
htmlUrl: string;
};
type GithubRepositoryData = {
htmlUrl: string;
fullName: string;
additions: number;
deletions: number;
changedFiles: number;
};
type GithubFirstCommitDate = {
firstCommitDate: Date;
};
declare const githubPullRequestsApiRef: _backstage_core_plugin_api.ApiRef<GithubPullRequestsApi>;
type GithubPullRequestsApi = {
listPullRequests: ({ search, owner, repo, pageSize, page, branch, hostname, }: {
search: string;
owner: string;
repo: string;
pageSize?: number;
page?: number;
branch?: string;
hostname?: string;
}) => Promise<{
pullRequestsData: SearchPullRequestsResponseData;
}>;
getRepositoryData: ({ hostname, url, }: {
hostname?: string;
url: string;
}) => Promise<GithubRepositoryData>;
getCommitDetailsData({ hostname, owner, repo, number, }: {
hostname?: string;
owner: string;
repo: string;
number: number;
}): Promise<GithubFirstCommitDate>;
searchPullRequest({ query, hostname, }: {
query: string;
hostname?: string;
}): Promise<GithubSearchPullRequestsDataItem[]>;
};
declare class GithubPullRequestsClient implements GithubPullRequestsApi {
private readonly configApi;
private readonly scmAuthApi;
constructor(options: {
configApi: ConfigApi;
scmAuthApi: ScmAuthApi;
});
private getOctokit;
listPullRequests({ search, owner, repo, pageSize, page, hostname, }: {
search: string;
owner: string;
repo: string;
pageSize?: number;
page?: number;
hostname?: string;
}): Promise<{
pullRequestsData: SearchPullRequestsResponseData;
}>;
getRepositoryData({ hostname, url, }: {
hostname?: string;
url: string;
}): Promise<GithubRepositoryData>;
getCommitDetailsData({ hostname, owner, repo, number, }: {
hostname: string;
owner: string;
repo: string;
number: number;
}): Promise<GithubFirstCommitDate>;
searchPullRequest({ query, hostname, }: {
query: string;
hostname?: string;
}): Promise<GithubSearchPullRequestsDataItem[]>;
}
declare const isGithubPullRequestsAvailable: (entity: Entity) => boolean;
declare const isGithubTeamPullRequestsAvailable: (entity: Entity) => boolean;
declare const Router: () => react_jsx_runtime.JSX.Element;
type Props$1 = {
/** @deprecated The entity is now grabbed from context instead */
entity?: Entity;
variant?: InfoCardVariants;
};
declare const PullRequestsStatsCard: (props: Props$1) => react_jsx_runtime.JSX.Element;
type PullRequest = {
id: number;
number: number;
url: string;
title: string;
updatedTime: string | null;
createdTime: string | null;
state: string;
draft: boolean;
merged: string | null;
creatorNickname?: string | null;
creatorProfileLink?: string | null;
body: string;
};
type Props = {
loading: boolean;
retry: () => void;
projectName: string;
page: number;
prData?: PullRequest[];
onChangePage: (page: number) => void;
total: number;
totalResults: number;
pageSize: number;
onChangePageSize: (pageSize: number) => void;
StateFilterComponent?: FC<{}>;
SearchComponent?: FC<{}>;
};
declare const PullRequestsTableView: FC<Props>;
export { EntityGithubGroupPullRequestsCard, EntityGithubPullRequestsContent, EntityGithubPullRequestsOverviewCard, EntityGithubPullRequestsTable, type GithubPullRequestsApi, GithubPullRequestsClient, HomePageRequestedReviewsCard, HomePageYourOpenPullRequestsCard, PullRequestsStatsCard, PullRequestsTableView, Router, githubPullRequestsApiRef, githubPullRequestsPlugin, isGithubPullRequestsAvailable, isGithubTeamPullRequestsAvailable, isGithubPullRequestsAvailable as isPluginApplicableToEntity, githubPullRequestsPlugin as plugin };