diff --git a/app/client/src/git/actions/helpers/singleArtifactInitialState.ts b/app/client/src/git/actions/helpers/singleArtifactInitialState.ts index 0c8e0cb282f8..26735b772c47 100644 --- a/app/client/src/git/actions/helpers/singleArtifactInitialState.ts +++ b/app/client/src/git/actions/helpers/singleArtifactInitialState.ts @@ -3,7 +3,7 @@ import { GitImportStep, GitOpsTab, GitSettingsTab, -} from "../../enums"; +} from "../../constants/enums"; import type { GitSingleArtifactAPIResponsesReduxState, GitSingleArtifactUIReduxState, diff --git a/app/client/src/git/components/QuickActions/index.test.tsx b/app/client/src/git/components/QuickActions/index.test.tsx index b920e6b51fde..189b3ea67be9 100644 --- a/app/client/src/git/components/QuickActions/index.test.tsx +++ b/app/client/src/git/components/QuickActions/index.test.tsx @@ -2,7 +2,7 @@ import React from "react"; import { render, screen, fireEvent } from "@testing-library/react"; import AnalyticsUtil from "ee/utils/AnalyticsUtil"; import QuickActions from "."; -import { GitSettingsTab } from "git/enums"; +import { GitSettingsTab } from "../../constants/enums"; import { GitSyncModalTab } from "entities/GitSync"; import { theme } from "constants/DefaultTheme"; import { ThemeProvider } from "styled-components"; diff --git a/app/client/src/git/components/QuickActions/index.tsx b/app/client/src/git/components/QuickActions/index.tsx index cab336ca1e52..21483fb83ad4 100644 --- a/app/client/src/git/components/QuickActions/index.tsx +++ b/app/client/src/git/components/QuickActions/index.tsx @@ -12,7 +12,7 @@ import { GitSyncModalTab } from "entities/GitSync"; import AnalyticsUtil from "ee/utils/AnalyticsUtil"; import type { GitMetadata, GitStatus } from "../../types"; import { getPullBtnStatus } from "./helpers"; -import { GitSettingsTab } from "../../enums"; +import { GitSettingsTab } from "../../constants/enums"; import ConnectButton from "./ConnectButton"; import QuickActionButton from "./QuickActionButton"; import AutocommitStatusbar from "./AutocommitStatusbar"; diff --git a/app/client/src/git/enums.ts b/app/client/src/git/constants/enums.ts similarity index 69% rename from app/client/src/git/enums.ts rename to app/client/src/git/constants/enums.ts index fe72149e9fe7..e431e6323ca8 100644 --- a/app/client/src/git/enums.ts +++ b/app/client/src/git/constants/enums.ts @@ -25,3 +25,12 @@ export enum GitSettingsTab { General = "General", Branch = "Branch", } + +export enum AutocommitStatus { + IN_PROGRESS = "IN_PROGRESS", + LOCKED = "LOCKED", + PUBLISHED = "PUBLISHED", + IDLE = "IDLE", + NOT_REQUIRED = "NOT_REQUIRED", + NON_GIT_APP = "NON_GIT_APP", +} diff --git a/app/client/src/git/requests/checkoutBranchRequest.ts b/app/client/src/git/requests/checkoutBranchRequest.ts new file mode 100644 index 000000000000..4df5da6112d3 --- /dev/null +++ b/app/client/src/git/requests/checkoutBranchRequest.ts @@ -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> { + return Api.get( + `${GIT_BASE_URL}/checkout-branch/app/${branchedApplicationId}`, + params, + ); +} diff --git a/app/client/src/git/requests/checkoutBranchRequest.types.ts b/app/client/src/git/requests/checkoutBranchRequest.types.ts new file mode 100644 index 000000000000..8c465fc624ee --- /dev/null +++ b/app/client/src/git/requests/checkoutBranchRequest.types.ts @@ -0,0 +1,8 @@ +export interface CheckoutBranchRequestParams { + branchName: string; +} + +export interface CheckoutBranchResponse { + id: string; // applicationId + baseId: string; // baseApplicationId +} diff --git a/app/client/src/git/requests/commitRequest.ts b/app/client/src/git/requests/commitRequest.ts new file mode 100644 index 000000000000..69541d030368 --- /dev/null +++ b/app/client/src/git/requests/commitRequest.ts @@ -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> { + return Api.post( + `${GIT_BASE_URL}/commit/app/${branchedApplicationId}`, + params, + ); +} diff --git a/app/client/src/git/requests/commitRequest.types.ts b/app/client/src/git/requests/commitRequest.types.ts new file mode 100644 index 000000000000..b9c4bd7d7871 --- /dev/null +++ b/app/client/src/git/requests/commitRequest.types.ts @@ -0,0 +1,6 @@ +export interface CommitRequestParams { + commitMessage: string; + doPush: boolean; +} + +export type CommitResponse = string; diff --git a/app/client/src/git/requests/connectRequest.ts b/app/client/src/git/requests/connectRequest.ts new file mode 100644 index 000000000000..b62578361024 --- /dev/null +++ b/app/client/src/git/requests/connectRequest.ts @@ -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> { + return Api.post(`${GIT_BASE_URL}/connect/app/${baseApplicationId}`, params); +} diff --git a/app/client/src/git/requests/connectRequest.types.ts b/app/client/src/git/requests/connectRequest.types.ts new file mode 100644 index 000000000000..ef529d1bc1ff --- /dev/null +++ b/app/client/src/git/requests/connectRequest.types.ts @@ -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; + }; +} diff --git a/app/client/src/git/requests/constants.ts b/app/client/src/git/requests/constants.ts new file mode 100644 index 000000000000..e8626c4cc4a0 --- /dev/null +++ b/app/client/src/git/requests/constants.ts @@ -0,0 +1,2 @@ +export const GIT_BASE_URL = "/v1/git"; +export const APPLICATION_BASE_URL = "/v1/applications"; diff --git a/app/client/src/git/requests/createBranchRequest.ts b/app/client/src/git/requests/createBranchRequest.ts new file mode 100644 index 000000000000..a67b5ee04099 --- /dev/null +++ b/app/client/src/git/requests/createBranchRequest.ts @@ -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> { + return Api.post( + `${GIT_BASE_URL}/create-branch/app/${branchedApplicationId}`, + params, + ); +} diff --git a/app/client/src/git/requests/createBranchRequest.types.ts b/app/client/src/git/requests/createBranchRequest.types.ts new file mode 100644 index 000000000000..28735db75183 --- /dev/null +++ b/app/client/src/git/requests/createBranchRequest.types.ts @@ -0,0 +1,8 @@ +export interface CreateBranchRequestParams { + branchName: string; +} + +export interface CreateBranchResponse { + id: string; // applicationId + baseId: string; // baseApplicationId +} diff --git a/app/client/src/git/requests/deleteBranchRequest.ts b/app/client/src/git/requests/deleteBranchRequest.ts new file mode 100644 index 000000000000..63f718506d48 --- /dev/null +++ b/app/client/src/git/requests/deleteBranchRequest.ts @@ -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> { + return Api.delete(`${GIT_BASE_URL}/branch/app/${baseApplicationId}`, params); +} diff --git a/app/client/src/git/requests/deleteBranchRequest.types.ts b/app/client/src/git/requests/deleteBranchRequest.types.ts new file mode 100644 index 000000000000..f7db6f834859 --- /dev/null +++ b/app/client/src/git/requests/deleteBranchRequest.types.ts @@ -0,0 +1,8 @@ +export interface DeleteBranchRequestParams { + branchName: string; +} + +export interface DeleteBranchResponse { + id: string; // applicationId + baseId: string; // baseApplicationId +} diff --git a/app/client/src/git/requests/discardRequest.ts b/app/client/src/git/requests/discardRequest.ts new file mode 100644 index 000000000000..fda452fc206c --- /dev/null +++ b/app/client/src/git/requests/discardRequest.ts @@ -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> { + return Api.put(`${GIT_BASE_URL}/discard/app/${branchedApplicationId}`); +} diff --git a/app/client/src/git/requests/disconnectRequest.ts b/app/client/src/git/requests/disconnectRequest.ts new file mode 100644 index 000000000000..9ec9b3a4e2b9 --- /dev/null +++ b/app/client/src/git/requests/disconnectRequest.ts @@ -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> { + return Api.post(`${GIT_BASE_URL}/disconnect/app/${baseApplicationId}`); +} diff --git a/app/client/src/git/requests/disconnectRequest.types.ts b/app/client/src/git/requests/disconnectRequest.types.ts new file mode 100644 index 000000000000..34ac4728a324 --- /dev/null +++ b/app/client/src/git/requests/disconnectRequest.types.ts @@ -0,0 +1,3 @@ +export interface DisconnectResponse { + [key: string]: string; +} diff --git a/app/client/src/git/requests/fetchAutocommitProgressRequest.ts b/app/client/src/git/requests/fetchAutocommitProgressRequest.ts new file mode 100644 index 000000000000..8ad1c71d22c8 --- /dev/null +++ b/app/client/src/git/requests/fetchAutocommitProgressRequest.ts @@ -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> { + return Api.get( + `${GIT_BASE_URL}/auto-commit/progress/app/${baseApplicationId}`, + ); +} diff --git a/app/client/src/git/requests/fetchAutocommitProgressRequest.types.ts b/app/client/src/git/requests/fetchAutocommitProgressRequest.types.ts new file mode 100644 index 000000000000..60f10b5fc6b3 --- /dev/null +++ b/app/client/src/git/requests/fetchAutocommitProgressRequest.types.ts @@ -0,0 +1,7 @@ +import type { AutocommitStatus } from "../constants/enums"; + +export interface FetchAutocommitProgressResponse { + autoCommitResponse: AutocommitStatus; + progress: number; + branchName: string; +} diff --git a/app/client/src/git/requests/fetchBranchesRequest.ts b/app/client/src/git/requests/fetchBranchesRequest.ts new file mode 100644 index 000000000000..90fdbf73d94a --- /dev/null +++ b/app/client/src/git/requests/fetchBranchesRequest.ts @@ -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> { + const queryParams = {} as FetchBranchesRequestParams; + + if (params?.pruneBranches) queryParams.pruneBranches = true; + + return Api.get( + `${GIT_BASE_URL}/branch/app/${branchedApplicationId}`, + queryParams, + ); +} diff --git a/app/client/src/git/requests/fetchBranchesRequest.types.ts b/app/client/src/git/requests/fetchBranchesRequest.types.ts new file mode 100644 index 000000000000..e86e545b309e --- /dev/null +++ b/app/client/src/git/requests/fetchBranchesRequest.types.ts @@ -0,0 +1,11 @@ +export interface FetchBranchesRequestParams { + pruneBranches: boolean; +} + +interface SingleBranch { + branchName: string; + createdFromLocal: string; + default: boolean; +} + +export type FetchBranchesResponse = SingleBranch[]; diff --git a/app/client/src/git/requests/fetchGitMetadataRequest.ts b/app/client/src/git/requests/fetchGitMetadataRequest.ts new file mode 100644 index 000000000000..136f5776f557 --- /dev/null +++ b/app/client/src/git/requests/fetchGitMetadataRequest.ts @@ -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> { + return Api.get(`${GIT_BASE_URL}/metadata/app/${baseApplicationId}`); +} diff --git a/app/client/src/git/requests/fetchGitMetadataRequest.types.ts b/app/client/src/git/requests/fetchGitMetadataRequest.types.ts new file mode 100644 index 000000000000..95ef9f6ec3ab --- /dev/null +++ b/app/client/src/git/requests/fetchGitMetadataRequest.types.ts @@ -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; +} diff --git a/app/client/src/git/requests/fetchGlobalConfigRequest.ts b/app/client/src/git/requests/fetchGlobalConfigRequest.ts new file mode 100644 index 000000000000..32b048c0bbf0 --- /dev/null +++ b/app/client/src/git/requests/fetchGlobalConfigRequest.ts @@ -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 +> { + return Api.get(`${GIT_BASE_URL}/profile/default`); +} diff --git a/app/client/src/git/requests/fetchGlobalConfigRequest.types.ts b/app/client/src/git/requests/fetchGlobalConfigRequest.types.ts new file mode 100644 index 000000000000..1939b2df65fd --- /dev/null +++ b/app/client/src/git/requests/fetchGlobalConfigRequest.types.ts @@ -0,0 +1,4 @@ +export interface FetchGlobalConfigResponse { + authorName: string; + authorEmail: string; +} diff --git a/app/client/src/git/requests/fetchLocalConfigRequest.ts b/app/client/src/git/requests/fetchLocalConfigRequest.ts new file mode 100644 index 000000000000..53159fc886f7 --- /dev/null +++ b/app/client/src/git/requests/fetchLocalConfigRequest.ts @@ -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> { + return Api.get(`${GIT_BASE_URL}/profile/app/${baseApplicationId}`); +} diff --git a/app/client/src/git/requests/fetchLocalConfigRequest.types.ts b/app/client/src/git/requests/fetchLocalConfigRequest.types.ts new file mode 100644 index 000000000000..abc83e1d83ba --- /dev/null +++ b/app/client/src/git/requests/fetchLocalConfigRequest.types.ts @@ -0,0 +1,5 @@ +export interface FetchLocalConfigResponse { + authorName: string; + authorEmail: string; + useGlobalProfile: boolean; +} diff --git a/app/client/src/git/requests/fetchMergeStatusRequest.ts b/app/client/src/git/requests/fetchMergeStatusRequest.ts new file mode 100644 index 000000000000..95701d5cadc8 --- /dev/null +++ b/app/client/src/git/requests/fetchMergeStatusRequest.ts @@ -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> { + return Api.post( + `${GIT_BASE_URL}/merge/status/app/${branchedApplicationId}`, + params, + ); +} diff --git a/app/client/src/git/requests/fetchMergeStatusRequest.types.ts b/app/client/src/git/requests/fetchMergeStatusRequest.types.ts new file mode 100644 index 000000000000..76965ee37ff5 --- /dev/null +++ b/app/client/src/git/requests/fetchMergeStatusRequest.types.ts @@ -0,0 +1,10 @@ +export interface FetchMergeStatusRequestParams { + sourceBranch: string; + destinationBranch: string; +} + +export interface FetchMergeStatusResponse { + isMergeAble: boolean; + status: string; // merge status + message: string; +} diff --git a/app/client/src/git/requests/fetchProtectedBranchesRequest.ts b/app/client/src/git/requests/fetchProtectedBranchesRequest.ts new file mode 100644 index 000000000000..492a23c5eeca --- /dev/null +++ b/app/client/src/git/requests/fetchProtectedBranchesRequest.ts @@ -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> { + return Api.get(`${GIT_BASE_URL}/branch/app/${baseApplicationId}/protected`); +} diff --git a/app/client/src/git/requests/fetchProtectedBranchesRequest.types.ts b/app/client/src/git/requests/fetchProtectedBranchesRequest.types.ts new file mode 100644 index 000000000000..166cc05322ed --- /dev/null +++ b/app/client/src/git/requests/fetchProtectedBranchesRequest.types.ts @@ -0,0 +1 @@ +export type FetchProtectedBranches = string[]; diff --git a/app/client/src/git/requests/fetchSSHKeyRequest.ts b/app/client/src/git/requests/fetchSSHKeyRequest.ts new file mode 100644 index 000000000000..e61884e28a3b --- /dev/null +++ b/app/client/src/git/requests/fetchSSHKeyRequest.ts @@ -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> { + return Api.get(`${APPLICATION_BASE_URL}/ssh-keypair/${baseApplicationId}`); +} diff --git a/app/client/src/git/requests/fetchSSHKeyRequest.types.ts b/app/client/src/git/requests/fetchSSHKeyRequest.types.ts new file mode 100644 index 000000000000..55b4f305b666 --- /dev/null +++ b/app/client/src/git/requests/fetchSSHKeyRequest.types.ts @@ -0,0 +1,6 @@ +export interface FetchSSHKeyResponse { + publicKey: string; + docUrl: string; + isRegeneratedKey: boolean; + regeneratedKey: boolean; +} diff --git a/app/client/src/git/requests/fetchStatusRequest.ts b/app/client/src/git/requests/fetchStatusRequest.ts new file mode 100644 index 000000000000..587b4f66ea0b --- /dev/null +++ b/app/client/src/git/requests/fetchStatusRequest.ts @@ -0,0 +1,14 @@ +import Api from "api/Api"; +import type { + FetchStatusRequestParams, + FetchStatusResponse, +} from "./fetchStatusRequest.types"; +import { GIT_BASE_URL } from "./constants"; +import type { AxiosResponse } from "axios"; + +export default async function fetchStatusRequest( + branchedApplicationId: string, + params: FetchStatusRequestParams, +): Promise> { + return Api.get(`${GIT_BASE_URL}/status/app/${branchedApplicationId}`, params); +} diff --git a/app/client/src/git/requests/fetchStatusRequest.types.ts b/app/client/src/git/requests/fetchStatusRequest.types.ts new file mode 100644 index 000000000000..9a63fc879487 --- /dev/null +++ b/app/client/src/git/requests/fetchStatusRequest.types.ts @@ -0,0 +1,38 @@ +export interface FetchStatusRequestParams { + compareRemote: boolean; +} + +export interface FetchStatusResponse { + added: string[]; + aheadCount: number; + behindCount: number; + conflicting: string[]; + datasourcesAdded: string[]; + datasourcesModified: string[]; + datasourcesRemoved: string[]; + discardDocUrl: string; + isClean: boolean; + jsLibsAdded: string[]; + jsLibsModified: string[]; + jsLibsRemoved: string[]; + jsObjectsAdded: string[]; + jsObjectsModified: string[]; + jsObjectsRemoved: string[]; + migrationMessage: string; + modified: string[]; + modifiedDatasources: number; + modifiedJSLibs: number; + modifiedJSObjects: number; + modifiedModuleInstances: number; + modifiedModules: number; + modifiedPages: number; + modifiedQueries: number; + pagesAdded: string[]; + pagesModified: string[]; + pagesRemoved: string[]; + queriesAdded: string[]; + queriesModified: string[]; + queriesRemoved: string[]; + remoteBranch: string; + removed: string[]; +} diff --git a/app/client/src/git/requests/generateSSHKeyRequest.ts b/app/client/src/git/requests/generateSSHKeyRequest.ts new file mode 100644 index 000000000000..525c0423a16f --- /dev/null +++ b/app/client/src/git/requests/generateSSHKeyRequest.ts @@ -0,0 +1,18 @@ +import type { AxiosResponse } from "axios"; +import type { + GenerateSSHKeyRequestParams, + GenerateSSHKeyResponse, +} from "./generateSSHKeyRequest.types"; +import { APPLICATION_BASE_URL, GIT_BASE_URL } from "./constants"; +import Api from "api/Api"; + +export default async function generateSSHKeyRequest( + baseApplicationId: string, + params: GenerateSSHKeyRequestParams, +): Promise> { + const url = params.isImporting + ? `${GIT_BASE_URL}/import/keys?keyType=${params.keyType}` + : `${APPLICATION_BASE_URL}/ssh-keypair/${baseApplicationId}?keyType=${params.keyType}`; + + return params.isImporting ? Api.get(url) : Api.post(url); +} diff --git a/app/client/src/git/requests/generateSSHKeyRequest.types.ts b/app/client/src/git/requests/generateSSHKeyRequest.types.ts new file mode 100644 index 000000000000..ced29ad6dbc0 --- /dev/null +++ b/app/client/src/git/requests/generateSSHKeyRequest.types.ts @@ -0,0 +1,11 @@ +export interface GenerateSSHKeyRequestParams { + keyType: string; + isImporting: boolean; +} + +export interface GenerateSSHKeyResponse { + publicKey: string; + docUrl: string; + isRegeneratedKey: boolean; + regeneratedKey: boolean; +} diff --git a/app/client/src/git/requests/importGitRequest.ts b/app/client/src/git/requests/importGitRequest.ts new file mode 100644 index 000000000000..e9378361da88 --- /dev/null +++ b/app/client/src/git/requests/importGitRequest.ts @@ -0,0 +1,14 @@ +import Api from "api/Api"; +import { GIT_BASE_URL } from "./constants"; +import type { + ImportGitRequestParams, + ImportGitResponse, +} from "./importGitRequest.types"; +import type { AxiosResponse } from "axios"; + +export default async function importGitRequest( + workspaceId: string, + params: ImportGitRequestParams, +): Promise> { + return Api.post(`${GIT_BASE_URL}/import/${workspaceId}`, params); +} diff --git a/app/client/src/git/requests/importGitRequest.types.ts b/app/client/src/git/requests/importGitRequest.types.ts new file mode 100644 index 000000000000..b0f3113d7a6e --- /dev/null +++ b/app/client/src/git/requests/importGitRequest.types.ts @@ -0,0 +1,24 @@ +export interface ImportGitRequestParams { + remoteUrl: string; + gitProfile?: { + authorName: string; + authorEmail: string; + useDefaultProfile?: boolean; + }; +} + +export interface ImportGitResponse { + id: string; + baseId: string; + gitApplicationMetadata: { + branchName: string; + browserSupportedRemoteUrl: string; + defaultApplicationId: string; + defaultArtifactId: string; + defaultBranchName: string; + isRepoPrivate: boolean; + lastCommitedAt: string; + remoteUrl: string; + repoName: string; + }; +} diff --git a/app/client/src/git/requests/mergeRequest.ts b/app/client/src/git/requests/mergeRequest.ts new file mode 100644 index 000000000000..ee30566c4936 --- /dev/null +++ b/app/client/src/git/requests/mergeRequest.ts @@ -0,0 +1,11 @@ +import Api from "api/Api"; +import type { MergeRequestParams, MergeResponse } from "./mergeRequest.types"; +import { GIT_BASE_URL } from "./constants"; +import type { AxiosResponse } from "axios"; + +export default async function mergeRequest( + branchedApplicationId: string, + params: MergeRequestParams, +): Promise> { + return Api.post(`${GIT_BASE_URL}/merge/app/${branchedApplicationId}`, params); +} diff --git a/app/client/src/git/requests/mergeRequest.types.ts b/app/client/src/git/requests/mergeRequest.types.ts new file mode 100644 index 000000000000..7ec27500b1ed --- /dev/null +++ b/app/client/src/git/requests/mergeRequest.types.ts @@ -0,0 +1,9 @@ +export interface MergeRequestParams { + sourceBranch: string; + destinationBranch: string; +} + +export interface MergeResponse { + isMergAble: boolean; + status: string; // merge status +} diff --git a/app/client/src/git/requests/pullRequest.ts b/app/client/src/git/requests/pullRequest.ts new file mode 100644 index 000000000000..21bd6f4f2a3c --- /dev/null +++ b/app/client/src/git/requests/pullRequest.ts @@ -0,0 +1,10 @@ +import Api from "api/Api"; +import { GIT_BASE_URL } from "./constants"; +import type { AxiosResponse } from "axios"; +import type { PullRequestResponse } from "./pullRequest.types"; + +export default async function pullRequest( + branchedApplicationId: string, +): Promise> { + return Api.get(`${GIT_BASE_URL}/pull/app/${branchedApplicationId}`); +} diff --git a/app/client/src/git/requests/pullRequest.types.ts b/app/client/src/git/requests/pullRequest.types.ts new file mode 100644 index 000000000000..abfb2586ca8e --- /dev/null +++ b/app/client/src/git/requests/pullRequest.types.ts @@ -0,0 +1,6 @@ +export interface PullRequestResponse { + mergeStatus: { + isMergeAble: boolean; + status: string; // pull merge status + }; +} diff --git a/app/client/src/git/requests/toggleAutocommitRequest.ts b/app/client/src/git/requests/toggleAutocommitRequest.ts new file mode 100644 index 000000000000..deba662ded3f --- /dev/null +++ b/app/client/src/git/requests/toggleAutocommitRequest.ts @@ -0,0 +1,12 @@ +import Api from "api/Api"; +import { GIT_BASE_URL } from "./constants"; +import type { AxiosResponse } from "axios"; +import type { ToggleAutocommitResponse } from "./toggleAutocommitRequest.types"; + +export default async function toggleAutocommitRequest( + baseApplicationId: string, +): Promise> { + return Api.patch( + `${GIT_BASE_URL}/auto-commit/toggle/app/${baseApplicationId}`, + ); +} diff --git a/app/client/src/git/requests/toggleAutocommitRequest.types.ts b/app/client/src/git/requests/toggleAutocommitRequest.types.ts new file mode 100644 index 000000000000..9dc99ed84528 --- /dev/null +++ b/app/client/src/git/requests/toggleAutocommitRequest.types.ts @@ -0,0 +1 @@ +export type ToggleAutocommitResponse = boolean; diff --git a/app/client/src/git/requests/triggerAutocommitRequest.ts b/app/client/src/git/requests/triggerAutocommitRequest.ts new file mode 100644 index 000000000000..01c603cb4ce5 --- /dev/null +++ b/app/client/src/git/requests/triggerAutocommitRequest.ts @@ -0,0 +1,10 @@ +import Api from "api/Api"; +import { GIT_BASE_URL } from "./constants"; +import type { AxiosResponse } from "axios"; +import type { TriggerAutocommitResponse } from "./triggerAutocommitRequest.types"; + +export default async function triggerAutocommitRequest( + branchedApplicationId: string, +): Promise> { + return Api.post(`${GIT_BASE_URL}/auto-commit/app/${branchedApplicationId}`); +} diff --git a/app/client/src/git/requests/triggerAutocommitRequest.types.ts b/app/client/src/git/requests/triggerAutocommitRequest.types.ts new file mode 100644 index 000000000000..6abf80ecf226 --- /dev/null +++ b/app/client/src/git/requests/triggerAutocommitRequest.types.ts @@ -0,0 +1,7 @@ +import type { AutocommitStatus } from "../constants/enums"; + +export interface TriggerAutocommitResponse { + autoCommitResponse: AutocommitStatus; + progress: number; + branchName: string; +} diff --git a/app/client/src/git/requests/updateGlobalConfigRequest.ts b/app/client/src/git/requests/updateGlobalConfigRequest.ts new file mode 100644 index 000000000000..a20cb5beb877 --- /dev/null +++ b/app/client/src/git/requests/updateGlobalConfigRequest.ts @@ -0,0 +1,13 @@ +import type { AxiosResponse } from "axios"; +import type { + UpdateGlobalConfigRequestParams, + UpdateGlobalConfigResponse, +} from "./updateGlobalConfigRequest.types"; +import Api from "api/Api"; +import { GIT_BASE_URL } from "./constants"; + +export default async function updateGlobalConfigRequest( + params: UpdateGlobalConfigRequestParams, +): Promise> { + return Api.post(`${GIT_BASE_URL}/profile/default`, params); +} diff --git a/app/client/src/git/requests/updateGlobalConfigRequest.types.ts b/app/client/src/git/requests/updateGlobalConfigRequest.types.ts new file mode 100644 index 000000000000..10116f7dc991 --- /dev/null +++ b/app/client/src/git/requests/updateGlobalConfigRequest.types.ts @@ -0,0 +1,11 @@ +export interface UpdateGlobalConfigRequestParams { + authorName: string; + authorEmail: string; +} + +export interface UpdateGlobalConfigResponse { + default: { + authorName: string; + authorEmail: string; + }; +} diff --git a/app/client/src/git/requests/updateLocalConfigRequest.ts b/app/client/src/git/requests/updateLocalConfigRequest.ts new file mode 100644 index 000000000000..4b69bc72c27d --- /dev/null +++ b/app/client/src/git/requests/updateLocalConfigRequest.ts @@ -0,0 +1,14 @@ +import type { AxiosResponse } from "axios"; +import type { + UpdateLocalConfigRequestParams, + UpdateLocalConfigResponse, +} from "./updateLocalConfigRequest.types"; +import Api from "api/Api"; +import { GIT_BASE_URL } from "./constants"; + +export default async function updateLocalConfigRequest( + baseApplicationId: string, + params: UpdateLocalConfigRequestParams, +): Promise> { + return Api.put(`${GIT_BASE_URL}/profile/app/${baseApplicationId}`, params); +} diff --git a/app/client/src/git/requests/updateLocalConfigRequest.types.ts b/app/client/src/git/requests/updateLocalConfigRequest.types.ts new file mode 100644 index 000000000000..5414637a46c8 --- /dev/null +++ b/app/client/src/git/requests/updateLocalConfigRequest.types.ts @@ -0,0 +1,13 @@ +export interface UpdateLocalConfigRequestParams { + authorName: string; + authorEmail: string; + useGlobalProfile: boolean; +} + +export interface UpdateLocalConfigResponse { + [baseApplicationId: string]: { + authorName: string; + authorEmail: string; + useGlobalProfile: boolean; + }; +} diff --git a/app/client/src/git/requests/updateProtectedBranchesRequest.ts b/app/client/src/git/requests/updateProtectedBranchesRequest.ts new file mode 100644 index 000000000000..5af603ecaa7d --- /dev/null +++ b/app/client/src/git/requests/updateProtectedBranchesRequest.ts @@ -0,0 +1,17 @@ +import Api from "api/Api"; +import { GIT_BASE_URL } from "./constants"; +import type { + UpdateProtectedBranchesRequestParams, + UpdateProtectedBranchesResponse, +} from "./updateProtectedBranchesRequest.types"; +import type { AxiosResponse } from "axios"; + +export default async function updateProtectedBranchesRequest( + baseApplicationId: string, + params: UpdateProtectedBranchesRequestParams, +): Promise> { + return Api.post( + `${GIT_BASE_URL}/branch/app/${baseApplicationId}/protected`, + params, + ); +} diff --git a/app/client/src/git/requests/updateProtectedBranchesRequest.types.ts b/app/client/src/git/requests/updateProtectedBranchesRequest.types.ts new file mode 100644 index 000000000000..fff7073624e4 --- /dev/null +++ b/app/client/src/git/requests/updateProtectedBranchesRequest.types.ts @@ -0,0 +1,5 @@ +export interface UpdateProtectedBranchesRequestParams { + branchNames: string[]; +} + +export type UpdateProtectedBranchesResponse = string[]; diff --git a/app/client/src/git/types.ts b/app/client/src/git/types.ts index 7786dcc1b4a0..af349c168fb8 100644 --- a/app/client/src/git/types.ts +++ b/app/client/src/git/types.ts @@ -5,7 +5,7 @@ import type { GitImportStep, GitOpsTab, GitSettingsTab, -} from "./enums"; +} from "./constants/enums"; // These will be updated when contracts are finalized export type GitMetadata = Record;