From 2227e13e7da7eada0454555f258b9cf94cbfd743 Mon Sep 17 00:00:00 2001 From: Johannes Batzill Date: Tue, 24 Jan 2023 15:46:49 -0800 Subject: [PATCH] [MISC] Fix Swagger and Regenerate WEB Services (#246) --- internal/api/openapi/pullreq.go | 4 +- .../components/CommitsView/CommitsView.tsx | 18 +- .../components/LatestCommit/LatestCommit.tsx | 4 +- web/src/pages/Compare/Compare.tsx | 4 +- .../PullRequestCommits/PullRequestCommits.tsx | 4 +- .../PullRequests/PullRequests.module.scss | 4 - .../PullRequests.module.scss.d.ts | 1 - web/src/pages/PullRequests/PullRequests.tsx | 5 - .../RepositoryCommits/RepositoryCommits.tsx | 4 +- web/src/services/code/index.tsx | 236 +++++++++--- web/src/services/code/swagger.yaml | 361 ++++++++++++++---- web/src/utils/GitUtils.ts | 4 +- 12 files changed, 500 insertions(+), 149 deletions(-) diff --git a/internal/api/openapi/pullreq.go b/internal/api/openapi/pullreq.go index c14107fec..14b85168c 100644 --- a/internal/api/openapi/pullreq.go +++ b/internal/api/openapi/pullreq.go @@ -416,7 +416,7 @@ func pullReqOperations(reflector *openapi3.Reflector) { opListCommits := openapi3.Operation{} opListCommits.WithTags("pullreq") - opListCommits.WithMapOfAnything(map[string]interface{}{"operationId": "listCommits"}) + opListCommits.WithMapOfAnything(map[string]interface{}{"operationId": "listPullReqCommits"}) opListCommits.WithParameters(queryParameterPage, queryParameterLimit) _ = reflector.SetRequest(&opListCommits, new(pullReqRequest), http.MethodGet) _ = reflector.SetJSONResponse(&opListCommits, []types.Commit{}, http.StatusOK) @@ -428,7 +428,7 @@ func pullReqOperations(reflector *openapi3.Reflector) { opRawDiff := openapi3.Operation{} 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.SetStringResponse(&opRawDiff, http.StatusOK, "text/plain") _ = reflector.SetJSONResponse(&opRawDiff, new(usererror.Error), http.StatusInternalServerError) diff --git a/web/src/components/CommitsView/CommitsView.tsx b/web/src/components/CommitsView/CommitsView.tsx index 23c79e0f9..74ce47e35 100644 --- a/web/src/components/CommitsView/CommitsView.tsx +++ b/web/src/components/CommitsView/CommitsView.tsx @@ -4,7 +4,7 @@ import type { CellProps, Column } from 'react-table' import { orderBy } from 'lodash-es' import { useStrings } from 'framework/strings' import { useAppContext } from 'AppContext' -import type { RepoCommit } from 'services/code' +import type { TypesCommit } from 'services/code' import { CommitActions } from 'components/CommitActions/CommitActions' import { NoResultCard } from 'components/NoResultCard/NoResultCard' import { ThreadSection } from 'components/ThreadSection/ThreadSection' @@ -13,7 +13,7 @@ import { CodeIcon, GitInfoProps } from 'utils/GitUtils' import css from './CommitsView.module.scss' interface CommitsViewProps extends Pick { - commits: RepoCommit[] + commits: TypesCommit[] emptyTitle: string emptyMessage: string } @@ -21,12 +21,12 @@ interface CommitsViewProps extends Pick { export function CommitsView({ repoMetadata, commits, emptyTitle, emptyMessage }: CommitsViewProps) { const { getString } = useStrings() const { routes } = useAppContext() - const columns: Column[] = useMemo( + const columns: Column[] = useMemo( () => [ { id: 'author', width: '20%', - Cell: ({ row }: CellProps) => { + Cell: ({ row }: CellProps) => { return ( @@ -40,7 +40,7 @@ export function CommitsView({ repoMetadata, commits, emptyTitle, emptyMessage }: { id: 'commit', width: 'calc(80% - 100px)', - Cell: ({ row }: CellProps) => { + Cell: ({ row }: CellProps) => { return ( {row.original.message} @@ -51,7 +51,7 @@ export function CommitsView({ repoMetadata, commits, emptyTitle, emptyMessage }: { id: 'sha', width: '100px', - Cell: ({ row }: CellProps) => { + Cell: ({ row }: CellProps) => { return ( = useMemo( + const commitsGroupedByDate: Record = useMemo( () => commits?.reduce((group, commit) => { const date = formatDate(commit.author?.when as string) group[date] = (group[date] || []).concat(commit) return group - }, {} as Record) || {}, + }, {} as Record) || {}, [commits] ) @@ -89,7 +89,7 @@ export function CommitsView({ repoMetadata, commits, emptyTitle, emptyMessage }: {getString('commitsOn', { date })} }> - + className={css.table} hideHeaders columns={columns} diff --git a/web/src/components/LatestCommit/LatestCommit.tsx b/web/src/components/LatestCommit/LatestCommit.tsx index 07588766e..7c3001930 100644 --- a/web/src/components/LatestCommit/LatestCommit.tsx +++ b/web/src/components/LatestCommit/LatestCommit.tsx @@ -15,7 +15,7 @@ import { Link } from 'react-router-dom' import { Render } from 'react-jsx-match' import ReactTimeago from 'react-timeago' import cx from 'classnames' -import type { RepoCommit } from 'services/code' +import type { TypesCommit } from 'services/code' import { CommitActions } from 'components/CommitActions/CommitActions' import { useAppContext } from 'AppContext' import { formatDate } from 'utils/Utils' @@ -25,7 +25,7 @@ import { useStrings } from 'framework/strings' import css from './LatestCommit.module.scss' interface LatestCommitProps extends Pick { - latestCommit?: RepoCommit + latestCommit?: TypesCommit standaloneStyle?: boolean } diff --git a/web/src/pages/Compare/Compare.tsx b/web/src/pages/Compare/Compare.tsx index 79a803865..a3d24d8d1 100644 --- a/web/src/pages/Compare/Compare.tsx +++ b/web/src/pages/Compare/Compare.tsx @@ -11,7 +11,7 @@ import emptyStateImage from 'images/empty-state.svg' import { makeDiffRefs } from 'utils/GitUtils' import { CommitsView } from 'components/CommitsView/CommitsView' 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 { usePageIndex } from 'hooks/usePageIndex' import { ResourceListingPagination } from 'components/ResourceListingPagination/ResourceListingPagination' @@ -32,7 +32,7 @@ export default function Compare() { error: commitsError, refetch, response - } = useGet({ + } = useGet({ path: `/api/v1/repos/${repoMetadata?.path}/+/commits`, queryParams: { limit, diff --git a/web/src/pages/PullRequest/PullRequestCommits/PullRequestCommits.tsx b/web/src/pages/PullRequest/PullRequestCommits/PullRequestCommits.tsx index 022402290..bd9692823 100644 --- a/web/src/pages/PullRequest/PullRequestCommits/PullRequestCommits.tsx +++ b/web/src/pages/PullRequest/PullRequestCommits/PullRequestCommits.tsx @@ -1,6 +1,6 @@ import React from '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 { voidFn, LIST_FETCHING_LIMIT } from 'utils/Utils' import { usePageIndex } from 'hooks/usePageIndex' @@ -22,7 +22,7 @@ export const PullRequestCommits: React.FC({ + } = useGet({ path: `/api/v1/repos/${repoMetadata?.path}/+/commits`, queryParams: { limit, diff --git a/web/src/pages/PullRequests/PullRequests.module.scss b/web/src/pages/PullRequests/PullRequests.module.scss index 90b896ca0..6f082a3dc 100644 --- a/web/src/pages/PullRequests/PullRequests.module.scss +++ b/web/src/pages/PullRequests/PullRequests.module.scss @@ -38,10 +38,6 @@ background-color: var(--grey-50); } - &.rejected { - background-color: var(--red-50); - } - &.draft { background-color: var(--orange-100); } diff --git a/web/src/pages/PullRequests/PullRequests.module.scss.d.ts b/web/src/pages/PullRequests/PullRequests.module.scss.d.ts index 3b82a6352..4caf95b25 100644 --- a/web/src/pages/PullRequests/PullRequests.module.scss.d.ts +++ b/web/src/pages/PullRequests/PullRequests.module.scss.d.ts @@ -10,7 +10,6 @@ declare const styles: { readonly open: string readonly merged: string readonly closed: string - readonly rejected: string readonly draft: string } export default styles diff --git a/web/src/pages/PullRequests/PullRequests.tsx b/web/src/pages/PullRequests/PullRequests.tsx index 6fa4eae44..0ab6cf8bc 100644 --- a/web/src/pages/PullRequests/PullRequests.tsx +++ b/web/src/pages/PullRequests/PullRequests.tsx @@ -20,7 +20,6 @@ import { PullRequestsContentHeader } from './PullRequestsContentHeader/PullReque import prImgOpen from './pull-request-open.svg' import prImgMerged from './pull-request-merged.svg' import prImgClosed from './pull-request-closed.svg' -import prImgRejected from './pull-request-rejected.svg' // import prImgDraft from './pull-request-draft.svg' import css from './PullRequests.module.scss' @@ -174,10 +173,6 @@ const stateToImageProps = (pr: TypesPullReq) => { src = prImgClosed clazz = css.closed break - case PullRequestFilterOption.REJECTED: - src = prImgRejected - clazz = css.rejected - break // TODO: Not supported yet from backend // case PullRequestFilterOption.DRAFT: // src = prImgDraft diff --git a/web/src/pages/RepositoryCommits/RepositoryCommits.tsx b/web/src/pages/RepositoryCommits/RepositoryCommits.tsx index 4c8d88eeb..d474e8f26 100644 --- a/web/src/pages/RepositoryCommits/RepositoryCommits.tsx +++ b/web/src/pages/RepositoryCommits/RepositoryCommits.tsx @@ -5,7 +5,7 @@ import { useGet } from 'restful-react' import { useGetRepositoryMetadata } from 'hooks/useGetRepositoryMetadata' import { useAppContext } from 'AppContext' 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 { useStrings } from 'framework/strings' import { RepositoryPageHeader } from 'components/RepositoryPageHeader/RepositoryPageHeader' @@ -26,7 +26,7 @@ export default function RepositoryCommits() { response, error: errorCommits, loading: loadingCommits - } = useGet({ + } = useGet({ path: `/api/v1/repos/${repoMetadata?.path}/+/commits`, queryParams: { limit: LIST_FETCHING_LIMIT, diff --git a/web/src/services/code/index.tsx b/web/src/services/code/index.tsx index 2a261eeeb..80a3ba176 100644 --- a/web/src/services/code/index.tsx +++ b/web/src/services/code/index.tsx @@ -7,33 +7,41 @@ import { getConfig } from '../config' export const SPEC_VERSION = '1.0.0' export type EnumAccessGrant = number -export type EnumMergeMethod = 'merge' | 'squash' | 'rebase' +export type EnumMergeMethod = 'merge' | 'rebase' | 'squash' export type EnumParentResourceType = 'space' | 'repo' 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 EnumWebhookExecutionResult = 'success' | 'retriable_error' | 'fatal_error' | null +export type EnumWebhookExecutionResult = 'fatal_error' | 'retriable_error' | 'success' | null export type EnumWebhookParent = 'repo' | 'space' export type EnumWebhookTrigger = | 'branch_created' - | 'branch_updated' | 'branch_deleted' + | 'branch_updated' | 'tag_created' - | 'tag_updated' | 'tag_deleted' + | 'tag_updated' export interface FormDataOpenapiLoginRequest { password?: string @@ -54,13 +62,13 @@ export interface OpenapiCalculateCommitDivergenceRequest { export interface OpenapiCommentCreatePullReqRequest { parent_id?: number - payload?: { [key: string]: any } | null + payload?: TypesPullRequestActivityPayloadComment text?: string } export interface OpenapiCommentUpdatePullReqRequest { - payload?: { [key: string]: any } | null - text?: string + payload?: TypesPullRequestActivityPayloadComment + text?: string | null } export interface OpenapiCommitFilesRequest { @@ -74,7 +82,7 @@ export interface OpenapiCommitFilesRequest { export type OpenapiContent = RepoFileContent | OpenapiDirContent | RepoSymlinkContent | RepoSubmoduleContent export interface OpenapiContentInfo { - latest_commit?: RepoCommit + latest_commit?: TypesCommit name?: string path?: string sha?: string @@ -94,6 +102,7 @@ export interface OpenapiCreatePathRequest { export interface OpenapiCreatePullReqRequest { description?: string + is_draft?: boolean source_branch?: string source_repo_ref?: string target_branch?: string @@ -139,7 +148,7 @@ export interface OpenapiDirContent { export interface OpenapiGetContentOutput { content?: OpenapiContent - latest_commit?: RepoCommit + latest_commit?: TypesCommit name?: string path?: string sha?: string @@ -173,6 +182,12 @@ export interface OpenapiReviewerAddPullReqRequest { reviewer_id?: number } +export interface OpenapiStatePullReqRequest { + is_draft?: boolean + message?: string + state?: EnumPullReqState +} + export interface OpenapiUpdatePullReqRequest { description?: string title?: string @@ -217,19 +232,11 @@ export interface OpenapiWebhookType { } export interface RepoBranch { - commit?: RepoCommit + commit?: TypesCommit name?: string sha?: string } -export interface RepoCommit { - author?: RepoSignature - committer?: RepoSignature - message?: string - sha?: string - title?: string -} - export interface RepoCommitDivergence { ahead?: number behind?: number @@ -253,12 +260,12 @@ export interface RepoCommitFilesResponse { } export interface RepoCommitTag { - commit?: RepoCommit + commit?: TypesCommit is_annotated?: boolean message?: string name?: string sha?: string - tagger?: RepoSignature + tagger?: TypesSignature title?: string } @@ -266,7 +273,7 @@ export interface RepoCommitTag { export interface RepoContent {} export interface RepoContentInfo { - latest_commit?: RepoCommit + latest_commit?: TypesCommit name?: string path?: string sha?: string @@ -283,16 +290,6 @@ export interface RepoFileContent { export type RepoFileEncodingType = string -export interface RepoIdentity { - email?: string - name?: string -} - -export interface RepoSignature { - identity?: RepoIdentity - when?: string -} - export interface RepoSubmoduleContent { commit_sha?: string url?: string @@ -303,11 +300,24 @@ export interface RepoSymlinkContent { 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 { created?: number created_by?: number id?: number - is_alias?: boolean + is_primary?: boolean target_id?: number target_type?: EnumPathTargetType updated?: number @@ -326,6 +336,9 @@ export interface TypesPullReq { created?: number description?: string edited?: number + is_draft?: boolean + merge_base_sha?: string | null + merge_head_sha?: string | null merge_strategy?: EnumMergeMethod merged?: number | null merger?: TypesPrincipalInfo @@ -348,7 +361,7 @@ export interface TypesPullReqActivity { metadata?: { [key: string]: any } | null order?: number parent_id?: number | null - payload?: { [key: string]: any } | null + payload?: {} pullreq_id?: number repo_id?: number resolved?: number | null @@ -358,6 +371,8 @@ export interface TypesPullReqActivity { type?: EnumPullReqActivityType } +export type TypesPullRequestActivityPayloadComment = { [key: string]: any } | null + export interface TypesRepository { created?: number created_by?: number @@ -375,7 +390,6 @@ export interface TypesRepository { path?: string uid?: string updated?: number - version?: number } export interface TypesServiceAccount { @@ -390,6 +404,11 @@ export interface TypesServiceAccount { updated?: number } +export interface TypesSignature { + identity?: TypesIdentity + when?: string +} + export interface TypesSpace { created?: number created_by?: number @@ -469,6 +488,7 @@ export interface UserUpdateInput { export interface UsererrorError { message?: string + values?: { [key: string]: any } } export type OnLoginProps = Omit, 'path' | 'verb'> @@ -766,13 +786,13 @@ export interface ListCommitsPathParams { } export type ListCommitsProps = Omit< - GetProps, + GetProps, 'path' > & ListCommitsPathParams export const ListCommits = ({ repo_ref, ...props }: ListCommitsProps) => ( - + path={`/repos/${repo_ref}/commits`} base={getConfig('code')} {...props} @@ -780,13 +800,13 @@ export const ListCommits = ({ repo_ref, ...props }: ListCommitsProps) => ( ) export type UseListCommitsProps = Omit< - UseGetProps, + UseGetProps, 'path' > & ListCommitsPathParams export const useListCommits = ({ repo_ref, ...props }: UseListCommitsProps) => - useGet( + useGet( (paramsInPath: ListCommitsPathParams) => `/repos/${paramsInPath.repo_ref}/commits`, { 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. */ - state?: ('open' | 'merged' | 'closed' | 'rejected')[] + state?: ('closed' | 'merged' | 'open')[] /** * Source repository ref of the pull requests. */ @@ -1115,7 +1135,7 @@ export interface ListPullReqQueryParams { /** * The data by which the pull requests are sorted. */ - sort?: 'number' | 'created' | 'edited' + sort?: 'created' | 'edited' | 'merged' | 'number' /** * The page to return. */ @@ -1250,11 +1270,20 @@ export interface ListPullReqActivitiesQueryParams { /** * 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. */ - 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). */ @@ -1467,6 +1496,75 @@ export const useCommentUpdatePullReq = ({ { 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, + 'path' +> & + ListPullReqCommitsPathParams + +export const ListPullReqCommits = ({ repo_ref, pullreq_number, ...props }: ListPullReqCommitsProps) => ( + + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/commits`} + base={getConfig('code')} + {...props} + /> +) + +export type UseListPullReqCommitsProps = Omit< + UseGetProps, + 'path' +> & + ListPullReqCommitsPathParams + +export const useListPullReqCommits = ({ repo_ref, pullreq_number, ...props }: UseListPullReqCommitsProps) => + useGet( + (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, 'path'> & + RawPullReqDiffPathParams + +export const RawPullReqDiff = ({ repo_ref, pullreq_number, ...props }: RawPullReqDiffProps) => ( + + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/diff`} + base={getConfig('code')} + {...props} + /> +) + +export type UseRawPullReqDiffProps = Omit, 'path'> & + RawPullReqDiffPathParams + +export const useRawPullReqDiff = ({ repo_ref, pullreq_number, ...props }: UseRawPullReqDiffProps) => + useGet( + (paramsInPath: RawPullReqDiffPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/diff`, + { base: getConfig('code'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + export interface MergePullReqOpPathParams { repo_ref: string 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 } ) +export interface StatePullReqPathParams { + repo_ref: string + pullreq_number: number +} + +export type StatePullReqProps = Omit< + MutateProps, + 'path' | 'verb' +> & + StatePullReqPathParams + +export const StatePullReq = ({ repo_ref, pullreq_number, ...props }: StatePullReqProps) => ( + + verb="POST" + path={`/repos/${repo_ref}/pullreq/${pullreq_number}/state`} + base={getConfig('code')} + {...props} + /> +) + +export type UseStatePullReqProps = Omit< + UseMutateProps, + 'path' | 'verb' +> & + StatePullReqPathParams + +export const useStatePullReq = ({ repo_ref, pullreq_number, ...props }: UseStatePullReqProps) => + useMutate( + 'POST', + (paramsInPath: StatePullReqPathParams) => + `/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/state`, + { base: getConfig('code'), pathParams: { repo_ref, pullreq_number }, ...props } + ) + export interface ListRepositoryServiceAccountsPathParams { repo_ref: string } @@ -1689,6 +1821,18 @@ export const useListTags = ({ repo_ref, ...props }: UseListTagsProps) => ) 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. */ diff --git a/web/src/services/code/swagger.yaml b/web/src/services/code/swagger.yaml index e6a5fd8be..5a3d77ddb 100644 --- a/web/src/services/code/swagger.yaml +++ b/web/src/services/code/swagger.yaml @@ -483,7 +483,7 @@ paths: application/json: schema: items: - $ref: '#/components/schemas/RepoCommit' + $ref: '#/components/schemas/TypesCommit' type: array description: OK '401': @@ -928,10 +928,9 @@ paths: items: default: open enum: - - open - - merged - closed - - rejected + - merged + - open type: string type: array - description: Source repository ref of the pull requests. @@ -981,9 +980,10 @@ paths: schema: default: number enum: - - number - created - edited + - merged + - number type: string - description: The page to return. in: query @@ -1197,9 +1197,9 @@ paths: schema: items: enum: - - system - - comment - code + - comment + - system type: string type: array - description: The type of the pull request activity to include in the result. @@ -1209,11 +1209,14 @@ paths: schema: items: enum: - - comment + - branch-delete + - branch-update - code-comment - - title-change - - review-submit + - comment - merge + - review-submit + - state-change + - title-change type: string type: array - description: The result should contain only entries created at and after this @@ -1442,6 +1445,119 @@ paths: description: Internal Server Error tags: - 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: post: operationId: mergePullReqOp @@ -1646,6 +1762,58 @@ paths: description: Internal Server Error tags: - 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: get: operationId: listRepositoryServiceAccounts @@ -1789,6 +1957,35 @@ paths: get: operationId: listWebhooks 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. in: query name: page @@ -3053,8 +3250,8 @@ components: EnumMergeMethod: enum: - merge - - squash - rebase + - squash type: string EnumParentResourceType: enum: @@ -3065,39 +3262,41 @@ components: type: string EnumPullReqActivityKind: enum: - - system - - comment - code + - comment + - system type: string EnumPullReqActivityType: enum: - - comment + - branch-delete + - branch-update - code-comment - - title-change - - review-submit + - comment - merge + - review-submit + - state-change + - title-change type: string EnumPullReqReviewDecision: enum: - - pending - - reviewed - approved - changereq + - pending + - reviewed type: string EnumPullReqState: enum: - - open - - merged - closed - - rejected + - merged + - open type: string EnumTokenType: type: string EnumWebhookExecutionResult: enum: - - success - - retriable_error - fatal_error + - retriable_error + - success nullable: true type: string EnumWebhookParent: @@ -3108,11 +3307,11 @@ components: EnumWebhookTrigger: enum: - branch_created - - branch_updated - branch_deleted + - branch_updated - tag_created - - tag_updated - tag_deleted + - tag_updated type: string FormDataOpenapiLoginRequest: properties: @@ -3150,19 +3349,16 @@ components: parent_id: type: integer payload: - additionalProperties: {} - nullable: true - type: object + $ref: '#/components/schemas/TypesPullRequestActivityPayloadComment' text: type: string type: object OpenapiCommentUpdatePullReqRequest: properties: payload: - additionalProperties: {} - nullable: true - type: object + $ref: '#/components/schemas/TypesPullRequestActivityPayloadComment' text: + nullable: true type: string type: object OpenapiCommitFilesRequest: @@ -3191,7 +3387,7 @@ components: OpenapiContentInfo: properties: latest_commit: - $ref: '#/components/schemas/RepoCommit' + $ref: '#/components/schemas/TypesCommit' name: type: string path: @@ -3225,6 +3421,8 @@ components: properties: description: type: string + is_draft: + type: boolean source_branch: type: string source_repo_ref: @@ -3304,7 +3502,7 @@ components: content: $ref: '#/components/schemas/OpenapiContent' latest_commit: - $ref: '#/components/schemas/RepoCommit' + $ref: '#/components/schemas/TypesCommit' name: type: string path: @@ -3357,6 +3555,15 @@ components: reviewer_id: type: integer type: object + OpenapiStatePullReqRequest: + properties: + is_draft: + type: boolean + message: + type: string + state: + $ref: '#/components/schemas/EnumPullReqState' + type: object OpenapiUpdatePullReqRequest: properties: description: @@ -3447,25 +3654,12 @@ components: RepoBranch: properties: commit: - $ref: '#/components/schemas/RepoCommit' + $ref: '#/components/schemas/TypesCommit' name: type: string sha: type: string 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: properties: ahead: @@ -3501,7 +3695,7 @@ components: RepoCommitTag: properties: commit: - $ref: '#/components/schemas/RepoCommit' + $ref: '#/components/schemas/TypesCommit' is_annotated: type: boolean message: @@ -3511,7 +3705,7 @@ components: sha: type: string tagger: - $ref: '#/components/schemas/RepoSignature' + $ref: '#/components/schemas/TypesSignature' title: type: string type: object @@ -3519,7 +3713,7 @@ components: RepoContentInfo: properties: latest_commit: - $ref: '#/components/schemas/RepoCommit' + $ref: '#/components/schemas/TypesCommit' name: type: string path: @@ -3542,21 +3736,6 @@ components: type: object RepoFileEncodingType: 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: properties: commit_sha: @@ -3571,6 +3750,26 @@ components: target: type: string 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: properties: created: @@ -3579,7 +3778,7 @@ components: type: integer id: type: integer - is_alias: + is_primary: type: boolean target_id: type: integer @@ -3612,6 +3811,14 @@ components: type: string edited: type: integer + is_draft: + type: boolean + merge_base_sha: + nullable: true + type: string + merge_head_sha: + nullable: true + type: string merge_strategy: $ref: '#/components/schemas/EnumMergeMethod' merged: @@ -3658,10 +3865,7 @@ components: parent_id: nullable: true type: integer - payload: - additionalProperties: {} - nullable: true - type: object + payload: {} pullreq_id: type: integer repo_id: @@ -3678,6 +3882,10 @@ components: type: $ref: '#/components/schemas/EnumPullReqActivityType' type: object + TypesPullRequestActivityPayloadComment: + additionalProperties: {} + nullable: true + type: object TypesRepository: properties: created: @@ -3712,8 +3920,6 @@ components: type: string updated: type: integer - version: - type: integer type: object TypesServiceAccount: properties: @@ -3736,6 +3942,14 @@ components: updated: type: integer type: object + TypesSignature: + properties: + identity: + $ref: '#/components/schemas/TypesIdentity' + when: + format: date-time + type: string + type: object TypesSpace: properties: created: @@ -3875,6 +4089,9 @@ components: properties: message: type: string + values: + additionalProperties: {} + type: object type: object securitySchemes: bearerAuth: diff --git a/web/src/utils/GitUtils.ts b/web/src/utils/GitUtils.ts index 718b69815..c3f181702 100644 --- a/web/src/utils/GitUtils.ts +++ b/web/src/utils/GitUtils.ts @@ -7,7 +7,7 @@ import type { OpenapiContentInfo, OpenapiDirContent, OpenapiGetContentOutput, - RepoCommit, + TypesCommit, TypesPullReq, TypesRepository } from 'services/code' @@ -18,7 +18,7 @@ export interface GitInfoProps { resourcePath: string resourceContent: OpenapiGetContentOutput commitRef: string - commits: RepoCommit[] + commits: TypesCommit[] pullRequestMetadata: TypesPullReq }