diff --git a/app/client/src/ce/entities/FeatureFlag.ts b/app/client/src/ce/entities/FeatureFlag.ts index a662c4807e10..f75ffc9527a6 100644 --- a/app/client/src/ce/entities/FeatureFlag.ts +++ b/app/client/src/ce/entities/FeatureFlag.ts @@ -49,6 +49,7 @@ export const FEATURE_FLAG = { release_gs_all_sheets_options_enabled: "release_gs_all_sheets_options_enabled", release_git_modularisation_enabled: "release_git_modularisation_enabled", + release_git_api_contracts_enabled: "release_git_api_contracts_enabled", ab_premium_datasources_view_enabled: "ab_premium_datasources_view_enabled", kill_session_recordings_enabled: "kill_session_recordings_enabled", config_mask_session_recordings_enabled: @@ -98,6 +99,7 @@ export const DEFAULT_FEATURE_FLAG_VALUE: FeatureFlags = { release_table_html_column_type_enabled: false, release_gs_all_sheets_options_enabled: false, release_git_modularisation_enabled: false, + release_git_api_contracts_enabled: false, ab_premium_datasources_view_enabled: false, kill_session_recordings_enabled: false, config_user_session_recordings_enabled: true, diff --git a/app/client/src/git/ce/components/DefaultBranch/DefaultBranchView.tsx b/app/client/src/git/ce/components/DefaultBranch/DefaultBranchView.tsx index 692c9403cf5f..45f7f02dad1c 100644 --- a/app/client/src/git/ce/components/DefaultBranch/DefaultBranchView.tsx +++ b/app/client/src/git/ce/components/DefaultBranch/DefaultBranchView.tsx @@ -9,9 +9,9 @@ import { Button, Link, Option, Select, Text } from "@appsmith/ads"; import React, { useCallback, useEffect, useMemo, useState } from "react"; import styled from "styled-components"; import AnalyticsUtil from "ee/utils/AnalyticsUtil"; -import type { FetchBranchesResponseData } from "git/requests/fetchBranchesRequest.types"; import noop from "lodash/noop"; import { useAppsmithEnterpriseUrl } from "git/hooks/useAppsmithEnterpriseUrl"; +import type { GitBranch } from "git/types"; const Container = styled.div` padding-top: 8px; @@ -45,7 +45,7 @@ const StyledLink = styled(Link)` `; interface DefaultBranchViewProps { - branches: FetchBranchesResponseData | null; + branches: GitBranch[] | null; isGitProtectedFeatureLicensed: boolean; updateDefaultBranch?: (branchName: string) => void; } diff --git a/app/client/src/git/components/BranchList/BranchListView.tsx b/app/client/src/git/components/BranchList/BranchListView.tsx index ce9bc9f0f1a8..d1df1d0a819b 100644 --- a/app/client/src/git/components/BranchList/BranchListView.tsx +++ b/app/client/src/git/components/BranchList/BranchListView.tsx @@ -33,8 +33,8 @@ import LocalBranchList from "./LocalBranchList"; import { useFilteredBranches } from "./hooks/useFilteredBranches"; import useActiveHoverIndex from "./hooks/useActiveHoverIndex"; import { Space } from "pages/Editor/gitSync/components/StyledComponents"; -import type { FetchBranchesResponseData } from "git/requests/fetchBranchesRequest.types"; import type { FetchProtectedBranchesResponseData } from "git/requests/fetchProtectedBranchesRequest.types"; +import type { GitBranch } from "git/types"; const ListContainer = styled.div` flex: 1; @@ -229,7 +229,7 @@ export function Header({ } interface BranchListViewProps { - branches: FetchBranchesResponseData | null; + branches: GitBranch[] | null; checkoutBranch: (branch: string) => void; checkoutDestBranch: string | null; createBranch: (branch: string) => void; diff --git a/app/client/src/git/components/BranchList/hooks/useFilteredBranches.ts b/app/client/src/git/components/BranchList/hooks/useFilteredBranches.ts index 0674ad81bdef..6c1b02cc2a7d 100644 --- a/app/client/src/git/components/BranchList/hooks/useFilteredBranches.ts +++ b/app/client/src/git/components/BranchList/hooks/useFilteredBranches.ts @@ -1,8 +1,8 @@ -import type { Branch } from "entities/GitSync"; +import type { GitBranch } from "git/types"; import { useEffect, useState } from "react"; export function useFilteredBranches( - branches: Array, + branches: Array, searchText: string, ) { const lowercaseSearchText = searchText.toLowerCase(); @@ -10,15 +10,15 @@ export function useFilteredBranches( useEffect( function setFilteredBranchesEffect() { - const matched = branches.filter((b: Branch) => + const matched = branches.filter((b) => lowercaseSearchText ? b.branchName.toLowerCase().includes(lowercaseSearchText) : true, ); const branchNames = [ - ...matched.filter((b: Branch) => b.default), - ...matched.filter((b: Branch) => !b.default), - ].map((b: Branch) => b.branchName); + ...matched.filter((b) => b.default), + ...matched.filter((b) => !b.default), + ].map((b) => b.branchName); setFilteredBranches(branchNames); }, diff --git a/app/client/src/git/components/GitContextProvider/index.tsx b/app/client/src/git/components/GitContextProvider/index.tsx index f3d6ad18915c..8154a1c67dec 100644 --- a/app/client/src/git/components/GitContextProvider/index.tsx +++ b/app/client/src/git/components/GitContextProvider/index.tsx @@ -31,7 +31,7 @@ export const useGitContext = () => { interface GitContextProviderProps { // artifact - artifactType: keyof typeof GitArtifactType | null; + artifactType: GitArtifactType | null; baseArtifactId: string | null; artifact: ApplicationPayload | null; artifacts: ApplicationPayload[] | null; diff --git a/app/client/src/git/components/OpsModal/TabMerge/TabMergeView.tsx b/app/client/src/git/components/OpsModal/TabMerge/TabMergeView.tsx index 337aa18e7406..eef1529ac534 100644 --- a/app/client/src/git/components/OpsModal/TabMerge/TabMergeView.tsx +++ b/app/client/src/git/components/OpsModal/TabMerge/TabMergeView.tsx @@ -31,10 +31,10 @@ import MergeStatus from "./MergeStatus"; import ConflictError from "git/components/ConflictError"; import MergeSuccessIndicator from "./MergeSuccessIndicator"; import { noop } from "lodash"; -import type { FetchBranchesResponseData } from "git/requests/fetchBranchesRequest.types"; import type { FetchProtectedBranchesResponseData } from "git/requests/fetchProtectedBranchesRequest.types"; import type { FetchMergeStatusResponseData } from "git/requests/fetchMergeStatusRequest.types"; import type { GitApiError } from "git/store/types"; +import type { GitBranch } from "git/types"; const Container = styled.div` min-height: 360px; @@ -64,7 +64,7 @@ interface BranchOption { } interface TabMergeViewProps { - branches: FetchBranchesResponseData | null; + branches: GitBranch[] | null; clearMergeStatus: () => void; currentBranch: string | null; fetchBranches: () => void; diff --git a/app/client/src/git/components/ProtectedBranches/ProtectedBranchesView.tsx b/app/client/src/git/components/ProtectedBranches/ProtectedBranchesView.tsx index f616a4e5b9b7..336db14212e9 100644 --- a/app/client/src/git/components/ProtectedBranches/ProtectedBranchesView.tsx +++ b/app/client/src/git/components/ProtectedBranches/ProtectedBranchesView.tsx @@ -13,10 +13,10 @@ import AnalyticsUtil from "ee/utils/AnalyticsUtil"; import { DOCS_BRANCH_PROTECTION_URL } from "constants/ThirdPartyConstants"; import { GIT_REMOTE_BRANCH_PREFIX } from "git/constants/misc"; import { useAppsmithEnterpriseUrl } from "git/hooks/useAppsmithEnterpriseUrl"; -import type { FetchBranchesResponseData } from "git/requests/fetchBranchesRequest.types"; import xor from "lodash/xor"; import noop from "lodash/noop"; import type { FetchProtectedBranchesResponseData } from "git/requests/fetchProtectedBranchesRequest.types"; +import type { GitBranch } from "git/types"; const Container = styled.div` padding-top: 16px; @@ -50,7 +50,7 @@ const StyledLink = styled(Link)` `; interface ProtectedBranchesViewProps { - branches: FetchBranchesResponseData | null; + branches: GitBranch[] | null; defaultBranch: string | null; isProtectedBranchesLicensed: boolean; isUpdateProtectedBranchesLoading: boolean; diff --git a/app/client/src/git/constants/enums.ts b/app/client/src/git/constants/enums.ts index b3950c1b2fea..af2fb31513a6 100644 --- a/app/client/src/git/constants/enums.ts +++ b/app/client/src/git/constants/enums.ts @@ -1,7 +1,7 @@ export enum GitArtifactType { - Application = "Application", - Package = "Package", - Workflow = "Workflow", + Application = "applications", + Package = "packages", + Workflow = "workflows", } export enum GitOpsTab { diff --git a/app/client/src/git/helpers/refToBranchList.ts b/app/client/src/git/helpers/refToBranchList.ts new file mode 100644 index 000000000000..15c8278ff2e6 --- /dev/null +++ b/app/client/src/git/helpers/refToBranchList.ts @@ -0,0 +1,8 @@ +import type { GitBranch, GitRef } from "git/types"; + +export default function refToBranchList(refs: GitRef[]): GitBranch[] { + return refs.map((ref) => ({ + branchName: ref.refName, + default: ref.default, + })); +} diff --git a/app/client/src/git/hooks/useBranches.ts b/app/client/src/git/hooks/useBranches.ts index fe85a318b8d4..b8ef5203a79a 100644 --- a/app/client/src/git/hooks/useBranches.ts +++ b/app/client/src/git/hooks/useBranches.ts @@ -9,9 +9,12 @@ import { selectDeleteBranchState, selectCurrentBranch, } from "git/store/selectors/gitArtifactSelectors"; -import { useCallback } from "react"; +import { useCallback, useMemo } from "react"; import { useDispatch } from "react-redux"; import useArtifactSelector from "./useArtifactSelector"; +import refToBranchList from "git/helpers/refToBranchList"; +import useGitFeatureFlags from "./useGitFeatureFlags"; +import type { GitBranch } from "git/types"; export default function useBranches() { const { artifact, artifactDef } = useGitContext(); @@ -21,6 +24,20 @@ export default function useBranches() { // fetch branches const branchesState = useArtifactSelector(selectFetchBranchesState); + const { release_git_api_contracts_enabled: isGitApiContractsEnabled } = + useGitFeatureFlags(); + + const branches = useMemo(() => { + if (!Array.isArray(branchesState?.value)) { + return null; + } + + if (!isGitApiContractsEnabled) { + return branchesState.value; + } + + return refToBranchList(branchesState.value); + }, [branchesState?.value, isGitApiContractsEnabled]); const fetchBranches = useCallback(() => { if (artifactDef && artifactId) { @@ -106,7 +123,7 @@ export default function useBranches() { ); return { - branches: branchesState?.value ?? null, + branches: branches as GitBranch[] | null, isFetchBranchesLoading: branchesState?.loading ?? false, fetchBranchesError: branchesState?.error ?? null, fetchBranches, diff --git a/app/client/src/git/hooks/useGitFeatureFlags.ts b/app/client/src/git/hooks/useGitFeatureFlags.ts index ea13f756a796..747e01dd9886 100644 --- a/app/client/src/git/hooks/useGitFeatureFlags.ts +++ b/app/client/src/git/hooks/useGitFeatureFlags.ts @@ -8,9 +8,13 @@ export default function useGitFeatureFlags() { const license_git_continuous_delivery_enabled = useFeatureFlag( FEATURE_FLAG.license_git_continuous_delivery_enabled, ); + const release_git_api_contracts_enabled = useFeatureFlag( + FEATURE_FLAG.release_git_api_contracts_enabled, + ); return { license_git_branch_protection_enabled, license_git_continuous_delivery_enabled, + release_git_api_contracts_enabled, }; } diff --git a/app/client/src/git/requests/checkoutBranchRequest.ts b/app/client/src/git/requests/checkoutBranchRequest.ts index e0c2f7e990ac..2e5a95ed598e 100644 --- a/app/client/src/git/requests/checkoutBranchRequest.ts +++ b/app/client/src/git/requests/checkoutBranchRequest.ts @@ -6,7 +6,7 @@ import type { import { GIT_BASE_URL } from "./constants"; import Api from "api/Api"; -export default async function checkoutBranchRequest( +export default async function checkoutBranchRequestOld( branchedApplicationId: string, params: CheckoutBranchRequestParams, ): AxiosPromise { diff --git a/app/client/src/git/requests/checkoutRefRequest.ts b/app/client/src/git/requests/checkoutRefRequest.ts new file mode 100644 index 000000000000..e95701223c24 --- /dev/null +++ b/app/client/src/git/requests/checkoutRefRequest.ts @@ -0,0 +1,37 @@ +import type { AxiosPromise } from "axios"; +import { GIT_BASE_URL } from "./constants"; +import Api from "api/Api"; +import type { GitArtifactType } from "git/constants/enums"; +import type { + CheckoutRefRequestParams, + CheckoutRefResponse, +} from "./checkoutRefRequest.types"; +import checkoutBranchRequestOld from "./checkoutBranchRequest"; + +async function checkoutRefRequestNew( + artifactType: GitArtifactType, + refArtifactid: string, + params: CheckoutRefRequestParams, +): AxiosPromise { + return Api.post( + `${GIT_BASE_URL}/${artifactType}/${refArtifactid}/checkout-ref`, + params, + ); +} + +export default async function checkoutRefRequest( + artifactType: GitArtifactType, + refArtifactid: string, + params: CheckoutRefRequestParams, + isNew: boolean, +) { + if (isNew) { + return checkoutRefRequestNew(artifactType, refArtifactid, params); + } else { + const checkoutBranchParams = { + branchName: params.refName, + }; + + return checkoutBranchRequestOld(refArtifactid, checkoutBranchParams); + } +} diff --git a/app/client/src/git/requests/checkoutRefRequest.types.ts b/app/client/src/git/requests/checkoutRefRequest.types.ts new file mode 100644 index 000000000000..df3b0b958a69 --- /dev/null +++ b/app/client/src/git/requests/checkoutRefRequest.types.ts @@ -0,0 +1,12 @@ +import type { ApiResponse } from "api/types"; +import type { GitArtifact } from "git/store/types"; + +export interface CheckoutRefRequestParams { + refType: "branch" | "tag"; + refName: string; + message?: string; +} + +export type CheckoutRefResponseData = GitArtifact; + +export type CheckoutRefResponse = ApiResponse; diff --git a/app/client/src/git/requests/commitRequest.ts b/app/client/src/git/requests/commitRequest.ts index 2cbd8aff65a6..75ff52da3040 100644 --- a/app/client/src/git/requests/commitRequest.ts +++ b/app/client/src/git/requests/commitRequest.ts @@ -5,8 +5,9 @@ import type { } from "./commitRequest.types"; import { GIT_BASE_URL } from "./constants"; import type { AxiosPromise } from "axios"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function commitRequest( +async function commitRequestOld( branchedApplicationId: string, params: CommitRequestParams, ): AxiosPromise { @@ -15,3 +16,27 @@ export default async function commitRequest( params, ); } + +async function commitRequestNew( + artifactType: GitArtifactType, + refArtifactId: string, + params: CommitRequestParams, +): AxiosPromise { + return Api.post( + `${GIT_BASE_URL}/${artifactType}/${refArtifactId}/commit`, + params, + ); +} + +export default async function commitRequest( + artifactType: GitArtifactType, + refArtifactId: string, + params: CommitRequestParams, + isNew: boolean, +) { + if (isNew) { + return commitRequestNew(artifactType, refArtifactId, params); + } else { + return commitRequestOld(refArtifactId, params); + } +} diff --git a/app/client/src/git/requests/connectRequest.ts b/app/client/src/git/requests/connectRequest.ts index dac70d3030d7..7051d3edcdc8 100644 --- a/app/client/src/git/requests/connectRequest.ts +++ b/app/client/src/git/requests/connectRequest.ts @@ -5,10 +5,35 @@ import type { ConnectResponse, } from "./connectRequest.types"; import type { AxiosPromise } from "axios"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function connectRequest( +async function connectRequestOld( baseApplicationId: string, params: ConnectRequestParams, ): AxiosPromise { return Api.post(`${GIT_BASE_URL}/connect/app/${baseApplicationId}`, params); } + +async function connectRequestNew( + artifactType: GitArtifactType, + baseArtifactId: string, + params: ConnectRequestParams, +): AxiosPromise { + return Api.post( + `${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/connect`, + params, + ); +} + +export default async function connectRequest( + artifactType: GitArtifactType, + baseArtifactId: string, + params: ConnectRequestParams, + isNew: boolean, +) { + if (isNew) { + return connectRequestNew(artifactType, baseArtifactId, params); + } else { + return connectRequestOld(baseArtifactId, params); + } +} diff --git a/app/client/src/git/requests/createBranchRequest.ts b/app/client/src/git/requests/createBranchRequest.ts index 9445ad2c3a55..a3a62f65e72c 100644 --- a/app/client/src/git/requests/createBranchRequest.ts +++ b/app/client/src/git/requests/createBranchRequest.ts @@ -6,7 +6,7 @@ import type { import { GIT_BASE_URL } from "./constants"; import Api from "api/Api"; -export default async function createBranchRequest( +export default async function createBranchRequestOld( branchedApplicationId: string, params: CreateBranchRequestParams, ): AxiosPromise { diff --git a/app/client/src/git/requests/createRefRequest.ts b/app/client/src/git/requests/createRefRequest.ts new file mode 100644 index 000000000000..b2a939b2d637 --- /dev/null +++ b/app/client/src/git/requests/createRefRequest.ts @@ -0,0 +1,37 @@ +import type { AxiosPromise } from "axios"; +import { GIT_BASE_URL } from "./constants"; +import Api from "api/Api"; +import type { GitArtifactType } from "git/constants/enums"; +import type { + CreateRefRequestParams, + CreateRefResponse, +} from "./createRefRequest.types"; +import createBranchRequestOld from "./createBranchRequest"; + +async function createRefRequestNew( + artifactType: GitArtifactType, + refArtifactId: string, + params: CreateRefRequestParams, +): AxiosPromise { + return Api.post( + `${GIT_BASE_URL}/${artifactType}/${refArtifactId}/create-ref`, + params, + ); +} + +export default async function createRefRequest( + artifactType: GitArtifactType, + refArtifactId: string, + params: CreateRefRequestParams, + isNew: boolean, +) { + if (isNew) { + return createRefRequestNew(artifactType, refArtifactId, params); + } else { + const createBranchParams = { + branchName: params.refName, + }; + + return createBranchRequestOld(refArtifactId, createBranchParams); + } +} diff --git a/app/client/src/git/requests/createRefRequest.types.ts b/app/client/src/git/requests/createRefRequest.types.ts new file mode 100644 index 000000000000..b61c4454fca3 --- /dev/null +++ b/app/client/src/git/requests/createRefRequest.types.ts @@ -0,0 +1,11 @@ +import type { ApiResponse } from "api/types"; +import type { GitArtifact } from "git/store/types"; + +export interface CreateRefRequestParams { + refType: "branch" | "tag"; + refName: string; +} + +export type CreateRefResponseData = GitArtifact; + +export type CreateRefResponse = ApiResponse; diff --git a/app/client/src/git/requests/deleteBranchRequest.ts b/app/client/src/git/requests/deleteBranchRequest.ts index cba2463d2019..e004d764d2ec 100644 --- a/app/client/src/git/requests/deleteBranchRequest.ts +++ b/app/client/src/git/requests/deleteBranchRequest.ts @@ -6,7 +6,7 @@ import type { import { GIT_BASE_URL } from "./constants"; import Api from "api/Api"; -export default async function deleteBranchRequest( +export default async function deleteBranchRequestOld( baseApplicationId: string, params: DeleteBranchRequestParams, ): AxiosPromise { diff --git a/app/client/src/git/requests/deleteRefRequest.ts b/app/client/src/git/requests/deleteRefRequest.ts new file mode 100644 index 000000000000..b3fbd2aa6a80 --- /dev/null +++ b/app/client/src/git/requests/deleteRefRequest.ts @@ -0,0 +1,37 @@ +import type { AxiosPromise } from "axios"; +import type { + DeleteRefRequestParams, + DeleteRefResponse, +} from "./deleteRefRequest.types"; +import { GIT_BASE_URL } from "./constants"; +import Api from "api/Api"; +import type { GitArtifactType } from "git/constants/enums"; +import deleteBranchRequestOld from "./deleteBranchRequest"; + +async function deleteRefRequestNew( + artifactType: GitArtifactType, + baseArtifactId: string, + params: DeleteRefRequestParams, +): AxiosPromise { + return Api.delete( + `${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/ref`, + params, + ); +} + +export default async function deleteRefRequest( + artifactType: GitArtifactType, + baseArtifactId: string, + params: DeleteRefRequestParams, + isNew: boolean, +) { + if (isNew) { + return deleteRefRequestNew(artifactType, baseArtifactId, params); + } else { + const deleteBranchParams = { + branchName: params.refName, + }; + + return deleteBranchRequestOld(baseArtifactId, deleteBranchParams); + } +} diff --git a/app/client/src/git/requests/deleteRefRequest.types.ts b/app/client/src/git/requests/deleteRefRequest.types.ts new file mode 100644 index 000000000000..f980668dd05f --- /dev/null +++ b/app/client/src/git/requests/deleteRefRequest.types.ts @@ -0,0 +1,11 @@ +import type { ApiResponse } from "api/types"; +import type { GitArtifact } from "git/store/types"; + +export interface DeleteRefRequestParams { + refType: "branch" | "tag"; + refName: string; +} + +export type DeleteRefResponseData = GitArtifact; + +export type DeleteRefResponse = ApiResponse; diff --git a/app/client/src/git/requests/discardRequest.ts b/app/client/src/git/requests/discardRequest.ts index 18f865b8f232..3b478fd5e4fd 100644 --- a/app/client/src/git/requests/discardRequest.ts +++ b/app/client/src/git/requests/discardRequest.ts @@ -2,9 +2,29 @@ import Api from "api/Api"; import { GIT_BASE_URL } from "./constants"; import type { AxiosPromise } from "axios"; import type { DiscardResponse } from "./discardRequest.types"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function discardRequest( +async function discardRequestOld( branchedApplicationId: string, ): AxiosPromise { return Api.put(`${GIT_BASE_URL}/discard/app/${branchedApplicationId}`); } + +async function discardRequestNew( + artifactType: GitArtifactType, + refArtifactId: string, +): AxiosPromise { + return Api.put(`${GIT_BASE_URL}/${artifactType}/${refArtifactId}/discard`); +} + +export default async function discardRequest( + artifactType: GitArtifactType, + refArtifactId: string, + isNew: boolean, +) { + if (isNew) { + return discardRequestNew(artifactType, refArtifactId); + } else { + return discardRequestOld(refArtifactId); + } +} diff --git a/app/client/src/git/requests/discardRequest.types.ts b/app/client/src/git/requests/discardRequest.types.ts index 22b7074b73a7..ad3c0a3f1686 100644 --- a/app/client/src/git/requests/discardRequest.types.ts +++ b/app/client/src/git/requests/discardRequest.types.ts @@ -1,4 +1,6 @@ import type { ApiResponse } from "api/types"; import type { GitArtifact } from "git/store/types"; -export type DiscardResponse = ApiResponse; +export type DiscardResponseData = GitArtifact; + +export type DiscardResponse = ApiResponse; diff --git a/app/client/src/git/requests/disconnectRequest.ts b/app/client/src/git/requests/disconnectRequest.ts index 93c16be07baa..6469d2a73b6b 100644 --- a/app/client/src/git/requests/disconnectRequest.ts +++ b/app/client/src/git/requests/disconnectRequest.ts @@ -2,9 +2,31 @@ import type { AxiosPromise } from "axios"; import { GIT_BASE_URL } from "./constants"; import type { DisconnectResponse } from "./disconnectRequest.types"; import Api from "api/Api"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function disconnectRequest( +async function disconnectRequestOld( baseApplicationId: string, ): AxiosPromise { return Api.post(`${GIT_BASE_URL}/disconnect/app/${baseApplicationId}`); } + +async function disconnectRequestNew( + artifactType: GitArtifactType, + baseArtifactId: string, +): AxiosPromise { + return Api.post( + `${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/disconnect`, + ); +} + +export default async function disconnectRequest( + artifactType: GitArtifactType, + baseArtifactId: string, + isNew: boolean, +) { + if (isNew) { + return disconnectRequestNew(artifactType, baseArtifactId); + } else { + return disconnectRequestOld(baseArtifactId); + } +} diff --git a/app/client/src/git/requests/disconnectRequest.types.ts b/app/client/src/git/requests/disconnectRequest.types.ts index b1cd5827d951..027a5bbc283a 100644 --- a/app/client/src/git/requests/disconnectRequest.types.ts +++ b/app/client/src/git/requests/disconnectRequest.types.ts @@ -1,6 +1,6 @@ import type { ApiResponse } from "api/types"; -import type { ApplicationPayload } from "entities/Application"; +import type { GitArtifact } from "git/store/types"; -export interface DisconnectResponseData extends ApplicationPayload {} +export type DisconnectResponseData = GitArtifact; export type DisconnectResponse = ApiResponse; diff --git a/app/client/src/git/requests/fetchAutocommitProgressRequest.ts b/app/client/src/git/requests/fetchAutocommitProgressRequest.ts index 1f68624b780c..0f877993b19b 100644 --- a/app/client/src/git/requests/fetchAutocommitProgressRequest.ts +++ b/app/client/src/git/requests/fetchAutocommitProgressRequest.ts @@ -2,11 +2,33 @@ import Api from "api/Api"; import { GIT_BASE_URL } from "./constants"; import type { AxiosPromise } from "axios"; import type { FetchAutocommitProgressResponse } from "./fetchAutocommitProgressRequest.types"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function fetchAutocommitProgressRequest( +async function fetchAutocommitProgressRequestOld( baseApplicationId: string, ): AxiosPromise { return Api.get( `${GIT_BASE_URL}/auto-commit/progress/app/${baseApplicationId}`, ); } + +async function fetchAutocommitProgressRequestNew( + artifactType: GitArtifactType, + baseArtifactId: string, +): AxiosPromise { + return Api.get( + `${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/auto-commit/progress`, + ); +} + +export default async function fetchAutocommitProgressRequest( + artifactType: GitArtifactType, + baseArtifactId: string, + isNew: boolean, +) { + if (isNew) { + return fetchAutocommitProgressRequestNew(artifactType, baseArtifactId); + } else { + return fetchAutocommitProgressRequestOld(baseArtifactId); + } +} diff --git a/app/client/src/git/requests/fetchGlobalSSHKeyRequest.ts b/app/client/src/git/requests/fetchGlobalSSHKeyRequest.ts index 00d900637f42..3c169d486ae3 100644 --- a/app/client/src/git/requests/fetchGlobalSSHKeyRequest.ts +++ b/app/client/src/git/requests/fetchGlobalSSHKeyRequest.ts @@ -6,10 +6,29 @@ import type { FetchGlobalSSHKeyResponse, } from "./fetchGlobalSSHKeyRequest.types"; -export default async function fetchGlobalSSHKeyRequest( +async function fetchGlobalSSHKeyRequestOld( params: FetchGlobalSSHKeyRequestParams, ): AxiosPromise { const url = `${GIT_BASE_URL}/import/keys?keyType=${params.keyType}`; return Api.get(url); } + +async function fetchGlobalSSHKeyRequestNew( + params: FetchGlobalSSHKeyRequestParams, +): AxiosPromise { + const url = `${GIT_BASE_URL}/artifacts/import/keys?keyType=${params.keyType}`; + + return Api.get(url); +} + +export default async function fetchGlobalSSHKeyRequest( + params: FetchGlobalSSHKeyRequestParams, + isNew: boolean, +): AxiosPromise { + if (isNew) { + return fetchGlobalSSHKeyRequestNew(params); + } else { + return fetchGlobalSSHKeyRequestOld(params); + } +} diff --git a/app/client/src/git/requests/fetchLocalProfileRequest.ts b/app/client/src/git/requests/fetchLocalProfileRequest.ts index 2e02a1fecc8d..5a4740a8b74b 100644 --- a/app/client/src/git/requests/fetchLocalProfileRequest.ts +++ b/app/client/src/git/requests/fetchLocalProfileRequest.ts @@ -2,9 +2,29 @@ import Api from "api/Api"; import type { AxiosPromise } from "axios"; import { GIT_BASE_URL } from "./constants"; import type { FetchLocalProfileResponse } from "./fetchLocalProfileRequest.types"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function fetchLocalProfileRequest( +async function fetchLocalProfileRequestOld( baseApplicationId: string, ): AxiosPromise { return Api.get(`${GIT_BASE_URL}/profile/app/${baseApplicationId}`); } + +async function fetchLocalProfileRequestNew( + artifactType: GitArtifactType, + baseArtifactId: string, +): AxiosPromise { + return Api.get(`${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/profile`); +} + +export default async function fetchLocalProfileRequest( + artifactType: GitArtifactType, + baseArtifactId: string, + isNew: boolean, +): AxiosPromise { + if (isNew) { + return fetchLocalProfileRequestNew(artifactType, baseArtifactId); + } else { + return fetchLocalProfileRequestOld(baseArtifactId); + } +} diff --git a/app/client/src/git/requests/fetchMergeStatusRequest.ts b/app/client/src/git/requests/fetchMergeStatusRequest.ts index 402ac66de587..0d4655a186d6 100644 --- a/app/client/src/git/requests/fetchMergeStatusRequest.ts +++ b/app/client/src/git/requests/fetchMergeStatusRequest.ts @@ -5,8 +5,9 @@ import type { } from "./fetchMergeStatusRequest.types"; import Api from "api/Api"; import { GIT_BASE_URL } from "./constants"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function fetchMergeStatusRequest( +async function fetchMergeStatusRequestOld( branchedApplicationId: string, params: FetchMergeStatusRequestParams, ): AxiosPromise { @@ -15,3 +16,27 @@ export default async function fetchMergeStatusRequest( params, ); } + +async function fetchMergeStatusRequestNew( + artifactType: GitArtifactType, + refArtifactId: string, + params: FetchMergeStatusRequestParams, +): AxiosPromise { + return Api.post( + `${GIT_BASE_URL}/${artifactType}/${refArtifactId}/merge/status`, + params, + ); +} + +export default async function fetchMergeStatusRequest( + artifactType: GitArtifactType, + refArtifactId: string, + params: FetchMergeStatusRequestParams, + isNew: boolean, +): AxiosPromise { + if (isNew) { + return fetchMergeStatusRequestNew(artifactType, refArtifactId, params); + } else { + return fetchMergeStatusRequestOld(refArtifactId, params); + } +} diff --git a/app/client/src/git/requests/fetchMetadataRequest.ts b/app/client/src/git/requests/fetchMetadataRequest.ts index 72c7762af4c4..4ca1f09e8037 100644 --- a/app/client/src/git/requests/fetchMetadataRequest.ts +++ b/app/client/src/git/requests/fetchMetadataRequest.ts @@ -2,9 +2,29 @@ import Api from "api/Api"; import { GIT_BASE_URL } from "./constants"; import type { AxiosPromise } from "axios"; import type { FetchMetadataResponse } from "./fetchMetadataRequest.types"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function fetchMetadataRequest( +async function fetchMetadataRequestOld( baseApplicationId: string, ): AxiosPromise { return Api.get(`${GIT_BASE_URL}/metadata/app/${baseApplicationId}`); } + +async function fetchMetadataRequestNew( + artifactType: GitArtifactType, + baseArtifactId: string, +): AxiosPromise { + return Api.get(`${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/metadata`); +} + +export default async function fetchMetadataRequest( + artifactType: GitArtifactType, + baseArtifactId: string, + isNew: boolean, +): AxiosPromise { + if (isNew) { + return fetchMetadataRequestNew(artifactType, baseArtifactId); + } else { + return fetchMetadataRequestOld(baseArtifactId); + } +} diff --git a/app/client/src/git/requests/fetchProtectedBranchesRequest.ts b/app/client/src/git/requests/fetchProtectedBranchesRequest.ts index 78f54d9d7140..762f88038e71 100644 --- a/app/client/src/git/requests/fetchProtectedBranchesRequest.ts +++ b/app/client/src/git/requests/fetchProtectedBranchesRequest.ts @@ -2,9 +2,29 @@ import Api from "api/Api"; import { GIT_BASE_URL } from "./constants"; import type { AxiosPromise } from "axios"; import type { FetchProtectedBranchesResponse } from "./fetchProtectedBranchesRequest.types"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function fetchProtectedBranchesRequest( +async function fetchProtectedBranchesRequestOld( baseApplicationId: string, ): AxiosPromise { return Api.get(`${GIT_BASE_URL}/branch/app/${baseApplicationId}/protected`); } + +async function fetchProtectedBranchesRequestNew( + artifactType: GitArtifactType, + baseArtifactId: string, +): AxiosPromise { + return Api.get(`${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/protected`); +} + +export default async function fetchProtectedBranchesRequest( + artifactType: GitArtifactType, + baseArtifactId: string, + isNew: boolean, +): AxiosPromise { + if (isNew) { + return fetchProtectedBranchesRequestNew(artifactType, baseArtifactId); + } else { + return fetchProtectedBranchesRequestOld(baseArtifactId); + } +} diff --git a/app/client/src/git/requests/fetchRefsRequest.ts b/app/client/src/git/requests/fetchRefsRequest.ts new file mode 100644 index 000000000000..cb33f287f7ad --- /dev/null +++ b/app/client/src/git/requests/fetchRefsRequest.ts @@ -0,0 +1,38 @@ +import Api from "api/Api"; +import { GIT_BASE_URL } from "./constants"; +import type { + FetchRefsRequestParams, + FetchRefsResponse, +} from "./fetchRefsRequest.types"; +import type { AxiosPromise } from "axios"; +import type { GitArtifactType } from "git/constants/enums"; +import fetchBranchesRequest from "./fetchBranchesRequest"; + +async function fetchRefsRequestNew( + artifactType: GitArtifactType, + refArtifactId: string, + params: FetchRefsRequestParams, +): AxiosPromise { + return Api.get( + `${GIT_BASE_URL}/${artifactType}/${refArtifactId}/refs`, + undefined, + { params }, + ); +} + +export default async function fetchRefsRequest( + artifactType: GitArtifactType, + refArtifactId: string, + params: FetchRefsRequestParams, + isNew: boolean, +) { + if (isNew) { + return fetchRefsRequestNew(artifactType, refArtifactId, params); + } else { + const fetchBranchesParams = { + pruneBranches: params.pruneRefs, + }; + + return fetchBranchesRequest(refArtifactId, fetchBranchesParams); + } +} diff --git a/app/client/src/git/requests/fetchRefsRequest.types.ts b/app/client/src/git/requests/fetchRefsRequest.types.ts new file mode 100644 index 000000000000..018efb5c402c --- /dev/null +++ b/app/client/src/git/requests/fetchRefsRequest.types.ts @@ -0,0 +1,11 @@ +import type { ApiResponse } from "api/types"; +import type { GitRef } from "git/types"; + +export interface FetchRefsRequestParams { + pruneRefs: boolean; + refType: "branch" | "tag"; +} + +export type FetchRefsResponseData = GitRef[]; + +export type FetchRefsResponse = ApiResponse; diff --git a/app/client/src/git/requests/fetchSSHKeyRequest.ts b/app/client/src/git/requests/fetchSSHKeyRequest.ts index 29c295dc6d02..5a96491fe710 100644 --- a/app/client/src/git/requests/fetchSSHKeyRequest.ts +++ b/app/client/src/git/requests/fetchSSHKeyRequest.ts @@ -4,7 +4,7 @@ import Api from "api/Api"; import { APPLICATION_BASE_URL } from "./constants"; export default async function fetchSSHKeyRequest( - baseApplicationId: string, + baseArtifactId: string, ): AxiosPromise { - return Api.get(`${APPLICATION_BASE_URL}/ssh-keypair/${baseApplicationId}`); + return Api.get(`${APPLICATION_BASE_URL}/ssh-keypair/${baseArtifactId}`); } diff --git a/app/client/src/git/requests/fetchStatusRequest.ts b/app/client/src/git/requests/fetchStatusRequest.ts index a0a68703f09c..d4577efb3f4b 100644 --- a/app/client/src/git/requests/fetchStatusRequest.ts +++ b/app/client/src/git/requests/fetchStatusRequest.ts @@ -5,10 +5,35 @@ import type { } from "./fetchStatusRequest.types"; import { GIT_BASE_URL } from "./constants"; import type { AxiosPromise } from "axios"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function fetchStatusRequest( +async function fetchStatusRequestOld( branchedApplicationId: string, params: FetchStatusRequestParams = { compareRemote: true }, ): AxiosPromise { return Api.get(`${GIT_BASE_URL}/status/app/${branchedApplicationId}`, params); } + +async function fetchStatusRequestNew( + artifactType: GitArtifactType, + baseArtifactId: string, + params: FetchStatusRequestParams, +): AxiosPromise { + return Api.get( + `${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/status`, + params, + ); +} + +export default async function fetchStatusRequest( + artifactType: GitArtifactType, + baseArtifactId: string, + params: FetchStatusRequestParams, + isNew: boolean, +): AxiosPromise { + if (isNew) { + return fetchStatusRequestNew(artifactType, baseArtifactId, params); + } else { + return fetchStatusRequestOld(baseArtifactId, params); + } +} diff --git a/app/client/src/git/requests/generateSSHKeyRequest.ts b/app/client/src/git/requests/generateSSHKeyRequest.ts index b0bea4f20ff8..ef2f8a1300ef 100644 --- a/app/client/src/git/requests/generateSSHKeyRequest.ts +++ b/app/client/src/git/requests/generateSSHKeyRequest.ts @@ -7,10 +7,10 @@ import { APPLICATION_BASE_URL } from "./constants"; import Api from "api/Api"; export default async function generateSSHKeyRequest( - baseApplicationId: string, + baseArtifactId: string, params: GenerateSSHKeyRequestParams, ): AxiosPromise { - const url = `${APPLICATION_BASE_URL}/ssh-keypair/${baseApplicationId}?keyType=${params.keyType}`; + const url = `${APPLICATION_BASE_URL}/ssh-keypair/${baseArtifactId}?keyType=${params.keyType}`; return Api.post(url); } diff --git a/app/client/src/git/requests/gitImportRequest.ts b/app/client/src/git/requests/gitImportRequest.ts index 94ad9b5d95c9..6d05dd543212 100644 --- a/app/client/src/git/requests/gitImportRequest.ts +++ b/app/client/src/git/requests/gitImportRequest.ts @@ -6,9 +6,30 @@ import type { } from "./gitImportRequest.types"; import type { AxiosPromise } from "axios"; -export default async function gitImportRequest( +async function gitImportRequestOld( workspaceId: string, params: GitImportRequestParams, ): AxiosPromise { return Api.post(`${GIT_BASE_URL}/import/${workspaceId}`, params); } + +async function gitImportRequestNew( + workspaceId: string, + params: GitImportRequestParams, +): AxiosPromise { + return Api.post(`${GIT_BASE_URL}/artifacts/import`, params, { + params: { workspaceId }, + }); +} + +export default async function gitImportRequest( + workspaceId: string, + params: GitImportRequestParams, + isNew: boolean, +): AxiosPromise { + if (isNew) { + return gitImportRequestNew(workspaceId, params); + } else { + return gitImportRequestOld(workspaceId, params); + } +} diff --git a/app/client/src/git/requests/mergeRequest.ts b/app/client/src/git/requests/mergeRequest.ts index daee44fad21d..0b2a1dfa4ccd 100644 --- a/app/client/src/git/requests/mergeRequest.ts +++ b/app/client/src/git/requests/mergeRequest.ts @@ -2,10 +2,35 @@ import Api from "api/Api"; import type { MergeRequestParams, MergeResponse } from "./mergeRequest.types"; import { GIT_BASE_URL } from "./constants"; import type { AxiosPromise } from "axios"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function mergeRequest( +async function mergeRequestOld( branchedApplicationId: string, params: MergeRequestParams, ): AxiosPromise { return Api.post(`${GIT_BASE_URL}/merge/app/${branchedApplicationId}`, params); } + +async function mergeRequestNew( + artifactType: GitArtifactType, + refArtifactId: string, + params: MergeRequestParams, +): AxiosPromise { + return Api.post( + `${GIT_BASE_URL}/${artifactType}/${refArtifactId}/merge`, + params, + ); +} + +export default async function mergeRequest( + artifactType: GitArtifactType, + refArtifactId: string, + params: MergeRequestParams, + isNew: boolean, +): AxiosPromise { + if (isNew) { + return mergeRequestNew(artifactType, refArtifactId, params); + } else { + return mergeRequestOld(refArtifactId, params); + } +} diff --git a/app/client/src/git/requests/pullRequest.ts b/app/client/src/git/requests/pullRequest.ts index cd533f6d7679..8d24353f2eff 100644 --- a/app/client/src/git/requests/pullRequest.ts +++ b/app/client/src/git/requests/pullRequest.ts @@ -2,9 +2,29 @@ import Api from "api/Api"; import { GIT_BASE_URL } from "./constants"; import type { AxiosPromise } from "axios"; import type { PullResponse } from "./pullRequest.types"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function pullRequest( +async function pullRequestOld( branchedApplicationId: string, ): AxiosPromise { return Api.get(`${GIT_BASE_URL}/pull/app/${branchedApplicationId}`); } + +async function pullRequestNew( + artifactType: GitArtifactType, + refArtifactId: string, +): AxiosPromise { + return Api.get(`${GIT_BASE_URL}/${artifactType}/${refArtifactId}/pull`); +} + +export default async function pullRequest( + artifactType: GitArtifactType, + refArtifactId: string, + isNew: boolean, +): AxiosPromise { + if (isNew) { + return pullRequestNew(artifactType, refArtifactId); + } else { + return pullRequestOld(refArtifactId); + } +} diff --git a/app/client/src/git/requests/toggleAutocommitRequest.ts b/app/client/src/git/requests/toggleAutocommitRequest.ts index 85131550f108..acdd3d7975a1 100644 --- a/app/client/src/git/requests/toggleAutocommitRequest.ts +++ b/app/client/src/git/requests/toggleAutocommitRequest.ts @@ -2,11 +2,33 @@ import Api from "api/Api"; import { GIT_BASE_URL } from "./constants"; import type { AxiosPromise } from "axios"; import type { ToggleAutocommitResponse } from "./toggleAutocommitRequest.types"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function toggleAutocommitRequest( +async function toggleAutocommitRequestOld( baseApplicationId: string, ): AxiosPromise { return Api.patch( `${GIT_BASE_URL}/auto-commit/toggle/app/${baseApplicationId}`, ); } + +async function toggleAutocommitRequestNew( + artifactType: GitArtifactType, + baseArtifactId: string, +): AxiosPromise { + return Api.patch( + `${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/auto-commit/toggle`, + ); +} + +export default async function toggleAutocommitRequest( + artifactType: GitArtifactType, + baseArtifactId: string, + isNew: boolean, +): AxiosPromise { + if (isNew) { + return toggleAutocommitRequestNew(artifactType, baseArtifactId); + } else { + return toggleAutocommitRequestOld(baseArtifactId); + } +} diff --git a/app/client/src/git/requests/triggerAutocommitRequest.ts b/app/client/src/git/requests/triggerAutocommitRequest.ts index 7a2085df2d31..14b68edad0c4 100644 --- a/app/client/src/git/requests/triggerAutocommitRequest.ts +++ b/app/client/src/git/requests/triggerAutocommitRequest.ts @@ -2,9 +2,31 @@ import Api from "api/Api"; import { GIT_BASE_URL } from "./constants"; import type { AxiosPromise } from "axios"; import type { TriggerAutocommitResponse } from "./triggerAutocommitRequest.types"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function triggerAutocommitRequest( +async function triggerAutocommitRequestOld( branchedApplicationId: string, ): AxiosPromise { return Api.post(`${GIT_BASE_URL}/auto-commit/app/${branchedApplicationId}`); } + +async function triggerAutocommitRequestNew( + artifactType: GitArtifactType, + refArtifactId: string, +): AxiosPromise { + return Api.post( + `${GIT_BASE_URL}/${artifactType}/${refArtifactId}/auto-commit`, + ); +} + +export default async function triggerAutocommitRequest( + artifactType: GitArtifactType, + refArtifactId: string, + isNew: boolean, +): AxiosPromise { + if (isNew) { + return triggerAutocommitRequestNew(artifactType, refArtifactId); + } else { + return triggerAutocommitRequestOld(refArtifactId); + } +} diff --git a/app/client/src/git/requests/updateLocalProfileRequest.ts b/app/client/src/git/requests/updateLocalProfileRequest.ts index 7e5dff54932f..07b42102ca9b 100644 --- a/app/client/src/git/requests/updateLocalProfileRequest.ts +++ b/app/client/src/git/requests/updateLocalProfileRequest.ts @@ -5,10 +5,35 @@ import type { } from "./updateLocalProfileRequest.types"; import Api from "api/Api"; import { GIT_BASE_URL } from "./constants"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function updateLocalProfileRequest( +async function updateLocalProfileRequestOld( baseApplicationId: string, params: UpdateLocalProfileRequestParams, ): AxiosPromise { return Api.put(`${GIT_BASE_URL}/profile/app/${baseApplicationId}`, params); } + +async function updateLocalProfileRequestNew( + artifactType: GitArtifactType, + baseArtifactId: string, + params: UpdateLocalProfileRequestParams, +): AxiosPromise { + return Api.put( + `${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/profile`, + params, + ); +} + +export default async function updateLocalProfileRequest( + artifactType: GitArtifactType, + baseArtifactId: string, + params: UpdateLocalProfileRequestParams, + isNew: boolean, +): AxiosPromise { + if (isNew) { + return updateLocalProfileRequestNew(artifactType, baseArtifactId, params); + } else { + return updateLocalProfileRequestOld(baseArtifactId, params); + } +} diff --git a/app/client/src/git/requests/updateProtectedBranchesRequest.ts b/app/client/src/git/requests/updateProtectedBranchesRequest.ts index aa3822c1b5e2..034126986789 100644 --- a/app/client/src/git/requests/updateProtectedBranchesRequest.ts +++ b/app/client/src/git/requests/updateProtectedBranchesRequest.ts @@ -5,8 +5,9 @@ import type { UpdateProtectedBranchesResponse, } from "./updateProtectedBranchesRequest.types"; import type { AxiosPromise } from "axios"; +import type { GitArtifactType } from "git/constants/enums"; -export default async function updateProtectedBranchesRequest( +async function updateProtectedBranchesRequestOld( baseApplicationId: string, params: UpdateProtectedBranchesRequestParams, ): AxiosPromise { @@ -15,3 +16,31 @@ export default async function updateProtectedBranchesRequest( params, ); } + +async function updateProtectedBranchesRequestNew( + artifactType: GitArtifactType, + baseArtifactId: string, + params: UpdateProtectedBranchesRequestParams, +): AxiosPromise { + return Api.post( + `${GIT_BASE_URL}/${artifactType}/${baseArtifactId}/protected`, + params, + ); +} + +export default async function updateProtectedBranchesRequest( + artifactType: GitArtifactType, + baseArtifactId: string, + params: UpdateProtectedBranchesRequestParams, + isNew: boolean, +): AxiosPromise { + if (isNew) { + return updateProtectedBranchesRequestNew( + artifactType, + baseArtifactId, + params, + ); + } else { + return updateProtectedBranchesRequestOld(baseArtifactId, params); + } +} diff --git a/app/client/src/git/sagas/checkoutBranchSaga.ts b/app/client/src/git/sagas/checkoutBranchSaga.ts index e92b579846b9..dcb856f66986 100644 --- a/app/client/src/git/sagas/checkoutBranchSaga.ts +++ b/app/client/src/git/sagas/checkoutBranchSaga.ts @@ -1,13 +1,15 @@ import { call, put, select, take } from "redux-saga/effects"; import type { CheckoutBranchInitPayload } from "../store/actions/checkoutBranchActions"; import { GitArtifactType } from "../constants/enums"; -import checkoutBranchRequest from "../requests/checkoutBranchRequest"; -import type { - CheckoutBranchRequestParams, - CheckoutBranchResponse, -} from "../requests/checkoutBranchRequest.types"; import { gitArtifactActions } from "../store/gitArtifactSlice"; import type { GitArtifactPayloadAction } from "../store/types"; +import log from "loglevel"; +import { captureException } from "@sentry/react"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; +import type { + CheckoutRefRequestParams, + CheckoutRefResponse, +} from "git/requests/checkoutRefRequest.types"; // internal dependencies import { builderURL } from "ee/RouteBuilder"; @@ -19,21 +21,30 @@ import { FocusEntity, identifyEntityFromPath } from "navigation/FocusEntity"; import { validateResponse } from "sagas/ErrorSagas"; import history from "utils/history"; import type { JSCollectionDataState } from "ee/reducers/entityReducers/jsActionsReducer"; -import log from "loglevel"; -import { captureException } from "@sentry/react"; +import checkoutRefRequest from "git/requests/checkoutRefRequest"; export default function* checkoutBranchSaga( action: GitArtifactPayloadAction, ) { const { artifactDef, artifactId, branchName } = action.payload; - let response: CheckoutBranchResponse | undefined; + let response: CheckoutRefResponse | undefined; try { - const params: CheckoutBranchRequestParams = { - branchName, + const params: CheckoutRefRequestParams = { + refType: "branch", + refName: branchName, }; - - response = yield call(checkoutBranchRequest, artifactId, params); + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + checkoutRefRequest, + artifactDef.artifactType, + artifactId, + params, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response); if (response && isValidResponse) { diff --git a/app/client/src/git/sagas/commitSaga.ts b/app/client/src/git/sagas/commitSaga.ts index 1c1d93e3fd2b..203baf485d36 100644 --- a/app/client/src/git/sagas/commitSaga.ts +++ b/app/client/src/git/sagas/commitSaga.ts @@ -17,6 +17,7 @@ import { gitGlobalActions } from "git/store/gitGlobalSlice"; import type { ApplicationPayload } from "entities/Application"; import { getCurrentApplication } from "ee/selectors/applicationSelectors"; import { ReduxActionTypes } from "ee/constants/ReduxActionConstants"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; export default function* commitSaga( action: GitArtifactPayloadAction, @@ -30,8 +31,17 @@ export default function* commitSaga( commitMessage: action.payload.commitMessage, doPush: action.payload.doPush, }; + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); - response = yield call(commitRequest, artifactId, params); + response = yield call( + commitRequest, + artifactDef.artifactType, + artifactId, + params, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response, false); diff --git a/app/client/src/git/sagas/connectSaga.ts b/app/client/src/git/sagas/connectSaga.ts index 0657aec6e5e0..2c379e3137a9 100644 --- a/app/client/src/git/sagas/connectSaga.ts +++ b/app/client/src/git/sagas/connectSaga.ts @@ -22,6 +22,7 @@ import { gitGlobalActions } from "git/store/gitGlobalSlice"; import { getCurrentApplication } from "ee/selectors/applicationSelectors"; import type { ApplicationPayload } from "entities/Application"; import { ReduxActionTypes } from "ee/constants/ReduxActionConstants"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; export default function* connectSaga( action: GitArtifactPayloadAction, @@ -36,7 +37,17 @@ export default function* connectSaga( gitProfile: action.payload.gitProfile, }; - response = yield call(connectRequest, artifactDef.baseArtifactId, params); + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + connectRequest, + artifactDef.artifactType, + artifactDef.baseArtifactId, + params, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response, false); diff --git a/app/client/src/git/sagas/createBranchSaga.ts b/app/client/src/git/sagas/createBranchSaga.ts index af5319087507..3e8ecb625c51 100644 --- a/app/client/src/git/sagas/createBranchSaga.ts +++ b/app/client/src/git/sagas/createBranchSaga.ts @@ -1,10 +1,5 @@ -import { call, put } from "redux-saga/effects"; +import { call, put, select } from "redux-saga/effects"; import type { CreateBranchInitPayload } from "../store/actions/createBranchActions"; -import createBranchRequest from "../requests/createBranchRequest"; -import type { - CreateBranchRequestParams, - CreateBranchResponse, -} from "../requests/createBranchRequest.types"; import { gitArtifactActions } from "../store/gitArtifactSlice"; import type { GitArtifactPayloadAction } from "../store/types"; @@ -12,29 +7,46 @@ import type { GitArtifactPayloadAction } from "../store/types"; import { validateResponse } from "sagas/ErrorSagas"; import { captureException } from "@sentry/react"; import log from "loglevel"; +import createRefRequest from "git/requests/createRefRequest"; +import type { + CreateRefRequestParams, + CreateRefResponse, +} from "git/requests/createRefRequest.types"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; export default function* createBranchSaga( action: GitArtifactPayloadAction, ) { const { artifactDef, artifactId } = action.payload; - let response: CreateBranchResponse | undefined; + let response: CreateRefResponse | undefined; try { - const params: CreateBranchRequestParams = { - branchName: action.payload.branchName, + const params: CreateRefRequestParams = { + refType: "branch", + refName: action.payload.branchName, }; - response = yield call(createBranchRequest, artifactId, params); + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + createRefRequest, + artifactDef.artifactType, + artifactId, + params, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response); if (isValidResponse) { - // yield put( - // gitArtifactActions.fetchBranchesInit({ - // artifactDef, - // artifactId, - // pruneBranches: true, - // }), - // ); + yield put( + gitArtifactActions.fetchBranchesInit({ + artifactDef, + artifactId, + pruneBranches: true, + }), + ); yield put( gitArtifactActions.checkoutBranchInit({ artifactDef, diff --git a/app/client/src/git/sagas/deleteBranchSaga.ts b/app/client/src/git/sagas/deleteBranchSaga.ts index 0f5126d4d2e5..d135238eb8f9 100644 --- a/app/client/src/git/sagas/deleteBranchSaga.ts +++ b/app/client/src/git/sagas/deleteBranchSaga.ts @@ -1,35 +1,41 @@ import type { DeleteBranchInitPayload } from "../store/actions/deleteBranchActions"; -import deleteBranchRequest from "../requests/deleteBranchRequest"; -import type { - DeleteBranchRequestParams, - DeleteBranchResponse, -} from "../requests/deleteBranchRequest.types"; import { gitArtifactActions } from "../store/gitArtifactSlice"; import type { GitArtifactPayloadAction } from "../store/types"; -import { call, put } from "redux-saga/effects"; - -// internal dependencies +import { call, put, select } from "redux-saga/effects"; import { validateResponse } from "sagas/ErrorSagas"; import log from "loglevel"; import { captureException } from "@sentry/react"; import { toast } from "@appsmith/ads"; import { createMessage, DELETE_BRANCH_SUCCESS } from "ee/constants/messages"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; +import deleteRefRequest from "git/requests/deleteRefRequest"; +import type { + DeleteRefRequestParams, + DeleteRefResponse, +} from "git/requests/deleteRefRequest.types"; export default function* deleteBranchSaga( action: GitArtifactPayloadAction, ) { const { artifactDef, artifactId } = action.payload; - let response: DeleteBranchResponse | undefined; + let response: DeleteRefResponse | undefined; try { - const params: DeleteBranchRequestParams = { - branchName: action.payload.branchName, + const params: DeleteRefRequestParams = { + refType: "branch", + refName: action.payload.branchName, }; + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + response = yield call( - deleteBranchRequest, + deleteRefRequest, + artifactDef.artifactType, artifactDef.baseArtifactId, params, + isGitApiContractsEnabled, ); const isValidResponse: boolean = yield validateResponse(response); diff --git a/app/client/src/git/sagas/discardSaga.ts b/app/client/src/git/sagas/discardSaga.ts index c7e5e3c7663b..18dac8704167 100644 --- a/app/client/src/git/sagas/discardSaga.ts +++ b/app/client/src/git/sagas/discardSaga.ts @@ -6,9 +6,10 @@ import discardRequest from "git/requests/discardRequest"; import type { DiscardResponse } from "git/requests/discardRequest.types"; import type { DiscardInitPayload } from "git/store/actions/discardActions"; import { gitArtifactActions } from "git/store/gitArtifactSlice"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; import type { GitArtifactPayloadAction } from "git/store/types"; import log from "loglevel"; -import { call, delay, put } from "redux-saga/effects"; +import { call, delay, put, select } from "redux-saga/effects"; import { validateResponse } from "sagas/ErrorSagas"; export default function* discardSaga( @@ -19,7 +20,16 @@ export default function* discardSaga( let response: DiscardResponse | undefined; try { - response = yield call(discardRequest, artifactId); + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + discardRequest, + artifactDef.artifactType, + artifactId, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response); if (response && isValidResponse) { diff --git a/app/client/src/git/sagas/disconnectSaga.ts b/app/client/src/git/sagas/disconnectSaga.ts index ef6788b9ca11..1ad1ca8f6993 100644 --- a/app/client/src/git/sagas/disconnectSaga.ts +++ b/app/client/src/git/sagas/disconnectSaga.ts @@ -6,6 +6,7 @@ import disconnectRequest from "git/requests/disconnectRequest"; import type { DisconnectResponse } from "git/requests/disconnectRequest.types"; import { gitArtifactActions } from "git/store/gitArtifactSlice"; import { selectDisconnectArtifactDef } from "git/store/selectors/gitArtifactSelectors"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; import type { GitArtifactDef, GitArtifactPayloadAction } from "git/store/types"; import log from "loglevel"; import { call, put, select } from "redux-saga/effects"; @@ -21,9 +22,15 @@ export default function* disconnectSaga(action: GitArtifactPayloadAction) { let response: DisconnectResponse | undefined; try { + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + response = yield call( disconnectRequest, + disconnectArtifactDef.artifactType, disconnectArtifactDef.baseArtifactId, + isGitApiContractsEnabled, ); const isValidResponse: boolean = yield validateResponse(response); diff --git a/app/client/src/git/sagas/fetchBranchesSaga.ts b/app/client/src/git/sagas/fetchBranchesSaga.ts index 5141db03e34f..4a586270d463 100644 --- a/app/client/src/git/sagas/fetchBranchesSaga.ts +++ b/app/client/src/git/sagas/fetchBranchesSaga.ts @@ -1,28 +1,40 @@ import type { FetchBranchesInitPayload } from "../store/actions/fetchBranchesActions"; -import fetchBranchesRequest from "git/requests/fetchBranchesRequest"; -import type { - FetchBranchesRequestParams, - FetchBranchesResponse, -} from "git/requests/fetchBranchesRequest.types"; import { gitArtifactActions } from "git/store/gitArtifactSlice"; import type { GitArtifactPayloadAction } from "../store/types"; -import { call, put } from "redux-saga/effects"; +import { call, put, select } from "redux-saga/effects"; import { validateResponse } from "sagas/ErrorSagas"; import log from "loglevel"; import { captureException } from "@sentry/react"; +import fetchRefsRequest from "git/requests/fetchRefsRequest"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; +import type { + FetchRefsRequestParams, + FetchRefsResponse, +} from "git/requests/fetchRefsRequest.types"; export default function* fetchBranchesSaga( action: GitArtifactPayloadAction, ) { const { artifactDef, artifactId } = action.payload; - let response: FetchBranchesResponse | undefined; + let response: FetchRefsResponse | undefined; try { - const params: FetchBranchesRequestParams = { - pruneBranches: action.payload.pruneBranches, + const params: FetchRefsRequestParams = { + refType: "branch", + pruneRefs: action.payload.pruneBranches ?? true, }; - response = yield call(fetchBranchesRequest, artifactId, params); + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + fetchRefsRequest, + artifactDef.artifactType, + artifactId, + params, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response, false); if (response && isValidResponse) { diff --git a/app/client/src/git/sagas/fetchGlobalSSHKeySaga.ts b/app/client/src/git/sagas/fetchGlobalSSHKeySaga.ts index e72711961844..61ca3b717496 100644 --- a/app/client/src/git/sagas/fetchGlobalSSHKeySaga.ts +++ b/app/client/src/git/sagas/fetchGlobalSSHKeySaga.ts @@ -6,9 +6,10 @@ import type { } from "git/requests/generateSSHKeyRequest.types"; import type { FetchGlobalSSHKeyInitPayload } from "git/store/actions/fetchGlobalSSHKeyActions"; import { gitGlobalActions } from "git/store/gitGlobalSlice"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; import type { GitArtifactPayloadAction } from "git/store/types"; import log from "loglevel"; -import { call, put } from "redux-saga/effects"; +import { call, put, select } from "redux-saga/effects"; import { validateResponse } from "sagas/ErrorSagas"; export function* fetchGlobalSSHKeySaga( @@ -21,7 +22,15 @@ export function* fetchGlobalSSHKeySaga( keyType: action.payload.keyType, }; - response = yield call(fetchGlobalSSHKeyRequest, params); + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + fetchGlobalSSHKeyRequest, + params, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response); if (response && isValidResponse) { diff --git a/app/client/src/git/sagas/fetchLocalProfileSaga.ts b/app/client/src/git/sagas/fetchLocalProfileSaga.ts index 28f24ef2198d..7f1df72f0d57 100644 --- a/app/client/src/git/sagas/fetchLocalProfileSaga.ts +++ b/app/client/src/git/sagas/fetchLocalProfileSaga.ts @@ -2,10 +2,11 @@ import fetchLocalProfileRequest from "git/requests/fetchLocalProfileRequest"; import type { FetchLocalProfileResponse } from "git/requests/fetchLocalProfileRequest.types"; import { gitArtifactActions } from "git/store/gitArtifactSlice"; import type { GitArtifactPayloadAction } from "../store/types"; -import { call, put } from "redux-saga/effects"; +import { call, put, select } from "redux-saga/effects"; import { validateResponse } from "sagas/ErrorSagas"; import log from "loglevel"; import { captureException } from "@sentry/react"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; export default function* fetchLocalProfileSaga( action: GitArtifactPayloadAction, @@ -14,7 +15,16 @@ export default function* fetchLocalProfileSaga( let response: FetchLocalProfileResponse | undefined; try { - response = yield call(fetchLocalProfileRequest, artifactDef.baseArtifactId); + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + fetchLocalProfileRequest, + artifactDef.artifactType, + artifactDef.baseArtifactId, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response); if (response && isValidResponse) { diff --git a/app/client/src/git/sagas/fetchMergeStatusSaga.ts b/app/client/src/git/sagas/fetchMergeStatusSaga.ts index 024954b017c5..32c33dae9339 100644 --- a/app/client/src/git/sagas/fetchMergeStatusSaga.ts +++ b/app/client/src/git/sagas/fetchMergeStatusSaga.ts @@ -6,9 +6,10 @@ import type { } from "git/requests/fetchMergeStatusRequest.types"; import type { FetchMergeStatusInitPayload } from "git/store/actions/fetchMergeStatusActions"; import { gitArtifactActions } from "git/store/gitArtifactSlice"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; import type { GitArtifactPayloadAction } from "git/store/types"; import log from "loglevel"; -import { call, put } from "redux-saga/effects"; +import { call, put, select } from "redux-saga/effects"; import { validateResponse } from "sagas/ErrorSagas"; export default function* fetchMergeStatusSaga( @@ -23,7 +24,17 @@ export default function* fetchMergeStatusSaga( sourceBranch: action.payload.sourceBranch, }; - response = yield call(fetchMergeStatusRequest, artifactId, params); + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + fetchMergeStatusRequest, + artifactDef.artifactType, + artifactId, + params, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response); if (response && isValidResponse) { diff --git a/app/client/src/git/sagas/fetchMetadataSaga.ts b/app/client/src/git/sagas/fetchMetadataSaga.ts index 9f8285847ee7..2e104e384e90 100644 --- a/app/client/src/git/sagas/fetchMetadataSaga.ts +++ b/app/client/src/git/sagas/fetchMetadataSaga.ts @@ -2,9 +2,10 @@ import { captureException } from "@sentry/react"; import fetchMetadataRequest from "git/requests/fetchMetadataRequest"; import type { FetchMetadataResponse } from "git/requests/fetchMetadataRequest.types"; import { gitArtifactActions } from "git/store/gitArtifactSlice"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; import type { GitArtifactPayloadAction } from "git/store/types"; import log from "loglevel"; -import { call, put } from "redux-saga/effects"; +import { call, put, select } from "redux-saga/effects"; import { validateResponse } from "sagas/ErrorSagas"; export default function* fetchMetadataSaga(action: GitArtifactPayloadAction) { @@ -12,7 +13,16 @@ export default function* fetchMetadataSaga(action: GitArtifactPayloadAction) { let response: FetchMetadataResponse | undefined; try { - response = yield call(fetchMetadataRequest, artifactDef.baseArtifactId); + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + fetchMetadataRequest, + artifactDef.artifactType, + artifactDef.baseArtifactId, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response, false); if (response && isValidResponse) { diff --git a/app/client/src/git/sagas/fetchProtectedBranchesSaga.ts b/app/client/src/git/sagas/fetchProtectedBranchesSaga.ts index 62f36f8ce93c..abd6cc1104c0 100644 --- a/app/client/src/git/sagas/fetchProtectedBranchesSaga.ts +++ b/app/client/src/git/sagas/fetchProtectedBranchesSaga.ts @@ -2,9 +2,10 @@ import { captureException } from "@sentry/react"; import fetchProtectedBranchesRequest from "git/requests/fetchProtectedBranchesRequest"; import type { FetchProtectedBranchesResponse } from "git/requests/fetchProtectedBranchesRequest.types"; import { gitArtifactActions } from "git/store/gitArtifactSlice"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; import type { GitArtifactPayloadAction } from "git/store/types"; import log from "loglevel"; -import { call, put } from "redux-saga/effects"; +import { call, put, select } from "redux-saga/effects"; import { validateResponse } from "sagas/ErrorSagas"; export default function* fetchProtectedBranchesSaga( @@ -14,9 +15,15 @@ export default function* fetchProtectedBranchesSaga( let response: FetchProtectedBranchesResponse | undefined; try { + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + response = yield call( fetchProtectedBranchesRequest, + artifactDef.artifactType, artifactDef.baseArtifactId, + isGitApiContractsEnabled, ); const isValidResponse: boolean = yield validateResponse(response); diff --git a/app/client/src/git/sagas/fetchStatusSaga.ts b/app/client/src/git/sagas/fetchStatusSaga.ts index 733f18cce776..27948ff569dc 100644 --- a/app/client/src/git/sagas/fetchStatusSaga.ts +++ b/app/client/src/git/sagas/fetchStatusSaga.ts @@ -3,9 +3,10 @@ import fetchStatusRequest from "git/requests/fetchStatusRequest"; import type { FetchStatusResponse } from "git/requests/fetchStatusRequest.types"; import type { FetchStatusInitPayload } from "git/store/actions/fetchStatusActions"; import { gitArtifactActions } from "git/store/gitArtifactSlice"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; import type { GitArtifactPayloadAction } from "git/store/types"; import log from "loglevel"; -import { call, put } from "redux-saga/effects"; +import { call, put, select } from "redux-saga/effects"; import { validateResponse } from "sagas/ErrorSagas"; export default function* fetchStatusSaga( @@ -15,7 +16,18 @@ export default function* fetchStatusSaga( let response: FetchStatusResponse | undefined; try { - response = yield call(fetchStatusRequest, artifactId); + const params = { compareRemote: true }; + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + fetchStatusRequest, + artifactDef.artifactType, + artifactId, + params, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response); if (response && isValidResponse) { diff --git a/app/client/src/git/sagas/gitImportSaga.ts b/app/client/src/git/sagas/gitImportSaga.ts index 1991032176fb..57d3e94f0b30 100644 --- a/app/client/src/git/sagas/gitImportSaga.ts +++ b/app/client/src/git/sagas/gitImportSaga.ts @@ -16,6 +16,7 @@ import { showReconnectDatasourceModal } from "ee/actions/applicationActions"; import type { Workspace } from "ee/constants/workspaceConstants"; import { getFetchedWorkspaces } from "ee/selectors/workspaceSelectors"; import { GitErrorCodes } from "git/constants/enums"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; export default function* gitImportSaga( action: PayloadAction, @@ -26,7 +27,16 @@ export default function* gitImportSaga( let response: GitImportResponse | undefined; try { - response = yield call(gitImportRequest, workspaceId, params); + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + gitImportRequest, + workspaceId, + params, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response); if (response && isValidResponse) { diff --git a/app/client/src/git/sagas/helpers/apiContractServerCall.ts b/app/client/src/git/sagas/helpers/apiContractServerCall.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/app/client/src/git/sagas/mergeSaga.ts b/app/client/src/git/sagas/mergeSaga.ts index 858ad62c4c3a..14ce140d4932 100644 --- a/app/client/src/git/sagas/mergeSaga.ts +++ b/app/client/src/git/sagas/mergeSaga.ts @@ -3,9 +3,10 @@ import mergeRequest from "git/requests/mergeRequest"; import type { MergeResponse } from "git/requests/mergeRequest.types"; import type { MergeInitPayload } from "git/store/actions/mergeActions"; import { gitArtifactActions } from "git/store/gitArtifactSlice"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; import type { GitArtifactPayloadAction } from "git/store/types"; import log from "loglevel"; -import { call, put } from "redux-saga/effects"; +import { call, put, select } from "redux-saga/effects"; import { validateResponse } from "sagas/ErrorSagas"; export default function* mergeSaga( @@ -20,7 +21,17 @@ export default function* mergeSaga( destinationBranch: action.payload.destinationBranch, }; - response = yield call(mergeRequest, artifactId, params); + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + mergeRequest, + artifactDef.artifactType, + artifactId, + params, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response); diff --git a/app/client/src/git/sagas/pullSaga.ts b/app/client/src/git/sagas/pullSaga.ts index 07347326e3e0..c73ad7b30e37 100644 --- a/app/client/src/git/sagas/pullSaga.ts +++ b/app/client/src/git/sagas/pullSaga.ts @@ -13,6 +13,7 @@ import { initEditorAction } from "actions/initActions"; import { APP_MODE } from "entities/App"; import log from "loglevel"; import { captureException } from "@sentry/react"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; export default function* pullSaga( action: GitArtifactPayloadAction, @@ -21,7 +22,16 @@ export default function* pullSaga( let response: PullResponse | undefined; try { - response = yield call(pullRequest, artifactId); + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + pullRequest, + artifactDef.artifactType, + artifactId, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response); if (response && isValidResponse) { diff --git a/app/client/src/git/sagas/toggleAutocommitSaga.ts b/app/client/src/git/sagas/toggleAutocommitSaga.ts index 4f97d0289543..598423cb9cec 100644 --- a/app/client/src/git/sagas/toggleAutocommitSaga.ts +++ b/app/client/src/git/sagas/toggleAutocommitSaga.ts @@ -2,9 +2,10 @@ import { captureException } from "@sentry/react"; import toggleAutocommitRequest from "git/requests/toggleAutocommitRequest"; import type { ToggleAutocommitResponse } from "git/requests/toggleAutocommitRequest.types"; import { gitArtifactActions } from "git/store/gitArtifactSlice"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; import type { GitArtifactPayloadAction } from "git/store/types"; import log from "loglevel"; -import { call, put } from "redux-saga/effects"; +import { call, put, select } from "redux-saga/effects"; import { validateResponse } from "sagas/ErrorSagas"; export default function* toggleAutocommitSaga( @@ -14,7 +15,16 @@ export default function* toggleAutocommitSaga( let response: ToggleAutocommitResponse | undefined; try { - response = yield call(toggleAutocommitRequest, artifactDef.baseArtifactId); + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + + response = yield call( + toggleAutocommitRequest, + artifactDef.artifactType, + artifactDef.baseArtifactId, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(response); if (isValidResponse) { diff --git a/app/client/src/git/sagas/triggerAutocommitSaga.ts b/app/client/src/git/sagas/triggerAutocommitSaga.ts index 6725fb0d59f9..6caa31fc0231 100644 --- a/app/client/src/git/sagas/triggerAutocommitSaga.ts +++ b/app/client/src/git/sagas/triggerAutocommitSaga.ts @@ -27,6 +27,7 @@ import type { Task } from "redux-saga"; import { validateResponse } from "sagas/ErrorSagas"; import log from "loglevel"; import { captureException } from "@sentry/react"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; const AUTOCOMMIT_POLL_DELAY = 1000; const AUTOCOMMIT_WHITELISTED_STATES = [ @@ -56,8 +57,17 @@ function* pollAutocommitProgressSaga(params: PollAutocommitProgressParams) { const { artifactDef, artifactId } = params; let triggerResponse: TriggerAutocommitResponse | undefined; + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + try { - triggerResponse = yield call(triggerAutocommitRequest, artifactId); + triggerResponse = yield call( + triggerAutocommitRequest, + artifactDef.artifactType, + artifactId, + isGitApiContractsEnabled, + ); const isValidResponse: boolean = yield validateResponse(triggerResponse); if (triggerResponse && isValidResponse) { @@ -88,9 +98,12 @@ function* pollAutocommitProgressSaga(params: PollAutocommitProgressParams) { yield put( gitArtifactActions.fetchAutocommitProgressInit({ artifactDef }), ); + progressResponse = yield call( fetchAutocommitProgressRequest, + artifactDef.artifactType, artifactDef.baseArtifactId, + isGitApiContractsEnabled, ); const isValidResponse: boolean = yield validateResponse(progressResponse); diff --git a/app/client/src/git/sagas/updateLocalProfileSaga.ts b/app/client/src/git/sagas/updateLocalProfileSaga.ts index 3b7253a391fe..c89a64e7166c 100644 --- a/app/client/src/git/sagas/updateLocalProfileSaga.ts +++ b/app/client/src/git/sagas/updateLocalProfileSaga.ts @@ -6,10 +6,11 @@ import type { } from "git/requests/updateLocalProfileRequest.types"; import { gitArtifactActions } from "../store/gitArtifactSlice"; import type { GitArtifactPayloadAction } from "../store/types"; -import { call, put } from "redux-saga/effects"; +import { call, put, select } from "redux-saga/effects"; import { validateResponse } from "sagas/ErrorSagas"; import log from "loglevel"; import { captureException } from "@sentry/react"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; export default function* updateLocalProfileSaga( action: GitArtifactPayloadAction, @@ -24,10 +25,16 @@ export default function* updateLocalProfileSaga( useGlobalProfile: action.payload.useGlobalProfile, }; + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + response = yield call( updateLocalProfileRequest, + artifactDef.artifactType, artifactDef.baseArtifactId, params, + isGitApiContractsEnabled, ); const isValidResponse: boolean = yield validateResponse(response); diff --git a/app/client/src/git/sagas/updateProtectedBranchesSaga.ts b/app/client/src/git/sagas/updateProtectedBranchesSaga.ts index f24b20ee9290..1a554e1280a3 100644 --- a/app/client/src/git/sagas/updateProtectedBranchesSaga.ts +++ b/app/client/src/git/sagas/updateProtectedBranchesSaga.ts @@ -6,9 +6,10 @@ import type { } from "git/requests/updateProtectedBranchesRequest.types"; import type { UpdateProtectedBranchesInitPayload } from "git/store/actions/updateProtectedBranchesActions"; import { gitArtifactActions } from "git/store/gitArtifactSlice"; +import { selectGitApiContractsEnabled } from "git/store/selectors/gitFeatureFlagSelectors"; import type { GitArtifactPayloadAction } from "git/store/types"; import log from "loglevel"; -import { call, put } from "redux-saga/effects"; +import { call, put, select } from "redux-saga/effects"; import { validateResponse } from "sagas/ErrorSagas"; export default function* updateProtectedBranchesSaga( @@ -22,10 +23,16 @@ export default function* updateProtectedBranchesSaga( branchNames: action.payload.branchNames, }; + const isGitApiContractsEnabled: boolean = yield select( + selectGitApiContractsEnabled, + ); + response = yield call( updateProtectedBranchesRequest, + artifactDef.artifactType, artifactDef.baseArtifactId, params, + isGitApiContractsEnabled, ); const isValidResponse: boolean = yield validateResponse(response); diff --git a/app/client/src/git/store/actions/checkoutBranchActions.ts b/app/client/src/git/store/actions/checkoutBranchActions.ts index e9451a614d7f..3fe758695297 100644 --- a/app/client/src/git/store/actions/checkoutBranchActions.ts +++ b/app/client/src/git/store/actions/checkoutBranchActions.ts @@ -1,9 +1,9 @@ import { createArtifactAction } from "../helpers/createArtifactAction"; import type { GitAsyncErrorPayload } from "../types"; -import type { CheckoutBranchRequestParams } from "git/requests/checkoutBranchRequest.types"; -export interface CheckoutBranchInitPayload extends CheckoutBranchRequestParams { +export interface CheckoutBranchInitPayload { artifactId: string; + branchName: string; } export const checkoutBranchInitAction = diff --git a/app/client/src/git/store/actions/createBranchActions.ts b/app/client/src/git/store/actions/createBranchActions.ts index 010a7550888f..311882d018c1 100644 --- a/app/client/src/git/store/actions/createBranchActions.ts +++ b/app/client/src/git/store/actions/createBranchActions.ts @@ -1,9 +1,9 @@ import { createArtifactAction } from "../helpers/createArtifactAction"; import type { GitAsyncErrorPayload } from "../types"; -import type { CreateBranchRequestParams } from "git/requests/createBranchRequest.types"; -export interface CreateBranchInitPayload extends CreateBranchRequestParams { +export interface CreateBranchInitPayload { artifactId: string; + branchName: string; } export const createBranchInitAction = diff --git a/app/client/src/git/store/actions/deleteBranchActions.ts b/app/client/src/git/store/actions/deleteBranchActions.ts index 0656886f39d4..ed0952b729e0 100644 --- a/app/client/src/git/store/actions/deleteBranchActions.ts +++ b/app/client/src/git/store/actions/deleteBranchActions.ts @@ -1,9 +1,9 @@ import { createArtifactAction } from "../helpers/createArtifactAction"; import type { GitAsyncErrorPayload } from "../types"; -import type { DeleteBranchRequestParams } from "../../requests/deleteBranchRequest.types"; -export interface DeleteBranchInitPayload extends DeleteBranchRequestParams { +export interface DeleteBranchInitPayload { artifactId: string; + branchName: string; } export const deleteBranchInitAction = diff --git a/app/client/src/git/store/actions/fetchBranchesActions.ts b/app/client/src/git/store/actions/fetchBranchesActions.ts index 6758ad918eb0..a957f762d84c 100644 --- a/app/client/src/git/store/actions/fetchBranchesActions.ts +++ b/app/client/src/git/store/actions/fetchBranchesActions.ts @@ -1,12 +1,10 @@ -import type { - FetchBranchesRequestParams, - FetchBranchesResponseData, -} from "../../requests/fetchBranchesRequest.types"; import type { GitAsyncErrorPayload, GitAsyncSuccessPayload } from "../types"; import { createArtifactAction } from "../helpers/createArtifactAction"; +import type { FetchRefsResponseData } from "git/requests/fetchRefsRequest.types"; -export interface FetchBranchesInitPayload extends FetchBranchesRequestParams { +export interface FetchBranchesInitPayload { artifactId: string; + pruneBranches?: boolean; } export const fetchBranchesInitAction = @@ -18,7 +16,7 @@ export const fetchBranchesInitAction = }); export const fetchBranchesSuccessAction = createArtifactAction< - GitAsyncSuccessPayload + GitAsyncSuccessPayload >((state, action) => { state.apiResponses.branches.loading = false; state.apiResponses.branches.value = action.payload.responseData; diff --git a/app/client/src/git/store/selectors/gitFeatureFlagSelectors.ts b/app/client/src/git/store/selectors/gitFeatureFlagSelectors.ts new file mode 100644 index 000000000000..e91f4436aba1 --- /dev/null +++ b/app/client/src/git/store/selectors/gitFeatureFlagSelectors.ts @@ -0,0 +1,9 @@ +import { createSelector } from "reselect"; +import { selectFeatureFlags } from "ee/selectors/featureFlagsSelectors"; +import { FEATURE_FLAG } from "ee/entities/FeatureFlag"; + +export const selectGitApiContractsEnabled = createSelector( + selectFeatureFlags, + (featureFlags) => + featureFlags[FEATURE_FLAG.release_git_api_contracts_enabled] ?? false, +); diff --git a/app/client/src/git/store/types.ts b/app/client/src/git/store/types.ts index bcf59c07599f..22804efbe144 100644 --- a/app/client/src/git/store/types.ts +++ b/app/client/src/git/store/types.ts @@ -5,7 +5,6 @@ import type { GitSettingsTab, } from "../constants/enums"; import type { FetchGlobalProfileResponseData } from "../requests/fetchGlobalProfileRequest.types"; -import type { FetchBranchesResponseData } from "../requests/fetchBranchesRequest.types"; import type { FetchLocalProfileResponseData } from "../requests/fetchLocalProfileRequest.types"; import type { FetchStatusResponseData } from "git/requests/fetchStatusRequest.types"; import type { FetchMergeStatusResponseData } from "git/requests/fetchMergeStatusRequest.types"; @@ -19,6 +18,7 @@ import type { } from "git/ee/store/types"; import type { FetchGlobalSSHKeyResponseData } from "git/requests/fetchGlobalSSHKeyRequest.types"; import type { ApplicationPayload } from "entities/Application"; +import type { FetchRefsResponseData } from "git/requests/fetchRefsRequest.types"; export interface GitApiError extends ApiResponseError { errorType?: string; @@ -45,7 +45,7 @@ export interface GitArtifactAPIResponsesReduxState discard: GitAsyncStateWithoutValue; mergeStatus: GitAsyncState; merge: GitAsyncStateWithoutValue; - branches: GitAsyncState; + branches: GitAsyncState; checkoutBranch: GitAsyncStateWithoutValue; createBranch: GitAsyncStateWithoutValue; deleteBranch: GitAsyncStateWithoutValue; @@ -68,7 +68,7 @@ export interface GitArtifactUIReduxState connectModalOpen: boolean; connectSuccessModalOpen: boolean; disconnectBaseArtifactId: string | null; - disconnectArtifactType: keyof typeof GitArtifactType | null; + disconnectArtifactType: GitArtifactType | null; disconnectArtifactName: string | null; branchPopupOpen: boolean; checkoutDestBranch: string | null; @@ -85,7 +85,7 @@ export interface GitArtifactUIReduxState export type GitArtifact = ApplicationPayload; export interface GitArtifactDef { - artifactType: keyof typeof GitArtifactType; + artifactType: GitArtifactType; baseArtifactId: string; } export interface GitArtifactReduxState { diff --git a/app/client/src/git/types.ts b/app/client/src/git/types.ts new file mode 100644 index 000000000000..23702c25955b --- /dev/null +++ b/app/client/src/git/types.ts @@ -0,0 +1,11 @@ +export interface GitRef { + refName: string; + refType: string; + createdFromLocal: string; + default: boolean; +} + +export interface GitBranch { + branchName: string; + default: boolean; +}