-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore: git mod - migrating apis for git #37984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1119f65
2900b65
0d1fa18
146238c
e72e02f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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, | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| export interface CheckoutBranchRequestParams { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are doing one api per file so why segregate further having types.ts? wouldn't it incur more context switching?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid circular dependencies.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| branchName: string; | ||
| } | ||
|
|
||
| export interface CheckoutBranchResponse { | ||
| id: string; // applicationId | ||
| baseId: string; // baseApplicationId | ||
| } | ||
| 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, | ||
| ); | ||
| } |
| 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; |
| 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); | ||
| } |
| 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; | ||
| }; | ||
| } |
| 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"; |
| 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, | ||
| ); | ||
| } |
| 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 | ||
| } |
| 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); | ||
| } |
| 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 | ||
| } |
| 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}`); | ||
| } |
| 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}`); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export interface DisconnectResponse { | ||
| [key: string]: string; | ||
| } |
| 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}`, | ||
| ); | ||
| } |
| 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; | ||
| } | ||
brayn003 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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, | ||
| ); | ||
| } |
| 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[]; |
| 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}`); | ||
| } |
| 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; | ||
| } |
| 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`); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export interface FetchGlobalConfigResponse { | ||
| authorName: string; | ||
| authorEmail: string; | ||
| } |
| 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}`); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export interface FetchLocalConfigResponse { | ||
| authorName: string; | ||
| authorEmail: string; | ||
| useGlobalProfile: boolean; | ||
| } |
| 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, | ||
| ); | ||
| } |
| 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; | ||
| } |
| 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`); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export type FetchProtectedBranches = string[]; |
| 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}`); | ||
| } |
| 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; | ||
| } |

Uh oh!
There was an error while loading. Please reload this page.