merge main

This commit is contained in:
Scott Wilson
2025-09-15 15:06:42 -07:00
605 changed files with 11025 additions and 4114 deletions

View File

@@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link, useParams } from "@tanstack/react-router";
import { twMerge } from "tailwind-merge";
import { useOrganization, useWorkspace } from "@app/context";
import { useOrganization, useProject } from "@app/context";
import { useToggle } from "@app/hooks";
import { createNotification } from "../notifications";
@@ -51,7 +51,7 @@ export default function NavHeader({
isProtectedBranch = false,
protectionPolicyName
}: Props): JSX.Element {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { currentOrg } = useOrganization();
const [isCopied, { timedToggle: toggleIsCopied }] = useToggle(false);
@@ -79,7 +79,7 @@ export default function NavHeader({
<>
<FontAwesomeIcon icon={faAngleRight} className="ml-3 mr-3 text-xs text-gray-400" />
<div className="truncate text-sm font-semibold text-bunker-300">
{currentWorkspace?.name}
{currentProject?.name}
</div>
</>
)}
@@ -93,7 +93,7 @@ export default function NavHeader({
{pageName === "Secrets" ? (
<Link
to="/projects/secret-management/$projectId/overview"
params={{ projectId: currentWorkspace.id }}
params={{ projectId: currentProject.id }}
className="text-sm font-semibold text-primary/80 hover:text-primary"
>
{pageName}
@@ -129,7 +129,7 @@ export default function NavHeader({
<FontAwesomeIcon icon={faAngleRight} className="ml-3 mr-1.5 text-xs text-gray-400" />
<Link
to="/projects/secret-management/$projectId/secrets/$envSlug"
params={{ projectId: currentWorkspace.id, envSlug: routerEnvSlug }}
params={{ projectId: currentProject.id, envSlug: routerEnvSlug }}
className="text-sm font-semibold text-primary/80 hover:text-primary"
>
{userAvailableEnvs?.find(({ slug }) => slug === currentEnv)?.name}
@@ -192,7 +192,7 @@ export default function NavHeader({
<Link
to="/projects/secret-management/$projectId/secrets/$envSlug"
params={{
projectId: currentWorkspace.id,
projectId: currentProject.id,
envSlug: routerEnvSlug || ""
}}
search={(query) => ({ ...query, secretPath: newSecretPath })}

View File

@@ -3,7 +3,7 @@ import { useFormContext, useWatch } from "react-hook-form";
import { MongoAbility, MongoQuery } from "@casl/ability";
import { Edge, Node, useEdgesState, useNodesState } from "@xyflow/react";
import { ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionSub, useProject } from "@app/context";
import { ProjectPermissionSet } from "@app/context/ProjectPermissionContext";
import { useListProjectEnvironmentsFolders } from "@app/hooks/api/secretFolders/queries";
import { TSecretFolderWithPath } from "@app/hooks/api/secretFolders/types";
@@ -36,15 +36,15 @@ export const useAccessTree = (
searchPath: string,
subject: ProjectPermissionSub
) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { secretName, setSecretName, setViewMode, viewMode } = useAccessTreeContext();
const { control } = useFormContext<AccessTreeForm>();
const metadata = useWatch({ control, name: "metadata" });
const [nodes, setNodes] = useNodesState<Node>([]);
const [edges, setEdges] = useEdgesState<Edge>([]);
const [environment, setEnvironment] = useState(currentWorkspace.environments[0]?.slug ?? "");
const [environment, setEnvironment] = useState(currentProject.environments[0]?.slug ?? "");
const { data: environmentsFolders, isPending } = useListProjectEnvironmentsFolders(
currentWorkspace.id
currentProject.id
);
const [levelFolderMap, setLevelFolderMap] = useState<LevelFolderMap>({});
@@ -279,7 +279,7 @@ export const useAccessTree = (
environment,
setEnvironment,
isLoading: isPending,
environments: currentWorkspace.environments,
environments: currentProject.environments,
secretName,
setSecretName,
viewMode,

View File

@@ -6,7 +6,7 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import { Button, FormControl, Input, TextArea } from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { useUpdateProject } from "@app/hooks/api";
const baseFormSchema = z.object({
@@ -37,35 +37,35 @@ type Props = {
};
export const ProjectOverviewChangeSection = ({ showSlugField = false }: Props) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { mutateAsync, isPending } = useUpdateProject();
const { handleSubmit, control, reset, watch } = useForm<BaseFormData | FormDataWithSlug>({
resolver: zodResolver(showSlugField ? formSchemaWithSlug : baseFormSchema)
});
const currentSlug = showSlugField ? watch("slug") : currentWorkspace?.slug;
const currentSlug = showSlugField ? watch("slug") : currentProject?.slug;
useEffect(() => {
if (currentWorkspace) {
if (currentProject) {
reset({
name: currentWorkspace.name,
description: currentWorkspace.description ?? "",
...(showSlugField && { slug: currentWorkspace.slug })
name: currentProject.name,
description: currentProject.description ?? "",
...(showSlugField && { slug: currentProject.slug })
});
}
}, [currentWorkspace, showSlugField]);
}, [currentProject, showSlugField]);
const onFormSubmit = async (data: BaseFormData | FormDataWithSlug) => {
try {
if (!currentWorkspace?.id) return;
if (!currentProject?.id) return;
await mutateAsync({
projectID: currentWorkspace.id,
projectId: currentProject.id,
newProjectName: data.name,
newProjectDescription: data.description,
...(showSlugField &&
"slug" in data && {
newSlug: data.slug !== currentWorkspace.slug ? data.slug : undefined
newSlug: data.slug !== currentProject.slug ? data.slug : undefined
})
});
@@ -105,7 +105,7 @@ export const ProjectOverviewChangeSection = ({ showSlugField = false }: Props) =
variant="outline_bg"
size="sm"
onClick={() => {
navigator.clipboard.writeText(currentWorkspace?.id || "");
navigator.clipboard.writeText(currentProject?.id || "");
createNotification({
text: "Copied project ID to clipboard",
type: "success"

View File

@@ -34,10 +34,10 @@ import {
useUser
} from "@app/context";
import { getProjectHomePage, getProjectLottieIcon } from "@app/helpers/project";
import { useCreateWorkspace, useGetExternalKmsList, useGetUserWorkspaces } from "@app/hooks/api";
import { useCreateWorkspace, useGetExternalKmsList, useGetUserProjects } from "@app/hooks/api";
import { INTERNAL_KMS_KEY_ID } from "@app/hooks/api/kms/types";
import { ProjectType } from "@app/hooks/api/projects/types";
import { InfisicalProjectTemplate, useListProjectTemplates } from "@app/hooks/api/projectTemplates";
import { ProjectType } from "@app/hooks/api/workspace/types";
const formSchema = z.object({
name: z.string().trim().min(1, "Required").max(64, "Too long, maximum length is 64 characters"),
@@ -89,7 +89,7 @@ const NewProjectForm = ({ onOpenChange }: NewProjectFormProps) => {
const { permission } = useOrgPermission();
const { user } = useUser();
const createWs = useCreateWorkspace();
const { refetch: refetchWorkspaces } = useGetUserWorkspaces();
const { refetch: refetchWorkspaces } = useGetUserProjects();
const { subscription } = useSubscription();
const canReadProjectTemplates = permission.can(

View File

@@ -3,7 +3,7 @@ import { useForm } from "react-hook-form";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Input, Modal, ModalClose, ModalContent } from "@app/components/v2";
import { useRequestProjectAccess } from "@app/hooks/api";
import { Workspace } from "@app/hooks/api/workspace/types";
import { Project } from "@app/hooks/api/projects/types";
type ContentProps = {
projectId: string;
@@ -57,7 +57,7 @@ const Content = ({ projectId, onComplete }: ContentProps) => {
type RequestProjectAccessModalProps = {
isOpen: boolean;
onOpenChange: (isOpen: boolean) => void;
project?: Workspace;
project?: Project;
onComplete?: () => void;
};

View File

@@ -8,13 +8,13 @@ import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms
import { SecretRotationV2ModalHeader } from "@app/components/secret-rotations-v2/SecretRotationV2ModalHeader";
import { SecretRotationV2Select } from "@app/components/secret-rotations-v2/SecretRotationV2Select";
import { Modal, ModalContent } from "@app/components/v2";
import { ProjectEnv } from "@app/hooks/api/projects/types";
import { SecretRotation, TSecretRotationV2 } from "@app/hooks/api/secretRotationsV2";
import { WorkspaceEnv } from "@app/hooks/api/workspace/types";
type SharedProps = {
secretPath: string;
environment?: string;
environments?: WorkspaceEnv[];
environments?: ProjectEnv[];
};
type Props = {

View File

@@ -9,14 +9,14 @@ import {
IS_ROTATION_DUAL_CREDENTIALS,
SECRET_ROTATION_MAP
} from "@app/helpers/secretRotationsV2";
import { WorkspaceEnv } from "@app/hooks/api/workspace/types";
import { ProjectEnv } from "@app/hooks/api/projects/types";
import { TSecretRotationV2Form } from "./schemas";
import { SecretRotationV2ConnectionField } from "./SecretRotationV2ConnectionField";
type Props = {
isUpdate: boolean;
environments?: WorkspaceEnv[];
environments?: ProjectEnv[];
};
export const SecretRotationV2ConfigurationFields = ({ isUpdate, environments }: Props) => {

View File

@@ -5,7 +5,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { AppConnectionOption } from "@app/components/app-connections";
import { FilterableSelect, FormControl } from "@app/components/v2";
import { ProjectPermissionSub, useProjectPermission, useWorkspace } from "@app/context";
import { ProjectPermissionSub, useProject, useProjectPermission } from "@app/context";
import { ProjectPermissionAppConnectionActions } from "@app/context/ProjectPermissionContext/types";
import { APP_CONNECTION_MAP } from "@app/helpers/appConnections";
import { SECRET_ROTATION_CONNECTION_MAP } from "@app/helpers/secretRotationsV2";
@@ -29,11 +29,11 @@ export const SecretRotationV2ConnectionField = ({ onChange: callback, isUpdate }
const rotationType = watch("type");
const app = SECRET_ROTATION_CONNECTION_MAP[rotationType];
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { data: availableConnections, isPending } = useListAvailableAppConnections(
app,
currentWorkspace.id
currentProject.id
);
const connectionName = APP_CONNECTION_MAP[app].name;
@@ -117,8 +117,8 @@ export const SecretRotationV2ConnectionField = ({ onChange: callback, isUpdate }
localStorage.removeItem("secretRotationFormData");
handlePopUpToggle("addConnection", isOpen);
}}
projectType={currentWorkspace.type}
projectId={currentWorkspace.id}
projectType={currentProject.type}
projectId={currentProject.id}
app={app}
onComplete={(connection) => {
if (connection) {

View File

@@ -11,8 +11,9 @@ import { SecretRotationV2ParametersFields } from "@app/components/secret-rotatio
import { SecretRotationV2ReviewFields } from "@app/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields";
import { SecretRotationV2SecretsMappingFields } from "@app/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields";
import { Button } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { IS_ROTATION_DUAL_CREDENTIALS, SECRET_ROTATION_MAP } from "@app/helpers/secretRotationsV2";
import { ProjectEnv } from "@app/hooks/api/projects/types";
import {
SecretRotation,
TSecretRotationV2,
@@ -22,7 +23,6 @@ import {
useCreateSecretRotationV2,
useUpdateSecretRotationV2
} from "@app/hooks/api/secretRotationsV2/mutations";
import { WorkspaceEnv } from "@app/hooks/api/workspace/types";
import { SecretRotationV2FormSchema, TSecretRotationV2Form } from "./schemas";
@@ -32,7 +32,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
environment?: string;
environments?: WorkspaceEnv[];
environments?: ProjectEnv[];
secretRotation?: TSecretRotationV2;
initialFormData?: Partial<TSecretRotationV2Form>;
};
@@ -70,7 +70,7 @@ export const SecretRotationV2Form = ({
}: Props) => {
const createSecretRotation = useCreateSecretRotationV2();
const updateSecretRotation = useUpdateSecretRotationV2();
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { name: rotationType } = SECRET_ROTATION_MAP[type];
const [selectedTabIndex, setSelectedTabIndex] = useState(0);
@@ -82,7 +82,7 @@ export const SecretRotationV2Form = ({
defaultValues: secretRotation
? {
...secretRotation,
environment: currentWorkspace?.environments.find((env) => env.slug === envSlug),
environment: currentProject?.environments.find((env) => env.slug === envSlug),
secretPath
}
: {
@@ -93,7 +93,7 @@ export const SecretRotationV2Form = ({
hours: 0,
minutes: 0
},
environment: currentWorkspace?.environments.find((env) => env.slug === envSlug),
environment: currentProject?.environments.find((env) => env.slug === envSlug),
secretPath,
...((rotationOption?.template as object) ?? {}), // can't infer type since we don't know which specific type it is
...(initialFormData as object)
@@ -118,7 +118,7 @@ export const SecretRotationV2Form = ({
connectionId: connection.id,
environment: environment.slug,
projectId: currentWorkspace.id
projectId: currentProject.id
});
try {
const rotation = await mutation;

View File

@@ -5,7 +5,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { AppConnectionOption } from "@app/components/app-connections";
import { FilterableSelect, FormControl } from "@app/components/v2";
import { ProjectPermissionSub, useProjectPermission, useWorkspace } from "@app/context";
import { ProjectPermissionSub, useProject, useProjectPermission } from "@app/context";
import { ProjectPermissionAppConnectionActions } from "@app/context/ProjectPermissionContext/types";
import { APP_CONNECTION_MAP } from "@app/helpers/appConnections";
import { SECRET_SCANNING_DATA_SOURCE_CONNECTION_MAP } from "@app/helpers/secretScanningV2";
@@ -32,11 +32,11 @@ export const SecretScanningDataSourceConnectionField = ({
const dataSourceType = watch("type");
const app = SECRET_SCANNING_DATA_SOURCE_CONNECTION_MAP[dataSourceType];
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { data: availableConnections, isPending } = useListAvailableAppConnections(
app,
currentWorkspace.id
currentProject.id
);
const connectionName = APP_CONNECTION_MAP[app].name;
@@ -119,8 +119,8 @@ export const SecretScanningDataSourceConnectionField = ({
localStorage.removeItem("secretScanningDataSourceFormData");
handlePopUpToggle("addConnection", isOpen);
}}
projectType={currentWorkspace.type}
projectId={currentWorkspace.id}
projectType={currentProject.type}
projectId={currentProject.id}
app={app}
onComplete={(connection) => {
if (connection) {

View File

@@ -6,7 +6,7 @@ import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
import { Button } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { SECRET_SCANNING_DATA_SOURCE_MAP } from "@app/helpers/secretScanningV2";
import {
SecretScanningDataSource,
@@ -46,7 +46,7 @@ export const SecretScanningDataSourceForm = ({
}: Props) => {
const createDataSource = useCreateSecretScanningDataSource();
const updateDataSource = useUpdateSecretScanningDataSource();
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { name: sourceType } = SECRET_SCANNING_DATA_SOURCE_MAP[type];
const [selectedTabIndex, setSelectedTabIndex] = useState(0);
@@ -71,7 +71,7 @@ export const SecretScanningDataSourceForm = ({
: createDataSource.mutateAsync({
...formData,
connectionId: connection?.id,
projectId: currentWorkspace.id
projectId: currentProject.id
});
try {
const source = await mutation;

View File

@@ -8,7 +8,7 @@ import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Switch } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { SECRET_SYNC_MAP } from "@app/helpers/secretSyncs";
import {
SecretSync,
@@ -47,7 +47,7 @@ export const CreateSecretSyncForm = ({
initialFormData
}: Props) => {
const createSecretSync = useCreateSecretSync();
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { name: destinationName } = SECRET_SYNC_MAP[destination];
const [showConfirmation, setShowConfirmation] = useState(false);
@@ -78,7 +78,7 @@ export const CreateSecretSyncForm = ({
...formData,
connectionId: connection.id,
environment: environment.slug,
projectId: currentWorkspace.id
projectId: currentProject.id
});
createNotification({

View File

@@ -5,7 +5,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { AppConnectionOption } from "@app/components/app-connections";
import { FilterableSelect, FormControl } from "@app/components/v2";
import { ProjectPermissionSub, useProjectPermission, useWorkspace } from "@app/context";
import { ProjectPermissionSub, useProject, useProjectPermission } from "@app/context";
import { ProjectPermissionAppConnectionActions } from "@app/context/ProjectPermissionContext/types";
import { APP_CONNECTION_MAP } from "@app/helpers/appConnections";
import { SECRET_SYNC_CONNECTION_MAP } from "@app/helpers/secretSyncs";
@@ -28,11 +28,11 @@ export const SecretSyncConnectionField = ({ onChange: callback }: Props) => {
const destination = watch("destination");
const app = SECRET_SYNC_CONNECTION_MAP[destination];
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { data: availableConnections, isPending } = useListAvailableAppConnections(
app,
currentWorkspace.id
currentProject.id
);
const connectionName = APP_CONNECTION_MAP[app].name;
@@ -101,8 +101,8 @@ export const SecretSyncConnectionField = ({ onChange: callback }: Props) => {
localStorage.removeItem("secretSyncFormData");
handlePopUpToggle("addConnection", isOpen);
}}
projectType={currentWorkspace.type}
projectId={currentWorkspace.id}
projectType={currentProject.type}
projectId={currentProject.id}
app={app}
onComplete={(connection) => {
if (connection) {

View File

@@ -4,7 +4,7 @@ import { subject } from "@casl/ability";
import { FilterableSelect, FormControl } from "@app/components/v2";
import { SecretPathInput } from "@app/components/v2/SecretPathInput";
import { useProjectPermission, useWorkspace } from "@app/context";
import { useProject, useProjectPermission } from "@app/context";
import {
ProjectPermissionSecretSyncActions,
ProjectPermissionSub
@@ -16,7 +16,7 @@ export const SecretSyncSourceFields = () => {
const { control, watch, setError, clearErrors } = useFormContext<TSecretSyncForm>();
const { permission } = useProjectPermission();
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const selectedEnvironment = watch("environment");
const selectedSecretPath = watch("secretPath");
@@ -48,7 +48,7 @@ export const SecretSyncSourceFields = () => {
</p>
<Controller
defaultValue={currentWorkspace.environments[0]}
defaultValue={currentProject.environments[0]}
control={control}
name="environment"
render={({ field: { value, onChange }, fieldState: { error } }) => (
@@ -56,7 +56,7 @@ export const SecretSyncSourceFields = () => {
<FilterableSelect
value={value}
onChange={onChange}
options={currentWorkspace.environments}
options={currentProject.environments}
placeholder="Select environment..."
getOptionLabel={(option) => option?.name}
getOptionValue={(option) => option?.id}

View File

@@ -13,7 +13,7 @@ import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
import { FormControl, FormLabel, SecretInput, Spinner, Tooltip } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { useGetSecretReferenceTree } from "@app/hooks/api";
import { ApiErrorTypes, TApiErrors, TSecretReferenceTraceNode } from "@app/hooks/api/types";
@@ -89,8 +89,8 @@ export const SecretReferenceNode = ({
};
export const SecretReferenceTree = ({ secretPath, environment, secretKey }: Props) => {
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { data, isPending, isError, error } = useGetSecretReferenceTree({
secretPath,

View File

@@ -15,7 +15,7 @@ import {
ModalContent,
Tooltip
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { useCreateWsTag } from "@app/hooks/api";
import { slugSchema } from "@app/lib/schemas";
@@ -115,11 +115,10 @@ export const CreateTagModal = ({ isOpen, onToggle }: Props): JSX.Element => {
}
});
const { currentWorkspace } = useWorkspace();
const workspaceId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { mutateAsync: createWsTag } = useCreateWsTag();
const [showHexInput, setShowHexInput] = useState<boolean>(false);
const selectedTagColor = watch("color", secretTagsColors[0].hex);
@@ -130,7 +129,7 @@ export const CreateTagModal = ({ isOpen, onToggle }: Props): JSX.Element => {
const onFormSubmit = async ({ slug, color }: FormData) => {
try {
await createWsTag({
workspaceID: workspaceId,
projectId,
tagColor: color,
tagSlug: slug
});

View File

@@ -3,7 +3,7 @@ import { faFolder, faKey, faLayerGroup } from "@fortawesome/free-solid-svg-icons
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import * as Popover from "@radix-ui/react-popover";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { useDebounce, useToggle } from "@app/hooks";
import { useGetProjectFolders, useGetProjectSecrets } from "@app/hooks/api";
@@ -76,8 +76,8 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
},
ref
) => {
const { currentWorkspace } = useWorkspace();
const workspaceId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const [debouncedValue] = useDebounce(value, 100);
@@ -101,7 +101,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
let predicate = suggestionSourceValue;
if (isDeep) {
const [envSlug, ...folderPaths] = suggestionSourceValue.split(".");
const isValidEnvSlug = currentWorkspace?.environments.find((e) => e.slug === envSlug);
const isValidEnvSlug = currentProject?.environments.find((e) => e.slug === envSlug);
suggestionSourceEnv = isValidEnvSlug ? envSlug : undefined;
suggestionSourceSecretPath = `/${folderPaths.slice(0, -1)?.join("/")}`;
predicate = folderPaths[folderPaths.length - 1];
@@ -125,7 +125,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
viewSecretValue: false,
environment: suggestionSource.environment || "",
secretPath: suggestionSource.secretPath || "",
workspaceId,
projectId,
options: {
enabled: isPopupOpen
}
@@ -133,7 +133,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
const { data: folders } = useGetProjectFolders({
environment: suggestionSource.environment || "",
path: suggestionSource.secretPath || "",
projectId: workspaceId,
projectId,
options: {
enabled: isPopupOpen
}
@@ -148,7 +148,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
if (!suggestionSource.isDeep) {
// At first level only environments and secrets
(currentWorkspace?.environments || []).forEach(({ name, slug }) => {
(currentProject?.environments || []).forEach(({ name, slug }) => {
if (name.toLowerCase().startsWith(predicate))
suggestionsArr.push({
label: name,
@@ -176,7 +176,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
});
});
return suggestionsArr;
}, [secrets, folders, currentWorkspace?.environments, isPopupOpen, suggestionSource.value]);
}, [secrets, folders, currentProject?.environments, isPopupOpen, suggestionSource.value]);
const handleSuggestionSelect = (selectIndex?: number) => {
const selectedSuggestion =

View File

@@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import * as Popover from "@radix-ui/react-popover";
import { twMerge } from "tailwind-merge";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { useDebounce } from "@app/hooks";
import { useGetFoldersByEnv } from "@app/hooks/api";
@@ -35,12 +35,12 @@ export const SecretPathInput = ({
const [highlightedIndex, setHighlightedIndex] = useState(-1);
const [debouncedInputValue] = useDebounce(inputValue, 200);
const { currentWorkspace } = useWorkspace();
const workspaceId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { folderNames: folders } = useGetFoldersByEnv({
path: secretPath,
environments: [environment || currentWorkspace?.environments?.[0].slug || ""],
projectId: workspaceId
environments: [environment || currentProject?.environments?.[0].slug || ""],
projectId
});
useEffect(() => {

View File

@@ -32,6 +32,7 @@ export enum OrgPermissionMachineIdentityAuthTemplateActions {
export enum OrgPermissionSubjects {
Workspace = "workspace",
Project = "project",
Role = "role",
Member = "member",
Settings = "settings",
@@ -109,6 +110,7 @@ export type AppConnectionSubjectFields = {
export type OrgPermissionSet =
| [OrgPermissionActions.Create, OrgPermissionSubjects.Workspace]
| [OrgPermissionActions.Create, OrgPermissionSubjects.Project]
| [OrgPermissionActions.Read, OrgPermissionSubjects.Workspace]
| [OrgPermissionActions, OrgPermissionSubjects.Role]
| [OrgPermissionActions, OrgPermissionSubjects.Member]

View File

@@ -0,0 +1,22 @@
import { useSuspenseQuery } from "@tanstack/react-query";
import { useParams } from "@tanstack/react-router";
import { projectKeys } from "@app/hooks/api";
import { fetchProjectById } from "@app/hooks/api/projects/queries";
export const useProject = () => {
const params = useParams({
strict: false
});
if (!params.projectId) {
throw new Error("Missing project id");
}
const { data: currentProject } = useSuspenseQuery({
queryKey: projectKeys.getProjectById(params.projectId),
queryFn: () => fetchProjectById(params.projectId as string),
staleTime: Infinity
});
return { currentProject, projectId: currentProject.id };
};

View File

@@ -0,0 +1 @@
export { useProject } from "./ProjectContext";

View File

@@ -22,8 +22,8 @@ export const useProjectPermission = () => {
const {
data: { permission, membership, assumedPrivilegeDetails }
} = useSuspenseQuery({
queryKey: roleQueryKeys.getUserProjectPermissions({ workspaceId: projectId }),
queryFn: () => fetchUserProjectPermissions({ workspaceId: projectId }),
queryKey: roleQueryKeys.getUserProjectPermissions({ projectId }),
queryFn: () => fetchUserProjectPermissions({ projectId }),
staleTime: Infinity,
select: (data) => {
const rule = unpackRules<RawRuleOf<MongoAbility<ProjectPermissionSet>>>(data.permissions);

View File

@@ -1,22 +0,0 @@
import { useSuspenseQuery } from "@tanstack/react-query";
import { useParams } from "@tanstack/react-router";
import { workspaceKeys } from "@app/hooks/api";
import { fetchWorkspaceById } from "@app/hooks/api/workspace/queries";
export const useWorkspace = () => {
const params = useParams({
strict: false
});
if (!params.projectId) {
throw new Error("Missing project id");
}
const { data: currentWorkspace } = useSuspenseQuery({
queryKey: workspaceKeys.getWorkspaceById(params.projectId),
queryFn: () => fetchWorkspaceById(params.projectId as string),
staleTime: Infinity
});
return { currentWorkspace };
};

View File

@@ -1 +0,0 @@
export { useWorkspace } from "./WorkspaceContext";

View File

@@ -9,6 +9,7 @@ export {
OrgPermissionSubjects,
useOrgPermission
} from "./OrgPermissionContext";
export { useProject } from "./ProjectContext";
export type { TProjectPermission } from "./ProjectPermissionContext";
export {
ProjectPermissionActions,
@@ -29,4 +30,3 @@ export {
export { useServerConfig } from "./ServerConfigContext";
export { useSubscription } from "./SubscriptionContext";
export { useUser } from "./UserContext";
export { useWorkspace } from "./WorkspaceContext";

View File

@@ -8,6 +8,7 @@ export const AUDIT_LOG_STREAM_PROVIDER_MAP: Record<
LogProvider,
{ name: string; image?: string; icon?: IconDefinition; size?: number }
> = {
[LogProvider.Azure]: { name: "Azure", image: "Microsoft Azure.png", size: 60 },
[LogProvider.Cribl]: { name: "Cribl", image: "Cribl.png", size: 60 },
[LogProvider.Custom]: { name: "Custom", icon: faCode },
[LogProvider.Datadog]: { name: "Datadog", image: "Datadog.png" },
@@ -25,6 +26,8 @@ export function getProviderUrl(
return logStream.credentials.url;
case LogProvider.Splunk:
return `https://${logStream.credentials.hostname}:8088/services/collector/event`;
case LogProvider.Azure:
return `${logStream.credentials.dceUrl}/dataCollectionRules/${logStream.credentials.dcrId}/streams/Custom-${logStream.credentials.cltName}_CL`;
default:
throw new Error(
`Unhandled provider in getProviderUrl: ${(logStream as TAuditLogStream).provider}`

View File

@@ -1,6 +1,6 @@
import { apiRequest } from "@app/config/request";
import { createWorkspace } from "@app/hooks/api/workspace/queries";
import { ProjectType, WorkspaceEnv } from "@app/hooks/api/workspace/types";
import { createWorkspace } from "@app/hooks/api/projects/queries";
import { ProjectEnv, ProjectType } from "@app/hooks/api/projects/types";
const secretsToBeAdded = [
{
@@ -47,8 +47,8 @@ export const initProjectHelper = async ({ projectName }: { projectName: string }
});
try {
const { data } = await apiRequest.post("/api/v3/secrets/batch/raw", {
workspaceId: project.id,
const { data } = await apiRequest.post("/api/v4/secrets/batch", {
projectId: project.id,
environment: "dev",
secretPath: "/",
secrets: secretsToBeAdded
@@ -74,7 +74,7 @@ export const getProjectBaseURL = (type: ProjectType) => {
// @ts-expect-error akhilmhdh: will remove this later
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getProjectHomePage = (type: ProjectType, environments: WorkspaceEnv[]) => {
export const getProjectHomePage = (type: ProjectType, environments: ProjectEnv[]) => {
switch (type) {
case ProjectType.SecretManager:
return "/projects/secret-management/$projectId/overview" as const;

View File

@@ -16,8 +16,8 @@ import {
export const accessApprovalKeys = {
getAccessApprovalPolicies: (projectSlug: string) =>
[{ projectSlug }, "access-approval-policies"] as const,
getAccessApprovalPolicyOfABoard: (workspaceId: string, environment: string) =>
[{ workspaceId, environment }, "access-approval-policy"] as const,
getAccessApprovalPolicyOfABoard: (projectId: string, environment: string) =>
[{ projectId, environment }, "access-approval-policy"] as const,
getAccessApprovalRequests: (
projectSlug: string,

View File

@@ -1,7 +1,7 @@
import { EnforcementLevel, PolicyType } from "../policies/enums";
import { ProjectEnv } from "../projects/types";
import { TProjectPermission } from "../roles/types";
import { ApprovalStatus } from "../secretApprovalRequest/types";
import { WorkspaceEnv } from "../workspace/types";
export type TAccessApprovalPolicy = {
id: string;
@@ -9,7 +9,7 @@ export type TAccessApprovalPolicy = {
approvals: number;
secretPath: string;
workspace: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
projectId: string;
policyType: PolicyType;
approversRequired: boolean;

View File

@@ -14,7 +14,7 @@ import {
TAppConnectionOption,
TAppConnectionOptionMap
} from "@app/hooks/api/appConnections/types/app-options";
import { ProjectType } from "@app/hooks/api/workspace/types";
import { ProjectType } from "@app/hooks/api/projects/types";
export const appConnectionKeys = {
all: ["app-connection"] as const,

View File

@@ -1,4 +1,4 @@
import { ProjectType } from "@app/hooks/api/workspace/types";
import { ProjectType } from "@app/hooks/api/projects/types";
export type TRootAppConnection = {
id: string;

View File

@@ -8,7 +8,7 @@ export const useAssumeProjectPrivileges = () =>
useMutation({
mutationFn: async ({ projectId, actorId, actorType }: TProjectAssumePrivilegesDTO) => {
const { data } = await apiRequest.post<{ message: string }>(
`/api/v1/workspace/${projectId}/assume-privileges`,
`/api/v1/projects/${projectId}/assume-privileges`,
{ actorId, actorType }
);
@@ -20,7 +20,7 @@ export const useRemoveAssumeProjectPrivilege = () =>
useMutation({
mutationFn: async ({ projectId }: { projectId: string }) => {
const { data } = await apiRequest.delete<{ message: string }>(
`/api/v1/workspace/${projectId}/assume-privileges`
`/api/v1/projects/${projectId}/assume-privileges`
);
return data;

View File

@@ -1,4 +1,5 @@
export enum LogProvider {
Azure = "azure",
Cribl = "cribl",
Custom = "custom",
Datadog = "datadog",

View File

@@ -1,4 +1,5 @@
import { LogProvider } from "../enums";
import { TAzureProviderLogStream } from "./providers/azure-provider";
import { TCriblProviderLogStream } from "./providers/cribl-provider";
import { TCustomProviderLogStream } from "./providers/custom-provider";
import { TDatadogProviderLogStream } from "./providers/datadog-provider";
@@ -8,9 +9,11 @@ export type TAuditLogStream =
| TCustomProviderLogStream
| TDatadogProviderLogStream
| TSplunkProviderLogStream
| TAzureProviderLogStream
| TCriblProviderLogStream;
export type TAuditLogStreamProviderMap = {
[LogProvider.Azure]: TAzureProviderLogStream;
[LogProvider.Cribl]: TCriblProviderLogStream;
[LogProvider.Custom]: TCustomProviderLogStream;
[LogProvider.Datadog]: TDatadogProviderLogStream;

View File

@@ -0,0 +1,14 @@
import { LogProvider } from "../../enums";
import { TRootProviderLogStream } from "./root-provider";
export type TAzureProviderLogStream = TRootProviderLogStream & {
provider: LogProvider.Azure;
credentials: {
tenantId: string;
clientId: string;
clientSecret: string;
dceUrl: string;
dcrId: string;
cltName: string;
};
};

View File

@@ -20,7 +20,7 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.CREATE_SECRET]: "Create secret",
[EventType.UPDATE_SECRET]: "Update secret",
[EventType.DELETE_SECRET]: "Delete secret",
[EventType.GET_WORKSPACE_KEY]: "Read project key",
[EventType.GET_PROJECT_KEY]: "Read project key",
[EventType.AUTHORIZE_INTEGRATION]: "Authorize integration",
[EventType.UPDATE_INTEGRATION_AUTH]: "Update integration auth",
[EventType.UNAUTHORIZE_INTEGRATION]: "Unauthorize integration",
@@ -45,8 +45,8 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.CREATE_ENVIRONMENT]: "Create environment",
[EventType.UPDATE_ENVIRONMENT]: "Update environment",
[EventType.DELETE_ENVIRONMENT]: "Delete environment",
[EventType.ADD_WORKSPACE_MEMBER]: "Add member",
[EventType.REMOVE_WORKSPACE_MEMBER]: "Remove member",
[EventType.ADD_PROJECT_MEMBER]: "Add member",
[EventType.REMOVE_PROJECT_MEMBER]: "Remove member",
[EventType.CREATE_FOLDER]: "Create folder",
[EventType.UPDATE_FOLDER]: "Update folder",
[EventType.DELETE_FOLDER]: "Delete folder",
@@ -58,8 +58,8 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.CREATE_SECRET_IMPORT]: "Create secret import",
[EventType.UPDATE_SECRET_IMPORT]: "Update secret import",
[EventType.DELETE_SECRET_IMPORT]: "Delete secret import",
[EventType.UPDATE_USER_WORKSPACE_DENIED_PERMISSIONS]: "Update denied permissions",
[EventType.UPDATE_USER_WORKSPACE_ROLE]: "Update user role",
[EventType.UPDATE_USER_PROJECT_DENIED_PERMISSIONS]: "Update denied permissions",
[EventType.UPDATE_USER_PROJECT_ROLE]: "Update user role",
[EventType.CREATE_CA]: "Create CA",
[EventType.GET_CA]: "Get CA",
[EventType.UPDATE_CA]: "Update CA",

View File

@@ -26,7 +26,7 @@ export enum EventType {
CREATE_SECRET = "create-secret",
UPDATE_SECRET = "update-secret",
DELETE_SECRET = "delete-secret",
GET_WORKSPACE_KEY = "get-workspace-key",
GET_PROJECT_KEY = "get-project-key",
AUTHORIZE_INTEGRATION = "authorize-integration",
UPDATE_INTEGRATION_AUTH = "update-integration-auth",
UNAUTHORIZE_INTEGRATION = "unauthorize-integration",
@@ -58,8 +58,8 @@ export enum EventType {
CREATE_ENVIRONMENT = "create-environment",
UPDATE_ENVIRONMENT = "update-environment",
DELETE_ENVIRONMENT = "delete-environment",
ADD_WORKSPACE_MEMBER = "add-workspace-member",
REMOVE_WORKSPACE_MEMBER = "remove-workspace-member",
ADD_PROJECT_MEMBER = "add-project-member",
REMOVE_PROJECT_MEMBER = "remove-project-member",
CREATE_FOLDER = "create-folder",
UPDATE_FOLDER = "update-folder",
DELETE_FOLDER = "delete-folder",
@@ -71,8 +71,8 @@ export enum EventType {
CREATE_SECRET_IMPORT = "create-secret-import",
UPDATE_SECRET_IMPORT = "update-secret-import",
DELETE_SECRET_IMPORT = "delete-secret-import",
UPDATE_USER_WORKSPACE_ROLE = "update-user-workspace-role",
UPDATE_USER_WORKSPACE_DENIED_PERMISSIONS = "update-user-workspace-denied-permissions",
UPDATE_USER_PROJECT_ROLE = "update-user-project-role",
UPDATE_USER_PROJECT_DENIED_PERMISSIONS = "update-user-project-denied-permissions",
CREATE_CA = "create-certificate-authority",
GET_CA = "get-certificate-authority",
UPDATE_CA = "update-certificate-authority",

View File

@@ -7,10 +7,10 @@ import { TReactQueryOptions } from "@app/types/reactQuery";
import { Actor, AuditLog, TGetAuditLogsFilter } from "./types";
export const auditLogKeys = {
getAuditLogs: (workspaceId: string | null, filters: TGetAuditLogsFilter) =>
[{ workspaceId, filters }, "audit-logs"] as const,
getAuditLogActorFilterOpts: (workspaceId: string) =>
[{ workspaceId }, "audit-log-actor-filters"] as const
getAuditLogs: (projectId: string | null, filters: TGetAuditLogsFilter) =>
[{ projectId, filters }, "audit-logs"] as const,
getAuditLogActorFilterOpts: (projectId: string) =>
[{ projectId }, "audit-log-actor-filters"] as const
};
export const useGetAuditLogs = (
@@ -56,12 +56,12 @@ export const useGetAuditLogs = (
});
};
export const useGetAuditLogActorFilterOpts = (workspaceId: string) => {
export const useGetAuditLogActorFilterOpts = (projectId: string) => {
return useQuery({
queryKey: auditLogKeys.getAuditLogActorFilterOpts(workspaceId),
queryKey: auditLogKeys.getAuditLogActorFilterOpts(projectId),
queryFn: async () => {
const { data } = await apiRequest.get<{ actors: Actor[] }>(
`/api/v1/workspace/${workspaceId}/audit-logs/filters/actors`
`/api/v1/projects/${projectId}/audit-logs/filters/actors`
);
return data.actors;
}

View File

@@ -129,7 +129,7 @@ interface DeleteSecretEvent {
}
interface GetWorkspaceKeyEvent {
type: EventType.GET_WORKSPACE_KEY;
type: EventType.GET_PROJECT_KEY;
metadata: {
keyId: string;
};
@@ -361,7 +361,7 @@ interface DeleteEnvironmentEvent {
}
interface AddWorkspaceMemberEvent {
type: EventType.ADD_WORKSPACE_MEMBER;
type: EventType.ADD_PROJECT_MEMBER;
metadata: {
userId: string;
email: string;
@@ -369,7 +369,7 @@ interface AddWorkspaceMemberEvent {
}
interface RemoveWorkspaceMemberEvent {
type: EventType.REMOVE_WORKSPACE_MEMBER;
type: EventType.REMOVE_PROJECT_MEMBER;
metadata: {
userId: string;
email: string;
@@ -500,7 +500,7 @@ interface DeleteSecretImportEvent {
}
interface UpdateUserRole {
type: EventType.UPDATE_USER_WORKSPACE_ROLE;
type: EventType.UPDATE_USER_PROJECT_ROLE;
metadata: {
userId: string;
email: string;
@@ -510,7 +510,7 @@ interface UpdateUserRole {
}
interface UpdateUserDeniedPermissions {
type: EventType.UPDATE_USER_WORKSPACE_DENIED_PERMISSIONS;
type: EventType.UPDATE_USER_PROJECT_DENIED_PERMISSIONS;
metadata: {
userId: string;
email: string;

View File

@@ -5,8 +5,8 @@ import { apiRequest } from "@app/config/request";
import { SessionStorageKeys } from "@app/const";
import { organizationKeys } from "../organization/queries";
import { projectKeys } from "../projects";
import { setAuthToken } from "../reactQuery";
import { workspaceKeys } from "../workspace";
import {
CompleteAccountDTO,
CompleteAccountSignupDTO,
@@ -101,7 +101,7 @@ export const useSelectOrganization = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: [organizationKeys.getUserOrganizations, workspaceKeys.getAllUserWorkspace]
queryKey: [organizationKeys.getUserOrganizations, projectKeys.getAllUserProjects]
});
}
});

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import { CaType } from "./enums";
import { caKeys } from "./queries";
import {
@@ -118,8 +118,8 @@ export const useImportCaCertificate = (projectId: string) => {
);
return data;
},
onSuccess: (_, { caId, projectSlug }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceCas({ projectSlug }) });
onSuccess: (_, { caId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectCas({ projectId }) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaCerts(caId) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaCert(caId) });
queryClient.invalidateQueries({
@@ -142,7 +142,7 @@ export const useCreateCertificate = () => {
},
onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.forWorkspaceCertificates(projectSlug)
queryKey: projectKeys.forProjectCertificates(projectSlug)
});
}
});
@@ -158,8 +158,8 @@ export const useRenewCa = () => {
);
return data;
},
onSuccess: (_, { caId, projectSlug }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceCas({ projectSlug }) });
onSuccess: ({ projectId }, { caId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectCas({ projectId }) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaById(caId) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaCert(caId) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaCerts(caId) });

View File

@@ -182,4 +182,5 @@ export type TRenewCaResponse = {
certificate: string;
certificateChain: string;
serialNumber: string;
projectId: string;
};

View File

@@ -3,7 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { caKeys } from "../ca/queries";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import { certTemplateKeys } from "./queries";
import {
TCertificateTemplate,
@@ -29,7 +29,7 @@ export const useCreateCertTemplate = () => {
},
onSuccess: ({ caId }, { projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceCertificateTemplates(projectId)
queryKey: projectKeys.getProjectCertificateTemplates(projectId)
});
queryClient.invalidateQueries({ queryKey: caKeys.getCaCertTemplates(caId) });
}
@@ -49,7 +49,7 @@ export const useUpdateCertTemplate = () => {
},
onSuccess: ({ caId }, { projectId, id }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceCertificateTemplates(projectId)
queryKey: projectKeys.getProjectCertificateTemplates(projectId)
});
queryClient.invalidateQueries({ queryKey: certTemplateKeys.getCertTemplateById(id) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaCertTemplates(caId) });
@@ -68,7 +68,7 @@ export const useDeleteCertTemplate = () => {
},
onSuccess: ({ caId }, { projectId, id }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceCertificateTemplates(projectId)
queryKey: projectKeys.getProjectCertificateTemplates(projectId)
});
queryClient.invalidateQueries({ queryKey: certTemplateKeys.getCertTemplateById(id) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaCertTemplates(caId) });

View File

@@ -3,7 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { pkiSubscriberKeys } from "../pkiSubscriber/queries";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import {
TCertificate,
TDeleteCertDTO,
@@ -25,7 +25,7 @@ export const useDeleteCert = () => {
},
onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.forWorkspaceCertificates(projectSlug)
queryKey: projectKeys.forProjectCertificates(projectSlug)
});
}
});
@@ -47,7 +47,7 @@ export const useRevokeCert = () => {
},
onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.forWorkspaceCertificates(projectSlug)
queryKey: projectKeys.forProjectCertificates(projectSlug)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.allPkiSubscriberCertificates()
@@ -68,7 +68,7 @@ export const useImportCertificate = () => {
},
onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.forWorkspaceCertificates(projectSlug)
queryKey: projectKeys.forProjectCertificates(projectSlug)
});
}
});

View File

@@ -7,27 +7,27 @@ import { Commit, CommitHistoryItem, CommitWithChanges, RollbackPreview } from ".
export const commitKeys = {
count: ({
workspaceId,
projectId,
environment,
directory
}: {
workspaceId: string;
projectId: string;
environment: string;
directory?: string;
}) => [{ workspaceId, environment, directory }, "folder-commits-count"] as const,
}) => [{ projectId, environment, directory }, "folder-commits-count"] as const,
history: ({
workspaceId,
projectId,
environment,
directory
}: {
workspaceId: string;
projectId: string;
environment: string;
directory?: string;
}) => [{ workspaceId, environment, directory }, "folder-commits"] as const,
}) => [{ projectId, environment, directory }, "folder-commits"] as const,
details: ({ workspaceId, commitId }: { workspaceId: string; commitId: string }) =>
[{ workspaceId, commitId }, "commit-details"] as const,
details: ({ projectId, commitId }: { projectId: string; commitId: string }) =>
[{ projectId, commitId }, "commit-details"] as const,
rollbackPreview: ({
folderId,
@@ -45,11 +45,11 @@ export const commitKeys = {
};
const fetchFolderCommitsCount = async ({
workspaceId,
projectId,
environment,
directory
}: {
workspaceId: string;
projectId: string;
environment: string;
directory?: string;
}) => {
@@ -59,7 +59,7 @@ const fetchFolderCommitsCount = async ({
params: {
environment,
path: directory,
projectId: workspaceId
projectId
}
}
);
@@ -67,7 +67,7 @@ const fetchFolderCommitsCount = async ({
};
const fetchFolderCommitHistory = async (
workspaceId: string,
projectId: string,
environment: string,
directory: string,
offset: number = 0,
@@ -87,7 +87,7 @@ const fetchFolderCommitHistory = async (
params: {
environment,
path: directory,
projectId: workspaceId,
projectId,
offset,
limit,
search,
@@ -97,12 +97,12 @@ const fetchFolderCommitHistory = async (
return res.data;
};
export const fetchCommitDetails = async (workspaceId: string, commitId: string) => {
export const fetchCommitDetails = async (projectId: string, commitId: string) => {
const { data } = await apiRequest.get<CommitWithChanges>(
`/api/v1/pit/commits/${commitId}/changes`,
{
params: {
projectId: workspaceId
projectId
}
}
);
@@ -113,7 +113,7 @@ export const fetchRollbackPreview = async (
folderId: string,
commitId: string,
envSlug: string,
workspaceId: string,
projectId: string,
deepRollback: boolean,
secretPath: string
): Promise<RollbackPreview[]> => {
@@ -125,7 +125,7 @@ export const fetchRollbackPreview = async (
environment: envSlug,
deepRollback,
secretPath,
projectId: workspaceId
projectId
}
}
);
@@ -135,7 +135,7 @@ export const fetchRollbackPreview = async (
const fetchRollback = async (
folderId: string,
commitId: string,
workspaceId: string,
projectId: string,
deepRollback: boolean,
message?: string,
envSlug?: string
@@ -147,17 +147,17 @@ const fetchRollback = async (
deepRollback,
message,
environment: envSlug,
projectId: workspaceId
projectId
}
);
return data;
};
const fetchRevert = async (commitId: string, workspaceId: string) => {
const fetchRevert = async (commitId: string, projectId: string) => {
const { data } = await apiRequest.post<{ success: boolean; message: string }>(
`/api/v1/pit/commits/${commitId}/revert`,
{
projectId: workspaceId
projectId
}
);
return data;
@@ -180,9 +180,9 @@ export const useCommitRevert = ({
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: [
commitKeys.details({ workspaceId: projectId, commitId }),
commitKeys.history({ workspaceId: projectId, environment, directory }),
commitKeys.count({ workspaceId: projectId, environment, directory })
commitKeys.details({ projectId, commitId }),
commitKeys.history({ projectId, environment, directory }),
commitKeys.count({ projectId, environment, directory })
]
});
}
@@ -190,7 +190,7 @@ export const useCommitRevert = ({
};
export const useCommitRollback = ({
workspaceId,
projectId,
commitId,
folderId,
deepRollback,
@@ -198,7 +198,7 @@ export const useCommitRollback = ({
directory,
envSlug
}: {
workspaceId: string;
projectId: string;
commitId: string;
folderId: string;
deepRollback: boolean;
@@ -209,13 +209,13 @@ export const useCommitRollback = ({
const queryClient = useQueryClient();
return useMutation({
mutationFn: (message: string) =>
fetchRollback(folderId, commitId, workspaceId, deepRollback, message, envSlug),
fetchRollback(folderId, commitId, projectId, deepRollback, message, envSlug),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: [
commitKeys.details({ workspaceId, commitId }),
commitKeys.history({ workspaceId, environment, directory }),
commitKeys.count({ workspaceId, environment, directory })
commitKeys.details({ projectId, commitId }),
commitKeys.history({ projectId, environment, directory }),
commitKeys.count({ projectId, environment, directory })
]
});
}
@@ -223,31 +223,31 @@ export const useCommitRollback = ({
};
export const useGetFolderCommitsCount = ({
workspaceId,
projectId,
environment,
directory,
isPaused
}: {
workspaceId: string;
projectId: string;
environment: string;
directory: string;
isPaused?: boolean;
}) =>
useQuery({
enabled: Boolean(workspaceId && environment) && !isPaused,
queryKey: commitKeys.count({ workspaceId, environment, directory }),
queryFn: () => fetchFolderCommitsCount({ workspaceId, environment, directory })
enabled: Boolean(projectId && environment) && !isPaused,
queryKey: commitKeys.count({ projectId, environment, directory }),
queryFn: () => fetchFolderCommitsCount({ projectId, environment, directory })
});
export const useGetFolderCommitHistory = ({
workspaceId,
projectId,
environment,
directory,
limit = 20,
search,
sort = "desc"
}: {
workspaceId: string;
projectId: string;
environment: string;
directory: string;
limit?: number;
@@ -256,10 +256,10 @@ export const useGetFolderCommitHistory = ({
}) => {
return useInfiniteQuery({
initialPageParam: 0,
queryKey: [commitKeys.history({ workspaceId, environment, directory }), limit, search, sort],
queryKey: [commitKeys.history({ projectId, environment, directory }), limit, search, sort],
queryFn: ({ pageParam }) =>
fetchFolderCommitHistory(workspaceId, environment, directory, pageParam, limit, search, sort),
enabled: Boolean(workspaceId && environment),
fetchFolderCommitHistory(projectId, environment, directory, pageParam, limit, search, sort),
enabled: Boolean(projectId && environment),
select: (data) => {
return (data?.pages ?? [])
?.map((page) => page.commits)
@@ -280,11 +280,11 @@ export const useGetFolderCommitHistory = ({
});
};
export const useGetCommitDetails = (workspaceId: string, commitId: string) => {
export const useGetCommitDetails = (projectId: string, commitId: string) => {
return useQuery({
queryKey: commitKeys.details({ workspaceId, commitId }),
queryFn: () => fetchCommitDetails(workspaceId, commitId),
enabled: Boolean(workspaceId) && Boolean(commitId)
queryKey: commitKeys.details({ projectId, commitId }),
queryFn: () => fetchCommitDetails(projectId, commitId),
enabled: Boolean(projectId) && Boolean(commitId)
});
};

View File

@@ -138,7 +138,7 @@ export const useListProjectGroupUsers = ({
});
const { data } = await apiRequest.get<{ users: TGroupUser[]; totalCount: number }>(
`/api/v2/workspace/${projectId}/groups/${id}/users`,
`/api/v1/projects/${projectId}/groups/${id}/users`,
{
params
}

View File

@@ -1,7 +1,7 @@
import { OrderByDirection } from "../generic/types";
import { OrgIdentityOrderBy } from "../organization/types";
import { Project, ProjectUserMembershipTemporaryMode } from "../projects/types";
import { TOrgRole } from "../roles/types";
import { ProjectUserMembershipTemporaryMode, Workspace } from "../workspace/types";
import { IdentityAuthMethod, IdentityJwtConfigurationType } from "./enums";
export type IdentityTrustedIp = {
@@ -54,7 +54,7 @@ export type IdentityMembershipOrg = {
export type IdentityMembership = {
id: string;
identity: Identity;
project: Pick<Workspace, "id" | "name" | "type">;
project: Pick<Project, "id" | "name" | "type">;
roles: Array<
{
id: string;

View File

@@ -20,7 +20,6 @@ export * from "./identityProjectAdditionalPrivilege";
export * from "./incidentContacts";
export * from "./integrationAuth";
export * from "./integrations";
export * from "./keys";
export * from "./kms";
export * from "./ldapConfig";
export * from "./oidcConfig";
@@ -29,6 +28,7 @@ export * from "./organization";
export * from "./pkiAlerts";
export * from "./pkiCollections";
export * from "./pkiSubscriber";
export * from "./projects";
export * from "./projectUserAdditionalPrivilege";
export * from "./rateLimit";
export * from "./roles";
@@ -54,4 +54,3 @@ export * from "./trustedIps";
export * from "./users";
export * from "./webhooks";
export * from "./workflowIntegrations";
export * from "./workspace";

View File

@@ -3,7 +3,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { TReactQueryOptions } from "@app/types/reactQuery";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import {
App,
BitbucketEnvironment,
@@ -970,7 +970,7 @@ export const useAuthorizeIntegration = () => {
},
onSuccess: (res) => {
queryClient.invalidateQueries({
queryKey: { queryKey: workspaceKeys.getWorkspaceAuthorization(res.workspace) }
queryKey: { queryKey: projectKeys.getProjectAuthorization(res.workspace) }
});
}
});
@@ -1016,7 +1016,7 @@ export const useSaveIntegrationAccessToken = () => {
},
onSuccess: (res) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceAuthorization(res.workspace)
queryKey: projectKeys.getProjectAuthorization(res.workspace)
});
}
});
@@ -1035,10 +1035,10 @@ export const useDeleteIntegrationAuths = () => {
),
onSuccess: (_, { workspaceId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceAuthorization(workspaceId)
queryKey: projectKeys.getProjectAuthorization(workspaceId)
});
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceIntegrations(workspaceId)
queryKey: projectKeys.getProjectIntegrations(workspaceId)
});
}
});
@@ -1052,10 +1052,10 @@ export const useDeleteIntegrationAuth = () => {
mutationFn: ({ id }) => apiRequest.delete(`/api/v1/integration-auth/${id}`),
onSuccess: (_, { workspaceId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceAuthorization(workspaceId)
queryKey: projectKeys.getProjectAuthorization(workspaceId)
});
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceIntegrations(workspaceId)
queryKey: projectKeys.getProjectIntegrations(workspaceId)
});
}
});

View File

@@ -3,7 +3,7 @@ import { useMutation, useQuery, useQueryClient, UseQueryOptions } from "@tanstac
import { createNotification } from "@app/components/notifications";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import {
IntegrationMetadataSyncMode,
TCloudIntegration,
@@ -121,7 +121,7 @@ export const useCreateIntegration = () => {
},
onSuccess: (res) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceIntegrations(res.workspace)
queryKey: projectKeys.getProjectIntegrations(res.workspace)
});
}
});
@@ -141,10 +141,10 @@ export const useDeleteIntegration = () => {
),
onSuccess: (_, { workspaceId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceIntegrations(workspaceId)
queryKey: projectKeys.getProjectIntegrations(workspaceId)
});
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceAuthorization(workspaceId)
queryKey: projectKeys.getProjectAuthorization(workspaceId)
});
}
});

View File

@@ -1 +0,0 @@
export { useGetUserWsKey, useUploadWsKey } from "./queries";

View File

@@ -1,43 +0,0 @@
import { useMutation, useQuery } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { UploadWsKeyDTO, UserWsKeyPair } from "./types";
const encKeyKeys = {
getUserWorkspaceKey: (workspaceID: string) => ["workspace-key-pair", { workspaceID }] as const
};
export const fetchUserWsKey = async (projectId: string) => {
const { data } = await apiRequest.get<UserWsKeyPair>(
`/api/v2/workspace/${projectId}/encrypted-key`
);
return data;
};
export const useGetUserWsKey = (workspaceID: string) =>
useQuery({
queryKey: encKeyKeys.getUserWorkspaceKey(workspaceID),
queryFn: () => fetchUserWsKey(workspaceID),
enabled: Boolean(workspaceID)
});
// mutations
export const uploadWsKey = async ({ workspaceId, userId, encryptedKey, nonce }: UploadWsKeyDTO) => {
return apiRequest.post(`/api/v1/workspace/${workspaceId}/key`, {
key: { userId, encryptedKey, nonce }
});
};
export const useUploadWsKey = () =>
useMutation<object, object, UploadWsKeyDTO>({
mutationFn: async ({ encryptedKey, nonce, userId, workspaceId }) => {
return uploadWsKey({
workspaceId,
userId,
encryptedKey,
nonce
});
}
});

View File

@@ -1,29 +0,0 @@
export type UserWsKeyPair = {
id: string;
encryptedKey: string;
nonce: string;
sender: Sender;
receiver: string;
workspace: string;
createdAt: string;
updatedAt: string;
__v: number;
};
export type Sender = {
id: string;
email: string;
createdAt: string;
updatedAt: string;
__v: number;
firstName: string;
lastName: string;
publicKey: string;
};
export type UploadWsKeyDTO = {
userId: string;
encryptedKey: string;
nonce: string;
workspaceId: string;
};

View File

@@ -75,7 +75,7 @@ export const useUpdateProjectKms = (projectId: string) => {
mutationFn: async (
updatedData: { type: KmsType.Internal } | { type: KmsType.External; kmsId: string }
) => {
const { data } = await apiRequest.patch(`/api/v1/workspace/${projectId}/kms`, {
const { data } = await apiRequest.patch(`/api/v1/projects/${projectId}/kms`, {
kms: updatedData
});
@@ -91,7 +91,7 @@ export const useLoadProjectKmsBackup = (projectId: string) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async (backup: string) => {
const { data } = await apiRequest.post(`/api/v1/workspace/${projectId}/kms/backup`, {
const { data } = await apiRequest.post(`/api/v1/projects/${projectId}/kms/backup`, {
backup
});

View File

@@ -49,7 +49,7 @@ export const useGetActiveProjectKms = (projectId: string) => {
name: string;
isExternal: string;
};
}>(`/api/v1/workspace/${projectId}/kms`);
}>(`/api/v1/projects/${projectId}/kms`);
return secretManagerKmsKey;
}
});
@@ -58,7 +58,7 @@ export const useGetActiveProjectKms = (projectId: string) => {
export const fetchProjectKmsBackup = async (projectId: string) => {
const { data } = await apiRequest.get<{
secretManager: string;
}>(`/api/v1/workspace/${projectId}/kms/backup`);
}>(`/api/v1/projects/${projectId}/kms/backup`);
return data;
};

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
export const useImportEnvKey = () => {
const queryClient = useQueryClient();
@@ -34,7 +34,7 @@ export const useImportEnvKey = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserProjects()
});
}
});

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import { pkiAlertKeys } from "./queries";
import { TCreatePkiAlertDTO, TDeletePkiAlertDTO, TPkiAlert, TUpdatePkiAlertDTO } from "./types";
@@ -14,7 +14,7 @@ export const useCreatePkiAlert = () => {
return alert;
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspacePkiAlerts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectPkiAlerts(projectId) });
}
});
};
@@ -30,7 +30,7 @@ export const useUpdatePkiAlert = () => {
return alert;
},
onSuccess: (_, { projectId, alertId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspacePkiAlerts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectPkiAlerts(projectId) });
queryClient.invalidateQueries({ queryKey: pkiAlertKeys.getPkiAlertById(alertId) });
}
});
@@ -44,7 +44,7 @@ export const useDeletePkiAlert = () => {
return alert;
},
onSuccess: (_, { projectId, alertId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspacePkiAlerts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectPkiAlerts(projectId) });
queryClient.invalidateQueries({ queryKey: pkiAlertKeys.getPkiAlertById(alertId) });
}
});

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import { pkiCollectionKeys } from "./queries";
import {
TAddItemToPkiCollectionDTO,
@@ -26,7 +26,7 @@ export const useCreatePkiCollection = () => {
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspacePkiCollections(projectId)
queryKey: projectKeys.getProjectPkiCollections(projectId)
});
}
});
@@ -44,7 +44,7 @@ export const useUpdatePkiCollection = () => {
},
onSuccess: (_, { projectId, collectionId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspacePkiCollections(projectId)
queryKey: projectKeys.getProjectPkiCollections(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiCollectionKeys.getPkiCollectionById(collectionId)
@@ -64,7 +64,7 @@ export const useDeletePkiCollection = () => {
},
onSuccess: (_, { projectId, collectionId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspacePkiCollections(projectId)
queryKey: projectKeys.getProjectPkiCollections(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiCollectionKeys.getPkiCollectionById(collectionId)

View File

@@ -3,7 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { TCreateCertificateResponse } from "../ca/types";
import { workspaceKeys } from "../workspace/query-keys";
import { projectKeys } from "../projects/query-keys";
import { pkiSubscriberKeys } from "./queries";
import {
TCreatePkiSubscriberDTO,
@@ -22,7 +22,7 @@ export const useCreatePkiSubscriber = () => {
},
onSuccess: ({ projectId, name }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspacePkiSubscribers(projectId)
queryKey: projectKeys.getProjectPkiSubscribers(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.getPkiSubscriber({
@@ -46,7 +46,7 @@ export const useUpdatePkiSubscriber = () => {
},
onSuccess: ({ projectId, name }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspacePkiSubscribers(projectId)
queryKey: projectKeys.getProjectPkiSubscribers(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.getPkiSubscriber({
@@ -74,7 +74,7 @@ export const useDeletePkiSubscriber = () => {
},
onSuccess: ({ name, projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspacePkiSubscribers(projectId)
queryKey: projectKeys.getProjectPkiSubscribers(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.getPkiSubscriber({

View File

@@ -1,6 +1,6 @@
import { TProjectRole } from "@app/hooks/api/roles/types";
import { ProjectType } from "../workspace/types";
import { ProjectType } from "../projects/types";
export type TProjectTemplate = {
id: string;

View File

@@ -17,15 +17,14 @@ export {
useDeleteWsEnvironment,
useGetProjectSshConfig,
useGetUpgradeProjectStatus,
useGetUserProjects,
useGetUserWorkspaceMemberships,
useGetUserWorkspaces,
useGetWorkspaceAuthorizations,
useGetWorkspaceById,
useGetWorkspaceIdentityMembershipDetails,
useGetWorkspaceIdentityMemberships,
useGetWorkspaceIndexStatus,
useGetWorkspaceIntegrations,
useGetWorkspaceSecrets,
useGetWorkspaceUserDetails,
useGetWorkspaceUsers,
useGetWorkspaceWorkflowIntegrationConfig,
@@ -41,13 +40,11 @@ export {
useListWorkspaceSshCertificateTemplates,
useListWorkspaceSshHostGroups,
useListWorkspaceSshHosts,
useNameWorkspaceSecrets,
useSearchProjects,
useToggleAutoCapitalization,
useUpdateIdentityWorkspaceRole,
useUpdateProject,
useUpdateUserWorkspaceRole,
useUpdateWsEnvironment,
useUpgradeProject
} from "./queries";
export { workspaceKeys } from "./query-keys";
export { projectKeys } from "./query-keys";

View File

@@ -3,7 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { userKeys } from "../users/query-keys";
import { workspaceKeys } from "./query-keys";
import { projectKeys } from "./query-keys";
import {
TProjectSshConfig,
TUpdateProjectSshConfigDTO,
@@ -24,7 +24,7 @@ export const useAddGroupToWorkspace = () => {
}) => {
const {
data: { groupMembership }
} = await apiRequest.post(`/api/v2/workspace/${projectId}/groups/${groupId}`, {
} = await apiRequest.post(`/api/v1/projects/${projectId}/groups/${groupId}`, {
role
});
@@ -32,7 +32,7 @@ export const useAddGroupToWorkspace = () => {
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceGroupMemberships(projectId)
queryKey: projectKeys.getProjectGroupMemberships(projectId)
});
}
});
@@ -44,7 +44,7 @@ export const useUpdateGroupWorkspaceRole = () => {
mutationFn: async ({ groupId, projectId, roles }: TUpdateWorkspaceGroupRoleDTO) => {
const {
data: { groupMembership }
} = await apiRequest.patch(`/api/v2/workspace/${projectId}/groups/${groupId}`, {
} = await apiRequest.patch(`/api/v1/projects/${projectId}/groups/${groupId}`, {
roles
});
@@ -52,10 +52,10 @@ export const useUpdateGroupWorkspaceRole = () => {
},
onSuccess: (_, { projectId, groupId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceGroupMemberships(projectId)
queryKey: projectKeys.getProjectGroupMemberships(projectId)
});
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceGroupMembershipDetails(projectId, groupId)
queryKey: projectKeys.getProjectGroupMembershipDetails(projectId, groupId)
});
}
});
@@ -74,12 +74,12 @@ export const useDeleteGroupFromWorkspace = () => {
}) => {
const {
data: { groupMembership }
} = await apiRequest.delete(`/api/v2/workspace/${projectId}/groups/${groupId}`);
} = await apiRequest.delete(`/api/v1/projects/${projectId}/groups/${groupId}`);
return groupMembership;
},
onSuccess: (_, { projectId, username }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceGroupMemberships(projectId)
queryKey: projectKeys.getProjectGroupMemberships(projectId)
});
if (username) {
@@ -91,25 +91,25 @@ export const useDeleteGroupFromWorkspace = () => {
export const useLeaveProject = () => {
const queryClient = useQueryClient();
return useMutation<object, object, { workspaceId: string }>({
mutationFn: ({ workspaceId }) => {
return apiRequest.delete(`/api/v1/workspace/${workspaceId}/leave`);
return useMutation<object, object, { projectId: string }>({
mutationFn: ({ projectId }) => {
return apiRequest.delete(`/api/v1/projects/${projectId}/leave`);
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserProjects() });
}
});
};
export const useMigrateProjectToV3 = () => {
const queryClient = useQueryClient();
return useMutation<object, object, { workspaceId: string }>({
mutationFn: ({ workspaceId }) => {
return apiRequest.post(`/api/v1/workspace/${workspaceId}/migrate-v3`);
return useMutation<object, object, { projectId: string }>({
mutationFn: ({ projectId }) => {
return apiRequest.post(`/api/v1/projects/${projectId}/migrate-v3`);
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserProjects()
});
}
});
@@ -118,7 +118,7 @@ export const useMigrateProjectToV3 = () => {
export const useRequestProjectAccess = () => {
return useMutation<object, object, { projectId: string; comment: string }>({
mutationFn: ({ projectId, comment }) => {
return apiRequest.post(`/api/v1/workspace/${projectId}/project-access`, {
return apiRequest.post(`/api/v1/projects/${projectId}/project-access`, {
comment
});
}
@@ -129,14 +129,14 @@ export const useUpdateProjectSshConfig = () => {
const queryClient = useQueryClient();
return useMutation<TProjectSshConfig, object, TUpdateProjectSshConfigDTO>({
mutationFn: ({ projectId, defaultUserSshCaId, defaultHostSshCaId }) => {
return apiRequest.patch(`/api/v1/workspace/${projectId}/ssh-config`, {
return apiRequest.patch(`/api/v1/projects/${projectId}/ssh-config`, {
defaultUserSshCaId,
defaultHostSshCaId
});
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getProjectSshConfig(projectId)
queryKey: projectKeys.getProjectSshConfig(projectId)
});
}
});

View File

@@ -0,0 +1,77 @@
import type { CaStatus } from "../ca";
import { WorkflowIntegrationPlatform } from "../workflowIntegrations/types";
import { TListProjectIdentitiesDTO, TSearchProjectsDTO } from "./types";
export const projectKeys = {
getProjectById: (projectId: string) => ["projects", { projectId }] as const,
getProjectSecrets: (projectId: string) => [{ projectId }, "project-secrets"] as const,
getProjectIndexStatus: (projectId: string) => [{ projectId }, "project-index-status"] as const,
getProjectUpgradeStatus: (projectId: string) => [{ projectId }, "project-upgrade-status"],
getProjectMemberships: (orgId: string) => [{ orgId }, "project-memberships"],
getProjectAuthorization: (projectId: string) => [{ projectId }, "project-authorizations"],
getProjectIntegrations: (projectId: string) => [{ projectId }, "project-integrations"],
getAllUserProjects: () => ["projects"] as const,
getProjectAuditLogs: (projectId: string) => [{ projectId }, "project-audit-logs"] as const,
getProjectUsers: (
projectId: string,
includeGroupMembers: boolean = false,
roles: string[] = []
) => [{ projectId, includeGroupMembers, roles }, "project-users"] as const,
getProjectUserDetails: (projectId: string, membershipId: string) =>
[{ projectId, membershipId }, "project-user-details"] as const,
getProjectIdentityMemberships: (projectId: string) =>
[{ projectId }, "project-identity-memberships"] as const,
getProjectIdentityMembershipDetails: (projectId: string, identityId: string) =>
[{ projectId, identityId }, "project-identity-membership-details"] as const,
// allows invalidation using above key without knowing params
getProjectIdentityMembershipsWithParams: ({ projectId, ...params }: TListProjectIdentitiesDTO) =>
[...projectKeys.getProjectIdentityMemberships(projectId), params] as const,
searchProject: (dto: TSearchProjectsDTO) => ["search-projects", dto] as const,
getProjectGroupMemberships: (projectId: string) => [{ projectId }, "project-groups"] as const,
getProjectGroupMembershipDetails: (projectId: string, groupId: string) =>
[{ projectId, groupId }, "project-group-membership-details"] as const,
getProjectCas: ({ projectId }: { projectId: string }) => [{ projectId }, "project-cas"] as const,
specificProjectCas: ({ projectId, status }: { projectId: string; status?: CaStatus }) =>
[...projectKeys.getProjectCas({ projectId }), { status }] as const,
allProjectCertificates: () => ["project-certificates"] as const,
forProjectCertificates: (projectId: string) =>
[...projectKeys.allProjectCertificates(), projectId] as const,
specificProjectCertificates: ({
projectId,
offset,
limit
}: {
projectId: string;
offset: number;
limit: number;
}) => [...projectKeys.forProjectCertificates(projectId), { offset, limit }] as const,
getProjectPkiAlerts: (projectId: string) => [{ projectId }, "project-pki-alerts"] as const,
getProjectPkiSubscribers: (projectId: string) =>
[{ projectId }, "project-pki-subscribers"] as const,
getProjectPkiCollections: (projectId: string) =>
[{ projectId }, "project-pki-collections"] as const,
getProjectCertificateTemplates: (projectId: string) =>
[{ projectId }, "project-certificate-templates"] as const,
getProjectWorkflowIntegrationConfig: (
projectId: string,
integration: WorkflowIntegrationPlatform
) => [{ projectId, integration }, "project-workflow-integration-config"] as const,
getProjectSshCas: (projectId: string) => [{ projectId }, "project-ssh-cas"] as const,
allProjectSshCertificates: (projectId: string) =>
[{ projectId }, "project-ssh-certificates"] as const,
getProjectSshHosts: (projectId: string) => [{ projectId }, "project-ssh-hosts"] as const,
getProjectSshHostGroups: (projectId: string) =>
[{ projectId }, "project-ssh-host-groups"] as const,
specificProjectSshCertificates: ({
offset,
limit,
projectId
}: {
offset: number;
limit: number;
projectId: string;
}) => [...projectKeys.allProjectSshCertificates(projectId), { offset, limit }] as const,
getProjectSshCertificateTemplates: (projectId: string) =>
[{ projectId }, "project-ssh-certificate-templates"] as const,
getProjectSshConfig: (projectId: string) => [{ projectId }, "project-ssh-config"] as const
};

View File

@@ -20,7 +20,7 @@ export enum ProjectUserMembershipTemporaryMode {
Relative = "relative"
}
export type Workspace = {
export type Project = {
__v: number;
id: string;
name: string;
@@ -31,7 +31,7 @@ export type Workspace = {
upgradeStatus: string | null;
updatedAt: string;
autoCapitalization: boolean;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
pitVersionLimit: number;
auditLogsRetentionDays: number;
slug: string;
@@ -43,16 +43,16 @@ export type Workspace = {
secretDetectionIgnoreValues: string[];
};
export type WorkspaceEnv = {
export type ProjectEnv = {
id: string;
name: string;
slug: string;
};
export type WorkspaceTag = { id: string; name: string; slug: string };
export type ProjectTag = { id: string; name: string; slug: string };
export type NameWorkspaceSecretsDTO = {
workspaceId: string;
projectId: string;
secretsToUpdate: {
secretName: string;
secretId: string;
@@ -76,30 +76,33 @@ export type CreateWorkspaceDTO = {
};
export type UpdateProjectDTO = {
projectID: string;
projectId: string;
newProjectName?: string;
newProjectDescription?: string;
newSlug?: string;
secretSharing?: boolean;
showSnapshotsLegacy?: boolean;
secretDetectionIgnoreValues?: string[];
pitVersionLimit?: number;
autoCapitalization?: boolean;
hasDeleteProtection?: boolean;
};
export type UpdatePitVersionLimitDTO = { projectSlug: string; pitVersionLimit: number };
export type UpdateAuditLogsRetentionDTO = { projectSlug: string; auditLogsRetentionDays: number };
export type ToggleAutoCapitalizationDTO = { workspaceID: string; state: boolean };
export type ToggleDeleteProjectProtectionDTO = { workspaceID: string; state: boolean };
export type ToggleAutoCapitalizationDTO = { projectID: string; state: boolean };
export type ToggleDeleteProjectProtectionDTO = { projectID: string; state: boolean };
export type DeleteWorkspaceDTO = { workspaceID: string };
export type DeleteWorkspaceDTO = { projectID: string };
export type CreateEnvironmentDTO = {
workspaceId: string;
projectId: string;
name: string;
slug: string;
};
export type ReorderEnvironmentsDTO = {
workspaceId: string;
projectId: string;
environmentSlug: string;
environmentName: string;
otherEnvironmentSlug: string;
@@ -107,18 +110,18 @@ export type ReorderEnvironmentsDTO = {
};
export type UpdateEnvironmentDTO = {
workspaceId: string;
projectId: string;
id: string;
name?: string;
slug?: string;
position?: number;
};
export type DeleteEnvironmentDTO = { workspaceId: string; id: string };
export type DeleteEnvironmentDTO = { projectId: string; id: string };
export type TUpdateWorkspaceUserRoleDTO = {
membershipId: string;
workspaceId: string;
projectId: string;
roles: (
| {
role: string;
@@ -136,7 +139,7 @@ export type TUpdateWorkspaceUserRoleDTO = {
export type TUpdateWorkspaceIdentityRoleDTO = {
identityId: string;
workspaceId: string;
projectId: string;
roles: (
| {
role: string;
@@ -171,7 +174,7 @@ export type TUpdateWorkspaceGroupRoleDTO = {
};
export type TListProjectIdentitiesDTO = {
workspaceId: string;
projectId: string;
offset?: number;
limit?: number;
orderBy?: ProjectIdentityOrderBy;

View File

@@ -22,7 +22,7 @@ export const useCreateProjectRole = () => {
mutationFn: async ({ projectId, ...dto }: TCreateProjectRoleDTO) => {
const {
data: { role }
} = await apiRequest.post(`/api/v2/workspace/${projectId}/roles`, dto);
} = await apiRequest.post(`/api/v1/projects/${projectId}/roles`, dto);
return role;
},
onSuccess: (_, { projectId }) => {
@@ -38,7 +38,7 @@ export const useUpdateProjectRole = () => {
mutationFn: async ({ id, projectId, ...dto }: TUpdateProjectRoleDTO) => {
const {
data: { role }
} = await apiRequest.patch(`/api/v2/workspace/${projectId}/roles/${id}`, dto);
} = await apiRequest.patch(`/api/v1/projects/${projectId}/roles/${id}`, dto);
return role;
},
onSuccess: (_, { projectId, slug }) => {
@@ -58,7 +58,7 @@ export const useDeleteProjectRole = () => {
mutationFn: async ({ projectId, id }: TDeleteProjectRoleDTO) => {
const {
data: { role }
} = await apiRequest.delete(`/api/v2/workspace/${projectId}/roles/${id}`);
} = await apiRequest.delete(`/api/v1/projects/${projectId}/roles/${id}`);
return role;
},
onSuccess: (_, { projectId }) => {

View File

@@ -46,13 +46,13 @@ export const roleQueryKeys = {
getOrgRole: (orgId: string, roleId: string) => [{ orgId, roleId }, "org-role"] as const,
getUserOrgPermissions: ({ orgId }: TGetUserOrgPermissionsDTO) =>
["user-permissions", { orgId }] as const,
getUserProjectPermissions: ({ workspaceId }: TGetUserProjectPermissionDTO) =>
["user-project-permissions", { workspaceId }] as const
getUserProjectPermissions: ({ projectId }: TGetUserProjectPermissionDTO) =>
["user-project-permissions", { projectId }] as const
};
export const getProjectRoles = async (projectId: string) => {
const { data } = await apiRequest.get<{ roles: Array<Omit<TProjectRole, "permissions">> }>(
`/api/v2/workspace/${projectId}/roles`
`/api/v1/projects/${projectId}/roles`
);
return data.roles;
};
@@ -69,7 +69,7 @@ export const useGetProjectRoleBySlug = (projectId: string, roleSlug: string) =>
queryKey: roleQueryKeys.getProjectRoleBySlug(projectId, roleSlug),
queryFn: async () => {
const { data } = await apiRequest.get<{ role: TProjectRole }>(
`/api/v2/workspace/${projectId}/roles/slug/${roleSlug}`
`/api/v1/projects/${projectId}/roles/slug/${roleSlug}`
);
return data.role;
},
@@ -131,9 +131,7 @@ export const useGetUserOrgPermissions = ({ orgId }: TGetUserOrgPermissionsDTO) =
}
});
export const fetchUserProjectPermissions = async ({
workspaceId
}: TGetUserProjectPermissionDTO) => {
export const fetchUserProjectPermissions = async ({ projectId }: TGetUserProjectPermissionDTO) => {
const { data } = await apiRequest.get<{
data: {
permissions: PackRule<RawRuleOf<MongoAbility<OrgPermissionSet>>>[];
@@ -145,16 +143,16 @@ export const fetchUserProjectPermissions = async ({
actorName: string;
};
};
}>(`/api/v1/workspace/${workspaceId}/permissions`, {});
}>(`/api/v1/projects/${projectId}/permissions`, {});
return data.data;
};
export const useGetUserProjectPermissions = ({ workspaceId }: TGetUserProjectPermissionDTO) =>
export const useGetUserProjectPermissions = ({ projectId }: TGetUserProjectPermissionDTO) =>
useQuery({
queryKey: roleQueryKeys.getUserProjectPermissions({ workspaceId }),
queryFn: () => fetchUserProjectPermissions({ workspaceId }),
enabled: Boolean(workspaceId),
queryKey: roleQueryKeys.getUserProjectPermissions({ projectId }),
queryFn: () => fetchUserProjectPermissions({ projectId }),
enabled: Boolean(projectId),
select: (data) => {
const rule = unpackRules<RawRuleOf<MongoAbility<ProjectPermissionSet>>>(data.permissions);
const negatedRules = groupBy(

View File

@@ -9,7 +9,7 @@ export enum ProjectMembershipRole {
}
export type TGetProjectRolesDTO = {
workspaceId?: string;
projectId?: string;
};
export type TProjectRole = {
@@ -52,7 +52,7 @@ export type TGetUserOrgPermissionsDTO = {
};
export type TGetUserProjectPermissionDTO = {
workspaceId: string;
projectId: string;
};
export type TCreateOrgRoleDTO = {

View File

@@ -11,7 +11,7 @@ export const useCreateSecretApprovalPolicy = () => {
return useMutation<object, object, TCreateSecretPolicyDTO>({
mutationFn: async ({
environments,
workspaceId,
projectId,
approvals,
approvers,
bypassers,
@@ -20,9 +20,9 @@ export const useCreateSecretApprovalPolicy = () => {
enforcementLevel,
allowedSelfApprovals
}) => {
const { data } = await apiRequest.post("/api/v1/secret-approvals", {
const { data } = await apiRequest.post("/api/v2/secret-approvals", {
environments,
workspaceId,
projectId,
approvals,
approvers,
bypassers,
@@ -33,9 +33,9 @@ export const useCreateSecretApprovalPolicy = () => {
});
return data;
},
onSuccess: (_, { workspaceId }) => {
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: secretApprovalKeys.getApprovalPolicies(workspaceId)
queryKey: secretApprovalKeys.getApprovalPolicies(projectId)
});
}
});
@@ -56,7 +56,7 @@ export const useUpdateSecretApprovalPolicy = () => {
allowedSelfApprovals,
environments
}) => {
const { data } = await apiRequest.patch(`/api/v1/secret-approvals/${id}`, {
const { data } = await apiRequest.patch(`/api/v2/secret-approvals/${id}`, {
approvals,
approvers,
bypassers,
@@ -68,9 +68,9 @@ export const useUpdateSecretApprovalPolicy = () => {
});
return data;
},
onSuccess: (_, { workspaceId }) => {
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: secretApprovalKeys.getApprovalPolicies(workspaceId)
queryKey: secretApprovalKeys.getApprovalPolicies(projectId)
});
}
});
@@ -81,12 +81,12 @@ export const useDeleteSecretApprovalPolicy = () => {
return useMutation<object, object, TDeleteSecretPolicyDTO>({
mutationFn: async ({ id }) => {
const { data } = await apiRequest.delete(`/api/v1/secret-approvals/${id}`);
const { data } = await apiRequest.delete(`/api/v2/secret-approvals/${id}`);
return data;
},
onSuccess: (_, { workspaceId }) => {
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: secretApprovalKeys.getApprovalPolicies(workspaceId)
queryKey: secretApprovalKeys.getApprovalPolicies(projectId)
});
}
});

View File

@@ -10,54 +10,53 @@ import {
} from "./types";
export const secretApprovalKeys = {
getApprovalPolicies: (workspaceId: string) =>
[{ workspaceId }, "secret-approval-policies"] as const,
getApprovalPolicyOfABoard: (workspaceId: string, environment: string, secretPath: string) => [
{ workspaceId, environment, secretPath },
getApprovalPolicies: (projectId: string) => [{ projectId }, "secret-approval-policies"] as const,
getApprovalPolicyOfABoard: (projectId: string, environment: string, secretPath: string) => [
{ projectId, environment, secretPath },
"Secret-approval-policy"
]
};
const fetchApprovalPolicies = async (workspaceId: string) => {
const fetchApprovalPolicies = async (projectId: string) => {
const { data } = await apiRequest.get<{ approvals: TSecretApprovalPolicy[] }>(
"/api/v1/secret-approvals",
{ params: { workspaceId } }
"/api/v2/secret-approvals",
{ params: { projectId } }
);
return data.approvals;
};
export const useGetSecretApprovalPolicies = ({
workspaceId,
projectId,
options = {}
}: TGetSecretApprovalPoliciesDTO & TReactQueryOptions) =>
useQuery({
queryKey: secretApprovalKeys.getApprovalPolicies(workspaceId),
queryFn: () => fetchApprovalPolicies(workspaceId),
queryKey: secretApprovalKeys.getApprovalPolicies(projectId),
queryFn: () => fetchApprovalPolicies(projectId),
...options,
enabled: Boolean(workspaceId) && (options?.enabled ?? true)
enabled: Boolean(projectId) && (options?.enabled ?? true)
});
const fetchApprovalPolicyOfABoard = async (
workspaceId: string,
projectId: string,
environment: string,
secretPath: string
) => {
const { data } = await apiRequest.get<{ policy: TSecretApprovalPolicy }>(
"/api/v1/secret-approvals/board",
{ params: { workspaceId, environment, secretPath } }
"/api/v2/secret-approvals/board",
{ params: { projectId, environment, secretPath } }
);
return data.policy || "";
};
export const useGetSecretApprovalPolicyOfABoard = ({
workspaceId,
projectId,
secretPath = "/",
environment,
options = {}
}: TGetSecretApprovalPolicyOfBoardDTO & TReactQueryOptions) =>
useQuery({
queryKey: secretApprovalKeys.getApprovalPolicyOfABoard(workspaceId, environment, secretPath),
queryFn: () => fetchApprovalPolicyOfABoard(workspaceId, environment, secretPath),
queryKey: secretApprovalKeys.getApprovalPolicyOfABoard(projectId, environment, secretPath),
queryFn: () => fetchApprovalPolicyOfABoard(projectId, environment, secretPath),
...options,
enabled: Boolean(workspaceId && secretPath && environment) && (options?.enabled ?? true)
enabled: Boolean(projectId && secretPath && environment) && (options?.enabled ?? true)
});

View File

@@ -1,11 +1,11 @@
import { EnforcementLevel } from "../policies/enums";
import { WorkspaceEnv } from "../workspace/types";
import { ProjectEnv } from "../projects/types";
export type TSecretApprovalPolicy = {
id: string;
workspace: string;
project: string;
name: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
secretPath?: string;
approvals: number;
approvers: Approver[];
@@ -36,17 +36,17 @@ export type Bypasser = {
};
export type TGetSecretApprovalPoliciesDTO = {
workspaceId: string;
projectId: string;
};
export type TGetSecretApprovalPolicyOfBoardDTO = {
workspaceId: string;
projectId: string;
environment: string;
secretPath: string;
};
export type TCreateSecretPolicyDTO = {
workspaceId: string;
projectId: string;
name?: string;
environments: string[];
secretPath: string;
@@ -67,12 +67,12 @@ export type TUpdateSecretPolicyDTO = {
allowedSelfApprovals?: boolean;
enforcementLevel?: EnforcementLevel;
// for invalidating list
workspaceId: string;
projectId: string;
environments?: string[];
};
export type TDeleteSecretPolicyDTO = {
id: string;
// for invalidating list
workspaceId: string;
projectId: string;
};

View File

@@ -36,9 +36,9 @@ export const useUpdateSecretApprovalRequestStatus = () => {
});
return data;
},
onSuccess: (_, { id, workspaceId }) => {
onSuccess: (_, { id, projectId }) => {
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.detail({ id }) });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
}
});
};
@@ -53,10 +53,10 @@ export const usePerformSecretApprovalRequestMerge = () => {
});
return data;
},
onSuccess: (_, { id, workspaceId }) => {
onSuccess: (_, { id, projectId }) => {
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.detail({ id }) });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.list({ workspaceId }) });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.list({ projectId }) });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
}
});
};

View File

@@ -14,7 +14,7 @@ import {
export const secretApprovalRequestKeys = {
list: ({
workspaceId,
projectId,
environment,
status,
committer,
@@ -23,20 +23,20 @@ export const secretApprovalRequestKeys = {
search
}: TGetSecretApprovalRequestList) =>
[
{ workspaceId, environment, status, committer, offset, limit, search },
{ projectId, environment, status, committer, offset, limit, search },
"secret-approval-requests"
] as const,
detail: ({ id }: Omit<TGetSecretApprovalRequestDetails, "decryptKey">) =>
[{ id }, "secret-approval-request-detail"] as const,
count: ({ workspaceId, policyId }: TGetSecretApprovalRequestCount) => [
{ workspaceId },
count: ({ projectId, policyId }: TGetSecretApprovalRequestCount) => [
{ projectId },
"secret-approval-request-count",
...(policyId ? [policyId] : [])
]
};
const fetchSecretApprovalRequestList = async ({
workspaceId,
projectId,
environment,
committer,
status = "open",
@@ -49,7 +49,7 @@ const fetchSecretApprovalRequestList = async ({
totalCount: number;
}>("/api/v1/secret-approval-requests", {
params: {
workspaceId,
projectId,
environment,
committer,
status,
@@ -63,7 +63,7 @@ const fetchSecretApprovalRequestList = async ({
};
export const useGetSecretApprovalRequests = ({
workspaceId,
projectId,
environment,
options = {},
status,
@@ -74,7 +74,7 @@ export const useGetSecretApprovalRequests = ({
}: TGetSecretApprovalRequestList & TReactQueryOptions) =>
useQuery({
queryKey: secretApprovalRequestKeys.list({
workspaceId,
projectId,
environment,
committer,
status,
@@ -84,7 +84,7 @@ export const useGetSecretApprovalRequests = ({
}),
queryFn: () =>
fetchSecretApprovalRequestList({
workspaceId,
projectId,
environment,
status,
committer,
@@ -92,7 +92,7 @@ export const useGetSecretApprovalRequests = ({
offset,
search
}),
enabled: Boolean(workspaceId) && (options?.enabled ?? true),
enabled: Boolean(projectId) && (options?.enabled ?? true),
placeholderData: (previousData) => previousData
});
@@ -127,19 +127,19 @@ export const useGetSecretApprovalRequestDetails = ({
});
const fetchSecretApprovalRequestCount = async ({
workspaceId,
projectId,
policyId
}: TGetSecretApprovalRequestCount) => {
const { data } = await apiRequest.get<{ approvals: TSecretApprovalRequestCount }>(
"/api/v1/secret-approval-requests/count",
{ params: { workspaceId, policyId } }
{ params: { projectId, policyId } }
);
return data.approvals;
};
export const useGetSecretApprovalRequestCount = ({
workspaceId,
projectId,
policyId,
options = {}
}: TGetSecretApprovalRequestCount & {
@@ -154,8 +154,8 @@ export const useGetSecretApprovalRequestCount = ({
>;
}) =>
useQuery({
queryKey: secretApprovalRequestKeys.count({ workspaceId, policyId }),
queryKey: secretApprovalRequestKeys.count({ projectId, policyId }),
refetchInterval: 15000,
queryFn: () => fetchSecretApprovalRequestCount({ workspaceId, policyId }),
enabled: Boolean(workspaceId) && (options?.enabled ?? true)
queryFn: () => fetchSecretApprovalRequestCount({ projectId, policyId }),
enabled: Boolean(projectId) && (options?.enabled ?? true)
});

View File

@@ -55,7 +55,7 @@ export type TSecretApprovalRequest = {
username: string;
isOrgMembershipActive: boolean;
}[];
workspace: string;
project: string;
environment: string;
folderId: string;
secretPath: string;
@@ -110,7 +110,7 @@ export type TSecretApprovalRequestCount = {
};
export type TGetSecretApprovalRequestList = {
workspaceId: string;
projectId: string;
environment?: string;
status?: "open" | "close";
committer?: string;
@@ -120,7 +120,7 @@ export type TGetSecretApprovalRequestList = {
};
export type TGetSecretApprovalRequestCount = {
workspaceId: string;
projectId: string;
policyId?: string;
};
@@ -137,11 +137,11 @@ export type TUpdateSecretApprovalReviewStatusDTO = {
export type TUpdateSecretApprovalRequestStatusDTO = {
status: "open" | "close";
id: string;
workspaceId: string;
projectId: string;
};
export type TPerformSecretApprovalRequestMerge = {
id: string;
workspaceId: string;
projectId: string;
bypassReason?: string;
};

View File

@@ -30,10 +30,10 @@ export const folderQueryKeys = {
["secret-folders", "environment", projectId] as const
};
const fetchProjectFolders = async (workspaceId: string, environment: string, path = "/") => {
const { data } = await apiRequest.get<{ folders: TSecretFolder[] }>("/api/v1/folders", {
const fetchProjectFolders = async (projectId: string, environment: string, path = "/") => {
const { data } = await apiRequest.get<{ folders: TSecretFolder[] }>("/api/v2/folders", {
params: {
workspaceId,
projectId,
environment,
path
}
@@ -57,7 +57,7 @@ export const useListProjectEnvironmentsFolders = (
queryKey: folderQueryKeys.getProjectEnvironmentsFolders(projectId),
queryFn: async () => {
const { data } = await apiRequest.get<TProjectEnvironmentsFolders>(
`/api/v1/workspace/${projectId}/environment-folder-tree`
`/api/v1/projects/${projectId}/environment-folder-tree`
);
return data;
},
@@ -145,9 +145,9 @@ export const useCreateFolder = () => {
return useMutation<object, object, TCreateFolderDTO>({
mutationFn: async (dto) => {
const { data } = await apiRequest.post("/api/v1/folders", {
const { data } = await apiRequest.post("/api/v2/folders", {
...dto,
workspaceId: dto.projectId
projectId: dto.projectId
});
return data;
},
@@ -162,13 +162,13 @@ export const useCreateFolder = () => {
queryKey: folderQueryKeys.getSecretFolders({ projectId, environment, path })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ workspaceId: projectId, environment, directory: path })
queryKey: secretSnapshotKeys.list({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ workspaceId: projectId, environment, directory: path })
queryKey: secretSnapshotKeys.count({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId: projectId, environment, directory: path })
queryKey: commitKeys.count({ projectId, environment, directory: path })
});
}
});
@@ -179,10 +179,10 @@ export const useUpdateFolder = () => {
return useMutation<object, object, TUpdateFolderDTO>({
mutationFn: async ({ path = "/", folderId, name, environment, projectId, description }) => {
const { data } = await apiRequest.patch(`/api/v1/folders/${folderId}`, {
const { data } = await apiRequest.patch(`/api/v2/folders/${folderId}`, {
name,
environment,
workspaceId: projectId,
projectId,
path,
description
});
@@ -199,16 +199,16 @@ export const useUpdateFolder = () => {
queryKey: folderQueryKeys.getSecretFolders({ projectId, environment, path })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ workspaceId: projectId, environment, directory: path })
queryKey: secretSnapshotKeys.list({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ workspaceId: projectId, environment, directory: path })
queryKey: secretSnapshotKeys.count({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId: projectId, environment, directory: path })
queryKey: commitKeys.count({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId: projectId, environment, directory: path })
queryKey: commitKeys.history({ projectId, environment, directory: path })
});
}
});
@@ -219,10 +219,10 @@ export const useDeleteFolder = () => {
return useMutation<object, object, TDeleteFolderDTO>({
mutationFn: async ({ path = "/", folderId, environment, projectId }) => {
const { data } = await apiRequest.delete(`/api/v1/folders/${folderId}`, {
const { data } = await apiRequest.delete(`/api/v2/folders/${folderId}`, {
data: {
environment,
workspaceId: projectId,
projectId,
path
}
});
@@ -239,16 +239,16 @@ export const useDeleteFolder = () => {
queryKey: folderQueryKeys.getSecretFolders({ projectId, environment, path })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ workspaceId: projectId, environment, directory: path })
queryKey: secretSnapshotKeys.list({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ workspaceId: projectId, environment, directory: path })
queryKey: secretSnapshotKeys.count({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId: projectId, environment, directory: path })
queryKey: commitKeys.count({ projectId, environment, directory: path })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId: projectId, environment, directory: path })
queryKey: commitKeys.history({ projectId, environment, directory: path })
});
}
});
@@ -258,9 +258,9 @@ export const useUpdateFolderBatch = () => {
const queryClient = useQueryClient();
return useMutation<object, object, TUpdateFolderBatchDTO>({
mutationFn: async ({ projectSlug, folders }) => {
const { data } = await apiRequest.patch("/api/v1/folders/batch", {
projectSlug,
mutationFn: async ({ projectId, folders }) => {
const { data } = await apiRequest.patch("/api/v2/folders/batch", {
projectId,
folders
});
@@ -283,28 +283,28 @@ export const useUpdateFolderBatch = () => {
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({
workspaceId: projectId,
projectId,
environment: folder.environment,
directory: folder.path
})
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({
workspaceId: projectId,
projectId,
environment: folder.environment,
directory: folder.path
})
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({
workspaceId: projectId,
projectId,
environment: folder.environment,
directory: folder.path
})
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({
workspaceId: projectId,
projectId,
environment: folder.environment,
directory: folder.path
})

View File

@@ -1,4 +1,4 @@
import { WorkspaceEnv } from "@app/hooks/api/workspace/types";
import { ProjectEnv } from "@app/hooks/api/projects/types";
export enum ReservedFolders {
SecretReplication = "__reserve_replication_"
@@ -22,7 +22,7 @@ export type TSecretFolder = {
export type TSecretFolderWithPath = TSecretFolder & { path: string };
export type TProjectEnvironmentsFolders = {
[key: string]: WorkspaceEnv & { folders: TSecretFolderWithPath[] };
[key: string]: ProjectEnv & { folders: TSecretFolderWithPath[] };
};
export type TGetProjectFoldersDTO = {
@@ -63,7 +63,6 @@ export type TDeleteFolderDTO = {
export type TUpdateFolderBatchDTO = {
projectId: string;
projectSlug: string;
folders: {
name: string;
environment: string;

View File

@@ -16,10 +16,10 @@ export const useCreateSecretImport = () => {
return useMutation<object, object, TCreateSecretImportDTO>({
mutationFn: async ({ import: secretImport, environment, isReplication, projectId, path }) => {
const { data } = await apiRequest.post("/api/v1/secret-imports", {
const { data } = await apiRequest.post("/api/v2/secret-imports", {
import: secretImport,
environment,
workspaceId: projectId,
projectId,
path,
isReplication
});
@@ -44,11 +44,11 @@ export const useUpdateSecretImport = () => {
return useMutation<object, object, TUpdateSecretImportDTO>({
mutationFn: async ({ environment, import: secretImports, projectId, path, id }) => {
const { data } = await apiRequest.patch(`/api/v1/secret-imports/${id}`, {
const { data } = await apiRequest.patch(`/api/v2/secret-imports/${id}`, {
import: secretImports,
environment,
path,
workspaceId: projectId
projectId
});
return data;
},
@@ -69,10 +69,10 @@ export const useUpdateSecretImport = () => {
export const useResyncSecretReplication = () => {
return useMutation<object, object, TResyncSecretReplicationDTO>({
mutationFn: async ({ environment, projectId, path, id }) => {
const { data } = await apiRequest.post(`/api/v1/secret-imports/${id}/replication-resync`, {
const { data } = await apiRequest.post(`/api/v2/secret-imports/${id}/replication-resync`, {
environment,
path,
workspaceId: projectId
projectId
});
return data;
}
@@ -84,9 +84,9 @@ export const useDeleteSecretImport = () => {
return useMutation<object, object, TDeleteSecretImportDTO>({
mutationFn: async ({ id, projectId, path, environment }) => {
const { data } = await apiRequest.delete(`/api/v1/secret-imports/${id}`, {
const { data } = await apiRequest.delete(`/api/v2/secret-imports/${id}`, {
data: {
workspaceId: projectId,
projectId,
path,
environment
}

View File

@@ -30,10 +30,10 @@ export const secretImportKeys = {
const fetchSecretImport = async ({ projectId, environment, path = "/" }: TGetSecretImports) => {
const { data } = await apiRequest.get<{ secretImports: TSecretImport[] }>(
"/api/v1/secret-imports",
"/api/v2/secret-imports",
{
params: {
workspaceId: projectId,
projectId,
environment,
path
}
@@ -65,16 +65,12 @@ export const useGetSecretImports = ({
queryFn: () => fetchSecretImport({ path, projectId, environment })
});
const fetchImportedSecrets = async (
workspaceId: string,
environment: string,
directory?: string
) => {
const fetchImportedSecrets = async (projectId: string, environment: string, directory?: string) => {
const { data } = await apiRequest.get<{ secrets: TImportedSecrets[] }>(
"/api/v1/secret-imports/secrets/raw",
"/api/v2/secret-imports/secrets",
{
params: {
workspaceId,
projectId,
environment,
path: directory
}
@@ -89,10 +85,10 @@ const fetchImportedFolders = async ({
path
}: TGetImportedFoldersByEnvDTO) => {
const { data } = await apiRequest.get<{ secretImports: TSecretImport[] }>(
"/api/v1/secret-imports",
"/api/v2/secret-imports",
{
params: {
workspaceId: projectId,
projectId,
environment,
path
}

View File

@@ -1,11 +1,11 @@
import { ProjectEnv } from "../projects/types";
import { SecretV3Raw } from "../secrets/types";
import { WorkspaceEnv } from "../workspace/types";
export type TSecretImport = {
id: string;
folderId: string;
importPath: string;
importEnv: WorkspaceEnv;
importEnv: ProjectEnv;
position: string;
createdAt: string;
updatedAt: string;
@@ -25,7 +25,7 @@ export type TGetImportedFoldersByEnvDTO = {
export type TImportedSecrets = {
environment: string;
environmentInfo: WorkspaceEnv;
environmentInfo: ProjectEnv;
secretPath: string;
folderId: string;
secrets: SecretV3Raw[];

View File

@@ -1,4 +1,4 @@
import { WorkspaceEnv } from "../workspace/types";
import { ProjectEnv } from "../projects/types";
export enum TProviderFunctionTypes {
HTTP = "http",
@@ -80,7 +80,7 @@ export type TSecretRotation = {
customProvider: string;
workspace: string;
envId: string;
environment: WorkspaceEnv;
environment: ProjectEnv;
secretPath: string;
outputs: Array<{
key: string;

View File

@@ -14,25 +14,25 @@ import {
} from "./types";
export const secretSnapshotKeys = {
list: ({ workspaceId, environment, directory }: Omit<TGetSecretSnapshotsDTO, "limit">) =>
[{ workspaceId, environment, directory }, "secret-snapshot"] as const,
list: ({ projectId, environment, directory }: Omit<TGetSecretSnapshotsDTO, "limit">) =>
[{ projectId, environment, directory }, "secret-snapshot"] as const,
snapshotData: (snapshotId: string) => [{ snapshotId }, "secret-snapshot"] as const,
count: ({ environment, workspaceId, directory }: Omit<TGetSecretSnapshotsDTO, "limit">) => [
{ workspaceId, environment, directory },
count: ({ environment, projectId, directory }: Omit<TGetSecretSnapshotsDTO, "limit">) => [
{ projectId, environment, directory },
"count",
"secret-snapshot"
]
};
const fetchWorkspaceSnaphots = async ({
workspaceId,
projectId,
environment,
directory = "/",
limit = 10,
offset = 0
}: TGetSecretSnapshotsDTO & { offset: number }) => {
const res = await apiRequest.get<{ secretSnapshots: TSecretSnapshot[] }>(
`/api/v1/workspace/${workspaceId}/secret-snapshots`,
`/api/v1/projects/${projectId}/secret-snapshots`,
{
params: {
limit,
@@ -49,7 +49,7 @@ const fetchWorkspaceSnaphots = async ({
export const useGetWorkspaceSnapshotList = (dto: TGetSecretSnapshotsDTO & { isPaused?: boolean }) =>
useInfiniteQuery({
initialPageParam: 0,
enabled: Boolean(dto.workspaceId && dto.environment) && !dto.isPaused,
enabled: Boolean(dto.projectId && dto.environment) && !dto.isPaused,
queryKey: secretSnapshotKeys.list({ ...dto }),
queryFn: ({ pageParam }) => fetchWorkspaceSnaphots({ ...dto, offset: pageParam }),
getNextPageParam: (lastPage, pages) =>
@@ -115,12 +115,12 @@ export const useGetSnapshotSecrets = ({ snapshotId }: TSnapshotDataProps) =>
});
const fetchWorkspaceSecretSnaphotCount = async (
workspaceId: string,
projectId: string,
environment: string,
directory = "/"
) => {
const res = await apiRequest.get<{ count: number }>(
`/api/v1/workspace/${workspaceId}/secret-snapshots/count`,
`/api/v1/projects/${projectId}/secret-snapshots/count`,
{
params: {
environment,
@@ -132,15 +132,15 @@ const fetchWorkspaceSecretSnaphotCount = async (
};
export const useGetWsSnapshotCount = ({
workspaceId,
projectId,
environment,
directory,
isPaused
}: Omit<TGetSecretSnapshotsDTO, "limit"> & { isPaused?: boolean }) =>
useQuery({
enabled: Boolean(workspaceId && environment) && !isPaused,
queryKey: secretSnapshotKeys.count({ workspaceId, environment, directory }),
queryFn: () => fetchWorkspaceSecretSnaphotCount(workspaceId, environment, directory)
enabled: Boolean(projectId && environment) && !isPaused,
queryKey: secretSnapshotKeys.count({ projectId, environment, directory }),
queryFn: () => fetchWorkspaceSecretSnaphotCount(projectId, environment, directory)
});
export const usePerformSecretRollback = () => {
@@ -151,22 +151,22 @@ export const usePerformSecretRollback = () => {
const { data } = await apiRequest.post(`/api/v1/secret-snapshot/${snapshotId}/rollback`);
return data;
},
onSuccess: (_, { workspaceId, environment, directory }) => {
onSuccess: (_, { projectId, environment, directory }) => {
queryClient.invalidateQueries({
queryKey: [{ workspaceId, environment, secretPath: directory }, "secrets"]
queryKey: [{ projectId, environment, secretPath: directory }, "secrets"]
});
queryClient.invalidateQueries({
queryKey: ["secret-folders", { projectId: workspaceId, environment, path: directory }]
queryKey: ["secret-folders", { projectId, environment, path: directory }]
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ workspaceId, environment, directory })
queryKey: secretSnapshotKeys.list({ projectId, environment, directory })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ workspaceId, environment, directory })
queryKey: secretSnapshotKeys.count({ projectId, environment, directory })
});
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({
projectId: workspaceId,
projectId,
secretPath: directory ?? "/"
})
});

View File

@@ -1,9 +1,9 @@
import { SecretVersions } from "../secrets/types";
import { WorkspaceEnv } from "../types";
import { ProjectEnv } from "../types";
export type TSecretSnapshot = {
id: string;
workspace: string;
projectId: string;
secretVersions: string[];
createdAt: string;
updatedAt: string;
@@ -13,7 +13,7 @@ export type TSnapshotData = Omit<TSecretSnapshot, "secretVersions"> & {
id: string;
secretVersions: (SecretVersions & { isRotatedSecret?: boolean })[];
folderVersion: Array<{ name: string; id: string }>;
environment: WorkspaceEnv;
environment: ProjectEnv;
};
export type TSnapshotDataProps = {
@@ -22,7 +22,7 @@ export type TSnapshotDataProps = {
};
export type TGetSecretSnapshotsDTO = {
workspaceId: string;
projectId: string;
limit: number;
environment: string;
directory?: string;
@@ -30,7 +30,7 @@ export type TGetSecretSnapshotsDTO = {
export type TSecretRollbackDTO = {
snapshotId: string;
workspaceId: string;
projectId: string;
environment: string;
directory?: string;
};

View File

@@ -33,18 +33,18 @@ export const useCreateSecretV3 = ({
secretPath = "/",
type,
environment,
workspaceId,
projectId,
secretKey,
secretValue,
secretComment,
skipMultilineEncoding,
tagIds
}) => {
const { data } = await apiRequest.post(`/api/v3/secrets/raw/${secretKey}`, {
const { data } = await apiRequest.post(`/api/v4/secrets/${secretKey}`, {
secretPath,
type,
environment,
workspaceId,
projectId,
secretValue,
secretComment,
skipMultilineEncoding,
@@ -52,26 +52,26 @@ export const useCreateSecretV3 = ({
});
return data;
},
onSuccess: (_, { workspaceId, environment, secretPath }) => {
onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
},
...options
});
@@ -88,7 +88,7 @@ export const useUpdateSecretV3 = ({
secretPath = "/",
type,
environment,
workspaceId,
projectId,
secretKey,
secretValue,
tagIds,
@@ -100,8 +100,8 @@ export const useUpdateSecretV3 = ({
skipMultilineEncoding,
secretMetadata
}) => {
const { data } = await apiRequest.patch(`/api/v3/secrets/raw/${secretKey}`, {
workspaceId,
const { data } = await apiRequest.patch(`/api/v4/secrets/${secretKey}`, {
projectId,
environment,
type,
secretReminderNote,
@@ -117,26 +117,26 @@ export const useUpdateSecretV3 = ({
});
return data;
},
onSuccess: (_, { workspaceId, environment, secretPath }) => {
onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
},
...options
});
@@ -150,17 +150,10 @@ export const useDeleteSecretV3 = ({
const queryClient = useQueryClient();
return useMutation<object, object, TDeleteSecretsV3DTO>({
mutationFn: async ({
secretPath = "/",
type,
environment,
workspaceId,
secretKey,
secretId
}) => {
const { data } = await apiRequest.delete(`/api/v3/secrets/raw/${secretKey}`, {
mutationFn: async ({ secretPath = "/", type, environment, projectId, secretKey, secretId }) => {
const { data } = await apiRequest.delete(`/api/v4/secrets/${secretKey}`, {
data: {
workspaceId,
projectId,
environment,
type,
secretPath,
@@ -169,26 +162,26 @@ export const useDeleteSecretV3 = ({
});
return data;
},
onSuccess: (_, { workspaceId, environment, secretPath }) => {
onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
},
...options
});
@@ -202,35 +195,35 @@ export const useCreateSecretBatch = ({
const queryClient = useQueryClient();
return useMutation<object, object, TCreateSecretBatchDTO>({
mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => {
const { data } = await apiRequest.post("/api/v3/secrets/batch/raw", {
workspaceId,
mutationFn: async ({ secretPath = "/", projectId, environment, secrets }) => {
const { data } = await apiRequest.post("/api/v4/secrets/batch", {
projectId,
environment,
secretPath,
secrets
});
return data;
},
onSuccess: (_, { workspaceId, environment, secretPath }) => {
onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
},
...options
});
@@ -244,35 +237,35 @@ export const useUpdateSecretBatch = ({
const queryClient = useQueryClient();
return useMutation<object, object, TUpdateSecretBatchDTO>({
mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => {
const { data } = await apiRequest.patch("/api/v3/secrets/batch/raw", {
workspaceId,
mutationFn: async ({ secretPath = "/", projectId, environment, secrets }) => {
const { data } = await apiRequest.patch("/api/v4/secrets/batch", {
projectId,
environment,
secretPath,
secrets
});
return data;
},
onSuccess: (_, { workspaceId, environment, secretPath }) => {
onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
},
...options
});
@@ -286,10 +279,10 @@ export const useDeleteSecretBatch = ({
const queryClient = useQueryClient();
return useMutation<object, object, TDeleteSecretBatchDTO>({
mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => {
const { data } = await apiRequest.delete("/api/v3/secrets/batch/raw", {
mutationFn: async ({ secretPath = "/", projectId, environment, secrets }) => {
const { data } = await apiRequest.delete("/api/v4/secrets/batch", {
data: {
workspaceId,
projectId,
environment,
secretPath,
secrets
@@ -297,26 +290,26 @@ export const useDeleteSecretBatch = ({
});
return data;
},
onSuccess: (_, { workspaceId, environment, secretPath }) => {
onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
},
...options
});
@@ -340,23 +333,23 @@ export const useMoveSecrets = ({
mutationFn: async ({
sourceEnvironment,
sourceSecretPath,
projectSlug,
destinationEnvironment,
destinationSecretPath,
secretIds,
shouldOverwrite
shouldOverwrite,
projectId
}) => {
const { data } = await apiRequest.post<{
isSourceUpdated: boolean;
isDestinationUpdated: boolean;
}>("/api/v3/secrets/move", {
}>("/api/v4/secrets/move", {
sourceEnvironment,
sourceSecretPath,
projectSlug,
destinationEnvironment,
destinationSecretPath,
secretIds,
shouldOverwrite
shouldOverwrite,
projectId
});
return data;
@@ -370,7 +363,7 @@ export const useMoveSecrets = ({
});
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({
workspaceId: projectId,
projectId,
environment: sourceEnvironment,
secretPath: sourceSecretPath
})
@@ -378,33 +371,33 @@ export const useMoveSecrets = ({
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({
environment: sourceEnvironment,
workspaceId: projectId,
projectId,
directory: sourceSecretPath
})
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({
environment: sourceEnvironment,
workspaceId: projectId,
projectId,
directory: sourceSecretPath
})
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({
workspaceId: projectId,
projectId,
environment: sourceEnvironment,
directory: sourceSecretPath
})
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({
workspaceId: projectId,
projectId,
environment: sourceEnvironment,
directory: sourceSecretPath
})
});
queryClient.invalidateQueries({
queryKey: secretApprovalRequestKeys.count({ workspaceId: projectId })
queryKey: secretApprovalRequestKeys.count({ projectId })
});
},
...options
@@ -412,14 +405,14 @@ export const useMoveSecrets = ({
};
export const createSecret = async (dto: TCreateSecretsV3DTO) => {
const { data } = await apiRequest.post(`/api/v3/secrets/${dto.secretKey}`, dto);
const { data } = await apiRequest.post(`/api/v4/secrets/${dto.secretKey}`, dto);
return data;
};
export const useBackfillSecretReference = () =>
useMutation<{ message: string }, object, { projectId: string }>({
mutationFn: async ({ projectId }) => {
const { data } = await apiRequest.post("/api/v3/secrets/backfill-secret-references", {
const { data } = await apiRequest.post("/api/v4/secrets/backfill-secret-references", {
projectId
});
return data.message;
@@ -432,16 +425,16 @@ export const useCreateCommit = () => {
object,
object,
{
workspaceId: string;
projectId: string;
environment: string;
secretPath: string;
pendingChanges: PendingChanges;
message: string;
}
>({
mutationFn: async ({ workspaceId, environment, secretPath, pendingChanges, message }) => {
mutationFn: async ({ projectId, environment, secretPath, pendingChanges, message }) => {
const { data } = await apiRequest.post("/api/v1/pit/batch/commit", {
projectId: workspaceId,
projectId,
environment,
secretPath,
changes: {
@@ -501,26 +494,26 @@ export const useCreateCommit = () => {
});
return data;
},
onSuccess: (_, { workspaceId, environment, secretPath }) => {
onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
}
});
};

View File

@@ -27,35 +27,35 @@ import {
export const secretKeys = {
// this is also used in secretSnapshot part
getProjectSecret: ({
workspaceId,
projectId,
environment,
secretPath,
viewSecretValue
}: TGetProjectSecretsKey) =>
[{ workspaceId, environment, secretPath, viewSecretValue }, "secrets"] as const,
[{ projectId, environment, secretPath, viewSecretValue }, "secrets"] as const,
getSecretVersion: (secretId: string) => [{ secretId }, "secret-versions"] as const,
getSecretAccessList: ({
workspaceId,
projectId,
environment,
secretPath,
secretKey
}: TGetSecretAccessListDTO) =>
["secret-access-list", { workspaceId, environment, secretPath, secretKey }] as const,
["secret-access-list", { projectId, environment, secretPath, secretKey }] as const,
getSecretReferenceTree: (dto: TGetSecretReferenceTreeDTO) => ["secret-reference-tree", dto]
};
export const fetchProjectSecrets = async ({
workspaceId,
projectId,
environment,
secretPath,
includeImports,
expandSecretReferences,
viewSecretValue
}: TGetProjectSecretsKey) => {
const { data } = await apiRequest.get<SecretV3RawResponse>("/api/v3/secrets/raw", {
const { data } = await apiRequest.get<SecretV3RawResponse>("/api/v4/secrets", {
params: {
environment,
workspaceId,
projectId,
secretPath,
viewSecretValue,
expandSecretReferences,
@@ -116,7 +116,7 @@ export const mergePersonalSecrets = (rawSecrets: SecretV3Raw[]) => {
};
export const useGetProjectSecrets = ({
workspaceId,
projectId,
environment,
secretPath,
viewSecretValue,
@@ -135,14 +135,14 @@ export const useGetProjectSecrets = ({
useQuery({
...options,
// wait for all values to be available
enabled: Boolean(workspaceId && environment) && (options?.enabled ?? true),
enabled: Boolean(projectId && environment) && (options?.enabled ?? true),
queryKey: secretKeys.getProjectSecret({
workspaceId,
projectId,
environment,
secretPath,
viewSecretValue
}),
queryFn: () => fetchProjectSecrets({ workspaceId, environment, secretPath, viewSecretValue }),
queryFn: () => fetchProjectSecrets({ projectId, environment, secretPath, viewSecretValue }),
select: useCallback(
(data: Awaited<ReturnType<typeof fetchProjectSecrets>>) => mergePersonalSecrets(data.secrets),
[]
@@ -150,7 +150,7 @@ export const useGetProjectSecrets = ({
});
export const useGetProjectSecretsAllEnv = ({
workspaceId,
projectId,
envs,
secretPath
}: TGetProjectSecretsAllEnvDTO) => {
@@ -159,11 +159,11 @@ export const useGetProjectSecretsAllEnv = ({
const secrets = useQueries({
queries: envs.map((environment) => ({
queryKey: secretKeys.getProjectSecret({
workspaceId,
projectId,
environment,
secretPath
}),
enabled: Boolean(workspaceId && environment),
enabled: Boolean(projectId && environment),
onError: (error: unknown) => {
if (axios.isAxiosError(error) && !isErrorHandled) {
const { message, requestId } = error.response?.data as {
@@ -187,7 +187,7 @@ export const useGetProjectSecretsAllEnv = ({
setIsErrorHandled.on();
}
},
queryFn: () => fetchProjectSecrets({ workspaceId, environment, secretPath }),
queryFn: () => fetchProjectSecrets({ projectId, environment, secretPath }),
staleTime: 60 * 1000,
// eslint-disable-next-line react-hooks/rules-of-hooks
select: useCallback(
@@ -270,7 +270,7 @@ export const useGetSecretAccessList = (dto: TGetSecretAccessListDTO) =>
users: SecretAccessListEntry[];
}>(`/api/v1/secrets/${dto.secretKey}/access-list`, {
params: {
workspaceId: dto.workspaceId,
projectId: dto.projectId,
environment: dto.environment,
secretPath: dto.secretPath
}
@@ -287,11 +287,11 @@ const fetchSecretReferenceTree = async ({
environmentSlug
}: TGetSecretReferenceTreeDTO) => {
const { data } = await apiRequest.get<{ tree: TSecretReferenceTraceNode; value: string }>(
`/api/v3/secrets/raw/${secretKey}/secret-reference-tree`,
`/api/v4/secrets/${secretKey}/secret-reference-tree`,
{
params: {
secretPath,
workspaceId: projectId,
projectId,
environment: environmentSlug
}
}

View File

@@ -17,30 +17,6 @@ export type SecretReminderRecipient = {
};
id: string;
};
export type EncryptedSecret = {
id: string;
version: number;
workspace: string;
type: SecretType;
environment: string;
secretKeyCiphertext: string;
secretKeyIV: string;
secretKeyTag: string;
secretValueCiphertext: string;
secretValueIV: string;
secretValueTag: string;
secretValueHidden: boolean;
__v: number;
createdAt: string;
updatedAt: string;
skipMultilineEncoding?: boolean;
secretCommentCiphertext: string;
secretCommentIV: string;
secretCommentTag: string;
secretReminderRepeatDays?: number | null;
secretReminderNote?: string | null;
tags: WsTag[];
};
// both personal and shared secret stitched together for dashboard
export type SecretV3RawSanitized = {
@@ -76,7 +52,7 @@ export type SecretV3RawSanitized = {
export type SecretV3Raw = {
id: string;
_id: string;
workspace: string;
project: string;
environment: string;
version: number;
type: string;
@@ -113,7 +89,7 @@ export type SecretVersions = {
id: string;
secretId: string;
version: number;
workspace: string;
project: string;
type: SecretType;
isDeleted: boolean;
envId: string;
@@ -136,7 +112,7 @@ export type SecretVersions = {
// dto
export type TGetProjectSecretsKey = {
workspaceId: string;
projectId: string;
environment: string;
secretPath?: string;
includeImports?: boolean;
@@ -148,7 +124,7 @@ export type TGetProjectSecretsKey = {
export type TGetProjectSecretsDTO = TGetProjectSecretsKey;
export type TGetProjectSecretsAllEnvDTO = {
workspaceId: string;
projectId: string;
envs: string[];
folderId?: string;
secretPath?: string;
@@ -162,7 +138,7 @@ export type GetSecretVersionsDTO = {
};
export type TGetSecretAccessListDTO = {
workspaceId: string;
projectId: string;
environment: string;
secretPath: string;
secretKey: string;
@@ -174,14 +150,14 @@ export type TCreateSecretsV3DTO = {
secretComment: string;
skipMultilineEncoding?: boolean;
secretPath: string;
workspaceId: string;
projectId: string;
environment: string;
type: SecretType;
tagIds?: string[];
};
export type TUpdateSecretsV3DTO = {
workspaceId: string;
projectId: string;
environment: string;
secretPath: string;
type: SecretType;
@@ -198,7 +174,7 @@ export type TUpdateSecretsV3DTO = {
};
export type TDeleteSecretsV3DTO = {
workspaceId: string;
projectId: string;
environment: string;
type: SecretType;
secretPath: string;
@@ -207,7 +183,7 @@ export type TDeleteSecretsV3DTO = {
};
export type TCreateSecretBatchDTO = {
workspaceId: string;
projectId: string;
environment: string;
secretPath: string;
secrets: Array<{
@@ -224,7 +200,7 @@ export type TCreateSecretBatchDTO = {
};
export type TUpdateSecretBatchDTO = {
workspaceId: string;
projectId: string;
environment: string;
secretPath: string;
secrets: Array<{
@@ -241,7 +217,7 @@ export type TUpdateSecretBatchDTO = {
};
export type TDeleteSecretBatchDTO = {
workspaceId: string;
projectId: string;
environment: string;
secretPath: string;
secrets: Array<{
@@ -251,7 +227,6 @@ export type TDeleteSecretBatchDTO = {
};
export type TMoveSecretsDTO = {
projectSlug: string;
projectId: string;
sourceEnvironment: string;
sourceSecretPath: string;

View File

@@ -13,9 +13,9 @@ const serviceTokenKeys = {
getAllWorkspaceServiceToken: (workspaceID: string) => [{ workspaceID }, "service-tokens"] as const
};
const fetchWorkspaceServiceTokens = async (workspaceID: string) => {
const fetchWorkspaceServiceTokens = async (projectID: string) => {
const { data } = await apiRequest.get<{ serviceTokenData: ServiceToken[] }>(
`/api/v1/workspace/${workspaceID}/service-token-data`
`/api/v1/projects/${projectID}/service-token-data`
);
return data.serviceTokenData;

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace/query-keys";
import { projectKeys } from "../projects/query-keys";
import {
TCreateSshCaDTO,
TDeleteSshCaDTO,
@@ -28,7 +28,7 @@ export const useCreateSshCa = () => {
return ca;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshCas(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectSshCas(projectId) });
}
});
};
@@ -43,7 +43,7 @@ export const useUpdateSshCa = () => {
return ca;
},
onSuccess: ({ projectId }, { caId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshCas(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectSshCas(projectId) });
queryClient.invalidateQueries({ queryKey: sshCaKeys.getSshCaById(caId) });
}
});
@@ -59,7 +59,7 @@ export const useDeleteSshCa = () => {
return ca;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshCas(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectSshCas(projectId) });
}
});
};
@@ -76,7 +76,7 @@ export const useSignSshKey = () => {
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.allWorkspaceSshCertificates(projectId)
queryKey: projectKeys.allProjectSshCertificates(projectId)
});
}
});
@@ -94,7 +94,7 @@ export const useIssueSshCreds = () => {
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.allWorkspaceSshCertificates(projectId)
queryKey: projectKeys.allProjectSshCertificates(projectId)
});
}
});

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace/query-keys";
import { projectKeys } from "../projects/query-keys";
import { TCreateSshHostDTO, TDeleteSshHostDTO, TSshHost, TUpdateSshHostDTO } from "./types";
export const useCreateSshHost = () => {
@@ -13,7 +13,7 @@ export const useCreateSshHost = () => {
return host;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshHosts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectSshHosts(projectId) });
}
});
};
@@ -26,7 +26,7 @@ export const useUpdateSshHost = () => {
return host;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshHosts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectSshHosts(projectId) });
}
});
};
@@ -39,7 +39,7 @@ export const useDeleteSshHost = () => {
return host;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshHosts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectSshHosts(projectId) });
}
});
};

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace/query-keys";
import { projectKeys } from "../projects/query-keys";
import { sshHostGroupKeys } from "./queries";
import {
TCreateSshHostGroupDTO,
@@ -20,7 +20,7 @@ export const useCreateSshHostGroup = () => {
},
onSuccess: ({ projectId, id }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceSshHostGroups(projectId)
queryKey: projectKeys.getProjectSshHostGroups(projectId)
});
queryClient.invalidateQueries({
queryKey: sshHostGroupKeys.getSshHostGroupById(id)
@@ -41,10 +41,10 @@ export const useUpdateSshHostGroup = () => {
},
onSuccess: ({ projectId }, { sshHostGroupId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceSshHostGroups(projectId)
queryKey: projectKeys.getProjectSshHostGroups(projectId)
});
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceSshHosts(projectId)
queryKey: projectKeys.getProjectSshHosts(projectId)
});
queryClient.invalidateQueries({
queryKey: sshHostGroupKeys.getSshHostGroupById(sshHostGroupId)
@@ -64,10 +64,10 @@ export const useDeleteSshHostGroup = () => {
},
onSuccess: ({ projectId }, { sshHostGroupId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceSshHostGroups(projectId)
queryKey: projectKeys.getProjectSshHostGroups(projectId)
});
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceSshHosts(projectId)
queryKey: projectKeys.getProjectSshHosts(projectId)
});
queryClient.invalidateQueries({
queryKey: sshHostGroupKeys.getSshHostGroupById(sshHostGroupId)

View File

@@ -4,23 +4,21 @@ import { apiRequest } from "@app/config/request";
import { CreateTagDTO, DeleteTagDTO, UserWsTags, WsTag } from "./types";
const workspaceTags = {
getWsTags: (workspaceID: string) => ["workspace-tags", { workspaceID }] as const
const projectTags = {
getWsTags: (projectID: string) => ["project-tags", { projectID }] as const
};
const fetchWsTag = async (workspaceID: string) => {
const { data } = await apiRequest.get<{ workspaceTags: UserWsTags }>(
`/api/v1/workspace/${workspaceID}/tags`
);
const fetchWsTag = async (projectID: string) => {
const { data } = await apiRequest.get<{ tags: UserWsTags }>(`/api/v1/projects/${projectID}/tags`);
return data.workspaceTags;
return data.tags;
};
export const useGetWsTags = (workspaceID: string) => {
export const useGetWsTags = (projectID: string) => {
return useQuery({
queryKey: workspaceTags.getWsTags(workspaceID),
queryFn: () => fetchWsTag(workspaceID),
enabled: Boolean(workspaceID)
queryKey: projectTags.getWsTags(projectID),
queryFn: () => fetchWsTag(projectID),
enabled: Boolean(projectID)
});
};
@@ -28,18 +26,15 @@ export const useCreateWsTag = () => {
const queryClient = useQueryClient();
return useMutation<WsTag, object, CreateTagDTO>({
mutationFn: async ({ workspaceID, tagColor, tagSlug }) => {
const { data } = await apiRequest.post<{ workspaceTag: WsTag }>(
`/api/v1/workspace/${workspaceID}/tags`,
{
color: tagColor || "",
slug: tagSlug
}
);
return data.workspaceTag;
mutationFn: async ({ projectId: projectID, tagColor, tagSlug }) => {
const { data } = await apiRequest.post<{ tag: WsTag }>(`/api/v1/projects/${projectID}/tags`, {
color: tagColor || "",
slug: tagSlug
});
return data.tag;
},
onSuccess: (tagData) => {
queryClient.invalidateQueries({ queryKey: workspaceTags.getWsTags(tagData?.projectId) });
queryClient.invalidateQueries({ queryKey: projectTags.getWsTags(tagData?.projectId) });
}
});
};
@@ -49,13 +44,13 @@ export const useDeleteWsTag = () => {
return useMutation<WsTag, object, DeleteTagDTO>({
mutationFn: async ({ tagID, projectId }) => {
const { data } = await apiRequest.delete<{ workspaceTag: WsTag }>(
`/api/v1/workspace/${projectId}/tags/${tagID}`
const { data } = await apiRequest.delete<{ tag: WsTag }>(
`/api/v1/projects/${projectId}/tags/${tagID}`
);
return data.workspaceTag;
return data.tag;
},
onSuccess: (tagData) => {
queryClient.invalidateQueries({ queryKey: workspaceTags.getWsTags(tagData?.projectId) });
queryClient.invalidateQueries({ queryKey: projectTags.getWsTags(tagData?.projectId) });
}
});
};

View File

@@ -13,7 +13,7 @@ export type WsTag = {
export type WorkspaceTag = { id: string; name: string; slug: string };
export type CreateTagDTO = {
workspaceID: string;
projectId: string;
tagSlug: string;
tagColor: string;
};

View File

@@ -5,15 +5,15 @@ import { apiRequest } from "@app/config/request";
import { TrustedIp } from "./types";
const trustedIps = {
getTrustedIps: (workspaceId: string) => [{ workspaceId }, "trusted-ips"] as const
getTrustedIps: (projectId: string) => [{ projectId }, "trusted-ips"] as const
};
export const useGetTrustedIps = (workspaceId: string) => {
export const useGetTrustedIps = (projectId: string) => {
return useQuery({
queryKey: trustedIps.getTrustedIps(workspaceId),
queryKey: trustedIps.getTrustedIps(projectId),
queryFn: async () => {
const { data } = await apiRequest.get<{ trustedIps: TrustedIp[] }>(
`/api/v1/workspace/${workspaceId}/trusted-ips`
`/api/v1/projects/${projectId}/trusted-ips`
);
return data.trustedIps;
@@ -25,17 +25,17 @@ export const useAddTrustedIp = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async ({
workspaceId,
projectId,
ipAddress,
comment,
isActive
}: {
workspaceId: string;
projectId: string;
ipAddress: string;
comment?: string;
isActive: boolean;
}) => {
const { data } = await apiRequest.post(`/api/v1/workspace/${workspaceId}/trusted-ips`, {
const { data } = await apiRequest.post(`/api/v1/projects/${projectId}/trusted-ips`, {
ipAddress,
...(comment ? { comment } : {}),
isActive
@@ -44,7 +44,7 @@ export const useAddTrustedIp = () => {
return data;
},
onSuccess(_, dto) {
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.workspaceId) });
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.projectId) });
}
});
};
@@ -53,20 +53,20 @@ export const useUpdateTrustedIp = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async ({
workspaceId,
projectId,
trustedIpId,
ipAddress,
comment,
isActive
}: {
workspaceId: string;
projectId: string;
trustedIpId: string;
ipAddress: string;
comment?: string;
isActive: boolean;
}) => {
const { data } = await apiRequest.patch(
`/api/v1/workspace/${workspaceId}/trusted-ips/${trustedIpId}`,
`/api/v1/projects/${projectId}/trusted-ips/${trustedIpId}`,
{
ipAddress,
...(comment ? { comment } : {}),
@@ -77,7 +77,7 @@ export const useUpdateTrustedIp = () => {
return data;
},
onSuccess(_, dto) {
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.workspaceId) });
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.projectId) });
}
});
};
@@ -85,21 +85,15 @@ export const useUpdateTrustedIp = () => {
export const useDeleteTrustedIp = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async ({
workspaceId,
trustedIpId
}: {
workspaceId: string;
trustedIpId: string;
}) => {
mutationFn: async ({ projectId, trustedIpId }: { projectId: string; trustedIpId: string }) => {
const { data } = await apiRequest.delete(
`/api/v1/workspace/${workspaceId}/trusted-ips/${trustedIpId}`
`/api/v1/projects/${projectId}/trusted-ips/${trustedIpId}`
);
return data;
},
onSuccess(_, dto) {
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.workspaceId) });
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.projectId) });
}
});
};

View File

@@ -7,8 +7,19 @@ export type { GetAuthTokenAPI } from "./auth/types";
export type { IncidentContact } from "./incidentContacts/types";
export type { IntegrationAuth } from "./integrationAuth/types";
export type { TCloudIntegration, TIntegration } from "./integrations/types";
export type { UserWsKeyPair } from "./keys/types";
export type { Organization } from "./organization/types";
export type {
CreateEnvironmentDTO,
CreateWorkspaceDTO,
DeleteEnvironmentDTO,
DeleteWorkspaceDTO,
Project,
ProjectEnv,
ProjectTag,
ToggleAutoCapitalizationDTO,
UpdateEnvironmentDTO,
UpdateProjectDTO
} from "./projects/types";
export type { TSecretApprovalPolicy } from "./secretApproval/types";
export type {
TGetSecretApprovalRequestDetails,
@@ -29,18 +40,6 @@ export type { SubscriptionPlan } from "./subscriptions/types";
export type { WsTag } from "./tags/types";
export type { OrgUser, TWorkspaceUser, User, UserEnc } from "./users/types";
export type { TWebhook } from "./webhooks/types";
export type {
CreateEnvironmentDTO,
CreateWorkspaceDTO,
DeleteEnvironmentDTO,
DeleteWorkspaceDTO,
ToggleAutoCapitalizationDTO,
UpdateEnvironmentDTO,
UpdateProjectDTO,
Workspace,
WorkspaceEnv,
WorkspaceTag
} from "./workspace/types";
export enum ApiErrorTypes {
ValidationError = "ValidationFailure",

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import { userKeys } from "./query-keys";
import { AddUserToWsDTONonE2EE } from "./types";
@@ -11,14 +11,14 @@ export const useAddUserToWsNonE2EE = () => {
return useMutation<object, object, AddUserToWsDTONonE2EE>({
mutationFn: async ({ projectId, usernames, roleSlugs }) => {
const { data } = await apiRequest.post(`/api/v2/workspace/${projectId}/memberships`, {
const { data } = await apiRequest.post(`/api/v1/projects/${projectId}/memberships`, {
usernames,
roleSlugs
});
return data;
},
onSuccess: (_, { orgId, projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceUsers(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectUsers(projectId) });
queryClient.invalidateQueries({
queryKey: userKeys.allOrgMembershipProjectMemberships(orgId)
});

View File

@@ -8,9 +8,9 @@ import { queryClient as qc } from "@app/hooks/api/reactQuery";
import { APIKeyDataV2 } from "../apiKeys/types";
import { MfaMethod } from "../auth/types";
import { TGroupWithProjectMemberships } from "../groups/types";
import { projectKeys } from "../projects";
import { setAuthToken } from "../reactQuery";
import { subscriptionQueryKeys } from "../subscriptions/queries";
import { workspaceKeys } from "../workspace";
import { userKeys } from "./query-keys";
import {
AddUserToOrgDTO,
@@ -197,10 +197,10 @@ export const useAddUsersToOrg = () => {
projects?.forEach((project) => {
if (project.slug) {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceGroupMemberships(project.slug)
queryKey: projectKeys.getProjectGroupMemberships(project.slug)
});
}
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceUsers(project.id) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectUsers(project.id) });
});
}
});

View File

@@ -1,5 +1,5 @@
import { MfaMethod } from "../auth/types";
import { ProjectType, ProjectUserMembershipTemporaryMode } from "../workspace/types";
import { ProjectType, ProjectUserMembershipTemporaryMode } from "../projects/types";
export enum AuthMethod {
EMAIL = "email",

View File

@@ -13,8 +13,8 @@ export const useCreateWebhook = () => {
const { data } = await apiRequest.post("/api/v1/webhooks", dto);
return data;
},
onSuccess: (_, { workspaceId }) => {
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(workspaceId) });
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(projectId) });
}
});
};
@@ -27,11 +27,11 @@ export const useTestWebhook = () => {
const { data } = await apiRequest.post(`/api/v1/webhooks/${webhookId}/test`);
return data;
},
onSuccess: (_, { workspaceId }) => {
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(workspaceId) });
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(projectId) });
},
onError: (_, { workspaceId }) => {
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(workspaceId) });
onError: (_, { projectId }) => {
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(projectId) });
}
});
};
@@ -46,8 +46,8 @@ export const useUpdateWebhook = () => {
});
return data;
},
onSuccess: (_, { workspaceId }) => {
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(workspaceId) });
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(projectId) });
}
});
};
@@ -60,8 +60,8 @@ export const useDeleteWebhook = () => {
const { data } = await apiRequest.delete(`/api/v1/webhooks/${dto.webhookId}`);
return data;
},
onSuccess: (_, { workspaceId }) => {
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(workspaceId) });
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({ queryKey: queryKeys.getWebhooks(projectId) });
}
});
};

View File

@@ -8,19 +8,19 @@ export const queryKeys = {
getWebhooks: (workspaceId: string) => ["webhooks", { workspaceId }]
};
const fetchWebhooks = async (workspaceId: string) => {
const fetchWebhooks = async (projectId: string) => {
const { data } = await apiRequest.get<{ webhooks: TWebhook[] }>("/api/v1/webhooks", {
params: {
workspaceId
projectId
}
});
return data.webhooks;
};
export const useGetWebhooks = (workspaceId: string) =>
export const useGetWebhooks = (projectId: string) =>
useQuery({
queryKey: queryKeys.getWebhooks(workspaceId),
queryFn: () => fetchWebhooks(workspaceId),
enabled: Boolean(workspaceId)
queryKey: queryKeys.getWebhooks(projectId),
queryFn: () => fetchWebhooks(projectId),
enabled: Boolean(projectId)
});

View File

@@ -23,7 +23,7 @@ export type TWebhook = {
};
export type TCreateWebhookDto = {
workspaceId: string;
projectId: string;
environment: string;
webhookUrl: string;
webhookSecretKey?: string;
@@ -33,16 +33,16 @@ export type TCreateWebhookDto = {
export type TUpdateWebhookDto = {
webhookId: string;
workspaceId: string;
projectId: string;
isDisabled?: boolean;
};
export type TDeleteWebhookDto = {
webhookId: string;
workspaceId: string;
projectId: string;
};
export type TTestWebhookDTO = {
webhookId: string;
workspaceId: string;
projectId: string;
};

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace/query-keys";
import { projectKeys } from "../projects/query-keys";
import { workflowIntegrationKeys } from "./queries";
import {
TCheckMicrosoftTeamsIntegrationInstallationStatusDTO,
@@ -118,15 +118,15 @@ export const useUpdateProjectWorkflowIntegrationConfig = () => {
return useMutation({
mutationFn: async (dto: TUpdateProjectWorkflowIntegrationConfigDTO) => {
const { data } = await apiRequest.put(
`/api/v1/workspace/${dto.workspaceId}/workflow-integration`,
`/api/v1/projects/${dto.projectId}/workflow-integration`,
dto
);
return data;
},
onSuccess: (_, { workspaceId, integration }) => {
onSuccess: (_, { projectId: workspaceId, integration }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceWorkflowIntegrationConfig(workspaceId, integration)
queryKey: projectKeys.getProjectWorkflowIntegrationConfig(workspaceId, integration)
});
}
});
@@ -138,14 +138,14 @@ export const useDeleteProjectWorkflowIntegration = () => {
return useMutation({
mutationFn: async (dto: TDeleteProjectWorkflowIntegrationDTO) => {
const { data } = await apiRequest.delete(
`/api/v1/workspace/${dto.projectId}/workflow-integration/${dto.integration}/${dto.integrationId}`
`/api/v1/projects/${dto.projectId}/workflow-integration/${dto.integration}/${dto.integrationId}`
);
return data;
},
onSuccess: (_, { projectId, integration }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceWorkflowIntegrationConfig(projectId, integration)
queryKey: projectKeys.getProjectWorkflowIntegrationConfig(projectId, integration)
});
}
});

Some files were not shown because too many files have changed in this diff Show More