[MISC] Fix Swagger and Regenerate WEB Services (#246)

This commit is contained in:
Johannes Batzill 2023-01-24 15:46:49 -08:00 committed by GitHub
parent b700603fef
commit 2227e13e7d
12 changed files with 500 additions and 149 deletions

View File

@ -416,7 +416,7 @@ func pullReqOperations(reflector *openapi3.Reflector) {
opListCommits := openapi3.Operation{} opListCommits := openapi3.Operation{}
opListCommits.WithTags("pullreq") opListCommits.WithTags("pullreq")
opListCommits.WithMapOfAnything(map[string]interface{}{"operationId": "listCommits"}) opListCommits.WithMapOfAnything(map[string]interface{}{"operationId": "listPullReqCommits"})
opListCommits.WithParameters(queryParameterPage, queryParameterLimit) opListCommits.WithParameters(queryParameterPage, queryParameterLimit)
_ = reflector.SetRequest(&opListCommits, new(pullReqRequest), http.MethodGet) _ = reflector.SetRequest(&opListCommits, new(pullReqRequest), http.MethodGet)
_ = reflector.SetJSONResponse(&opListCommits, []types.Commit{}, http.StatusOK) _ = reflector.SetJSONResponse(&opListCommits, []types.Commit{}, http.StatusOK)
@ -428,7 +428,7 @@ func pullReqOperations(reflector *openapi3.Reflector) {
opRawDiff := openapi3.Operation{} opRawDiff := openapi3.Operation{}
opRawDiff.WithTags("pullreq") opRawDiff.WithTags("pullreq")
opRawDiff.WithMapOfAnything(map[string]interface{}{"operationId": "rawDiff"}) opRawDiff.WithMapOfAnything(map[string]interface{}{"operationId": "rawPullReqDiff"})
_ = reflector.SetRequest(&opRawDiff, new(pullReqRequest), http.MethodGet) _ = reflector.SetRequest(&opRawDiff, new(pullReqRequest), http.MethodGet)
_ = reflector.SetStringResponse(&opRawDiff, http.StatusOK, "text/plain") _ = reflector.SetStringResponse(&opRawDiff, http.StatusOK, "text/plain")
_ = reflector.SetJSONResponse(&opRawDiff, new(usererror.Error), http.StatusInternalServerError) _ = reflector.SetJSONResponse(&opRawDiff, new(usererror.Error), http.StatusInternalServerError)

View File

@ -4,7 +4,7 @@ import type { CellProps, Column } from 'react-table'
import { orderBy } from 'lodash-es' import { orderBy } from 'lodash-es'
import { useStrings } from 'framework/strings' import { useStrings } from 'framework/strings'
import { useAppContext } from 'AppContext' import { useAppContext } from 'AppContext'
import type { RepoCommit } from 'services/code' import type { TypesCommit } from 'services/code'
import { CommitActions } from 'components/CommitActions/CommitActions' import { CommitActions } from 'components/CommitActions/CommitActions'
import { NoResultCard } from 'components/NoResultCard/NoResultCard' import { NoResultCard } from 'components/NoResultCard/NoResultCard'
import { ThreadSection } from 'components/ThreadSection/ThreadSection' import { ThreadSection } from 'components/ThreadSection/ThreadSection'
@ -13,7 +13,7 @@ import { CodeIcon, GitInfoProps } from 'utils/GitUtils'
import css from './CommitsView.module.scss' import css from './CommitsView.module.scss'
interface CommitsViewProps extends Pick<GitInfoProps, 'repoMetadata'> { interface CommitsViewProps extends Pick<GitInfoProps, 'repoMetadata'> {
commits: RepoCommit[] commits: TypesCommit[]
emptyTitle: string emptyTitle: string
emptyMessage: string emptyMessage: string
} }
@ -21,12 +21,12 @@ interface CommitsViewProps extends Pick<GitInfoProps, 'repoMetadata'> {
export function CommitsView({ repoMetadata, commits, emptyTitle, emptyMessage }: CommitsViewProps) { export function CommitsView({ repoMetadata, commits, emptyTitle, emptyMessage }: CommitsViewProps) {
const { getString } = useStrings() const { getString } = useStrings()
const { routes } = useAppContext() const { routes } = useAppContext()
const columns: Column<RepoCommit>[] = useMemo( const columns: Column<TypesCommit>[] = useMemo(
() => [ () => [
{ {
id: 'author', id: 'author',
width: '20%', width: '20%',
Cell: ({ row }: CellProps<RepoCommit>) => { Cell: ({ row }: CellProps<TypesCommit>) => {
return ( return (
<Layout.Horizontal spacing="small" flex={{ alignItems: 'center' }} style={{ display: 'inline-flex' }}> <Layout.Horizontal spacing="small" flex={{ alignItems: 'center' }} style={{ display: 'inline-flex' }}>
<Avatar hoverCard={false} size="small" name={row.original.author?.identity?.name || ''} /> <Avatar hoverCard={false} size="small" name={row.original.author?.identity?.name || ''} />
@ -40,7 +40,7 @@ export function CommitsView({ repoMetadata, commits, emptyTitle, emptyMessage }:
{ {
id: 'commit', id: 'commit',
width: 'calc(80% - 100px)', width: 'calc(80% - 100px)',
Cell: ({ row }: CellProps<RepoCommit>) => { Cell: ({ row }: CellProps<TypesCommit>) => {
return ( return (
<Text color={Color.BLACK} lineClamp={1} className={css.rowText}> <Text color={Color.BLACK} lineClamp={1} className={css.rowText}>
{row.original.message} {row.original.message}
@ -51,7 +51,7 @@ export function CommitsView({ repoMetadata, commits, emptyTitle, emptyMessage }:
{ {
id: 'sha', id: 'sha',
width: '100px', width: '100px',
Cell: ({ row }: CellProps<RepoCommit>) => { Cell: ({ row }: CellProps<TypesCommit>) => {
return ( return (
<CommitActions <CommitActions
sha={row.original.sha as string} sha={row.original.sha as string}
@ -67,13 +67,13 @@ export function CommitsView({ repoMetadata, commits, emptyTitle, emptyMessage }:
], ],
[repoMetadata.path, routes] [repoMetadata.path, routes]
) )
const commitsGroupedByDate: Record<string, RepoCommit[]> = useMemo( const commitsGroupedByDate: Record<string, TypesCommit[]> = useMemo(
() => () =>
commits?.reduce((group, commit) => { commits?.reduce((group, commit) => {
const date = formatDate(commit.author?.when as string) const date = formatDate(commit.author?.when as string)
group[date] = (group[date] || []).concat(commit) group[date] = (group[date] || []).concat(commit)
return group return group
}, {} as Record<string, RepoCommit[]>) || {}, }, {} as Record<string, TypesCommit[]>) || {},
[commits] [commits]
) )
@ -89,7 +89,7 @@ export function CommitsView({ repoMetadata, commits, emptyTitle, emptyMessage }:
{getString('commitsOn', { date })} {getString('commitsOn', { date })}
</Text> </Text>
}> }>
<Table<RepoCommit> <Table<TypesCommit>
className={css.table} className={css.table}
hideHeaders hideHeaders
columns={columns} columns={columns}

View File

@ -15,7 +15,7 @@ import { Link } from 'react-router-dom'
import { Render } from 'react-jsx-match' import { Render } from 'react-jsx-match'
import ReactTimeago from 'react-timeago' import ReactTimeago from 'react-timeago'
import cx from 'classnames' import cx from 'classnames'
import type { RepoCommit } from 'services/code' import type { TypesCommit } from 'services/code'
import { CommitActions } from 'components/CommitActions/CommitActions' import { CommitActions } from 'components/CommitActions/CommitActions'
import { useAppContext } from 'AppContext' import { useAppContext } from 'AppContext'
import { formatDate } from 'utils/Utils' import { formatDate } from 'utils/Utils'
@ -25,7 +25,7 @@ import { useStrings } from 'framework/strings'
import css from './LatestCommit.module.scss' import css from './LatestCommit.module.scss'
interface LatestCommitProps extends Pick<GitInfoProps, 'repoMetadata'> { interface LatestCommitProps extends Pick<GitInfoProps, 'repoMetadata'> {
latestCommit?: RepoCommit latestCommit?: TypesCommit
standaloneStyle?: boolean standaloneStyle?: boolean
} }

View File

@ -11,7 +11,7 @@ import emptyStateImage from 'images/empty-state.svg'
import { makeDiffRefs } from 'utils/GitUtils' import { makeDiffRefs } from 'utils/GitUtils'
import { CommitsView } from 'components/CommitsView/CommitsView' import { CommitsView } from 'components/CommitsView/CommitsView'
import { Changes } from 'components/Changes/Changes' import { Changes } from 'components/Changes/Changes'
import type { RepoCommit } from 'services/code' import type { TypesCommit } from 'services/code'
import { LoadingSpinner } from 'components/LoadingSpinner/LoadingSpinner' import { LoadingSpinner } from 'components/LoadingSpinner/LoadingSpinner'
import { usePageIndex } from 'hooks/usePageIndex' import { usePageIndex } from 'hooks/usePageIndex'
import { ResourceListingPagination } from 'components/ResourceListingPagination/ResourceListingPagination' import { ResourceListingPagination } from 'components/ResourceListingPagination/ResourceListingPagination'
@ -32,7 +32,7 @@ export default function Compare() {
error: commitsError, error: commitsError,
refetch, refetch,
response response
} = useGet<RepoCommit[]>({ } = useGet<TypesCommit[]>({
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`, path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
queryParams: { queryParams: {
limit, limit,

View File

@ -1,6 +1,6 @@
import React from 'react' import React from 'react'
import { useGet } from 'restful-react' import { useGet } from 'restful-react'
import type { RepoCommit } from 'services/code' import type { TypesCommit } from 'services/code'
import type { GitInfoProps } from 'utils/GitUtils' import type { GitInfoProps } from 'utils/GitUtils'
import { voidFn, LIST_FETCHING_LIMIT } from 'utils/Utils' import { voidFn, LIST_FETCHING_LIMIT } from 'utils/Utils'
import { usePageIndex } from 'hooks/usePageIndex' import { usePageIndex } from 'hooks/usePageIndex'
@ -22,7 +22,7 @@ export const PullRequestCommits: React.FC<Pick<GitInfoProps, 'repoMetadata' | 'p
loading, loading,
refetch, refetch,
response response
} = useGet<RepoCommit[]>({ } = useGet<TypesCommit[]>({
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`, path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
queryParams: { queryParams: {
limit, limit,

View File

@ -38,10 +38,6 @@
background-color: var(--grey-50); background-color: var(--grey-50);
} }
&.rejected {
background-color: var(--red-50);
}
&.draft { &.draft {
background-color: var(--orange-100); background-color: var(--orange-100);
} }

View File

@ -10,7 +10,6 @@ declare const styles: {
readonly open: string readonly open: string
readonly merged: string readonly merged: string
readonly closed: string readonly closed: string
readonly rejected: string
readonly draft: string readonly draft: string
} }
export default styles export default styles

View File

@ -20,7 +20,6 @@ import { PullRequestsContentHeader } from './PullRequestsContentHeader/PullReque
import prImgOpen from './pull-request-open.svg' import prImgOpen from './pull-request-open.svg'
import prImgMerged from './pull-request-merged.svg' import prImgMerged from './pull-request-merged.svg'
import prImgClosed from './pull-request-closed.svg' import prImgClosed from './pull-request-closed.svg'
import prImgRejected from './pull-request-rejected.svg'
// import prImgDraft from './pull-request-draft.svg' // import prImgDraft from './pull-request-draft.svg'
import css from './PullRequests.module.scss' import css from './PullRequests.module.scss'
@ -174,10 +173,6 @@ const stateToImageProps = (pr: TypesPullReq) => {
src = prImgClosed src = prImgClosed
clazz = css.closed clazz = css.closed
break break
case PullRequestFilterOption.REJECTED:
src = prImgRejected
clazz = css.rejected
break
// TODO: Not supported yet from backend // TODO: Not supported yet from backend
// case PullRequestFilterOption.DRAFT: // case PullRequestFilterOption.DRAFT:
// src = prImgDraft // src = prImgDraft

View File

@ -5,7 +5,7 @@ import { useGet } from 'restful-react'
import { useGetRepositoryMetadata } from 'hooks/useGetRepositoryMetadata' import { useGetRepositoryMetadata } from 'hooks/useGetRepositoryMetadata'
import { useAppContext } from 'AppContext' import { useAppContext } from 'AppContext'
import { usePageIndex } from 'hooks/usePageIndex' import { usePageIndex } from 'hooks/usePageIndex'
import type { RepoCommit } from 'services/code' import type { TypesCommit } from 'services/code'
import { voidFn, getErrorMessage, LIST_FETCHING_LIMIT } from 'utils/Utils' import { voidFn, getErrorMessage, LIST_FETCHING_LIMIT } from 'utils/Utils'
import { useStrings } from 'framework/strings' import { useStrings } from 'framework/strings'
import { RepositoryPageHeader } from 'components/RepositoryPageHeader/RepositoryPageHeader' import { RepositoryPageHeader } from 'components/RepositoryPageHeader/RepositoryPageHeader'
@ -26,7 +26,7 @@ export default function RepositoryCommits() {
response, response,
error: errorCommits, error: errorCommits,
loading: loadingCommits loading: loadingCommits
} = useGet<RepoCommit[]>({ } = useGet<TypesCommit[]>({
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`, path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
queryParams: { queryParams: {
limit: LIST_FETCHING_LIMIT, limit: LIST_FETCHING_LIMIT,

View File

@ -7,33 +7,41 @@ import { getConfig } from '../config'
export const SPEC_VERSION = '1.0.0' export const SPEC_VERSION = '1.0.0'
export type EnumAccessGrant = number export type EnumAccessGrant = number
export type EnumMergeMethod = 'merge' | 'squash' | 'rebase' export type EnumMergeMethod = 'merge' | 'rebase' | 'squash'
export type EnumParentResourceType = 'space' | 'repo' export type EnumParentResourceType = 'space' | 'repo'
export type EnumPathTargetType = string export type EnumPathTargetType = string
export type EnumPullReqActivityKind = 'system' | 'comment' | 'code' export type EnumPullReqActivityKind = 'code' | 'comment' | 'system'
export type EnumPullReqActivityType = 'comment' | 'code-comment' | 'title-change' | 'review-submit' | 'merge' export type EnumPullReqActivityType =
| 'branch-delete'
| 'branch-update'
| 'code-comment'
| 'comment'
| 'merge'
| 'review-submit'
| 'state-change'
| 'title-change'
export type EnumPullReqReviewDecision = 'pending' | 'reviewed' | 'approved' | 'changereq' export type EnumPullReqReviewDecision = 'approved' | 'changereq' | 'pending' | 'reviewed'
export type EnumPullReqState = 'open' | 'merged' | 'closed' | 'rejected' export type EnumPullReqState = 'closed' | 'merged' | 'open'
export type EnumTokenType = string export type EnumTokenType = string
export type EnumWebhookExecutionResult = 'success' | 'retriable_error' | 'fatal_error' | null export type EnumWebhookExecutionResult = 'fatal_error' | 'retriable_error' | 'success' | null
export type EnumWebhookParent = 'repo' | 'space' export type EnumWebhookParent = 'repo' | 'space'
export type EnumWebhookTrigger = export type EnumWebhookTrigger =
| 'branch_created' | 'branch_created'
| 'branch_updated'
| 'branch_deleted' | 'branch_deleted'
| 'branch_updated'
| 'tag_created' | 'tag_created'
| 'tag_updated'
| 'tag_deleted' | 'tag_deleted'
| 'tag_updated'
export interface FormDataOpenapiLoginRequest { export interface FormDataOpenapiLoginRequest {
password?: string password?: string
@ -54,13 +62,13 @@ export interface OpenapiCalculateCommitDivergenceRequest {
export interface OpenapiCommentCreatePullReqRequest { export interface OpenapiCommentCreatePullReqRequest {
parent_id?: number parent_id?: number
payload?: { [key: string]: any } | null payload?: TypesPullRequestActivityPayloadComment
text?: string text?: string
} }
export interface OpenapiCommentUpdatePullReqRequest { export interface OpenapiCommentUpdatePullReqRequest {
payload?: { [key: string]: any } | null payload?: TypesPullRequestActivityPayloadComment
text?: string text?: string | null
} }
export interface OpenapiCommitFilesRequest { export interface OpenapiCommitFilesRequest {
@ -74,7 +82,7 @@ export interface OpenapiCommitFilesRequest {
export type OpenapiContent = RepoFileContent | OpenapiDirContent | RepoSymlinkContent | RepoSubmoduleContent export type OpenapiContent = RepoFileContent | OpenapiDirContent | RepoSymlinkContent | RepoSubmoduleContent
export interface OpenapiContentInfo { export interface OpenapiContentInfo {
latest_commit?: RepoCommit latest_commit?: TypesCommit
name?: string name?: string
path?: string path?: string
sha?: string sha?: string
@ -94,6 +102,7 @@ export interface OpenapiCreatePathRequest {
export interface OpenapiCreatePullReqRequest { export interface OpenapiCreatePullReqRequest {
description?: string description?: string
is_draft?: boolean
source_branch?: string source_branch?: string
source_repo_ref?: string source_repo_ref?: string
target_branch?: string target_branch?: string
@ -139,7 +148,7 @@ export interface OpenapiDirContent {
export interface OpenapiGetContentOutput { export interface OpenapiGetContentOutput {
content?: OpenapiContent content?: OpenapiContent
latest_commit?: RepoCommit latest_commit?: TypesCommit
name?: string name?: string
path?: string path?: string
sha?: string sha?: string
@ -173,6 +182,12 @@ export interface OpenapiReviewerAddPullReqRequest {
reviewer_id?: number reviewer_id?: number
} }
export interface OpenapiStatePullReqRequest {
is_draft?: boolean
message?: string
state?: EnumPullReqState
}
export interface OpenapiUpdatePullReqRequest { export interface OpenapiUpdatePullReqRequest {
description?: string description?: string
title?: string title?: string
@ -217,19 +232,11 @@ export interface OpenapiWebhookType {
} }
export interface RepoBranch { export interface RepoBranch {
commit?: RepoCommit commit?: TypesCommit
name?: string name?: string
sha?: string sha?: string
} }
export interface RepoCommit {
author?: RepoSignature
committer?: RepoSignature
message?: string
sha?: string
title?: string
}
export interface RepoCommitDivergence { export interface RepoCommitDivergence {
ahead?: number ahead?: number
behind?: number behind?: number
@ -253,12 +260,12 @@ export interface RepoCommitFilesResponse {
} }
export interface RepoCommitTag { export interface RepoCommitTag {
commit?: RepoCommit commit?: TypesCommit
is_annotated?: boolean is_annotated?: boolean
message?: string message?: string
name?: string name?: string
sha?: string sha?: string
tagger?: RepoSignature tagger?: TypesSignature
title?: string title?: string
} }
@ -266,7 +273,7 @@ export interface RepoCommitTag {
export interface RepoContent {} export interface RepoContent {}
export interface RepoContentInfo { export interface RepoContentInfo {
latest_commit?: RepoCommit latest_commit?: TypesCommit
name?: string name?: string
path?: string path?: string
sha?: string sha?: string
@ -283,16 +290,6 @@ export interface RepoFileContent {
export type RepoFileEncodingType = string export type RepoFileEncodingType = string
export interface RepoIdentity {
email?: string
name?: string
}
export interface RepoSignature {
identity?: RepoIdentity
when?: string
}
export interface RepoSubmoduleContent { export interface RepoSubmoduleContent {
commit_sha?: string commit_sha?: string
url?: string url?: string
@ -303,11 +300,24 @@ export interface RepoSymlinkContent {
target?: string target?: string
} }
export interface TypesCommit {
author?: TypesSignature
committer?: TypesSignature
message?: string
sha?: string
title?: string
}
export interface TypesIdentity {
email?: string
name?: string
}
export interface TypesPath { export interface TypesPath {
created?: number created?: number
created_by?: number created_by?: number
id?: number id?: number
is_alias?: boolean is_primary?: boolean
target_id?: number target_id?: number
target_type?: EnumPathTargetType target_type?: EnumPathTargetType
updated?: number updated?: number
@ -326,6 +336,9 @@ export interface TypesPullReq {
created?: number created?: number
description?: string description?: string
edited?: number edited?: number
is_draft?: boolean
merge_base_sha?: string | null
merge_head_sha?: string | null
merge_strategy?: EnumMergeMethod merge_strategy?: EnumMergeMethod
merged?: number | null merged?: number | null
merger?: TypesPrincipalInfo merger?: TypesPrincipalInfo
@ -348,7 +361,7 @@ export interface TypesPullReqActivity {
metadata?: { [key: string]: any } | null metadata?: { [key: string]: any } | null
order?: number order?: number
parent_id?: number | null parent_id?: number | null
payload?: { [key: string]: any } | null payload?: {}
pullreq_id?: number pullreq_id?: number
repo_id?: number repo_id?: number
resolved?: number | null resolved?: number | null
@ -358,6 +371,8 @@ export interface TypesPullReqActivity {
type?: EnumPullReqActivityType type?: EnumPullReqActivityType
} }
export type TypesPullRequestActivityPayloadComment = { [key: string]: any } | null
export interface TypesRepository { export interface TypesRepository {
created?: number created?: number
created_by?: number created_by?: number
@ -375,7 +390,6 @@ export interface TypesRepository {
path?: string path?: string
uid?: string uid?: string
updated?: number updated?: number
version?: number
} }
export interface TypesServiceAccount { export interface TypesServiceAccount {
@ -390,6 +404,11 @@ export interface TypesServiceAccount {
updated?: number updated?: number
} }
export interface TypesSignature {
identity?: TypesIdentity
when?: string
}
export interface TypesSpace { export interface TypesSpace {
created?: number created?: number
created_by?: number created_by?: number
@ -469,6 +488,7 @@ export interface UserUpdateInput {
export interface UsererrorError { export interface UsererrorError {
message?: string message?: string
values?: { [key: string]: any }
} }
export type OnLoginProps = Omit<MutateProps<TypesTokenResponse, UsererrorError, void, void, void>, 'path' | 'verb'> export type OnLoginProps = Omit<MutateProps<TypesTokenResponse, UsererrorError, void, void, void>, 'path' | 'verb'>
@ -766,13 +786,13 @@ export interface ListCommitsPathParams {
} }
export type ListCommitsProps = Omit< export type ListCommitsProps = Omit<
GetProps<RepoCommit[], UsererrorError, ListCommitsQueryParams, ListCommitsPathParams>, GetProps<TypesCommit[], UsererrorError, ListCommitsQueryParams, ListCommitsPathParams>,
'path' 'path'
> & > &
ListCommitsPathParams ListCommitsPathParams
export const ListCommits = ({ repo_ref, ...props }: ListCommitsProps) => ( export const ListCommits = ({ repo_ref, ...props }: ListCommitsProps) => (
<Get<RepoCommit[], UsererrorError, ListCommitsQueryParams, ListCommitsPathParams> <Get<TypesCommit[], UsererrorError, ListCommitsQueryParams, ListCommitsPathParams>
path={`/repos/${repo_ref}/commits`} path={`/repos/${repo_ref}/commits`}
base={getConfig('code')} base={getConfig('code')}
{...props} {...props}
@ -780,13 +800,13 @@ export const ListCommits = ({ repo_ref, ...props }: ListCommitsProps) => (
) )
export type UseListCommitsProps = Omit< export type UseListCommitsProps = Omit<
UseGetProps<RepoCommit[], UsererrorError, ListCommitsQueryParams, ListCommitsPathParams>, UseGetProps<TypesCommit[], UsererrorError, ListCommitsQueryParams, ListCommitsPathParams>,
'path' 'path'
> & > &
ListCommitsPathParams ListCommitsPathParams
export const useListCommits = ({ repo_ref, ...props }: UseListCommitsProps) => export const useListCommits = ({ repo_ref, ...props }: UseListCommitsProps) =>
useGet<RepoCommit[], UsererrorError, ListCommitsQueryParams, ListCommitsPathParams>( useGet<TypesCommit[], UsererrorError, ListCommitsQueryParams, ListCommitsPathParams>(
(paramsInPath: ListCommitsPathParams) => `/repos/${paramsInPath.repo_ref}/commits`, (paramsInPath: ListCommitsPathParams) => `/repos/${paramsInPath.repo_ref}/commits`,
{ base: getConfig('code'), pathParams: { repo_ref }, ...props } { base: getConfig('code'), pathParams: { repo_ref }, ...props }
) )
@ -1087,7 +1107,7 @@ export interface ListPullReqQueryParams {
/** /**
* The state of the pull requests to include in the result. * The state of the pull requests to include in the result.
*/ */
state?: ('open' | 'merged' | 'closed' | 'rejected')[] state?: ('closed' | 'merged' | 'open')[]
/** /**
* Source repository ref of the pull requests. * Source repository ref of the pull requests.
*/ */
@ -1115,7 +1135,7 @@ export interface ListPullReqQueryParams {
/** /**
* The data by which the pull requests are sorted. * The data by which the pull requests are sorted.
*/ */
sort?: 'number' | 'created' | 'edited' sort?: 'created' | 'edited' | 'merged' | 'number'
/** /**
* The page to return. * The page to return.
*/ */
@ -1250,11 +1270,20 @@ export interface ListPullReqActivitiesQueryParams {
/** /**
* The kind of the pull request activity to include in the result. * The kind of the pull request activity to include in the result.
*/ */
kind?: ('system' | 'comment' | 'code')[] kind?: ('code' | 'comment' | 'system')[]
/** /**
* The type of the pull request activity to include in the result. * The type of the pull request activity to include in the result.
*/ */
type?: ('comment' | 'code-comment' | 'title-change' | 'review-submit' | 'merge')[] type?: (
| 'branch-delete'
| 'branch-update'
| 'code-comment'
| 'comment'
| 'merge'
| 'review-submit'
| 'state-change'
| 'title-change'
)[]
/** /**
* The result should contain only entries created at and after this timestamp (unix millis). * The result should contain only entries created at and after this timestamp (unix millis).
*/ */
@ -1467,6 +1496,75 @@ export const useCommentUpdatePullReq = ({
{ base: getConfig('code'), pathParams: { repo_ref, pullreq_number, pullreq_comment_id }, ...props } { base: getConfig('code'), pathParams: { repo_ref, pullreq_number, pullreq_comment_id }, ...props }
) )
export interface ListPullReqCommitsQueryParams {
/**
* The page to return.
*/
page?: number
/**
* The maximum number of results to return.
*/
limit?: number
}
export interface ListPullReqCommitsPathParams {
repo_ref: string
pullreq_number: number
}
export type ListPullReqCommitsProps = Omit<
GetProps<TypesCommit[], UsererrorError, ListPullReqCommitsQueryParams, ListPullReqCommitsPathParams>,
'path'
> &
ListPullReqCommitsPathParams
export const ListPullReqCommits = ({ repo_ref, pullreq_number, ...props }: ListPullReqCommitsProps) => (
<Get<TypesCommit[], UsererrorError, ListPullReqCommitsQueryParams, ListPullReqCommitsPathParams>
path={`/repos/${repo_ref}/pullreq/${pullreq_number}/commits`}
base={getConfig('code')}
{...props}
/>
)
export type UseListPullReqCommitsProps = Omit<
UseGetProps<TypesCommit[], UsererrorError, ListPullReqCommitsQueryParams, ListPullReqCommitsPathParams>,
'path'
> &
ListPullReqCommitsPathParams
export const useListPullReqCommits = ({ repo_ref, pullreq_number, ...props }: UseListPullReqCommitsProps) =>
useGet<TypesCommit[], UsererrorError, ListPullReqCommitsQueryParams, ListPullReqCommitsPathParams>(
(paramsInPath: ListPullReqCommitsPathParams) =>
`/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/commits`,
{ base: getConfig('code'), pathParams: { repo_ref, pullreq_number }, ...props }
)
export interface RawPullReqDiffPathParams {
repo_ref: string
pullreq_number: number
}
export type RawPullReqDiffProps = Omit<GetProps<void, UsererrorError, void, RawPullReqDiffPathParams>, 'path'> &
RawPullReqDiffPathParams
export const RawPullReqDiff = ({ repo_ref, pullreq_number, ...props }: RawPullReqDiffProps) => (
<Get<void, UsererrorError, void, RawPullReqDiffPathParams>
path={`/repos/${repo_ref}/pullreq/${pullreq_number}/diff`}
base={getConfig('code')}
{...props}
/>
)
export type UseRawPullReqDiffProps = Omit<UseGetProps<void, UsererrorError, void, RawPullReqDiffPathParams>, 'path'> &
RawPullReqDiffPathParams
export const useRawPullReqDiff = ({ repo_ref, pullreq_number, ...props }: UseRawPullReqDiffProps) =>
useGet<void, UsererrorError, void, RawPullReqDiffPathParams>(
(paramsInPath: RawPullReqDiffPathParams) =>
`/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/diff`,
{ base: getConfig('code'), pathParams: { repo_ref, pullreq_number }, ...props }
)
export interface MergePullReqOpPathParams { export interface MergePullReqOpPathParams {
repo_ref: string repo_ref: string
pullreq_number: number pullreq_number: number
@ -1601,6 +1699,40 @@ export const useReviewSubmitPullReq = ({ repo_ref, pullreq_number, ...props }: U
{ base: getConfig('code'), pathParams: { repo_ref, pullreq_number }, ...props } { base: getConfig('code'), pathParams: { repo_ref, pullreq_number }, ...props }
) )
export interface StatePullReqPathParams {
repo_ref: string
pullreq_number: number
}
export type StatePullReqProps = Omit<
MutateProps<TypesPullReq, UsererrorError, void, OpenapiStatePullReqRequest, StatePullReqPathParams>,
'path' | 'verb'
> &
StatePullReqPathParams
export const StatePullReq = ({ repo_ref, pullreq_number, ...props }: StatePullReqProps) => (
<Mutate<TypesPullReq, UsererrorError, void, OpenapiStatePullReqRequest, StatePullReqPathParams>
verb="POST"
path={`/repos/${repo_ref}/pullreq/${pullreq_number}/state`}
base={getConfig('code')}
{...props}
/>
)
export type UseStatePullReqProps = Omit<
UseMutateProps<TypesPullReq, UsererrorError, void, OpenapiStatePullReqRequest, StatePullReqPathParams>,
'path' | 'verb'
> &
StatePullReqPathParams
export const useStatePullReq = ({ repo_ref, pullreq_number, ...props }: UseStatePullReqProps) =>
useMutate<TypesPullReq, UsererrorError, void, OpenapiStatePullReqRequest, StatePullReqPathParams>(
'POST',
(paramsInPath: StatePullReqPathParams) =>
`/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/state`,
{ base: getConfig('code'), pathParams: { repo_ref, pullreq_number }, ...props }
)
export interface ListRepositoryServiceAccountsPathParams { export interface ListRepositoryServiceAccountsPathParams {
repo_ref: string repo_ref: string
} }
@ -1689,6 +1821,18 @@ export const useListTags = ({ repo_ref, ...props }: UseListTagsProps) =>
) )
export interface ListWebhooksQueryParams { export interface ListWebhooksQueryParams {
/**
* The substring which is used to filter the spaces by their path name.
*/
query?: string
/**
* The data by which the webhooks are sorted.
*/
sort?: 'id' | 'display_name' | 'created' | 'updated'
/**
* The order of the output.
*/
order?: 'asc' | 'desc'
/** /**
* The page to return. * The page to return.
*/ */

View File

@ -483,7 +483,7 @@ paths:
application/json: application/json:
schema: schema:
items: items:
$ref: '#/components/schemas/RepoCommit' $ref: '#/components/schemas/TypesCommit'
type: array type: array
description: OK description: OK
'401': '401':
@ -928,10 +928,9 @@ paths:
items: items:
default: open default: open
enum: enum:
- open
- merged
- closed - closed
- rejected - merged
- open
type: string type: string
type: array type: array
- description: Source repository ref of the pull requests. - description: Source repository ref of the pull requests.
@ -981,9 +980,10 @@ paths:
schema: schema:
default: number default: number
enum: enum:
- number
- created - created
- edited - edited
- merged
- number
type: string type: string
- description: The page to return. - description: The page to return.
in: query in: query
@ -1197,9 +1197,9 @@ paths:
schema: schema:
items: items:
enum: enum:
- system
- comment
- code - code
- comment
- system
type: string type: string
type: array type: array
- description: The type of the pull request activity to include in the result. - description: The type of the pull request activity to include in the result.
@ -1209,11 +1209,14 @@ paths:
schema: schema:
items: items:
enum: enum:
- comment - branch-delete
- branch-update
- code-comment - code-comment
- title-change - comment
- review-submit
- merge - merge
- review-submit
- state-change
- title-change
type: string type: string
type: array type: array
- description: The result should contain only entries created at and after this - description: The result should contain only entries created at and after this
@ -1442,6 +1445,119 @@ paths:
description: Internal Server Error description: Internal Server Error
tags: tags:
- pullreq - pullreq
/repos/{repo_ref}/pullreq/{pullreq_number}/commits:
get:
operationId: listPullReqCommits
parameters:
- description: The page to return.
in: query
name: page
required: false
schema:
default: 1
minimum: 1
type: integer
- description: The maximum number of results to return.
in: query
name: limit
required: false
schema:
default: 30
maximum: 100
minimum: 1
type: integer
- in: path
name: repo_ref
required: true
schema:
type: string
- in: path
name: pullreq_number
required: true
schema:
type: integer
responses:
'200':
content:
application/json:
schema:
items:
$ref: '#/components/schemas/TypesCommit'
type: array
description: OK
'401':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Unauthorized
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Forbidden
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Not Found
'500':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Internal Server Error
tags:
- pullreq
/repos/{repo_ref}/pullreq/{pullreq_number}/diff:
get:
operationId: rawPullReqDiff
parameters:
- in: path
name: repo_ref
required: true
schema:
type: string
- in: path
name: pullreq_number
required: true
schema:
type: integer
responses:
'200':
content:
text/plain:
schema:
type: string
description: OK
'401':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Unauthorized
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Forbidden
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Not Found
'500':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Internal Server Error
tags:
- pullreq
/repos/{repo_ref}/pullreq/{pullreq_number}/merge: /repos/{repo_ref}/pullreq/{pullreq_number}/merge:
post: post:
operationId: mergePullReqOp operationId: mergePullReqOp
@ -1646,6 +1762,58 @@ paths:
description: Internal Server Error description: Internal Server Error
tags: tags:
- pullreq - pullreq
/repos/{repo_ref}/pullreq/{pullreq_number}/state:
post:
operationId: statePullReq
parameters:
- in: path
name: repo_ref
required: true
schema:
type: string
- in: path
name: pullreq_number
required: true
schema:
type: integer
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/OpenapiStatePullReqRequest'
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/TypesPullReq'
description: OK
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Bad Request
'401':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Unauthorized
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Forbidden
'500':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Internal Server Error
tags:
- pullreq
/repos/{repo_ref}/service-accounts: /repos/{repo_ref}/service-accounts:
get: get:
operationId: listRepositoryServiceAccounts operationId: listRepositoryServiceAccounts
@ -1789,6 +1957,35 @@ paths:
get: get:
operationId: listWebhooks operationId: listWebhooks
parameters: parameters:
- description: The substring which is used to filter the spaces by their path
name.
in: query
name: query
required: false
schema:
type: string
- description: The data by which the webhooks are sorted.
in: query
name: sort
required: false
schema:
default: id
enum:
- id
- display_name
- created
- updated
type: string
- description: The order of the output.
in: query
name: order
required: false
schema:
default: asc
enum:
- asc
- desc
type: string
- description: The page to return. - description: The page to return.
in: query in: query
name: page name: page
@ -3053,8 +3250,8 @@ components:
EnumMergeMethod: EnumMergeMethod:
enum: enum:
- merge - merge
- squash
- rebase - rebase
- squash
type: string type: string
EnumParentResourceType: EnumParentResourceType:
enum: enum:
@ -3065,39 +3262,41 @@ components:
type: string type: string
EnumPullReqActivityKind: EnumPullReqActivityKind:
enum: enum:
- system
- comment
- code - code
- comment
- system
type: string type: string
EnumPullReqActivityType: EnumPullReqActivityType:
enum: enum:
- comment - branch-delete
- branch-update
- code-comment - code-comment
- title-change - comment
- review-submit
- merge - merge
- review-submit
- state-change
- title-change
type: string type: string
EnumPullReqReviewDecision: EnumPullReqReviewDecision:
enum: enum:
- pending
- reviewed
- approved - approved
- changereq - changereq
- pending
- reviewed
type: string type: string
EnumPullReqState: EnumPullReqState:
enum: enum:
- open
- merged
- closed - closed
- rejected - merged
- open
type: string type: string
EnumTokenType: EnumTokenType:
type: string type: string
EnumWebhookExecutionResult: EnumWebhookExecutionResult:
enum: enum:
- success
- retriable_error
- fatal_error - fatal_error
- retriable_error
- success
nullable: true nullable: true
type: string type: string
EnumWebhookParent: EnumWebhookParent:
@ -3108,11 +3307,11 @@ components:
EnumWebhookTrigger: EnumWebhookTrigger:
enum: enum:
- branch_created - branch_created
- branch_updated
- branch_deleted - branch_deleted
- branch_updated
- tag_created - tag_created
- tag_updated
- tag_deleted - tag_deleted
- tag_updated
type: string type: string
FormDataOpenapiLoginRequest: FormDataOpenapiLoginRequest:
properties: properties:
@ -3150,19 +3349,16 @@ components:
parent_id: parent_id:
type: integer type: integer
payload: payload:
additionalProperties: {} $ref: '#/components/schemas/TypesPullRequestActivityPayloadComment'
nullable: true
type: object
text: text:
type: string type: string
type: object type: object
OpenapiCommentUpdatePullReqRequest: OpenapiCommentUpdatePullReqRequest:
properties: properties:
payload: payload:
additionalProperties: {} $ref: '#/components/schemas/TypesPullRequestActivityPayloadComment'
nullable: true
type: object
text: text:
nullable: true
type: string type: string
type: object type: object
OpenapiCommitFilesRequest: OpenapiCommitFilesRequest:
@ -3191,7 +3387,7 @@ components:
OpenapiContentInfo: OpenapiContentInfo:
properties: properties:
latest_commit: latest_commit:
$ref: '#/components/schemas/RepoCommit' $ref: '#/components/schemas/TypesCommit'
name: name:
type: string type: string
path: path:
@ -3225,6 +3421,8 @@ components:
properties: properties:
description: description:
type: string type: string
is_draft:
type: boolean
source_branch: source_branch:
type: string type: string
source_repo_ref: source_repo_ref:
@ -3304,7 +3502,7 @@ components:
content: content:
$ref: '#/components/schemas/OpenapiContent' $ref: '#/components/schemas/OpenapiContent'
latest_commit: latest_commit:
$ref: '#/components/schemas/RepoCommit' $ref: '#/components/schemas/TypesCommit'
name: name:
type: string type: string
path: path:
@ -3357,6 +3555,15 @@ components:
reviewer_id: reviewer_id:
type: integer type: integer
type: object type: object
OpenapiStatePullReqRequest:
properties:
is_draft:
type: boolean
message:
type: string
state:
$ref: '#/components/schemas/EnumPullReqState'
type: object
OpenapiUpdatePullReqRequest: OpenapiUpdatePullReqRequest:
properties: properties:
description: description:
@ -3447,25 +3654,12 @@ components:
RepoBranch: RepoBranch:
properties: properties:
commit: commit:
$ref: '#/components/schemas/RepoCommit' $ref: '#/components/schemas/TypesCommit'
name: name:
type: string type: string
sha: sha:
type: string type: string
type: object type: object
RepoCommit:
properties:
author:
$ref: '#/components/schemas/RepoSignature'
committer:
$ref: '#/components/schemas/RepoSignature'
message:
type: string
sha:
type: string
title:
type: string
type: object
RepoCommitDivergence: RepoCommitDivergence:
properties: properties:
ahead: ahead:
@ -3501,7 +3695,7 @@ components:
RepoCommitTag: RepoCommitTag:
properties: properties:
commit: commit:
$ref: '#/components/schemas/RepoCommit' $ref: '#/components/schemas/TypesCommit'
is_annotated: is_annotated:
type: boolean type: boolean
message: message:
@ -3511,7 +3705,7 @@ components:
sha: sha:
type: string type: string
tagger: tagger:
$ref: '#/components/schemas/RepoSignature' $ref: '#/components/schemas/TypesSignature'
title: title:
type: string type: string
type: object type: object
@ -3519,7 +3713,7 @@ components:
RepoContentInfo: RepoContentInfo:
properties: properties:
latest_commit: latest_commit:
$ref: '#/components/schemas/RepoCommit' $ref: '#/components/schemas/TypesCommit'
name: name:
type: string type: string
path: path:
@ -3542,21 +3736,6 @@ components:
type: object type: object
RepoFileEncodingType: RepoFileEncodingType:
type: string type: string
RepoIdentity:
properties:
email:
type: string
name:
type: string
type: object
RepoSignature:
properties:
identity:
$ref: '#/components/schemas/RepoIdentity'
when:
format: date-time
type: string
type: object
RepoSubmoduleContent: RepoSubmoduleContent:
properties: properties:
commit_sha: commit_sha:
@ -3571,6 +3750,26 @@ components:
target: target:
type: string type: string
type: object type: object
TypesCommit:
properties:
author:
$ref: '#/components/schemas/TypesSignature'
committer:
$ref: '#/components/schemas/TypesSignature'
message:
type: string
sha:
type: string
title:
type: string
type: object
TypesIdentity:
properties:
email:
type: string
name:
type: string
type: object
TypesPath: TypesPath:
properties: properties:
created: created:
@ -3579,7 +3778,7 @@ components:
type: integer type: integer
id: id:
type: integer type: integer
is_alias: is_primary:
type: boolean type: boolean
target_id: target_id:
type: integer type: integer
@ -3612,6 +3811,14 @@ components:
type: string type: string
edited: edited:
type: integer type: integer
is_draft:
type: boolean
merge_base_sha:
nullable: true
type: string
merge_head_sha:
nullable: true
type: string
merge_strategy: merge_strategy:
$ref: '#/components/schemas/EnumMergeMethod' $ref: '#/components/schemas/EnumMergeMethod'
merged: merged:
@ -3658,10 +3865,7 @@ components:
parent_id: parent_id:
nullable: true nullable: true
type: integer type: integer
payload: payload: {}
additionalProperties: {}
nullable: true
type: object
pullreq_id: pullreq_id:
type: integer type: integer
repo_id: repo_id:
@ -3678,6 +3882,10 @@ components:
type: type:
$ref: '#/components/schemas/EnumPullReqActivityType' $ref: '#/components/schemas/EnumPullReqActivityType'
type: object type: object
TypesPullRequestActivityPayloadComment:
additionalProperties: {}
nullable: true
type: object
TypesRepository: TypesRepository:
properties: properties:
created: created:
@ -3712,8 +3920,6 @@ components:
type: string type: string
updated: updated:
type: integer type: integer
version:
type: integer
type: object type: object
TypesServiceAccount: TypesServiceAccount:
properties: properties:
@ -3736,6 +3942,14 @@ components:
updated: updated:
type: integer type: integer
type: object type: object
TypesSignature:
properties:
identity:
$ref: '#/components/schemas/TypesIdentity'
when:
format: date-time
type: string
type: object
TypesSpace: TypesSpace:
properties: properties:
created: created:
@ -3875,6 +4089,9 @@ components:
properties: properties:
message: message:
type: string type: string
values:
additionalProperties: {}
type: object
type: object type: object
securitySchemes: securitySchemes:
bearerAuth: bearerAuth:

View File

@ -7,7 +7,7 @@ import type {
OpenapiContentInfo, OpenapiContentInfo,
OpenapiDirContent, OpenapiDirContent,
OpenapiGetContentOutput, OpenapiGetContentOutput,
RepoCommit, TypesCommit,
TypesPullReq, TypesPullReq,
TypesRepository TypesRepository
} from 'services/code' } from 'services/code'
@ -18,7 +18,7 @@ export interface GitInfoProps {
resourcePath: string resourcePath: string
resourceContent: OpenapiGetContentOutput resourceContent: OpenapiGetContentOutput
commitRef: string commitRef: string
commits: RepoCommit[] commits: TypesCommit[]
pullRequestMetadata: TypesPullReq pullRequestMetadata: TypesPullReq
} }