-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: git mod - migrating apis for git (#37984)
## Description - Add application apis for git package Fixes #37823 ## Automation /ok-to-test tags="@tag.Git" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/12194637717> > Commit: e72e02f > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12194637717&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Git` > Spec: > <hr>Fri, 06 Dec 2024 08:23:16 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced various asynchronous functions for Git operations, including: - `checkoutBranchRequest` - `commitRequest` - `connectRequest` - `createBranchRequest` - `deleteBranchRequest` - `fetchBranchesRequest` - `fetchGitMetadataRequest` - `fetchProtectedBranchesRequest` - `mergeRequest` - `pullRequest` - `toggleAutocommitRequest` - `triggerAutocommitRequest` - `updateGlobalConfigRequest` - `updateLocalConfigRequest` - `updateProtectedBranchesRequest` - Added new enumeration `AutocommitStatus` and interfaces to enhance type safety for Git operations. - **Bug Fixes** - Updated import paths for consistency and clarity across multiple files. - **Documentation** - Enhanced type definitions for various request and response structures. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
55 changed files
with
587 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { AxiosResponse } from "axios"; | ||
import type { | ||
CheckoutBranchRequestParams, | ||
CheckoutBranchResponse, | ||
} from "./checkoutBranchRequest.types"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
import Api from "api/Api"; | ||
|
||
export default async function checkoutBranchRequest( | ||
branchedApplicationId: string, | ||
params: CheckoutBranchRequestParams, | ||
): Promise<AxiosResponse<CheckoutBranchResponse>> { | ||
return Api.get( | ||
`${GIT_BASE_URL}/checkout-branch/app/${branchedApplicationId}`, | ||
params, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface CheckoutBranchRequestParams { | ||
branchName: string; | ||
} | ||
|
||
export interface CheckoutBranchResponse { | ||
id: string; // applicationId | ||
baseId: string; // baseApplicationId | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Api from "api/Api"; | ||
import type { | ||
CommitRequestParams, | ||
CommitResponse, | ||
} from "./commitRequest.types"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
import type { AxiosResponse } from "axios"; | ||
|
||
export default async function commitRequest( | ||
branchedApplicationId: string, | ||
params: CommitRequestParams, | ||
): Promise<AxiosResponse<CommitResponse>> { | ||
return Api.post( | ||
`${GIT_BASE_URL}/commit/app/${branchedApplicationId}`, | ||
params, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface CommitRequestParams { | ||
commitMessage: string; | ||
doPush: boolean; | ||
} | ||
|
||
export type CommitResponse = string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Api from "api/Api"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
import type { | ||
ConnectRequestParams, | ||
ConnectResponse, | ||
} from "./connectRequest.types"; | ||
import type { AxiosResponse } from "axios"; | ||
|
||
export default async function connectRequest( | ||
baseApplicationId: string, | ||
params: ConnectRequestParams, | ||
): Promise<AxiosResponse<ConnectResponse>> { | ||
return Api.post(`${GIT_BASE_URL}/connect/app/${baseApplicationId}`, params); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export interface ConnectRequestParams { | ||
remoteUrl: string; | ||
gitProfile?: { | ||
authorName: string; | ||
authorEmail: string; | ||
useDefaultProfile?: boolean; | ||
}; | ||
} | ||
|
||
export interface ConnectResponse { | ||
id: string; | ||
baseId: string; | ||
gitApplicationMetadata: { | ||
branchName: string; | ||
browserSupportedRemoteUrl: string; | ||
defaultApplicationId: string; | ||
defaultArtifactId: string; | ||
defaultBranchName: string; | ||
isRepoPrivate: boolean; | ||
lastCommitedAt: string; | ||
remoteUrl: string; | ||
repoName: string; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const GIT_BASE_URL = "/v1/git"; | ||
export const APPLICATION_BASE_URL = "/v1/applications"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { AxiosResponse } from "axios"; | ||
import type { | ||
CreateBranchRequestParams, | ||
CreateBranchResponse, | ||
} from "./createBranchRequest.types"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
import Api from "api/Api"; | ||
|
||
export default async function createBranchRequest( | ||
branchedApplicationId: string, | ||
params: CreateBranchRequestParams, | ||
): Promise<AxiosResponse<CreateBranchResponse>> { | ||
return Api.post( | ||
`${GIT_BASE_URL}/create-branch/app/${branchedApplicationId}`, | ||
params, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface CreateBranchRequestParams { | ||
branchName: string; | ||
} | ||
|
||
export interface CreateBranchResponse { | ||
id: string; // applicationId | ||
baseId: string; // baseApplicationId | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { AxiosResponse } from "axios"; | ||
import type { | ||
DeleteBranchRequestParams, | ||
DeleteBranchResponse, | ||
} from "./deleteBranchRequest.types"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
import Api from "api/Api"; | ||
|
||
export default async function deleteBranchRequest( | ||
baseApplicationId: string, | ||
params: DeleteBranchRequestParams, | ||
): Promise<AxiosResponse<DeleteBranchResponse>> { | ||
return Api.delete(`${GIT_BASE_URL}/branch/app/${baseApplicationId}`, params); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface DeleteBranchRequestParams { | ||
branchName: string; | ||
} | ||
|
||
export interface DeleteBranchResponse { | ||
id: string; // applicationId | ||
baseId: string; // baseApplicationId | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Api from "api/Api"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
import type { AxiosResponse } from "axios"; | ||
|
||
export default async function discardRequest( | ||
branchedApplicationId: string, | ||
): Promise<AxiosResponse<void>> { | ||
return Api.put(`${GIT_BASE_URL}/discard/app/${branchedApplicationId}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { AxiosResponse } from "axios"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
import type { DisconnectResponse } from "./disconnectRequest.types"; | ||
import Api from "api/Api"; | ||
|
||
export default async function disconnectRequest( | ||
baseApplicationId: string, | ||
): Promise<AxiosResponse<DisconnectResponse>> { | ||
return Api.post(`${GIT_BASE_URL}/disconnect/app/${baseApplicationId}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface DisconnectResponse { | ||
[key: string]: string; | ||
} |
12 changes: 12 additions & 0 deletions
12
app/client/src/git/requests/fetchAutocommitProgressRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Api from "api/Api"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
import type { AxiosResponse } from "axios"; | ||
import type { FetchAutocommitProgressResponse } from "./fetchAutocommitProgressRequest.types"; | ||
|
||
export default async function fetchAutocommitProgressRequest( | ||
baseApplicationId: string, | ||
): Promise<AxiosResponse<FetchAutocommitProgressResponse>> { | ||
return Api.get( | ||
`${GIT_BASE_URL}/auto-commit/progress/app/${baseApplicationId}`, | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
app/client/src/git/requests/fetchAutocommitProgressRequest.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { AutocommitStatus } from "../constants/enums"; | ||
|
||
export interface FetchAutocommitProgressResponse { | ||
autoCommitResponse: AutocommitStatus; | ||
progress: number; | ||
branchName: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Api from "api/Api"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
import type { | ||
FetchBranchesRequestParams, | ||
FetchBranchesResponse, | ||
} from "./fetchBranchesRequest.types"; | ||
import type { AxiosResponse } from "axios"; | ||
|
||
export default async function fetchBranchesRequest( | ||
branchedApplicationId: string, | ||
params?: FetchBranchesRequestParams, | ||
): Promise<AxiosResponse<FetchBranchesResponse>> { | ||
const queryParams = {} as FetchBranchesRequestParams; | ||
|
||
if (params?.pruneBranches) queryParams.pruneBranches = true; | ||
|
||
return Api.get( | ||
`${GIT_BASE_URL}/branch/app/${branchedApplicationId}`, | ||
queryParams, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface FetchBranchesRequestParams { | ||
pruneBranches: boolean; | ||
} | ||
|
||
interface SingleBranch { | ||
branchName: string; | ||
createdFromLocal: string; | ||
default: boolean; | ||
} | ||
|
||
export type FetchBranchesResponse = SingleBranch[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Api from "api/Api"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
import type { AxiosResponse } from "axios"; | ||
import type { FetchGitMetadataResponse } from "./fetchGitMetadataRequest.types"; | ||
|
||
export default async function fetchGitMetadataRequest( | ||
baseApplicationId: string, | ||
): Promise<AxiosResponse<FetchGitMetadataResponse>> { | ||
return Api.get(`${GIT_BASE_URL}/metadata/app/${baseApplicationId}`); | ||
} |
15 changes: 15 additions & 0 deletions
15
app/client/src/git/requests/fetchGitMetadataRequest.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export interface FetchGitMetadataResponse { | ||
branchName: string; | ||
defaultBranchName: string; | ||
remoteUrl: string; | ||
repoName: string; | ||
browserSupportedUrl?: string; | ||
isRepoPrivate?: boolean; | ||
browserSupportedRemoteUrl: string; | ||
defaultApplicationId: string; | ||
isProtectedBranch: boolean; | ||
autoCommitConfig: { | ||
enabled: boolean; | ||
}; | ||
isAutoDeploymentEnabled?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Api from "api/Api"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
import type { AxiosResponse } from "axios"; | ||
import type { FetchGlobalConfigResponse } from "./fetchGlobalConfigRequest.types"; | ||
|
||
export default async function fetchGlobalConfigRequest(): Promise< | ||
AxiosResponse<FetchGlobalConfigResponse> | ||
> { | ||
return Api.get(`${GIT_BASE_URL}/profile/default`); | ||
} |
4 changes: 4 additions & 0 deletions
4
app/client/src/git/requests/fetchGlobalConfigRequest.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface FetchGlobalConfigResponse { | ||
authorName: string; | ||
authorEmail: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Api from "api/Api"; | ||
import type { AxiosResponse } from "axios"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
import type { FetchLocalConfigResponse } from "./fetchLocalConfigRequest.types"; | ||
|
||
export default async function fetchLocalConfigRequest( | ||
baseApplicationId: string, | ||
): Promise<AxiosResponse<FetchLocalConfigResponse>> { | ||
return Api.get(`${GIT_BASE_URL}/profile/app/${baseApplicationId}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface FetchLocalConfigResponse { | ||
authorName: string; | ||
authorEmail: string; | ||
useGlobalProfile: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { AxiosResponse } from "axios"; | ||
import type { | ||
FetchMergeStatusRequestParams, | ||
FetchMergeStatusResponse, | ||
} from "./fetchMergeStatusRequest.types"; | ||
import Api from "api/Api"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
|
||
export default async function fetchMergeStatusRequest( | ||
branchedApplicationId: string, | ||
params: FetchMergeStatusRequestParams, | ||
): Promise<AxiosResponse<FetchMergeStatusResponse>> { | ||
return Api.post( | ||
`${GIT_BASE_URL}/merge/status/app/${branchedApplicationId}`, | ||
params, | ||
); | ||
} |
10 changes: 10 additions & 0 deletions
10
app/client/src/git/requests/fetchMergeStatusRequest.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface FetchMergeStatusRequestParams { | ||
sourceBranch: string; | ||
destinationBranch: string; | ||
} | ||
|
||
export interface FetchMergeStatusResponse { | ||
isMergeAble: boolean; | ||
status: string; // merge status | ||
message: string; | ||
} |
10 changes: 10 additions & 0 deletions
10
app/client/src/git/requests/fetchProtectedBranchesRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Api from "api/Api"; | ||
import { GIT_BASE_URL } from "./constants"; | ||
import type { AxiosResponse } from "axios"; | ||
import type { FetchProtectedBranches } from "./fetchProtectedBranchesRequest.types"; | ||
|
||
export default async function fetchProtectedBranchesRequest( | ||
baseApplicationId: string, | ||
): Promise<AxiosResponse<FetchProtectedBranches>> { | ||
return Api.get(`${GIT_BASE_URL}/branch/app/${baseApplicationId}/protected`); | ||
} |
1 change: 1 addition & 0 deletions
1
app/client/src/git/requests/fetchProtectedBranchesRequest.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type FetchProtectedBranches = string[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { AxiosResponse } from "axios"; | ||
import type { FetchSSHKeyResponse } from "./fetchSSHKeyRequest.types"; | ||
import Api from "api/Api"; | ||
import { APPLICATION_BASE_URL } from "./constants"; | ||
|
||
export default async function fetchSSHKeyRequest( | ||
baseApplicationId: string, | ||
): Promise<AxiosResponse<FetchSSHKeyResponse>> { | ||
return Api.get(`${APPLICATION_BASE_URL}/ssh-keypair/${baseApplicationId}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface FetchSSHKeyResponse { | ||
publicKey: string; | ||
docUrl: string; | ||
isRegeneratedKey: boolean; | ||
regeneratedKey: boolean; | ||
} |
Oops, something went wrong.