Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

featL completed v1 routes for projects

=cd2a39b374b7
diff --git a/backend/src/ee/routes/v2/project-role-router.ts b/backend/src/ee/routes/v2/depreciated-project-role-router.ts
similarity index 98%
rename from backend/src/ee/routes/v2/project-role-router.ts
rename to backend/src/ee/routes/v2/depreciated-project-role-router.ts
index 5389293164..fd61acc361 100644
--- a/backend/src/ee/routes/v2/project-role-router.ts
+++ b/backend/src/ee/routes/v2/depreciated-project-role-router.ts
@@ -12,7 +12,7 @@ import { SanitizedRoleSchema } from "@app/server/routes/sanitizedSchemas";
import { AuthMode } from "@app/services/auth/auth-type";
import { ProjectRoleServiceIdentifierType } from "@app/services/project-role/project-role-types";
-export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
+export const registerDepreciatedProjectRoleRouter = async (server: FastifyZodProvider) => {
server.route({
method: "POST",
url: "/:projectId/roles",
diff --git a/backend/src/ee/routes/v2/index.ts b/backend/src/ee/routes/v2/index.ts
index e082773dd6..9f6aa0511f 100644
--- a/backend/src/ee/routes/v2/index.ts
+++ b/backend/src/ee/routes/v2/index.ts
@@ -9,13 +9,13 @@ import {
import { registerGatewayV2Router } from "./gateway-router";
import { registerIdentityProjectAdditionalPrivilegeRouter } from "./identity-project-additional-privilege-router";
-import { registerProjectRoleRouter } from "./project-role-router";
+import { registerDepreciatedProjectRoleRouter } from "./depreciated-project-role-router";
export const registerV2EERoutes = async (server: FastifyZodProvider) => {
- // org role starts with organization
await server.register(
async (projectRouter) => {
- await projectRouter.register(registerProjectRoleRouter);
+ // this has been depreciated and moved to /api/v1/projects
+ await projectRouter.register(registerDepreciatedProjectRoleRouter);
},
{ prefix: "/workspace" }
);
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 154634d41e..ba799ec366 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -711,13 +711,13 @@ export const PROJECTS = {
template: "The name of the project template, if specified, to apply to this project."
},
DELETE: {
- workspaceId: "The ID of the project to delete."
+ projectId: "The ID of the project to delete."
},
GET: {
- workspaceId: "The ID of the project."
+ projectId: "The ID of the project."
},
UPDATE: {
- workspaceId: "The ID of the project to update.",
+ projectId: "The ID of the project to update.",
name: "The new name of the project.",
projectDescription: "An optional description label for the project.",
autoCapitalization: "Disable or enable auto-capitalization for the project.",
@@ -729,7 +729,7 @@ export const PROJECTS = {
secretDetectionIgnoreValues: "The list of secret values to ignore for secret detection."
},
GET_KEY: {
- workspaceId: "The ID of the project to get the key from."
+ projectId: "The ID of the project to get the key from."
},
GET_SNAPSHOTS: {
projectId: "The ID of the project to get snapshots from.",
@@ -759,10 +759,10 @@ export const PROJECTS = {
projectId: "The ID of the project to list groups for."
},
LIST_INTEGRATION: {
- workspaceId: "The ID of the project to list integrations for."
+ projectId: "The ID of the project to list integrations for."
},
LIST_INTEGRATION_AUTHORIZATION: {
- workspaceId: "The ID of the project to list integration auths for."
+ projectId: "The ID of the project to list integration auths for."
},
LIST_SSH_CAS: {
projectId: "The ID of the project to list SSH CAs for."
@@ -815,15 +815,15 @@ export const PROJECT_USERS = {
usernames: "A list of usernames to remove from the project."
},
GET_USER_MEMBERSHIPS: {
- workspaceId: "The ID of the project to get memberships from."
+ projectId: "The ID of the project to get memberships from."
},
GET_USER_MEMBERSHIP: {
- workspaceId: "The ID of the project to get memberships from.",
+ projectId: "The ID of the project to get memberships from.",
membershipId: "The ID of the user's project membership.",
username: "The username to get project membership of. Email is the default username."
},
UPDATE_USER_MEMBERSHIP: {
- workspaceId: "The ID of the project to update the membership for.",
+ projectId: "The ID of the project to update the membership for.",
membershipId: "The ID of the membership to update.",
roles: "A list of roles to update the membership to."
}
@@ -877,24 +877,24 @@ export const PROJECT_IDENTITIES = {
export const ENVIRONMENTS = {
CREATE: {
- workspaceId: "The ID of the project to create the environment in.",
+ projectId: "The ID of the project to create the environment in.",
name: "The name of the environment to create.",
slug: "The slug of the environment to create.",
position: "The position of the environment. The lowest number will be displayed as the first environment."
},
UPDATE: {
- workspaceId: "The ID of the project to update the environment in.",
+ projectId: "The ID of the project to update the environment in.",
id: "The ID of the environment to update.",
name: "The new name of the environment.",
slug: "The new slug of the environment.",
position: "The new position of the environment. The lowest number will be displayed as the first environment."
},
DELETE: {
- workspaceId: "The ID of the project to delete the environment from.",
+ projectId: "The ID of the project to delete the environment from.",
id: "The ID of the environment to delete."
},
GET: {
- workspaceId: "The ID of the project the environment belongs to.",
+ projectId: "The ID of the project the environment belongs to.",
id: "The ID of the environment to fetch."
}
} as const;
diff --git a/backend/src/server/routes/v1/depreciated-project-env-router.ts b/backend/src/server/routes/v1/depreciated-project-env-router.ts
new file mode 100644
index 0000000000..b03b61664c
--- /dev/null
+++ b/backend/src/server/routes/v1/depreciated-project-env-router.ts
@@ -0,0 +1,298 @@
+import { z } from "zod";
+
+import { ProjectEnvironmentsSchema } from "@app/db/schemas";
+import { EventType } from "@app/ee/services/audit-log/audit-log-types";
+import { ApiDocsTags, ENVIRONMENTS } from "@app/lib/api-docs";
+import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
+import { slugSchema } from "@app/server/lib/schemas";
+import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
+import { AuthMode } from "@app/services/auth/auth-type";
+
+export const registerDepreciatedProjectEnvRouter = async (server: FastifyZodProvider) => {
+ server.route({
+ method: "GET",
+ url: "/:workspaceId/environments/:envId",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Environments],
+ description: "Get Environment",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ // NOTE(daniel): workspaceId isn't used, but we need to keep it for backwards compatibility. The endpoint defined below, uses no project ID, and is takes a pure environment ID.
+ workspaceId: z.string().trim().describe(ENVIRONMENTS.GET.projectId),
+ envId: z.string().trim().describe(ENVIRONMENTS.GET.id)
+ }),
+ response: {
+ 200: z.object({
+ environment: ProjectEnvironmentsSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const environment = await server.services.projectEnv.getEnvironmentById({
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ actorAuthMethod: req.permission.authMethod,
+ id: req.params.envId
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: environment.projectId,
+ event: {
+ type: EventType.GET_ENVIRONMENT,
+ metadata: {
+ id: environment.id
+ }
+ }
+ });
+
+ return { environment };
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/environments/:envId",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Environments],
+ description: "Get Environment by ID",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ envId: z.string().trim().describe(ENVIRONMENTS.GET.id)
+ }),
+ response: {
+ 200: z.object({
+ environment: ProjectEnvironmentsSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const environment = await server.services.projectEnv.getEnvironmentById({
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ actorAuthMethod: req.permission.authMethod,
+ id: req.params.envId
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: environment.projectId,
+ event: {
+ type: EventType.GET_ENVIRONMENT,
+ metadata: {
+ id: environment.id
+ }
+ }
+ });
+
+ return { environment };
+ }
+ });
+
+ server.route({
+ method: "POST",
+ url: "/:workspaceId/environments",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Environments],
+ description: "Create environment",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ workspaceId: z.string().trim().describe(ENVIRONMENTS.CREATE.projectId)
+ }),
+ body: z.object({
+ name: z.string().trim().describe(ENVIRONMENTS.CREATE.name),
+ position: z.number().min(1).optional().describe(ENVIRONMENTS.CREATE.position),
+ slug: slugSchema({ max: 64 }).describe(ENVIRONMENTS.CREATE.slug)
+ }),
+ response: {
+ 200: z.object({
+ message: z.string(),
+ workspace: z.string(),
+ environment: ProjectEnvironmentsSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const environment = await server.services.projectEnv.createEnvironment({
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ actorAuthMethod: req.permission.authMethod,
+ projectId: req.params.workspaceId,
+ ...req.body
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: environment.projectId,
+ event: {
+ type: EventType.CREATE_ENVIRONMENT,
+ metadata: {
+ name: environment.name,
+ slug: environment.slug
+ }
+ }
+ });
+ return {
+ message: "Successfully created new environment",
+ workspace: req.params.workspaceId,
+ environment
+ };
+ }
+ });
+
+ server.route({
+ method: "PATCH",
+ url: "/:workspaceId/environments/:id",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Environments],
+ description: "Update environment",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ workspaceId: z.string().trim().describe(ENVIRONMENTS.UPDATE.projectId),
+ id: z.string().trim().describe(ENVIRONMENTS.UPDATE.id)
+ }),
+ body: z.object({
+ slug: slugSchema({ max: 64 }).optional().describe(ENVIRONMENTS.UPDATE.slug),
+ name: z.string().trim().optional().describe(ENVIRONMENTS.UPDATE.name),
+ position: z.number().optional().describe(ENVIRONMENTS.UPDATE.position)
+ }),
+ response: {
+ 200: z.object({
+ message: z.string(),
+ workspace: z.string(),
+ environment: ProjectEnvironmentsSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const { environment, old } = await server.services.projectEnv.updateEnvironment({
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId,
+ id: req.params.id,
+ ...req.body
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: environment.projectId,
+ event: {
+ type: EventType.UPDATE_ENVIRONMENT,
+ metadata: {
+ oldName: old.name,
+ oldSlug: old.slug,
+ oldPos: old.position,
+ newName: environment.name,
+ newSlug: environment.slug,
+ newPos: environment.position
+ }
+ }
+ });
+
+ return {
+ message: "Successfully updated environment",
+ workspace: req.params.workspaceId,
+ environment
+ };
+ }
+ });
+
+ server.route({
+ method: "DELETE",
+ url: "/:workspaceId/environments/:id",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Environments],
+ description: "Delete environment",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ workspaceId: z.string().trim().describe(ENVIRONMENTS.DELETE.projectId),
+ id: z.string().trim().describe(ENVIRONMENTS.DELETE.id)
+ }),
+ response: {
+ 200: z.object({
+ message: z.string(),
+ workspace: z.string(),
+ environment: ProjectEnvironmentsSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const environment = await server.services.projectEnv.deleteEnvironment({
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId,
+ id: req.params.id
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: environment.projectId,
+ event: {
+ type: EventType.DELETE_ENVIRONMENT,
+ metadata: {
+ slug: environment.slug,
+ name: environment.name
+ }
+ }
+ });
+
+ return {
+ message: "Successfully deleted environment",
+ workspace: req.params.workspaceId,
+ environment
+ };
+ }
+ });
+};
diff --git a/backend/src/server/routes/v1/depreciated-project-membership-router.ts b/backend/src/server/routes/v1/depreciated-project-membership-router.ts
new file mode 100644
index 0000000000..63d4d6dcd9
--- /dev/null
+++ b/backend/src/server/routes/v1/depreciated-project-membership-router.ts
@@ -0,0 +1,378 @@
+import { z } from "zod";
+
+import {
+ OrgMembershipsSchema,
+ ProjectMembershipsSchema,
+ ProjectUserMembershipRolesSchema,
+ UserEncryptionKeysSchema,
+ UsersSchema
+} from "@app/db/schemas";
+import { EventType } from "@app/ee/services/audit-log/audit-log-types";
+import { ApiDocsTags, PROJECT_USERS } from "@app/lib/api-docs";
+import { ms } from "@app/lib/ms";
+import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
+import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
+import { AuthMode } from "@app/services/auth/auth-type";
+import { ProjectUserMembershipTemporaryMode } from "@app/services/project-membership/project-membership-types";
+
+export const registerDepreciatedProjectMembershipRouter = async (server: FastifyZodProvider) => {
+ server.route({
+ method: "GET",
+ url: "/:workspaceId/memberships",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.ProjectUsers],
+ description: "Return project user memberships",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ workspaceId: z.string().trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIPS.projectId)
+ }),
+ response: {
+ 200: z.object({
+ memberships: ProjectMembershipsSchema.extend({
+ user: UsersSchema.pick({
+ email: true,
+ firstName: true,
+ lastName: true,
+ id: true,
+ username: true
+ }).merge(UserEncryptionKeysSchema.pick({ publicKey: true })),
+ roles: z.array(
+ z.object({
+ id: z.string(),
+ role: z.string(),
+ customRoleId: z.string().optional().nullable(),
+ customRoleName: z.string().optional().nullable(),
+ customRoleSlug: z.string().optional().nullable(),
+ isTemporary: z.boolean(),
+ temporaryMode: z.string().optional().nullable(),
+ temporaryRange: z.string().nullable().optional(),
+ temporaryAccessStartTime: z.date().nullable().optional(),
+ temporaryAccessEndTime: z.date().nullable().optional()
+ })
+ )
+ })
+ .omit({ updatedAt: true })
+ .array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const memberships = await server.services.projectMembership.getProjectMemberships({
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId
+ });
+ return { memberships };
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/:workspaceId/memberships/:membershipId",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ description: "Return project user membership",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ workspaceId: z.string().min(1).trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP.projectId),
+ membershipId: z.string().min(1).trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP.membershipId)
+ }),
+ response: {
+ 200: z.object({
+ membership: ProjectMembershipsSchema.extend({
+ user: UsersSchema.pick({
+ email: true,
+ firstName: true,
+ lastName: true,
+ id: true,
+ username: true
+ }).merge(UserEncryptionKeysSchema.pick({ publicKey: true })),
+ roles: z.array(
+ z.object({
+ id: z.string(),
+ role: z.string(),
+ customRoleId: z.string().optional().nullable(),
+ customRoleName: z.string().optional().nullable(),
+ customRoleSlug: z.string().optional().nullable(),
+ isTemporary: z.boolean(),
+ temporaryMode: z.string().optional().nullable(),
+ temporaryRange: z.string().nullable().optional(),
+ temporaryAccessStartTime: z.date().nullable().optional(),
+ temporaryAccessEndTime: z.date().nullable().optional()
+ })
+ )
+ }).omit({ updatedAt: true })
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const membership = await server.services.projectMembership.getProjectMembershipById({
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId,
+ id: req.params.membershipId
+ });
+ return { membership };
+ }
+ });
+
+ server.route({
+ method: "POST",
+ url: "/:workspaceId/memberships/details",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.ProjectUsers],
+ description: "Return project user memberships",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ workspaceId: z.string().min(1).trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP.projectId)
+ }),
+ body: z.object({
+ username: z.string().min(1).trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP.username)
+ }),
+ response: {
+ 200: z.object({
+ membership: ProjectMembershipsSchema.extend({
+ user: UsersSchema.pick({
+ email: true,
+ firstName: true,
+ lastName: true,
+ id: true
+ }).merge(UserEncryptionKeysSchema.pick({ publicKey: true })),
+ roles: z.array(
+ z.object({
+ id: z.string(),
+ role: z.string(),
+ customRoleId: z.string().optional().nullable(),
+ customRoleName: z.string().optional().nullable(),
+ customRoleSlug: z.string().optional().nullable(),
+ isTemporary: z.boolean(),
+ temporaryMode: z.string().optional().nullable(),
+ temporaryRange: z.string().nullable().optional(),
+ temporaryAccessStartTime: z.date().nullable().optional(),
+ temporaryAccessEndTime: z.date().nullable().optional()
+ })
+ )
+ }).omit({ createdAt: true, updatedAt: true })
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const membership = await server.services.projectMembership.getProjectMembershipByUsername({
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId,
+ username: req.body.username
+ });
+ return { membership };
+ }
+ });
+
+ server.route({
+ method: "POST",
+ url: "/:workspaceId/memberships",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ params: z.object({
+ workspaceId: z.string().trim()
+ }),
+ body: z.object({
+ members: z
+ .object({
+ orgMembershipId: z.string().trim(),
+ workspaceEncryptedKey: z.string().trim(),
+ workspaceEncryptedNonce: z.string().trim()
+ })
+ .array()
+ .min(1)
+ }),
+ response: {
+ 200: z.object({
+ success: z.boolean(),
+ data: OrgMembershipsSchema.array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const data = await server.services.projectMembership.addUsersToProject({
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId,
+ members: req.body.members
+ });
+
+ await server.services.auditLog.createAuditLog({
+ projectId: req.params.workspaceId,
+ ...req.auditLogInfo,
+ event: {
+ type: EventType.ADD_BATCH_WORKSPACE_MEMBER,
+ metadata: data.map(({ userId }) => ({
+ userId: userId || "",
+ email: ""
+ }))
+ }
+ });
+
+ return { data, success: true };
+ }
+ });
+
+ server.route({
+ method: "PATCH",
+ url: "/:workspaceId/memberships/:membershipId",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.ProjectUsers],
+ description: "Update project user membership",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ workspaceId: z.string().trim().describe(PROJECT_USERS.UPDATE_USER_MEMBERSHIP.projectId),
+ membershipId: z.string().trim().describe(PROJECT_USERS.UPDATE_USER_MEMBERSHIP.membershipId)
+ }),
+ body: z.object({
+ roles: z
+ .array(
+ z.union([
+ z.object({
+ role: z.string(),
+ isTemporary: z.literal(false).default(false)
+ }),
+ z.object({
+ role: z.string(),
+ isTemporary: z.literal(true),
+ temporaryMode: z.nativeEnum(ProjectUserMembershipTemporaryMode),
+ temporaryRange: z.string().refine((val) => ms(val) > 0, "Temporary range must be a positive number"),
+ temporaryAccessStartTime: z.string().datetime()
+ })
+ ])
+ )
+ .min(1)
+ .refine((data) => data.some(({ isTemporary }) => !isTemporary), "At least one long lived role is required")
+ .describe(PROJECT_USERS.UPDATE_USER_MEMBERSHIP.roles)
+ }),
+ response: {
+ 200: z.object({
+ roles: ProjectUserMembershipRolesSchema.array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const roles = await server.services.projectMembership.updateProjectMembership({
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId,
+ membershipId: req.params.membershipId,
+ roles: req.body.roles
+ });
+
+ // await server.services.auditLog.createAuditLog({
+ // ...req.auditLogInfo,
+ // projectId: req.params.workspaceId,
+ // event: {
+ // type: EventType.UPDATE_USER_WORKSPACE_ROLE,
+ // metadata: {
+ // userId: membership.userId,
+ // newRole: req.body.role,
+ // oldRole: membership.role,
+ // email: ""
+ // }
+ // }
+ // });
+ return { roles };
+ }
+ });
+
+ server.route({
+ method: "DELETE",
+ url: "/:workspaceId/memberships/:membershipId",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ description: "Delete project user membership",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ workspaceId: z.string().trim(),
+ membershipId: z.string().trim()
+ }),
+ response: {
+ 200: z.object({
+ membership: ProjectMembershipsSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const membership = await server.services.projectMembership.deleteProjectMembership({
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId,
+ membershipId: req.params.membershipId
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: req.params.workspaceId,
+ event: {
+ type: EventType.REMOVE_WORKSPACE_MEMBER,
+ metadata: {
+ userId: membership.userId,
+ email: ""
+ }
+ }
+ });
+ return { membership };
+ }
+ });
+};
diff --git a/backend/src/server/routes/v1/depreciated-project-router.ts b/backend/src/server/routes/v1/depreciated-project-router.ts
new file mode 100644
index 0000000000..89fb93662d
--- /dev/null
+++ b/backend/src/server/routes/v1/depreciated-project-router.ts
@@ -0,0 +1,724 @@
+import { z } from "zod";
+
+import {
+ IntegrationsSchema,
+ ProjectRolesSchema,
+ ProjectSlackConfigsSchema,
+ ProjectSshConfigsSchema,
+ ProjectType,
+ SortDirection
+} from "@app/db/schemas";
+import { ProjectMicrosoftTeamsConfigsSchema } from "@app/db/schemas/project-microsoft-teams-configs";
+import { EventType } from "@app/ee/services/audit-log/audit-log-types";
+import { ApiDocsTags, PROJECTS } from "@app/lib/api-docs";
+import { CharacterType, characterValidator } from "@app/lib/validator/validate-string";
+import { re2Validator } from "@app/lib/zod";
+import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
+import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
+import { AuthMode } from "@app/services/auth/auth-type";
+import { validateMicrosoftTeamsChannelsSchema } from "@app/services/microsoft-teams/microsoft-teams-fns";
+import { ProjectFilterType, SearchProjectSortBy } from "@app/services/project/project-types";
+import { validateSlackChannelsField } from "@app/services/slack/slack-auth-validators";
+import { WorkflowIntegration } from "@app/services/workflow-integration/workflow-integration-types";
+
+import { integrationAuthPubSchema, SanitizedProjectSchema } from "../sanitizedSchemas";
+
+const projectWithEnv = SanitizedProjectSchema.merge(
+ z.object({
+ _id: z.string(),
+ environments: z.object({ name: z.string(), slug: z.string(), id: z.string() }).array()
+ })
+);
+
+export const registerDepreciatedProjectRouter = async (server: FastifyZodProvider) => {
+ server.route({
+ method: "GET",
+ url: "/",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ querystring: z.object({
+ includeRoles: z
+ .enum(["true", "false"])
+ .default("false")
+ .transform((value) => value === "true"),
+ type: z.nativeEnum(ProjectType).optional()
+ }),
+ response: {
+ 200: z.object({
+ workspaces: projectWithEnv
+ .extend({
+ roles: ProjectRolesSchema.array().optional()
+ })
+ .array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const workspaces = await server.services.project.getProjects({
+ includeRoles: req.query.includeRoles,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ type: req.query.type
+ });
+ return { workspaces };
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/:workspaceId",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Projects],
+ description: "Get project",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ workspaceId: z.string().trim().describe(PROJECTS.GET.workspaceId)
+ }),
+ response: {
+ 200: z.object({
+ workspace: projectWithEnv.optional()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.SERVICE_TOKEN, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const workspace = await server.services.project.getAProject({
+ filter: {
+ type: ProjectFilterType.ID,
+ projectId: req.params.workspaceId
+ },
+ actorAuthMethod: req.permission.authMethod,
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId
+ });
+ return { workspace };
+ }
+ });
+
+ server.route({
+ method: "DELETE",
+ url: "/:workspaceId",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Projects],
+ description: "Delete project",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ workspaceId: z.string().trim().describe(PROJECTS.DELETE.projectId)
+ }),
+ response: {
+ 200: z.object({
+ workspace: SanitizedProjectSchema.optional()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const workspace = await server.services.project.deleteProject({
+ filter: {
+ type: ProjectFilterType.ID,
+ projectId: req.params.workspaceId
+ },
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ orgId: req.permission.orgId,
+ projectId: req.params.workspaceId,
+ event: {
+ type: EventType.DELETE_PROJECT,
+ metadata: workspace
+ }
+ });
+
+ return { workspace };
+ }
+ });
+
+ server.route({
+ method: "PATCH",
+ url: "/:workspaceId",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Projects],
+ description: "Update project",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ workspaceId: z.string().trim().describe(PROJECTS.UPDATE.workspaceId)
+ }),
+ body: z.object({
+ name: z
+ .string()
+ .trim()
+ .max(64, { message: "Name must be 64 or fewer characters" })
+ .optional()
+ .describe(PROJECTS.UPDATE.name),
+ description: z
+ .string()
+ .trim()
+ .max(256, { message: "Description must be 256 or fewer characters" })
+ .optional()
+ .describe(PROJECTS.UPDATE.projectDescription),
+ autoCapitalization: z.boolean().optional().describe(PROJECTS.UPDATE.autoCapitalization),
+ hasDeleteProtection: z.boolean().optional().describe(PROJECTS.UPDATE.hasDeleteProtection),
+ slug: z
+ .string()
+ .trim()
+ .max(64, { message: "Slug must be 64 characters or fewer" })
+ .refine(re2Validator(/^[a-z0-9]+(?:[_-][a-z0-9]+)*$/), {
+ message:
+ "Project slug can only contain lowercase letters and numbers, with optional single hyphens (-) or underscores (_) between words. Cannot start or end with a hyphen or underscore."
+ })
+ .optional()
+ .describe(PROJECTS.UPDATE.slug),
+ secretSharing: z.boolean().optional().describe(PROJECTS.UPDATE.secretSharing),
+ showSnapshotsLegacy: z.boolean().optional().describe(PROJECTS.UPDATE.showSnapshotsLegacy),
+ defaultProduct: z.nativeEnum(ProjectType).optional().describe(PROJECTS.UPDATE.defaultProduct),
+ secretDetectionIgnoreValues: z
+ .array(z.string())
+ .optional()
+ .describe(PROJECTS.UPDATE.secretDetectionIgnoreValues)
+ }),
+ response: {
+ 200: z.object({
+ workspace: SanitizedProjectSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const workspace = await server.services.project.updateProject({
+ filter: {
+ type: ProjectFilterType.ID,
+ projectId: req.params.workspaceId
+ },
+ update: {
+ name: req.body.name,
+ description: req.body.description,
+ autoCapitalization: req.body.autoCapitalization,
+ defaultProduct: req.body.defaultProduct,
+ hasDeleteProtection: req.body.hasDeleteProtection,
+ slug: req.body.slug,
+ secretSharing: req.body.secretSharing,
+ showSnapshotsLegacy: req.body.showSnapshotsLegacy,
+ secretDetectionIgnoreValues: req.body.secretDetectionIgnoreValues
+ },
+ actorAuthMethod: req.permission.authMethod,
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ orgId: req.permission.orgId,
+ projectId: req.params.workspaceId,
+ event: {
+ type: EventType.UPDATE_PROJECT,
+ metadata: req.body
+ }
+ });
+
+ return {
+ workspace
+ };
+ }
+ });
+
+ server.route({
+ method: "PUT",
+ url: "/:workspaceSlug/audit-logs-retention",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ params: z.object({
+ workspaceSlug: z.string().trim()
+ }),
+ body: z.object({
+ auditLogsRetentionDays: z.number().min(0)
+ }),
+ response: {
+ 200: z.object({
+ message: z.string(),
+ workspace: SanitizedProjectSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const workspace = await server.services.project.updateAuditLogsRetention({
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ workspaceSlug: req.params.workspaceSlug,
+ auditLogsRetentionDays: req.body.auditLogsRetentionDays
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ orgId: req.permission.orgId,
+ projectId: workspace.id,
+ event: {
+ type: EventType.UPDATE_PROJECT,
+ metadata: req.body
+ }
+ });
+
+ return {
+ message: "Successfully updated project's audit logs retention period",
+ workspace
+ };
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/:workspaceId/integrations",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Integrations],
+ description: "List integrations for a project.",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ workspaceId: z.string().trim().describe(PROJECTS.LIST_INTEGRATION.workspaceId)
+ }),
+ response: {
+ 200: z.object({
+ integrations: IntegrationsSchema.merge(
+ z.object({
+ environment: z.object({
+ id: z.string(),
+ name: z.string(),
+ slug: z.string()
+ })
+ })
+ ).array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const integrations = await server.services.integration.listIntegrationByProject({
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId
+ });
+ return { integrations };
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/:workspaceId/authorizations",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Integrations],
+ description: "List integration auth objects for a workspace.",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ workspaceId: z.string().trim().describe(PROJECTS.LIST_INTEGRATION_AUTHORIZATION.workspaceId)
+ }),
+ response: {
+ 200: z.object({
+ authorizations: integrationAuthPubSchema.array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const authorizations = await server.services.integrationAuth.listIntegrationAuthByProjectId({
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId
+ });
+ return { authorizations };
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/:workspaceId/ssh-config",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ params: z.object({
+ workspaceId: z.string().trim()
+ }),
+ response: {
+ 200: ProjectSshConfigsSchema.pick({
+ id: true,
+ createdAt: true,
+ updatedAt: true,
+ projectId: true,
+ defaultUserSshCaId: true,
+ defaultHostSshCaId: true
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const sshConfig = await server.services.project.getProjectSshConfig({
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: sshConfig.projectId,
+ event: {
+ type: EventType.GET_PROJECT_SSH_CONFIG,
+ metadata: {
+ id: sshConfig.id,
+ projectId: sshConfig.projectId
+ }
+ }
+ });
+
+ return sshConfig;
+ }
+ });
+
+ server.route({
+ method: "PATCH",
+ url: "/:workspaceId/ssh-config",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ params: z.object({
+ workspaceId: z.string().trim()
+ }),
+ body: z.object({
+ defaultUserSshCaId: z.string().optional(),
+ defaultHostSshCaId: z.string().optional()
+ }),
+ response: {
+ 200: ProjectSshConfigsSchema.pick({
+ id: true,
+ createdAt: true,
+ updatedAt: true,
+ projectId: true,
+ defaultUserSshCaId: true,
+ defaultHostSshCaId: true
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const sshConfig = await server.services.project.updateProjectSshConfig({
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId,
+ ...req.body
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: sshConfig.projectId,
+ event: {
+ type: EventType.UPDATE_PROJECT_SSH_CONFIG,
+ metadata: {
+ id: sshConfig.id,
+ projectId: sshConfig.projectId,
+ defaultUserSshCaId: sshConfig.defaultUserSshCaId,
+ defaultHostSshCaId: sshConfig.defaultHostSshCaId
+ }
+ }
+ });
+
+ return sshConfig;
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/:workspaceId/workflow-integration-config/:integration",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ params: z.object({
+ workspaceId: z.string().trim(),
+ integration: z.nativeEnum(WorkflowIntegration)
+ }),
+ response: {
+ 200: z.discriminatedUnion("integration", [
+ ProjectSlackConfigsSchema.pick({
+ id: true,
+ isAccessRequestNotificationEnabled: true,
+ accessRequestChannels: true,
+ isSecretRequestNotificationEnabled: true,
+ secretRequestChannels: true
+ }).merge(
+ z.object({
+ integration: z.literal(WorkflowIntegration.SLACK),
+ integrationId: z.string()
+ })
+ ),
+ ProjectMicrosoftTeamsConfigsSchema.pick({
+ id: true,
+ isAccessRequestNotificationEnabled: true,
+ accessRequestChannels: true,
+ isSecretRequestNotificationEnabled: true,
+ secretRequestChannels: true
+ }).merge(
+ z.object({
+ integration: z.literal(WorkflowIntegration.MICROSOFT_TEAMS),
+ integrationId: z.string()
+ })
+ )
+ ])
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const config = await server.services.project.getProjectWorkflowIntegrationConfig({
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId,
+ integration: req.params.integration
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: req.params.workspaceId,
+ event: {
+ type: EventType.GET_PROJECT_WORKFLOW_INTEGRATION_CONFIG,
+ metadata: {
+ id: config.id,
+ integration: config.integration
+ }
+ }
+ });
+
+ return config;
+ }
+ });
+
+ server.route({
+ method: "DELETE",
+ url: "/:projectId/workflow-integration/:integration/:integrationId",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ params: z.object({
+ projectId: z.string().trim(),
+ integration: z.nativeEnum(WorkflowIntegration),
+ integrationId: z.string()
+ }),
+ response: {
+ 200: z.object({
+ integrationConfig: z.object({
+ id: z.string()
+ })
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const deletedIntegration = await server.services.project.deleteProjectWorkflowIntegration({
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.projectId,
+ integration: req.params.integration,
+ integrationId: req.params.integrationId
+ });
+
+ return {
+ integrationConfig: deletedIntegration
+ };
+ }
+ });
+
+ server.route({
+ method: "PUT",
+ url: "/:workspaceId/workflow-integration",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ params: z.object({
+ workspaceId: z.string().trim()
+ }),
+
+ body: z.discriminatedUnion("integration", [
+ z.object({
+ integration: z.literal(WorkflowIntegration.SLACK),
+ integrationId: z.string(),
+ accessRequestChannels: validateSlackChannelsField,
+ secretRequestChannels: validateSlackChannelsField,
+ isAccessRequestNotificationEnabled: z.boolean(),
+ isSecretRequestNotificationEnabled: z.boolean()
+ }),
+ z.object({
+ integration: z.literal(WorkflowIntegration.MICROSOFT_TEAMS),
+ integrationId: z.string(),
+ accessRequestChannels: validateMicrosoftTeamsChannelsSchema,
+ secretRequestChannels: validateMicrosoftTeamsChannelsSchema,
+ isAccessRequestNotificationEnabled: z.boolean(),
+ isSecretRequestNotificationEnabled: z.boolean()
+ })
+ ]),
+ response: {
+ 200: z.discriminatedUnion("integration", [
+ ProjectSlackConfigsSchema.pick({
+ id: true,
+ isAccessRequestNotificationEnabled: true,
+ accessRequestChannels: true,
+ isSecretRequestNotificationEnabled: true,
+ secretRequestChannels: true
+ }).merge(
+ z.object({
+ integration: z.literal(WorkflowIntegration.SLACK),
+ integrationId: z.string()
+ })
+ ),
+ ProjectMicrosoftTeamsConfigsSchema.pick({
+ id: true,
+ isAccessRequestNotificationEnabled: true,
+ isSecretRequestNotificationEnabled: true
+ }).merge(
+ z.object({
+ integration: z.literal(WorkflowIntegration.MICROSOFT_TEAMS),
+ integrationId: z.string(),
+ accessRequestChannels: validateMicrosoftTeamsChannelsSchema,
+ secretRequestChannels: validateMicrosoftTeamsChannelsSchema
+ })
+ )
+ ])
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const workflowIntegrationConfig = await server.services.project.updateProjectWorkflowIntegration({
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.workspaceId,
+ ...req.body
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: req.params.workspaceId,
+ event: {
+ type: EventType.UPDATE_PROJECT_WORKFLOW_INTEGRATION_CONFIG,
+ metadata: {
+ id: workflowIntegrationConfig.id,
+ integrationId: workflowIntegrationConfig.integrationId,
+ integration: workflowIntegrationConfig.integration,
+ isAccessRequestNotificationEnabled: workflowIntegrationConfig.isAccessRequestNotificationEnabled,
+ accessRequestChannels: workflowIntegrationConfig.accessRequestChannels,
+ isSecretRequestNotificationEnabled: workflowIntegrationConfig.isSecretRequestNotificationEnabled,
+ secretRequestChannels: workflowIntegrationConfig.secretRequestChannels
+ }
+ }
+ });
+
+ return workflowIntegrationConfig;
+ }
+ });
+
+ server.route({
+ method: "POST",
+ url: "/search",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ body: z.object({
+ limit: z.number().default(100),
+ offset: z.number().default(0),
+ type: z.nativeEnum(ProjectType).optional(),
+ orderBy: z.nativeEnum(SearchProjectSortBy).optional().default(SearchProjectSortBy.NAME),
+ orderDirection: z.nativeEnum(SortDirection).optional().default(SortDirection.ASC),
+ name: z
+ .string()
+ .trim()
+ .refine((val) => characterValidator([CharacterType.AlphaNumeric, CharacterType.Hyphen])(val), {
+ message: "Invalid pattern: only alphanumeric characters, - are allowed."
+ })
+ .optional()
+ }),
+ response: {
+ 200: z.object({
+ projects: SanitizedProjectSchema.extend({ isMember: z.boolean() }).array(),
+ totalCount: z.number()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const { docs: projects, totalCount } = await server.services.project.searchProjects({
+ permission: req.permission,
+ ...req.body
+ });
+
+ return { projects, totalCount };
+ }
+ });
+};
diff --git a/backend/src/server/routes/v1/depreciated-secret-tag-router.ts b/backend/src/server/routes/v1/depreciated-secret-tag-router.ts
new file mode 100644
index 0000000000..246867cabe
--- /dev/null
+++ b/backend/src/server/routes/v1/depreciated-secret-tag-router.ts
@@ -0,0 +1,213 @@
+import { z } from "zod";
+
+import { SecretTagsSchema } from "@app/db/schemas";
+import { ApiDocsTags, SECRET_TAGS } from "@app/lib/api-docs";
+import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
+import { slugSchema } from "@app/server/lib/schemas";
+import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
+import { AuthMode } from "@app/services/auth/auth-type";
+
+export const registerDepreciatedSecretTagRouter = async (server: FastifyZodProvider) => {
+ server.route({
+ method: "GET",
+ url: "/:projectId/tags",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Folders],
+ params: z.object({
+ projectId: z.string().trim().describe(SECRET_TAGS.LIST.projectId)
+ }),
+ response: {
+ 200: z.object({
+ workspaceTags: SecretTagsSchema.array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const workspaceTags = await server.services.secretTag.getProjectTags({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.projectId
+ });
+ return { workspaceTags };
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/:projectId/tags/:tagId",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Folders],
+ params: z.object({
+ projectId: z.string().trim().describe(SECRET_TAGS.GET_TAG_BY_ID.projectId),
+ tagId: z.string().trim().describe(SECRET_TAGS.GET_TAG_BY_ID.tagId)
+ }),
+ response: {
+ 200: z.object({
+ // akhilmhdh: for terraform backward compatiability
+ workspaceTag: SecretTagsSchema.extend({ name: z.string() })
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const workspaceTag = await server.services.secretTag.getTagById({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ id: req.params.tagId
+ });
+ return { workspaceTag };
+ }
+ });
+
+ server.route({
+ method: "GET",
+ url: "/:projectId/tags/slug/:tagSlug",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Folders],
+ params: z.object({
+ projectId: z.string().trim().describe(SECRET_TAGS.GET_TAG_BY_SLUG.projectId),
+ tagSlug: z.string().trim().describe(SECRET_TAGS.GET_TAG_BY_SLUG.tagSlug)
+ }),
+ response: {
+ 200: z.object({
+ // akhilmhdh: for terraform backward compatiability
+ workspaceTag: SecretTagsSchema.extend({ name: z.string() })
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const workspaceTag = await server.services.secretTag.getTagBySlug({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ slug: req.params.tagSlug,
+ projectId: req.params.projectId
+ });
+ return { workspaceTag };
+ }
+ });
+
+ server.route({
+ method: "POST",
+ url: "/:projectId/tags",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Folders],
+ params: z.object({
+ projectId: z.string().trim().describe(SECRET_TAGS.CREATE.projectId)
+ }),
+ body: z.object({
+ slug: slugSchema({ max: 64 }).describe(SECRET_TAGS.CREATE.slug),
+ color: z.string().trim().describe(SECRET_TAGS.CREATE.color)
+ }),
+ response: {
+ 200: z.object({
+ workspaceTag: SecretTagsSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const workspaceTag = await server.services.secretTag.createTag({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.projectId,
+ ...req.body
+ });
+ return { workspaceTag };
+ }
+ });
+
+ server.route({
+ method: "PATCH",
+ url: "/:projectId/tags/:tagId",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Folders],
+ params: z.object({
+ projectId: z.string().trim().describe(SECRET_TAGS.UPDATE.projectId),
+ tagId: z.string().trim().describe(SECRET_TAGS.UPDATE.tagId)
+ }),
+ body: z.object({
+ slug: slugSchema({ max: 64 }).describe(SECRET_TAGS.UPDATE.slug),
+ color: z.string().trim().describe(SECRET_TAGS.UPDATE.color)
+ }),
+ response: {
+ 200: z.object({
+ workspaceTag: SecretTagsSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const workspaceTag = await server.services.secretTag.updateTag({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ ...req.body,
+ id: req.params.tagId
+ });
+ return { workspaceTag };
+ }
+ });
+
+ server.route({
+ method: "DELETE",
+ url: "/:projectId/tags/:tagId",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.Folders],
+ params: z.object({
+ projectId: z.string().trim().describe(SECRET_TAGS.DELETE.projectId),
+ tagId: z.string().trim().describe(SECRET_TAGS.DELETE.tagId)
+ }),
+ response: {
+ 200: z.object({
+ workspaceTag: SecretTagsSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const workspaceTag = await server.services.secretTag.deleteTag({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ id: req.params.tagId
+ });
+ return { workspaceTag };
+ }
+ });
+};
diff --git a/backend/src/server/routes/v1/index.ts b/backend/src/server/routes/v1/index.ts
index 6108be32bf..caca4b6f67 100644
--- a/backend/src/server/routes/v1/index.ts
+++ b/backend/src/server/routes/v1/index.ts
@@ -13,6 +13,9 @@ import { registerCaRouter } from "./certificate-authority-router";
import { CERTIFICATE_AUTHORITY_REGISTER_ROUTER_MAP } from "./certificate-authority-routers";
import { registerCertRouter } from "./certificate-router";
import { registerCertificateTemplateRouter } from "./certificate-template-router";
+import { registerDepreciatedProjectEnvRouter } from "./depreciated-project-env-router";
+import { registerDepreciatedProjectMembershipRouter } from "./depreciated-project-membership-router";
+import { registerDepreciatedSecretTagRouter } from "./depreciated-secret-tag-router";
import { registerEventRouter } from "./event-router";
import { registerExternalGroupOrgRoleMappingRouter } from "./external-group-org-role-mapping-router";
import { registerIdentityAccessTokenRouter } from "./identity-access-token-router";
@@ -43,10 +46,10 @@ import { registerPkiSubscriberRouter } from "./pki-subscriber-router";
import { registerProjectEnvRouter } from "./project-env-router";
import { registerProjectKeyRouter } from "./project-key-router";
import { registerProjectMembershipRouter } from "./project-membership-router";
+import { registerDepreciatedProjectRouter } from "./depreciated-project-router";
import { registerProjectRouter } from "./project-router";
import { SECRET_REMINDER_REGISTER_ROUTER_MAP } from "./reminder-routers";
import { registerSecretFolderRouter } from "./secret-folder-router";
-import { registerSecretImportRouter } from "./secret-import-router";
import { registerSecretRequestsRouter } from "./secret-requests-router";
import { registerSecretSharingRouter } from "./secret-sharing-router";
import { registerSecretTagRouter } from "./secret-tag-router";
@@ -57,6 +60,7 @@ import { registerUserEngagementRouter } from "./user-engagement-router";
import { registerUserRouter } from "./user-router";
import { registerWebhookRouter } from "./webhook-router";
import { registerWorkflowIntegrationRouter } from "./workflow-integration-router";
+import { registerSecretImportRouter } from "./secret-import-router";
export const registerV1Routes = async (server: FastifyZodProvider) => {
await server.register(registerSsoRouter, { prefix: "/sso" });
@@ -101,13 +105,24 @@ export const registerV1Routes = async (server: FastifyZodProvider) => {
await server.register(
async (projectRouter) => {
- await projectRouter.register(registerProjectRouter);
- await projectRouter.register(registerProjectEnvRouter);
+ await projectRouter.register(registerDepreciatedProjectRouter);
+ await projectRouter.register(registerDepreciatedProjectEnvRouter);
+ // depreciated completed in use
await projectRouter.register(registerProjectKeyRouter);
+ await projectRouter.register(registerDepreciatedProjectMembershipRouter);
+ await projectRouter.register(registerDepreciatedSecretTagRouter);
+ },
+ { prefix: "/workspace" }
+ );
+
+ await server.register(
+ async (projectRouter) => {
+ await projectRouter.register(registerProjectRouter);
await projectRouter.register(registerProjectMembershipRouter);
+ await projectRouter.register(registerProjectEnvRouter);
await projectRouter.register(registerSecretTagRouter);
},
- { prefix: "/workspace" }
+ { prefix: "/projects" }
);
await server.register(
diff --git a/backend/src/server/routes/v1/project-env-router.ts b/backend/src/server/routes/v1/project-env-router.ts
index 9a136e1608..af71c54666 100644
--- a/backend/src/server/routes/v1/project-env-router.ts
+++ b/backend/src/server/routes/v1/project-env-router.ts
@@ -11,58 +11,7 @@ import { AuthMode } from "@app/services/auth/auth-type";
export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
server.route({
method: "GET",
- url: "/:workspaceId/environments/:envId",
- config: {
- rateLimit: readLimit
- },
- schema: {
- hide: false,
- tags: [ApiDocsTags.Environments],
- description: "Get Environment",
- security: [
- {
- bearerAuth: []
- }
- ],
- params: z.object({
- // NOTE(daniel): workspaceId isn't used, but we need to keep it for backwards compatibility. The endpoint defined below, uses no project ID, and is takes a pure environment ID.
- workspaceId: z.string().trim().describe(ENVIRONMENTS.GET.workspaceId),
- envId: z.string().trim().describe(ENVIRONMENTS.GET.id)
- }),
- response: {
- 200: z.object({
- environment: ProjectEnvironmentsSchema
- })
- }
- },
- onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
- handler: async (req) => {
- const environment = await server.services.projectEnv.getEnvironmentById({
- actorId: req.permission.id,
- actor: req.permission.type,
- actorOrgId: req.permission.orgId,
- actorAuthMethod: req.permission.authMethod,
- id: req.params.envId
- });
-
- await server.services.auditLog.createAuditLog({
- ...req.auditLogInfo,
- projectId: environment.projectId,
- event: {
- type: EventType.GET_ENVIRONMENT,
- metadata: {
- id: environment.id
- }
- }
- });
-
- return { environment };
- }
- });
-
- server.route({
- method: "GET",
- url: "/environments/:envId",
+ url: "/:projectId/environments/:envId",
config: {
rateLimit: readLimit
},
@@ -76,7 +25,8 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
}
],
params: z.object({
- envId: z.string().trim().describe(ENVIRONMENTS.GET.id)
+ envId: z.string().trim().describe(ENVIRONMENTS.GET.id),
+ projectId: z.string().trim().describe(ENVIRONMENTS.GET.projectId)
}),
response: {
200: z.object({
@@ -111,7 +61,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
server.route({
method: "POST",
- url: "/:workspaceId/environments",
+ url: "/:projectId/environments",
config: {
rateLimit: writeLimit
},
@@ -125,7 +75,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
}
],
params: z.object({
- workspaceId: z.string().trim().describe(ENVIRONMENTS.CREATE.workspaceId)
+ projectId: z.string().trim().describe(ENVIRONMENTS.CREATE.projectId)
}),
body: z.object({
name: z.string().trim().describe(ENVIRONMENTS.CREATE.name),
@@ -147,7 +97,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
actor: req.permission.type,
actorOrgId: req.permission.orgId,
actorAuthMethod: req.permission.authMethod,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
...req.body
});
@@ -164,7 +114,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
});
return {
message: "Successfully created new environment",
- workspace: req.params.workspaceId,
+ workspace: req.params.projectId,
environment
};
}
@@ -172,7 +122,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
server.route({
method: "PATCH",
- url: "/:workspaceId/environments/:id",
+ url: "/:projectId/environments/:id",
config: {
rateLimit: writeLimit
},
@@ -186,7 +136,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
}
],
params: z.object({
- workspaceId: z.string().trim().describe(ENVIRONMENTS.UPDATE.workspaceId),
+ projectId: z.string().trim().describe(ENVIRONMENTS.UPDATE.projectId),
id: z.string().trim().describe(ENVIRONMENTS.UPDATE.id)
}),
body: z.object({
@@ -209,7 +159,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
id: req.params.id,
...req.body
});
@@ -232,7 +182,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
return {
message: "Successfully updated environment",
- workspace: req.params.workspaceId,
+ workspace: req.params.projectId,
environment
};
}
@@ -240,7 +190,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
server.route({
method: "DELETE",
- url: "/:workspaceId/environments/:id",
+ url: "/:projectId/environments/:id",
config: {
rateLimit: writeLimit
},
@@ -254,7 +204,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
}
],
params: z.object({
- workspaceId: z.string().trim().describe(ENVIRONMENTS.DELETE.workspaceId),
+ projectId: z.string().trim().describe(ENVIRONMENTS.DELETE.projectId),
id: z.string().trim().describe(ENVIRONMENTS.DELETE.id)
}),
response: {
@@ -272,7 +222,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
id: req.params.id
});
@@ -290,7 +240,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
return {
message: "Successfully deleted environment",
- workspace: req.params.workspaceId,
+ workspace: req.params.projectId,
environment
};
}
diff --git a/backend/src/server/routes/v1/project-membership-router.ts b/backend/src/server/routes/v1/project-membership-router.ts
index cd3734efc4..95048b0489 100644
--- a/backend/src/server/routes/v1/project-membership-router.ts
+++ b/backend/src/server/routes/v1/project-membership-router.ts
@@ -18,7 +18,7 @@ import { ProjectUserMembershipTemporaryMode } from "@app/services/project-member
export const registerProjectMembershipRouter = async (server: FastifyZodProvider) => {
server.route({
method: "GET",
- url: "/:workspaceId/memberships",
+ url: "/:projectId/memberships",
config: {
rateLimit: readLimit
},
@@ -32,7 +32,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
}
],
params: z.object({
- workspaceId: z.string().trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIPS.workspaceId)
+ projectId: z.string().trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIPS.projectId)
}),
response: {
200: z.object({
@@ -71,7 +71,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId
+ projectId: req.params.projectId
});
return { memberships };
}
@@ -79,7 +79,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
server.route({
method: "GET",
- url: "/:workspaceId/memberships/:membershipId",
+ url: "/:projectId/memberships/:membershipId",
config: {
rateLimit: readLimit
},
@@ -91,7 +91,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
}
],
params: z.object({
- workspaceId: z.string().min(1).trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP.workspaceId),
+ projectId: z.string().min(1).trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP.projectId),
membershipId: z.string().min(1).trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP.membershipId)
}),
response: {
@@ -129,16 +129,17 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
id: req.params.membershipId
});
return { membership };
}
});
+ // TODO(depri): ask this usage again
server.route({
method: "POST",
- url: "/:workspaceId/memberships/details",
+ url: "/:projectId/memberships/details",
config: {
rateLimit: readLimit
},
@@ -152,7 +153,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
}
],
params: z.object({
- workspaceId: z.string().min(1).trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP.workspaceId)
+ projectId: z.string().min(1).trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP.projectId)
}),
body: z.object({
username: z.string().min(1).trim().describe(PROJECT_USERS.GET_USER_MEMBERSHIP.username)
@@ -191,7 +192,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
username: req.body.username
});
return { membership };
@@ -200,13 +201,13 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
server.route({
method: "POST",
- url: "/:workspaceId/memberships",
+ url: "/:projectId/memberships",
config: {
rateLimit: writeLimit
},
schema: {
params: z.object({
- workspaceId: z.string().trim()
+ projectId: z.string().trim()
}),
body: z.object({
members: z
@@ -232,12 +233,12 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
members: req.body.members
});
await server.services.auditLog.createAuditLog({
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
...req.auditLogInfo,
event: {
type: EventType.ADD_BATCH_WORKSPACE_MEMBER,
@@ -254,7 +255,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
server.route({
method: "PATCH",
- url: "/:workspaceId/memberships/:membershipId",
+ url: "/:projectId/memberships/:membershipId",
config: {
rateLimit: writeLimit
},
@@ -268,7 +269,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
}
],
params: z.object({
- workspaceId: z.string().trim().describe(PROJECT_USERS.UPDATE_USER_MEMBERSHIP.workspaceId),
+ projectId: z.string().trim().describe(PROJECT_USERS.UPDATE_USER_MEMBERSHIP.projectId),
membershipId: z.string().trim().describe(PROJECT_USERS.UPDATE_USER_MEMBERSHIP.membershipId)
}),
body: z.object({
@@ -305,14 +306,14 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
membershipId: req.params.membershipId,
roles: req.body.roles
});
// await server.services.auditLog.createAuditLog({
// ...req.auditLogInfo,
- // projectId: req.params.workspaceId,
+ // projectId: req.params.projectId,
// event: {
// type: EventType.UPDATE_USER_WORKSPACE_ROLE,
// metadata: {
@@ -329,7 +330,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
server.route({
method: "DELETE",
- url: "/:workspaceId/memberships/:membershipId",
+ url: "/:projectId/memberships/:membershipId",
config: {
rateLimit: writeLimit
},
@@ -341,7 +342,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
}
],
params: z.object({
- workspaceId: z.string().trim(),
+ projectId: z.string().trim(),
membershipId: z.string().trim()
}),
response: {
@@ -357,13 +358,13 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
membershipId: req.params.membershipId
});
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
event: {
type: EventType.REMOVE_WORKSPACE_MEMBER,
metadata: {
@@ -378,13 +379,13 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
server.route({
method: "DELETE",
- url: "/:workspaceId/leave",
+ url: "/:projectId/leave",
config: {
rateLimit: writeLimit
},
schema: {
params: z.object({
- workspaceId: z.string().trim()
+ projectId: z.string().trim()
}),
response: {
200: z.object({
@@ -398,7 +399,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
const membership = await server.services.projectMembership.leaveProject({
actorId: req.permission.id,
actor: req.permission.type,
- projectId: req.params.workspaceId
+ projectId: req.params.projectId
});
return { membership };
}
diff --git a/backend/src/server/routes/v1/project-router.ts b/backend/src/server/routes/v1/project-router.ts
index 5e7dce76eb..da5d07f70e 100644
--- a/backend/src/server/routes/v1/project-router.ts
+++ b/backend/src/server/routes/v1/project-router.ts
@@ -40,41 +40,7 @@ const projectWithEnv = SanitizedProjectSchema.merge(
export const registerProjectRouter = async (server: FastifyZodProvider) => {
server.route({
method: "GET",
- url: "/:workspaceId/keys",
- config: {
- rateLimit: readLimit
- },
- schema: {
- params: z.object({
- workspaceId: z.string().trim()
- }),
- response: {
- 200: z.object({
- publicKeys: z
- .object({
- publicKey: z.string().nullable().optional(),
- userId: z.string()
- })
- .array()
- })
- }
- },
- onRequest: verifyAuth([AuthMode.JWT]),
- handler: async (req) => {
- const publicKeys = await server.services.projectKey.getProjectPublicKeys({
- actorId: req.permission.id,
- actor: req.permission.type,
- actorAuthMethod: req.permission.authMethod,
- actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId
- });
- return { publicKeys };
- }
- });
-
- server.route({
- method: "GET",
- url: "/:workspaceId/users",
+ url: "/:projectId/users",
config: {
rateLimit: readLimit
},
@@ -96,7 +62,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
.optional()
}),
params: z.object({
- workspaceId: z.string().trim()
+ projectId: z.string().trim()
}),
response: {
200: z.object({
@@ -142,7 +108,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
includeGroupMembers: req.query.includeGroupMembers,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
actorOrgId: req.permission.orgId,
roles
});
@@ -167,7 +133,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- workspaces: projectWithEnv
+ projects: projectWithEnv
.extend({
roles: ProjectRolesSchema.array().optional()
})
@@ -177,7 +143,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const workspaces = await server.services.project.getProjects({
+ const projects = await server.services.project.getProjects({
includeRoles: req.query.includeRoles,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
@@ -185,13 +151,13 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
actorOrgId: req.permission.orgId,
type: req.query.type
});
- return { workspaces };
+ return { projects };
}
});
server.route({
method: "GET",
- url: "/:workspaceId",
+ url: "/:projectId",
config: {
rateLimit: readLimit
},
@@ -205,33 +171,33 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
}
],
params: z.object({
- workspaceId: z.string().trim().describe(PROJECTS.GET.workspaceId)
+ projectId: z.string().trim().describe(PROJECTS.GET.projectId)
}),
response: {
200: z.object({
- workspace: projectWithEnv.optional()
+ project: projectWithEnv.optional()
})
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.SERVICE_TOKEN, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const workspace = await server.services.project.getAProject({
+ const project = await server.services.project.getAProject({
filter: {
type: ProjectFilterType.ID,
- projectId: req.params.workspaceId
+ projectId: req.params.projectId
},
actorAuthMethod: req.permission.authMethod,
actorId: req.permission.id,
actor: req.permission.type,
actorOrgId: req.permission.orgId
});
- return { workspace };
+ return { project };
}
});
server.route({
method: "DELETE",
- url: "/:workspaceId",
+ url: "/:projectId",
config: {
rateLimit: writeLimit
},
@@ -245,20 +211,20 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
}
],
params: z.object({
- workspaceId: z.string().trim().describe(PROJECTS.DELETE.workspaceId)
+ projectId: z.string().trim().describe(PROJECTS.DELETE.projectId)
}),
response: {
200: z.object({
- workspace: SanitizedProjectSchema.optional()
+ project: SanitizedProjectSchema.optional()
})
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const workspace = await server.services.project.deleteProject({
+ const project = await server.services.project.deleteProject({
filter: {
type: ProjectFilterType.ID,
- projectId: req.params.workspaceId
+ projectId: req.params.projectId
},
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
@@ -269,68 +235,20 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
orgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
event: {
type: EventType.DELETE_PROJECT,
- metadata: workspace
- }
- });
-
- return { workspace };
- }
- });
-
- server.route({
- url: "/:workspaceId/name",
- method: "POST",
- config: {
- rateLimit: writeLimit
- },
- schema: {
- params: z.object({
- workspaceId: z.string().trim()
- }),
- body: z.object({
- name: z.string().trim()
- }),
- response: {
- 200: z.object({
- message: z.string(),
- workspace: SanitizedProjectSchema
- })
- }
- },
- onRequest: verifyAuth([AuthMode.JWT]),
- handler: async (req) => {
- const workspace = await server.services.project.updateName({
- actorId: req.permission.id,
- actor: req.permission.type,
- actorAuthMethod: req.permission.authMethod,
- actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId,
- name: req.body.name
- });
-
- await server.services.auditLog.createAuditLog({
- ...req.auditLogInfo,
- orgId: req.permission.orgId,
- projectId: req.params.workspaceId,
- event: {
- type: EventType.UPDATE_PROJECT,
- metadata: req.body
+ metadata: project
}
});
- return {
- message: "Successfully changed workspace name",
- workspace
- };
+ return { project };
}
});
server.route({
method: "PATCH",
- url: "/:workspaceId",
+ url: "/:projectId",
config: {
rateLimit: writeLimit
},
@@ -344,7 +262,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
}
],
params: z.object({
- workspaceId: z.string().trim().describe(PROJECTS.UPDATE.workspaceId)
+ projectId: z.string().trim().describe(PROJECTS.UPDATE.projectId)
}),
body: z.object({
name: z
@@ -381,16 +299,16 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- workspace: SanitizedProjectSchema
+ project: SanitizedProjectSchema
})
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const workspace = await server.services.project.updateProject({
+ const project = await server.services.project.updateProject({
filter: {
type: ProjectFilterType.ID,
- projectId: req.params.workspaceId
+ projectId: req.params.projectId
},
update: {
name: req.body.name,
@@ -412,7 +330,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
orgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
event: {
type: EventType.UPDATE_PROJECT,
metadata: req.body
@@ -420,20 +338,20 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
});
return {
- workspace
+ project
};
}
});
server.route({
method: "POST",
- url: "/:workspaceId/auto-capitalization",
+ url: "/:projectId/auto-capitalization",
config: {
rateLimit: writeLimit
},
schema: {
params: z.object({
- workspaceId: z.string().trim()
+ projectId: z.string().trim()
}),
body: z.object({
autoCapitalization: z.boolean()
@@ -441,25 +359,25 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
response: {
200: z.object({
message: z.string(),
- workspace: SanitizedProjectSchema
+ project: SanitizedProjectSchema
})
}
},
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
- const workspace = await server.services.project.toggleAutoCapitalization({
+ const project = await server.services.project.toggleAutoCapitalization({
actorId: req.permission.id,
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
autoCapitalization: req.body.autoCapitalization
});
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
orgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
event: {
type: EventType.UPDATE_PROJECT,
metadata: req.body
@@ -467,21 +385,21 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
});
return {
- message: "Successfully changed workspace settings",
- workspace
+ message: "Successfully changed project settings",
+ project
};
}
});
server.route({
method: "POST",
- url: "/:workspaceId/delete-protection",
+ url: "/:projectId/delete-protection",
config: {
rateLimit: writeLimit
},
schema: {
params: z.object({
- workspaceId: z.string().trim()
+ projectId: z.string().trim()
}),
body: z.object({
hasDeleteProtection: z.boolean()
@@ -489,25 +407,25 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
response: {
200: z.object({
message: z.string(),
- workspace: SanitizedProjectSchema
+ project: SanitizedProjectSchema
})
}
},
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
- const workspace = await server.services.project.toggleDeleteProtection({
+ const project = await server.services.project.toggleDeleteProtection({
actorId: req.permission.id,
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
hasDeleteProtection: req.body.hasDeleteProtection
});
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
orgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
event: {
type: EventType.UPDATE_PROJECT,
metadata: req.body
@@ -515,8 +433,8 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
});
return {
- message: "Successfully changed workspace settings",
- workspace
+ message: "Successfully changed project settings",
+ project
};
}
});
@@ -537,13 +455,13 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
response: {
200: z.object({
message: z.string(),
- workspace: SanitizedProjectSchema
+ project: SanitizedProjectSchema
})
}
},
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
- const workspace = await server.services.project.updateVersionLimit({
+ const project = await server.services.project.updateVersionLimit({
actorId: req.permission.id,
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
@@ -555,7 +473,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
orgId: req.permission.orgId,
- projectId: workspace.id,
+ projectId: project.id,
event: {
type: EventType.UPDATE_PROJECT,
metadata: req.body
@@ -563,8 +481,8 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
});
return {
- message: "Successfully changed workspace version limit",
- workspace
+ message: "Successfully changed project version limit",
+ project
};
}
});
@@ -585,13 +503,13 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
response: {
200: z.object({
message: z.string(),
- workspace: SanitizedProjectSchema
+ project: SanitizedProjectSchema
})
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const workspace = await server.services.project.updateAuditLogsRetention({
+ const project = await server.services.project.updateAuditLogsRetention({
actorId: req.permission.id,
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
@@ -603,7 +521,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
orgId: req.permission.orgId,
- projectId: workspace.id,
+ projectId: project.id,
event: {
type: EventType.UPDATE_PROJECT,
metadata: req.body
@@ -612,14 +530,14 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
return {
message: "Successfully updated project's audit logs retention period",
- workspace
+ project
};
}
});
server.route({
method: "GET",
- url: "/:workspaceId/integrations",
+ url: "/:projectId/integrations",
config: {
rateLimit: readLimit
},
@@ -633,7 +551,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
}
],
params: z.object({
- workspaceId: z.string().trim().describe(PROJECTS.LIST_INTEGRATION.workspaceId)
+ projectId: z.string().trim().describe(PROJECTS.LIST_INTEGRATION.projectId)
}),
response: {
200: z.object({
@@ -656,7 +574,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
actorAuthMethod: req.permission.authMethod,
actor: req.permission.type,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId
+ projectId: req.params.projectId
});
return { integrations };
}
@@ -664,21 +582,21 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
server.route({
method: "GET",
- url: "/:workspaceId/authorizations",
+ url: "/:projectId/authorizations",
config: {
rateLimit: readLimit
},
schema: {
hide: false,
tags: [ApiDocsTags.Integrations],
- description: "List integration auth objects for a workspace.",
+ description: "List integration auth objects for a project.",
security: [
{
bearerAuth: []
}
],
params: z.object({
- workspaceId: z.string().trim().describe(PROJECTS.LIST_INTEGRATION_AUTHORIZATION.workspaceId)
+ projectId: z.string().trim().describe(PROJECTS.LIST_INTEGRATION_AUTHORIZATION.projectId)
}),
response: {
200: z.object({
@@ -693,7 +611,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
actorAuthMethod: req.permission.authMethod,
actor: req.permission.type,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId
+ projectId: req.params.projectId
});
return { authorizations };
}
@@ -701,13 +619,13 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
server.route({
method: "GET",
- url: "/:workspaceId/service-token-data",
+ url: "/:projectId/service-token-data",
config: {
rateLimit: readLimit
},
schema: {
params: z.object({
- workspaceId: z.string().trim()
+ projectId: z.string().trim()
}),
response: {
200: z.object({
@@ -722,7 +640,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
actorAuthMethod: req.permission.authMethod,
actor: req.permission.type,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId
+ projectId: req.params.projectId
});
return { serviceTokenData };
}
@@ -730,13 +648,13 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
server.route({
method: "GET",
- url: "/:workspaceId/ssh-config",
+ url: "/:projectId/ssh-config",
config: {
rateLimit: readLimit
},
schema: {
params: z.object({
- workspaceId: z.string().trim()
+ projectId: z.string().trim()
}),
response: {
200: ProjectSshConfigsSchema.pick({
@@ -756,7 +674,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
actorAuthMethod: req.permission.authMethod,
actor: req.permission.type,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId
+ projectId: req.params.projectId
});
await server.services.auditLog.createAuditLog({
@@ -777,13 +695,13 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
server.route({
method: "PATCH",
- url: "/:workspaceId/ssh-config",
+ url: "/:projectId/ssh-config",
config: {
rateLimit: writeLimit
},
schema: {
params: z.object({
- workspaceId: z.string().trim()
+ projectId: z.string().trim()
}),
body: z.object({
defaultUserSshCaId: z.string().optional(),
@@ -807,7 +725,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
actorAuthMethod: req.permission.authMethod,
actor: req.permission.type,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
...req.body
});
@@ -831,13 +749,13 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
server.route({
method: "GET",
- url: "/:workspaceId/workflow-integration-config/:integration",
+ url: "/:projectId/workflow-integration-config/:integration",
config: {
rateLimit: readLimit
},
schema: {
params: z.object({
- workspaceId: z.string().trim(),
+ projectId: z.string().trim(),
integration: z.nativeEnum(WorkflowIntegration)
}),
response: {
@@ -876,13 +794,13 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
actorAuthMethod: req.permission.authMethod,
actor: req.permission.type,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
integration: req.params.integration
});
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
event: {
type: EventType.GET_PROJECT_WORKFLOW_INTEGRATION_CONFIG,
metadata: {
@@ -936,13 +854,13 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
server.route({
method: "PUT",
- url: "/:workspaceId/workflow-integration",
+ url: "/:projectId/workflow-integration",
config: {
rateLimit: readLimit
},
schema: {
params: z.object({
- workspaceId: z.string().trim()
+ projectId: z.string().trim()
}),
body: z.discriminatedUnion("integration", [
@@ -999,13 +917,13 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
actorAuthMethod: req.permission.authMethod,
actor: req.permission.type,
actorOrgId: req.permission.orgId,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
...req.body
});
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
event: {
type: EventType.UPDATE_PROJECT_WORKFLOW_INTEGRATION_CONFIG,
metadata: {
@@ -1026,13 +944,13 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
server.route({
method: "GET",
- url: "/:workspaceId/environment-folder-tree",
+ url: "/:projectId/environment-folder-tree",
config: {
rateLimit: readLimit
},
schema: {
params: z.object({
- workspaceId: z.string().trim()
+ projectId: z.string().trim()
}),
response: {
200: z.record(
@@ -1043,7 +961,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
const environmentsFolders = await server.services.folder.getProjectEnvironmentsFolders(
- req.params.workspaceId,
+ req.params.projectId,
req.permission
);
@@ -1092,13 +1010,13 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
server.route({
method: "POST",
- url: "/:workspaceId/project-access",
+ url: "/:projectId/project-access",
config: {
rateLimit: requestAccessLimit
},
schema: {
params: z.object({
- workspaceId: z.string().trim()
+ projectId: z.string().trim()
}),
body: z.object({
comment: z
@@ -1132,17 +1050,17 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
await server.services.project.requestProjectAccess({
permission: req.permission,
comment: req.body.comment,
- projectId: req.params.workspaceId
+ projectId: req.params.projectId
});
if (req.auth.actor === ActorType.USER) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
event: {
type: EventType.PROJECT_ACCESS_REQUEST,
metadata: {
- projectId: req.params.workspaceId,
+ projectId: req.params.projectId,
requesterEmail: req.auth.user.email || req.auth.user.username,
requesterId: req.auth.userId
}
diff --git a/backend/src/server/routes/v1/secret-tag-router.ts b/backend/src/server/routes/v1/secret-tag-router.ts
index 01ba783fef..3c6c99eaff 100644
--- a/backend/src/server/routes/v1/secret-tag-router.ts
+++ b/backend/src/server/routes/v1/secret-tag-router.ts
@@ -22,20 +22,20 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- workspaceTags: SecretTagsSchema.array()
+ tags: SecretTagsSchema.array()
})
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const workspaceTags = await server.services.secretTag.getProjectTags({
+ const tags = await server.services.secretTag.getProjectTags({
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
projectId: req.params.projectId
});
- return { workspaceTags };
+ return { tags };
}
});
@@ -55,20 +55,20 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
response: {
200: z.object({
// akhilmhdh: for terraform backward compatiability
- workspaceTag: SecretTagsSchema.extend({ name: z.string() })
+ tag: SecretTagsSchema.extend({ name: z.string() })
})
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const workspaceTag = await server.services.secretTag.getTagById({
+ const tag = await server.services.secretTag.getTagById({
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
id: req.params.tagId
});
- return { workspaceTag };
+ return { tag };
}
});
@@ -88,13 +88,13 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
response: {
200: z.object({
// akhilmhdh: for terraform backward compatiability
- workspaceTag: SecretTagsSchema.extend({ name: z.string() })
+ tag: SecretTagsSchema.extend({ name: z.string() })
})
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const workspaceTag = await server.services.secretTag.getTagBySlug({
+ const tag = await server.services.secretTag.getTagBySlug({
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
@@ -102,7 +102,7 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
slug: req.params.tagSlug,
projectId: req.params.projectId
});
- return { workspaceTag };
+ return { tag };
}
});
@@ -124,13 +124,13 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- workspaceTag: SecretTagsSchema
+ tag: SecretTagsSchema
})
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const workspaceTag = await server.services.secretTag.createTag({
+ const tag = await server.services.secretTag.createTag({
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
@@ -138,7 +138,7 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
projectId: req.params.projectId,
...req.body
});
- return { workspaceTag };
+ return { tag };
}
});
@@ -161,13 +161,13 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- workspaceTag: SecretTagsSchema
+ tag: SecretTagsSchema
})
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const workspaceTag = await server.services.secretTag.updateTag({
+ const tag = await server.services.secretTag.updateTag({
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
@@ -175,7 +175,7 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
...req.body,
id: req.params.tagId
});
- return { workspaceTag };
+ return { tag };
}
});
@@ -194,20 +194,20 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- workspaceTag: SecretTagsSchema
+ tag: SecretTagsSchema
})
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const workspaceTag = await server.services.secretTag.deleteTag({
+ const tag = await server.services.secretTag.deleteTag({
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
id: req.params.tagId
});
- return { workspaceTag };
+ return { tag };
}
});
};
diff --git a/frontend/src/context/WorkspaceContext/WorkspaceContext.tsx b/frontend/src/context/WorkspaceContext/WorkspaceContext.tsx
index 8bef13b314..9d3aadd5db 100644
--- a/frontend/src/context/WorkspaceContext/WorkspaceContext.tsx
+++ b/frontend/src/context/WorkspaceContext/WorkspaceContext.tsx
@@ -1,7 +1,7 @@
import { useSuspenseQuery } from "@tanstack/react-query";
import { useParams } from "@tanstack/react-router";
-import { workspaceKeys } from "@app/hooks/api";
+import { projectKeys } from "@app/hooks/api";
import { fetchWorkspaceById } from "@app/hooks/api/workspace/queries";
export const useWorkspace = () => {
@@ -13,7 +13,7 @@ export const useWorkspace = () => {
}
const { data: currentWorkspace } = useSuspenseQuery({
- queryKey: workspaceKeys.getWorkspaceById(params.projectId),
+ queryKey: projectKeys.getWorkspaceById(params.projectId),
queryFn: () => fetchWorkspaceById(params.projectId as string),
staleTime: Infinity
});
diff --git a/frontend/src/hooks/api/folderCommits/queries.tsx b/frontend/src/hooks/api/folderCommits/queries.tsx
index 1bca7ce9a3..68d1f67adb 100644
--- a/frontend/src/hooks/api/folderCommits/queries.tsx
+++ b/frontend/src/hooks/api/folderCommits/queries.tsx
@@ -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: 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: 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: 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: 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: 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)
});
};
diff --git a/frontend/src/hooks/api/identities/types.ts b/frontend/src/hooks/api/identities/types.ts
index 36f9eae4ea..c16c61c577 100644
--- a/frontend/src/hooks/api/identities/types.ts
+++ b/frontend/src/hooks/api/identities/types.ts
@@ -1,7 +1,7 @@
import { OrderByDirection } from "../generic/types";
import { OrgIdentityOrderBy } from "../organization/types";
import { TOrgRole } from "../roles/types";
-import { ProjectUserMembershipTemporaryMode, Workspace } from "../workspace/types";
+import { ProjectUserMembershipTemporaryMode, Project } 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;
diff --git a/frontend/src/hooks/api/keys/index.tsx b/frontend/src/hooks/api/keys/index.tsx
deleted file mode 100644
index cd4f0aea8c..0000000000
--- a/frontend/src/hooks/api/keys/index.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { useGetUserWsKey, useUploadWsKey } from "./queries";
diff --git a/frontend/src/hooks/api/keys/queries.tsx b/frontend/src/hooks/api/keys/queries.tsx
deleted file mode 100644
index f902f85d37..0000000000
--- a/frontend/src/hooks/api/keys/queries.tsx
+++ /dev/null
@@ -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
- });
- }
- });
diff --git a/frontend/src/hooks/api/keys/types.ts b/frontend/src/hooks/api/keys/types.ts
deleted file mode 100644
index fc455deaf6..0000000000
--- a/frontend/src/hooks/api/keys/types.ts
+++ /dev/null
@@ -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;
-};
diff --git a/frontend/src/hooks/api/pkiSubscriber/mutations.tsx b/frontend/src/hooks/api/pkiSubscriber/mutations.tsx
index b30924f97a..17b53004be 100644
--- a/frontend/src/hooks/api/pkiSubscriber/mutations.tsx
+++ b/frontend/src/hooks/api/pkiSubscriber/mutations.tsx
@@ -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 "../workspace/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.getWorkspacePkiSubscribers(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.getPkiSubscriber({
@@ -46,7 +46,7 @@ export const useUpdatePkiSubscriber = () => {
},
onSuccess: ({ projectId, name }) => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getWorkspacePkiSubscribers(projectId)
+ queryKey: projectKeys.getWorkspacePkiSubscribers(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.getPkiSubscriber({
@@ -74,7 +74,7 @@ export const useDeletePkiSubscriber = () => {
},
onSuccess: ({ name, projectId }) => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getWorkspacePkiSubscribers(projectId)
+ queryKey: projectKeys.getWorkspacePkiSubscribers(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.getPkiSubscriber({
diff --git a/frontend/src/hooks/api/secretFolders/queries.tsx b/frontend/src/hooks/api/secretFolders/queries.tsx
index 9e12f329da..250db962a6 100644
--- a/frontend/src/hooks/api/secretFolders/queries.tsx
+++ b/frontend/src/hooks/api/secretFolders/queries.tsx
@@ -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;
},
@@ -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 })
});
}
});
@@ -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 })
});
}
});
@@ -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 })
});
}
});
@@ -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
})
diff --git a/frontend/src/hooks/api/secrets/mutations.tsx b/frontend/src/hooks/api/secrets/mutations.tsx
index 11ebad4b13..715aa108a8 100644
--- a/frontend/src/hooks/api/secrets/mutations.tsx
+++ b/frontend/src/hooks/api/secrets/mutations.tsx
@@ -66,7 +66,7 @@ export const useCreateSecretV3 = ({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
- queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
+ queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -131,7 +131,7 @@ export const useUpdateSecretV3 = ({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
- queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
+ queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -183,7 +183,7 @@ export const useDeleteSecretV3 = ({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
- queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
+ queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -225,7 +225,7 @@ export const useCreateSecretBatch = ({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
- queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
+ queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -267,7 +267,7 @@ export const useUpdateSecretBatch = ({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
- queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
+ queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -311,7 +311,7 @@ export const useDeleteSecretBatch = ({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
- queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
+ queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -391,7 +391,7 @@ export const useMoveSecrets = ({
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({
- workspaceId: projectId,
+ projectId: projectId,
environment: sourceEnvironment,
directory: sourceSecretPath
})
@@ -515,7 +515,7 @@ export const useCreateCommit = () => {
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath })
});
queryClient.invalidateQueries({
- queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
+ queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
diff --git a/frontend/src/hooks/api/serviceTokens/queries.tsx b/frontend/src/hooks/api/serviceTokens/queries.tsx
index 06b9b09c6f..41421b2796 100644
--- a/frontend/src/hooks/api/serviceTokens/queries.tsx
+++ b/frontend/src/hooks/api/serviceTokens/queries.tsx
@@ -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;
diff --git a/frontend/src/hooks/api/sshCa/mutations.tsx b/frontend/src/hooks/api/sshCa/mutations.tsx
index c7e90c3b9d..11d7fa8f55 100644
--- a/frontend/src/hooks/api/sshCa/mutations.tsx
+++ b/frontend/src/hooks/api/sshCa/mutations.tsx
@@ -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 "../workspace/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.getWorkspaceSshCas(projectId) });
}
});
};
@@ -43,7 +43,7 @@ export const useUpdateSshCa = () => {
return ca;
},
onSuccess: ({ projectId }, { caId }) => {
- queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshCas(projectId) });
+ queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshCas(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.getWorkspaceSshCas(projectId) });
}
});
};
@@ -76,7 +76,7 @@ export const useSignSshKey = () => {
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.allWorkspaceSshCertificates(projectId)
+ queryKey: projectKeys.allWorkspaceSshCertificates(projectId)
});
}
});
@@ -94,7 +94,7 @@ export const useIssueSshCreds = () => {
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.allWorkspaceSshCertificates(projectId)
+ queryKey: projectKeys.allWorkspaceSshCertificates(projectId)
});
}
});
diff --git a/frontend/src/hooks/api/sshHost/mutations.tsx b/frontend/src/hooks/api/sshHost/mutations.tsx
index f6b831f3e7..0ebfd087e6 100644
--- a/frontend/src/hooks/api/sshHost/mutations.tsx
+++ b/frontend/src/hooks/api/sshHost/mutations.tsx
@@ -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 "../workspace/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.getWorkspaceSshHosts(projectId) });
}
});
};
@@ -26,7 +26,7 @@ export const useUpdateSshHost = () => {
return host;
},
onSuccess: ({ projectId }) => {
- queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshHosts(projectId) });
+ queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshHosts(projectId) });
}
});
};
@@ -39,7 +39,7 @@ export const useDeleteSshHost = () => {
return host;
},
onSuccess: ({ projectId }) => {
- queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceSshHosts(projectId) });
+ queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshHosts(projectId) });
}
});
};
diff --git a/frontend/src/hooks/api/sshHostGroup/mutations.tsx b/frontend/src/hooks/api/sshHostGroup/mutations.tsx
index b75cff1872..b06089809d 100644
--- a/frontend/src/hooks/api/sshHostGroup/mutations.tsx
+++ b/frontend/src/hooks/api/sshHostGroup/mutations.tsx
@@ -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 "../workspace/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.getWorkspaceSshHostGroups(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.getWorkspaceSshHostGroups(projectId)
});
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getWorkspaceSshHosts(projectId)
+ queryKey: projectKeys.getWorkspaceSshHosts(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.getWorkspaceSshHostGroups(projectId)
});
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getWorkspaceSshHosts(projectId)
+ queryKey: projectKeys.getWorkspaceSshHosts(projectId)
});
queryClient.invalidateQueries({
queryKey: sshHostGroupKeys.getSshHostGroupById(sshHostGroupId)
diff --git a/frontend/src/hooks/api/types.ts b/frontend/src/hooks/api/types.ts
index 8c29d48258..99c991c358 100644
--- a/frontend/src/hooks/api/types.ts
+++ b/frontend/src/hooks/api/types.ts
@@ -7,7 +7,6 @@ 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 { TSecretApprovalPolicy } from "./secretApproval/types";
export type {
@@ -37,7 +36,7 @@ export type {
ToggleAutoCapitalizationDTO,
UpdateEnvironmentDTO,
UpdateProjectDTO,
- Workspace,
+ Project as Workspace,
WorkspaceEnv,
WorkspaceTag
} from "./workspace/types";
diff --git a/frontend/src/hooks/api/users/mutation.tsx b/frontend/src/hooks/api/users/mutation.tsx
index 1f3fdf3ad4..adc37fd42d 100644
--- a/frontend/src/hooks/api/users/mutation.tsx
+++ b/frontend/src/hooks/api/users/mutation.tsx
@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
-import { workspaceKeys } from "../workspace";
+import { projectKeys } from "../workspace";
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.getWorkspaceUsers(projectId) });
queryClient.invalidateQueries({
queryKey: userKeys.allOrgMembershipProjectMemberships(orgId)
});
diff --git a/frontend/src/hooks/api/workflowIntegrations/mutation.tsx b/frontend/src/hooks/api/workflowIntegrations/mutation.tsx
index 89c65f888b..49aaab815f 100644
--- a/frontend/src/hooks/api/workflowIntegrations/mutation.tsx
+++ b/frontend/src/hooks/api/workflowIntegrations/mutation.tsx
@@ -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 "../workspace/query-keys";
import { workflowIntegrationKeys } from "./queries";
import {
TCheckMicrosoftTeamsIntegrationInstallationStatusDTO,
@@ -126,7 +126,7 @@ export const useUpdateProjectWorkflowIntegrationConfig = () => {
},
onSuccess: (_, { workspaceId, integration }) => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getWorkspaceWorkflowIntegrationConfig(workspaceId, integration)
+ queryKey: projectKeys.getWorkspaceWorkflowIntegrationConfig(workspaceId, integration)
});
}
});
@@ -145,7 +145,7 @@ export const useDeleteProjectWorkflowIntegration = () => {
},
onSuccess: (_, { projectId, integration }) => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getWorkspaceWorkflowIntegrationConfig(projectId, integration)
+ queryKey: projectKeys.getWorkspaceWorkflowIntegrationConfig(projectId, integration)
});
}
});
diff --git a/frontend/src/hooks/api/workspace/index.tsx b/frontend/src/hooks/api/workspace/index.tsx
index df2d55dc3b..02d17f14c5 100644
--- a/frontend/src/hooks/api/workspace/index.tsx
+++ b/frontend/src/hooks/api/workspace/index.tsx
@@ -50,4 +50,4 @@ export {
useUpdateWsEnvironment,
useUpgradeProject
} from "./queries";
-export { workspaceKeys } from "./query-keys";
+export { projectKeys } from "./query-keys";
diff --git a/frontend/src/hooks/api/workspace/mutations.tsx b/frontend/src/hooks/api/workspace/mutations.tsx
index f62fc831c5..bde2666a95 100644
--- a/frontend/src/hooks/api/workspace/mutations.tsx
+++ b/frontend/src/hooks/api/workspace/mutations.tsx
@@ -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 as projectKeys } 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
});
@@ -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
});
@@ -74,7 +74,7 @@ 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 }) => {
@@ -91,9 +91,9 @@ 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: projectKeys.getAllUserWorkspace() });
@@ -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,7 +129,7 @@ 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
});
diff --git a/frontend/src/hooks/api/workspace/queries.tsx b/frontend/src/hooks/api/workspace/queries.tsx
index 3c7a6d30c6..cdda24ee40 100644
--- a/frontend/src/hooks/api/workspace/queries.tsx
+++ b/frontend/src/hooks/api/workspace/queries.tsx
@@ -26,7 +26,7 @@ import {
ProjectWorkflowIntegrationConfig,
WorkflowIntegrationPlatform
} from "../workflowIntegrations/types";
-import { workspaceKeys } from "./query-keys";
+import { projectKeys } from "./query-keys";
import {
CreateEnvironmentDTO,
CreateWorkspaceDTO,
@@ -47,21 +47,19 @@ import {
UpdateEnvironmentDTO,
UpdatePitVersionLimitDTO,
UpdateProjectDTO,
- Workspace,
+ Project,
WorkspaceEnv
} from "./types";
-export const fetchWorkspaceById = async (workspaceId: string) => {
- const { data } = await apiRequest.get<{ workspace: Workspace }>(
- `/api/v1/workspace/${workspaceId}`
- );
+export const fetchWorkspaceById = async (projectId: string) => {
+ const { data } = await apiRequest.get<{ project: Project }>(`/api/v1/projects/${projectId}`);
- return data.workspace;
+ return data.project;
};
-const fetchWorkspaceIndexStatus = async (workspaceId: string) => {
+const fetchWorkspaceIndexStatus = async (projectId: string) => {
const { data } = await apiRequest.get<boolean>(
- `/api/v3/workspaces/${workspaceId}/secrets/blind-index-status`
+ `/api/v3/projects/${projectId}/secrets/blind-index-status`
);
return data;
@@ -69,18 +67,16 @@ const fetchWorkspaceIndexStatus = async (workspaceId: string) => {
const fetchProjectUpgradeStatus = async (projectId: string) => {
const { data } = await apiRequest.get<{ status: string }>(
- `/api/v2/workspace/${projectId}/upgrade/status`
+ `/api/v1/projects/${projectId}/upgrade/status`
);
return data;
};
-export const fetchWorkspaceSecrets = async (workspaceId: string) => {
+export const fetchWorkspaceSecrets = async (projectId: string) => {
const {
data: { secrets }
- } = await apiRequest.get<{ secrets: EncryptedSecret[] }>(
- `/api/v3/workspaces/${workspaceId}/secrets`
- );
+ } = await apiRequest.get<{ secrets: EncryptedSecret[] }>(`/api/v3/projects/${projectId}/secrets`);
return secrets;
};
@@ -90,13 +86,13 @@ export const useUpgradeProject = () => {
return useMutation<object, object, { projectId: string; privateKey: string }>({
mutationFn: ({ projectId, privateKey }) => {
- return apiRequest.post(`/api/v2/workspace/${projectId}/upgrade`, {
+ return apiRequest.post(`/api/v1/projects/${projectId}/upgrade`, {
userPrivateKey: privateKey
});
},
onSuccess: () => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getAllUserWorkspace()
+ queryKey: projectKeys.getAllUserWorkspace()
});
}
});
@@ -108,7 +104,7 @@ export const useGetUpgradeProjectStatus = ({
refetchInterval
}: TGetUpgradeProjectStatusDTO) => {
return useQuery({
- queryKey: workspaceKeys.getProjectUpgradeStatus(projectId),
+ queryKey: projectKeys.getProjectUpgradeStatus(projectId),
queryFn: () => fetchProjectUpgradeStatus(projectId),
enabled,
refetchInterval
@@ -116,39 +112,39 @@ export const useGetUpgradeProjectStatus = ({
};
const fetchUserWorkspaces = async (includeRoles?: boolean, type?: ProjectType | "all") => {
- const { data } = await apiRequest.get<{ workspaces: Workspace[] }>("/api/v1/workspace", {
+ const { data } = await apiRequest.get<{ projects: Project[] }>("/api/v1/projects", {
params: {
includeRoles,
type
}
});
- return data.workspaces;
+ return data.projects;
};
-export const useGetWorkspaceIndexStatus = (workspaceId: string) => {
+export const useGetWorkspaceIndexStatus = (projectId: string) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspaceIndexStatus(workspaceId),
- queryFn: () => fetchWorkspaceIndexStatus(workspaceId),
+ queryKey: projectKeys.getWorkspaceIndexStatus(projectId),
+ queryFn: () => fetchWorkspaceIndexStatus(projectId),
enabled: true
});
};
-export const useGetWorkspaceSecrets = (workspaceId: string) => {
+export const useGetWorkspaceSecrets = (projectId: string) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspaceSecrets(workspaceId),
- queryFn: () => fetchWorkspaceSecrets(workspaceId),
+ queryKey: projectKeys.getWorkspaceSecrets(projectId),
+ queryFn: () => fetchWorkspaceSecrets(projectId),
enabled: true
});
};
export const useGetWorkspaceById = (
- workspaceId: string,
+ projectId: string,
dto?: { refetchInterval?: number | false }
) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspaceById(workspaceId),
- queryFn: () => fetchWorkspaceById(workspaceId),
- enabled: Boolean(workspaceId),
+ queryKey: projectKeys.getWorkspaceById(projectId),
+ queryFn: () => fetchWorkspaceById(projectId),
+ enabled: Boolean(projectId),
refetchInterval: dto?.refetchInterval
});
};
@@ -161,19 +157,19 @@ export const useGetUserWorkspaces = ({
options?: { enabled?: boolean };
} = {}) =>
useQuery({
- queryKey: workspaceKeys.getAllUserWorkspace(),
+ queryKey: projectKeys.getAllUserWorkspace(),
queryFn: () => fetchUserWorkspaces(includeRoles),
...options
});
export const useSearchProjects = ({ options, ...dto }: TSearchProjectsDTO) =>
useQuery({
- queryKey: workspaceKeys.searchWorkspace(dto),
+ queryKey: projectKeys.searchWorkspace(dto),
queryFn: async () => {
const { data } = await apiRequest.post<{
- projects: (Workspace & { isMember: boolean })[];
+ projects: (Project & { isMember: boolean })[];
totalCount: number;
- }>("/api/v1/workspace/search", dto);
+ }>("/api/v1/projects/search", dto);
return data;
},
@@ -181,17 +177,17 @@ export const useSearchProjects = ({ options, ...dto }: TSearchProjectsDTO) =>
});
const fetchUserWorkspaceMemberships = async (orgId: string) => {
- const { data } = await apiRequest.get<Record<string, Workspace[]>>(
- `/api/v1/organization/${orgId}/workspace-memberships`
+ const { data } = await apiRequest.get<Record<string, Project[]>>(
+ `/api/v1/organization/${orgId}/project-memberships`
);
return data;
};
-// to get all userids in an org with the workspace they are part of
+// to get all userids in an org with the project they are part of
export const useGetUserWorkspaceMemberships = (orgId: string) =>
useQuery({
- queryKey: workspaceKeys.getWorkspaceMemberships(orgId),
+ queryKey: projectKeys.getWorkspaceMemberships(orgId),
queryFn: () => fetchUserWorkspaceMemberships(orgId),
enabled: Boolean(orgId)
});
@@ -200,62 +196,62 @@ export const useNameWorkspaceSecrets = () => {
const queryClient = useQueryClient();
return useMutation<object, object, NameWorkspaceSecretsDTO>({
- mutationFn: async ({ workspaceId, secretsToUpdate }) =>
- apiRequest.post(`/api/v3/workspaces/${workspaceId}/secrets/names`, {
+ mutationFn: async ({ projectId, secretsToUpdate }) =>
+ apiRequest.post(`/api/v3/projects/${projectId}/secrets/names`, {
secretsToUpdate
}),
onSuccess: (_, variables) => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getWorkspaceIndexStatus(variables.workspaceId)
+ queryKey: projectKeys.getWorkspaceIndexStatus(variables.projectId)
});
}
});
};
-const fetchWorkspaceAuthorization = async (workspaceId: string) => {
+const fetchWorkspaceAuthorization = async (projectId: string) => {
const { data } = await apiRequest.get<{ authorizations: IntegrationAuth[] }>(
- `/api/v1/workspace/${workspaceId}/authorizations`
+ `/api/v1/projects/${projectId}/authorizations`
);
return data.authorizations;
};
export const useGetWorkspaceAuthorizations = <TData = IntegrationAuth[],>(
- workspaceId: string,
+ projectId: string,
select?: (data: IntegrationAuth[]) => TData
) =>
useQuery({
- queryKey: workspaceKeys.getWorkspaceAuthorization(workspaceId),
- queryFn: () => fetchWorkspaceAuthorization(workspaceId),
- enabled: Boolean(workspaceId),
+ queryKey: projectKeys.getWorkspaceAuthorization(projectId),
+ queryFn: () => fetchWorkspaceAuthorization(projectId),
+ enabled: Boolean(projectId),
select
});
-export const fetchWorkspaceIntegrations = async (workspaceId: string) => {
+export const fetchWorkspaceIntegrations = async (projectId: string) => {
const { data } = await apiRequest.get<{ integrations: TIntegration[] }>(
- `/api/v1/workspace/${workspaceId}/integrations`
+ `/api/v1/projects/${projectId}/integrations`
);
return data.integrations;
};
-export const useGetWorkspaceIntegrations = (workspaceId: string) =>
+export const useGetWorkspaceIntegrations = (projectId: string) =>
useQuery({
- queryKey: workspaceKeys.getWorkspaceIntegrations(workspaceId),
- queryFn: () => fetchWorkspaceIntegrations(workspaceId),
- enabled: Boolean(workspaceId),
+ queryKey: projectKeys.getWorkspaceIntegrations(projectId),
+ queryFn: () => fetchWorkspaceIntegrations(projectId),
+ enabled: Boolean(projectId),
refetchInterval: 4000
});
export const createWorkspace = (
dto: CreateWorkspaceDTO
-): Promise<{ data: { project: Workspace } }> => {
- return apiRequest.post("/api/v2/workspace", dto);
+): Promise<{ data: { project: Project } }> => {
+ return apiRequest.post("/api/v1/projects", dto);
};
export const useCreateWorkspace = () => {
const queryClient = useQueryClient();
- return useMutation<{ data: { project: Workspace } }, object, CreateWorkspaceDTO>({
+ return useMutation<{ data: { project: Project } }, object, CreateWorkspaceDTO>({
mutationFn: async ({ projectName, projectDescription, kmsKeyId, template, type }) =>
createWorkspace({
projectName,
@@ -266,7 +262,7 @@ export const useCreateWorkspace = () => {
}),
onSuccess: () => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getAllUserWorkspace()
+ queryKey: projectKeys.getAllUserWorkspace()
});
}
});
@@ -275,7 +271,7 @@ export const useCreateWorkspace = () => {
export const useUpdateProject = () => {
const queryClient = useQueryClient();
- return useMutation<Workspace, object, UpdateProjectDTO>({
+ return useMutation<Project, object, UpdateProjectDTO>({
mutationFn: async ({
projectID,
newProjectName,
@@ -285,8 +281,8 @@ export const useUpdateProject = () => {
showSnapshotsLegacy,
secretDetectionIgnoreValues
}) => {
- const { data } = await apiRequest.patch<{ workspace: Workspace }>(
- `/api/v1/workspace/${projectID}`,
+ const { data } = await apiRequest.patch<{ project: Project }>(
+ `/api/v1/projects/${projectID}`,
{
name: newProjectName,
description: newProjectDescription,
@@ -296,10 +292,10 @@ export const useUpdateProject = () => {
secretDetectionIgnoreValues
}
);
- return data.workspace;
+ return data.project;
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
+ queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
}
});
};
@@ -307,18 +303,18 @@ export const useUpdateProject = () => {
export const useToggleAutoCapitalization = () => {
const queryClient = useQueryClient();
- return useMutation<Workspace, object, ToggleAutoCapitalizationDTO>({
- mutationFn: async ({ workspaceID, state }) => {
- const { data } = await apiRequest.post<{ workspace: Workspace }>(
- `/api/v1/workspace/${workspaceID}/auto-capitalization`,
+ return useMutation<Project, object, ToggleAutoCapitalizationDTO>({
+ mutationFn: async ({ projectID, state }) => {
+ const { data } = await apiRequest.post<{ project: Project }>(
+ `/api/v1/projects/${projectID}/auto-capitalization`,
{
autoCapitalization: state
}
);
- return data.workspace;
+ return data.project;
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
+ queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
}
});
};
@@ -326,18 +322,18 @@ export const useToggleAutoCapitalization = () => {
export const useToggleDeleteProjectProtection = () => {
const queryClient = useQueryClient();
- return useMutation<Workspace, object, ToggleDeleteProjectProtectionDTO>({
- mutationFn: async ({ workspaceID, state }) => {
- const { data } = await apiRequest.post<{ workspace: Workspace }>(
- `/api/v1/workspace/${workspaceID}/delete-protection`,
+ return useMutation<Project, object, ToggleDeleteProjectProtectionDTO>({
+ mutationFn: async ({ projectID, state }) => {
+ const { data } = await apiRequest.post<{ project: Project }>(
+ `/api/v1/projects/${projectID}/delete-protection`,
{
hasDeleteProtection: state
}
);
- return data.workspace;
+ return data.project;
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
+ queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
}
});
};
@@ -345,15 +341,15 @@ export const useToggleDeleteProjectProtection = () => {
export const useUpdateWorkspaceVersionLimit = () => {
const queryClient = useQueryClient();
- return useMutation<Workspace, object, UpdatePitVersionLimitDTO>({
+ return useMutation<Project, object, UpdatePitVersionLimitDTO>({
mutationFn: async ({ projectSlug, pitVersionLimit }) => {
- const { data } = await apiRequest.put(`/api/v1/workspace/${projectSlug}/version-limit`, {
+ const { data } = await apiRequest.put(`/api/v1/projects/${projectSlug}/version-limit`, {
pitVersionLimit
});
- return data.workspace;
+ return data.project;
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
+ queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
}
});
};
@@ -361,18 +357,18 @@ export const useUpdateWorkspaceVersionLimit = () => {
export const useUpdateWorkspaceAuditLogsRetention = () => {
const queryClient = useQueryClient();
- return useMutation<Workspace, object, UpdateAuditLogsRetentionDTO>({
+ return useMutation<Project, object, UpdateAuditLogsRetentionDTO>({
mutationFn: async ({ projectSlug, auditLogsRetentionDays }) => {
const { data } = await apiRequest.put(
- `/api/v1/workspace/${projectSlug}/audit-logs-retention`,
+ `/api/v1/projects/${projectSlug}/audit-logs-retention`,
{
auditLogsRetentionDays
}
);
- return data.workspace;
+ return data.project;
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
+ queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
}
});
};
@@ -380,13 +376,13 @@ export const useUpdateWorkspaceAuditLogsRetention = () => {
export const useDeleteWorkspace = () => {
const queryClient = useQueryClient();
- return useMutation<Workspace, object, DeleteWorkspaceDTO>({
- mutationFn: async ({ workspaceID }) => {
- const { data } = await apiRequest.delete(`/api/v1/workspace/${workspaceID}`);
- return data.workspace;
+ return useMutation<Project, object, DeleteWorkspaceDTO>({
+ mutationFn: async ({ projectID }) => {
+ const { data } = await apiRequest.delete(`/api/v1/projects/${projectID}`);
+ return data.project;
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
+ queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
queryClient.invalidateQueries({
queryKey: ["org-admin-projects"]
});
@@ -398,9 +394,9 @@ export const useCreateWsEnvironment = () => {
const queryClient = useQueryClient();
return useMutation<WorkspaceEnv, WorkspaceEnv, CreateEnvironmentDTO>({
- mutationFn: async ({ workspaceId, name, slug }) => {
+ mutationFn: async ({ projectId, name, slug }) => {
const { data } = await apiRequest.post<{ environment: WorkspaceEnv }>(
- `/api/v1/workspace/${workspaceId}/environments`,
+ `/api/v1/projects/${projectId}/environments`,
{
name,
slug
@@ -410,7 +406,7 @@ export const useCreateWsEnvironment = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getAllUserWorkspace()
+ queryKey: projectKeys.getAllUserWorkspace()
});
}
});
@@ -420,8 +416,8 @@ export const useUpdateWsEnvironment = () => {
const queryClient = useQueryClient();
return useMutation<object, object, UpdateEnvironmentDTO>({
- mutationFn: ({ workspaceId, id, name, slug, position }) => {
- return apiRequest.patch(`/api/v1/workspace/${workspaceId}/environments/${id}`, {
+ mutationFn: ({ projectId, id, name, slug, position }) => {
+ return apiRequest.patch(`/api/v1/projects/${projectId}/environments/${id}`, {
name,
slug,
position
@@ -429,7 +425,7 @@ export const useUpdateWsEnvironment = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getAllUserWorkspace()
+ queryKey: projectKeys.getAllUserWorkspace()
});
}
});
@@ -439,57 +435,54 @@ export const useDeleteWsEnvironment = () => {
const queryClient = useQueryClient();
return useMutation<object, object, DeleteEnvironmentDTO>({
- mutationFn: ({ id, workspaceId }) => {
- return apiRequest.delete(`/api/v1/workspace/${workspaceId}/environments/${id}`);
+ mutationFn: ({ id, projectId }) => {
+ return apiRequest.delete(`/api/v1/projects/${projectId}/environments/${id}`);
},
onSuccess: () => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getAllUserWorkspace()
+ queryKey: projectKeys.getAllUserWorkspace()
});
}
});
};
export const useGetWorkspaceUsers = (
- workspaceId: string,
+ projectId: string,
includeGroupMembers?: boolean,
roles?: string[]
) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspaceUsers(workspaceId, includeGroupMembers, roles),
+ queryKey: projectKeys.getWorkspaceUsers(projectId, includeGroupMembers, roles),
queryFn: async () => {
const {
data: { users }
- } = await apiRequest.get<{ users: TWorkspaceUser[] }>(
- `/api/v1/workspace/${workspaceId}/users`,
- {
- params: {
- includeGroupMembers,
- roles:
- roles && roles.length > 0
- ? roles.map((role) => encodeURIComponent(role)).join(",")
- : undefined
- }
+ } = await apiRequest.get<{ users: TWorkspaceUser[] }>(`/api/v1/projects/${projectId}/users`, {
+ params: {
+ includeGroupMembers,
+ roles:
+ roles && roles.length > 0
+ ? roles.map((role) => encodeURIComponent(role)).join(",")
+ : undefined
}
- );
+ });
return users;
},
enabled: true
});
};
-export const useGetWorkspaceUserDetails = (workspaceId: string, membershipId: string) => {
+export const useGetWorkspaceUserDetails = (projectId: string, membershipId: string) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspaceUserDetails(workspaceId, membershipId),
+ queryKey: projectKeys.getWorkspaceUserDetails(projectId, membershipId),
queryFn: async () => {
const {
data: { membership }
} = await apiRequest.get<{ membership: TWorkspaceUser }>(
- `/api/v1/workspace/${workspaceId}/memberships/${membershipId}`
+ `/api/v1/projects/${projectId}/memberships/${membershipId}`
);
return membership;
},
- enabled: Boolean(workspaceId) && Boolean(membershipId)
+ enabled: Boolean(projectId) && Boolean(membershipId)
});
};
@@ -499,21 +492,21 @@ export const useDeleteUserFromWorkspace = () => {
return useMutation({
mutationFn: async ({
usernames,
- workspaceId
+ projectId
}: {
- workspaceId: string;
+ projectId: string;
usernames: string[];
orgId: string;
}) => {
const {
data: { deletedMembership }
- } = await apiRequest.delete(`/api/v2/workspace/${workspaceId}/memberships`, {
+ } = await apiRequest.delete(`/api/v1/projects/${projectId}/memberships`, {
data: { usernames }
});
return deletedMembership;
},
- onSuccess: (_, { orgId, workspaceId }) => {
- queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceUsers(workspaceId) });
+ onSuccess: (_, { orgId, projectId }) => {
+ queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceUsers(projectId) });
queryClient.invalidateQueries({
queryKey: userKeys.allOrgMembershipProjectMemberships(orgId)
});
@@ -524,21 +517,21 @@ export const useDeleteUserFromWorkspace = () => {
export const useUpdateUserWorkspaceRole = () => {
const queryClient = useQueryClient();
return useMutation({
- mutationFn: async ({ membershipId, roles, workspaceId }: TUpdateWorkspaceUserRoleDTO) => {
+ mutationFn: async ({ membershipId, roles, projectId }: TUpdateWorkspaceUserRoleDTO) => {
const {
data: { membership }
} = await apiRequest.patch<{ membership: { projectId: string } }>(
- `/api/v1/workspace/${workspaceId}/memberships/${membershipId}`,
+ `/api/v1/projects/${projectId}/memberships/${membershipId}`,
{
roles
}
);
return membership;
},
- onSuccess: (_, { workspaceId, membershipId }) => {
- queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceUsers(workspaceId) });
+ onSuccess: (_, { projectId, membershipId }) => {
+ queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceUsers(projectId) });
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getWorkspaceUserDetails(workspaceId, membershipId)
+ queryKey: projectKeys.getWorkspaceUserDetails(projectId, membershipId)
});
}
});
@@ -549,17 +542,17 @@ export const useAddIdentityToWorkspace = () => {
return useMutation({
mutationFn: async ({
identityId,
- workspaceId,
+ projectId,
role
}: {
identityId: string;
- workspaceId: string;
+ projectId: string;
role?: string;
}) => {
const {
data: { identityMembership }
} = await apiRequest.post(
- `/api/v2/workspace/${workspaceId}/identity-memberships/${identityId}`,
+ `/api/v1/projects/${projectId}/identity-memberships/${identityId}`,
{
role
}
@@ -567,9 +560,9 @@ export const useAddIdentityToWorkspace = () => {
return identityMembership;
},
- onSuccess: (_, { identityId, workspaceId }) => {
+ onSuccess: (_, { identityId, projectId }) => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getWorkspaceIdentityMemberships(workspaceId)
+ queryKey: projectKeys.getWorkspaceIdentityMemberships(projectId)
});
queryClient.invalidateQueries({
queryKey: identitiesKeys.getIdentityProjectMemberships(identityId)
@@ -581,11 +574,11 @@ export const useAddIdentityToWorkspace = () => {
export const useUpdateIdentityWorkspaceRole = () => {
const queryClient = useQueryClient();
return useMutation({
- mutationFn: async ({ identityId, workspaceId, roles }: TUpdateWorkspaceIdentityRoleDTO) => {
+ mutationFn: async ({ identityId, projectId, roles }: TUpdateWorkspaceIdentityRoleDTO) => {
const {
data: { identityMembership }
} = await apiRequest.patch(
- `/api/v2/workspace/${workspaceId}/identity-memberships/${identityId}`,
+ `/api/v1/projects/${projectId}/identity-memberships/${identityId}`,
{
roles
}
@@ -593,15 +586,15 @@ export const useUpdateIdentityWorkspaceRole = () => {
return identityMembership;
},
- onSuccess: (_, { identityId, workspaceId }) => {
+ onSuccess: (_, { identityId, projectId }) => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getWorkspaceIdentityMemberships(workspaceId)
+ queryKey: projectKeys.getWorkspaceIdentityMemberships(projectId)
});
queryClient.invalidateQueries({
queryKey: identitiesKeys.getIdentityProjectMemberships(identityId)
});
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getWorkspaceIdentityMembershipDetails(workspaceId, identityId)
+ queryKey: projectKeys.getWorkspaceIdentityMembershipDetails(projectId, identityId)
});
}
});
@@ -610,23 +603,17 @@ export const useUpdateIdentityWorkspaceRole = () => {
export const useDeleteIdentityFromWorkspace = () => {
const queryClient = useQueryClient();
return useMutation({
- mutationFn: async ({
- identityId,
- workspaceId
- }: {
- identityId: string;
- workspaceId: string;
- }) => {
+ mutationFn: async ({ identityId, projectId }: { identityId: string; projectId: string }) => {
const {
data: { identityMembership }
} = await apiRequest.delete(
- `/api/v2/workspace/${workspaceId}/identity-memberships/${identityId}`
+ `/api/v1/projects/${projectId}/identity-memberships/${identityId}`
);
return identityMembership;
},
- onSuccess: (_, { identityId, workspaceId }) => {
+ onSuccess: (_, { identityId, projectId }) => {
queryClient.invalidateQueries({
- queryKey: workspaceKeys.getWorkspaceIdentityMemberships(workspaceId)
+ queryKey: projectKeys.getWorkspaceIdentityMemberships(projectId)
});
queryClient.invalidateQueries({
queryKey: identitiesKeys.getIdentityProjectMemberships(identityId)
@@ -637,7 +624,7 @@ export const useDeleteIdentityFromWorkspace = () => {
export const useGetWorkspaceIdentityMemberships = (
{
- workspaceId,
+ projectId,
offset = 0,
limit = 100,
orderBy = ProjectIdentityOrderBy.Name,
@@ -649,14 +636,14 @@ export const useGetWorkspaceIdentityMemberships = (
TProjectIdentitiesList,
unknown,
TProjectIdentitiesList,
- ReturnType<typeof workspaceKeys.getWorkspaceIdentityMembershipsWithParams>
+ ReturnType<typeof projectKeys.getWorkspaceIdentityMembershipsWithParams>
>,
"queryKey" | "queryFn"
>
) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspaceIdentityMembershipsWithParams({
- workspaceId,
+ queryKey: projectKeys.getWorkspaceIdentityMembershipsWithParams({
+ projectId,
offset,
limit,
orderBy,
@@ -673,7 +660,7 @@ export const useGetWorkspaceIdentityMemberships = (
});
const { data } = await apiRequest.get<TProjectIdentitiesList>(
- `/api/v2/workspace/${workspaceId}/identity-memberships`,
+ `/api/v1/projects/${projectId}/identity-memberships`,
{ params }
);
return data;
@@ -686,12 +673,12 @@ export const useGetWorkspaceIdentityMemberships = (
export const useGetWorkspaceIdentityMembershipDetails = (projectId: string, identityId: string) => {
return useQuery({
enabled: Boolean(projectId && identityId),
- queryKey: workspaceKeys.getWorkspaceIdentityMembershipDetails(projectId, identityId),
+ queryKey: projectKeys.getWorkspaceIdentityMembershipDetails(projectId, identityId),
queryFn: async () => {
const {
data: { identityMembership }
} = await apiRequest.get<{ identityMembership: IdentityMembership }>(
- `/api/v2/workspace/${projectId}/identity-memberships/${identityId}`
+ `/api/v1/projects/${projectId}/identity-memberships/${identityId}`
);
return identityMembership;
}
@@ -701,12 +688,12 @@ export const useGetWorkspaceIdentityMembershipDetails = (projectId: string, iden
export const useGetWorkspaceGroupMembershipDetails = (projectId: string, groupId: string) => {
return useQuery({
enabled: Boolean(projectId && groupId),
- queryKey: workspaceKeys.getWorkspaceGroupMembershipDetails(projectId, groupId),
+ queryKey: projectKeys.getWorkspaceGroupMembershipDetails(projectId, groupId),
queryFn: async () => {
const {
data: { groupMembership }
} = await apiRequest.get<{ groupMembership: TGroupMembership }>(
- `/api/v2/workspace/${projectId}/groups/${groupId}`
+ `/api/v1/projects/${projectId}/groups/${groupId}`
);
return groupMembership;
}
@@ -715,12 +702,12 @@ export const useGetWorkspaceGroupMembershipDetails = (projectId: string, groupId
export const useListWorkspaceGroups = (projectId: string) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspaceGroupMemberships(projectId),
+ queryKey: projectKeys.getWorkspaceGroupMemberships(projectId),
queryFn: async () => {
const {
data: { groupMemberships }
} = await apiRequest.get<{ groupMemberships: TGroupMembership[] }>(
- `/api/v2/workspace/${projectId}/groups`
+ `/api/v1/projects/${projectId}/groups`
);
return groupMemberships;
},
@@ -736,7 +723,7 @@ export const useListWorkspaceCas = ({
status?: CaStatus;
}) => {
return useQuery({
- queryKey: workspaceKeys.specificWorkspaceCas({
+ queryKey: projectKeys.specificWorkspaceCas({
projectSlug,
status
}),
@@ -748,7 +735,7 @@ export const useListWorkspaceCas = ({
const {
data: { cas }
} = await apiRequest.get<{ cas: TCertificateAuthority[] }>(
- `/api/v2/workspace/${projectSlug}/cas`,
+ `/api/v1/projects/${projectSlug}/cas`,
{
params
}
@@ -769,7 +756,7 @@ export const useListWorkspaceCertificates = ({
limit: number;
}) => {
return useQuery({
- queryKey: workspaceKeys.specificWorkspaceCertificates({
+ queryKey: projectKeys.specificWorkspaceCertificates({
slug: projectSlug,
offset,
limit
@@ -783,7 +770,7 @@ export const useListWorkspaceCertificates = ({
const {
data: { certificates, totalCount }
} = await apiRequest.get<{ certificates: TCertificate[]; totalCount: number }>(
- `/api/v2/workspace/${projectSlug}/certificates`,
+ `/api/v1/projects/${projectSlug}/certificates`,
{
params
}
@@ -795,51 +782,49 @@ export const useListWorkspaceCertificates = ({
});
};
-export const useListWorkspacePkiAlerts = ({ workspaceId }: { workspaceId: string }) => {
+export const useListWorkspacePkiAlerts = ({ projectId }: { projectId: string }) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspacePkiAlerts(workspaceId),
+ queryKey: projectKeys.getWorkspacePkiAlerts(projectId),
queryFn: async () => {
const {
data: { alerts }
- } = await apiRequest.get<{ alerts: TPkiAlert[] }>(
- `/api/v2/workspace/${workspaceId}/pki-alerts`
- );
+ } = await apiRequest.get<{ alerts: TPkiAlert[] }>(`/api/v1/projects/${projectId}/pki-alerts`);
return { alerts };
},
- enabled: Boolean(workspaceId)
+ enabled: Boolean(projectId)
});
};
-export const useListWorkspacePkiCollections = ({ workspaceId }: { workspaceId: string }) => {
+export const useListWorkspacePkiCollections = ({ projectId }: { projectId: string }) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspacePkiCollections(workspaceId),
+ queryKey: projectKeys.getWorkspacePkiCollections(projectId),
queryFn: async () => {
const {
data: { collections }
} = await apiRequest.get<{ collections: TPkiCollection[] }>(
- `/api/v2/workspace/${workspaceId}/pki-collections`
+ `/api/v1/projects/${projectId}/pki-collections`
);
return { collections };
},
- enabled: Boolean(workspaceId)
+ enabled: Boolean(projectId)
});
};
-export const useListWorkspaceCertificateTemplates = ({ workspaceId }: { workspaceId: string }) => {
+export const useListWorkspaceCertificateTemplates = ({ projectId }: { projectId: string }) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspaceCertificateTemplates(workspaceId),
+ queryKey: projectKeys.getWorkspaceCertificateTemplates(projectId),
queryFn: async () => {
const {
data: { certificateTemplates }
} = await apiRequest.get<{ certificateTemplates: TCertificateTemplate[] }>(
- `/api/v2/workspace/${workspaceId}/certificate-templates`
+ `/api/v1/projects/${projectId}/certificate-templates`
);
return { certificateTemplates };
},
- enabled: Boolean(workspaceId)
+ enabled: Boolean(projectId)
});
};
@@ -853,7 +838,7 @@ export const useListWorkspaceSshCertificates = ({
projectId: string;
}) => {
return useQuery({
- queryKey: workspaceKeys.specificWorkspaceSshCertificates({
+ queryKey: projectKeys.specificWorkspaceSshCertificates({
offset,
limit,
projectId
@@ -867,7 +852,7 @@ export const useListWorkspaceSshCertificates = ({
const { data } = await apiRequest.get<{
certificates: TSshCertificate[];
totalCount: number;
- }>(`/api/v2/workspace/${projectId}/ssh-certificates`, {
+ }>(`/api/v1/projects/${projectId}/ssh-certificates`, {
params
});
return data;
@@ -878,12 +863,12 @@ export const useListWorkspaceSshCertificates = ({
export const useListWorkspaceSshCas = (projectId: string) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspaceSshCas(projectId),
+ queryKey: projectKeys.getWorkspaceSshCas(projectId),
queryFn: async () => {
const {
data: { cas }
} = await apiRequest.get<{ cas: Omit<TSshCertificateAuthority, "publicKey">[] }>(
- `/api/v2/workspace/${projectId}/ssh-cas`
+ `/api/v1/projects/${projectId}/ssh-cas`
);
return cas;
},
@@ -893,11 +878,11 @@ export const useListWorkspaceSshCas = (projectId: string) => {
export const useListWorkspaceSshHosts = (projectId: string) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspaceSshHosts(projectId),
+ queryKey: projectKeys.getWorkspaceSshHosts(projectId),
queryFn: async () => {
const {
data: { hosts }
- } = await apiRequest.get<{ hosts: TSshHost[] }>(`/api/v2/workspace/${projectId}/ssh-hosts`);
+ } = await apiRequest.get<{ hosts: TSshHost[] }>(`/api/v1/projects/${projectId}/ssh-hosts`);
return hosts;
},
enabled: Boolean(projectId)
@@ -906,12 +891,12 @@ export const useListWorkspaceSshHosts = (projectId: string) => {
export const useListWorkspacePkiSubscribers = (projectId: string) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspacePkiSubscribers(projectId),
+ queryKey: projectKeys.getWorkspacePkiSubscribers(projectId),
queryFn: async () => {
const {
data: { subscribers }
} = await apiRequest.get<{ subscribers: TPkiSubscriber[] }>(
- `/api/v2/workspace/${projectId}/pki-subscribers`
+ `/api/v1/projects/${projectId}/pki-subscribers`
);
return subscribers;
},
@@ -921,12 +906,12 @@ export const useListWorkspacePkiSubscribers = (projectId: string) => {
export const useListWorkspaceSshHostGroups = (projectId: string) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspaceSshHostGroups(projectId),
+ queryKey: projectKeys.getWorkspaceSshHostGroups(projectId),
queryFn: async () => {
const {
data: { groups }
} = await apiRequest.get<{ groups: (TSshHostGroup & { hostCount: number })[] }>(
- `/api/v2/workspace/${projectId}/ssh-host-groups`
+ `/api/v1/projects/${projectId}/ssh-host-groups`
);
return groups;
},
@@ -936,10 +921,10 @@ export const useListWorkspaceSshHostGroups = (projectId: string) => {
export const useListWorkspaceSshCertificateTemplates = (projectId: string) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspaceSshCertificateTemplates(projectId),
+ queryKey: projectKeys.getWorkspaceSshCertificateTemplates(projectId),
queryFn: async () => {
const { data } = await apiRequest.get<{ certificateTemplates: TSshCertificateTemplate[] }>(
- `/api/v2/workspace/${projectId}/ssh-certificate-templates`
+ `/api/v1/projects/${projectId}/ssh-certificate-templates`
);
return data;
},
@@ -948,18 +933,18 @@ export const useListWorkspaceSshCertificateTemplates = (projectId: string) => {
};
export const useGetWorkspaceWorkflowIntegrationConfig = ({
- workspaceId,
+ projectId,
integration
}: {
- workspaceId: string;
+ projectId: string;
integration: WorkflowIntegrationPlatform;
}) => {
return useQuery({
- queryKey: workspaceKeys.getWorkspaceWorkflowIntegrationConfig(workspaceId, integration),
+ queryKey: projectKeys.getWorkspaceWorkflowIntegrationConfig(projectId, integration),
queryFn: async () => {
const { data } = await apiRequest
.get<ProjectWorkflowIntegrationConfig>(
- `/api/v1/workspace/${workspaceId}/workflow-integration-config/${integration}`
+ `/api/v1/projects/${projectId}/workflow-integration-config/${integration}`
)
.catch((err) => {
if (err.response.status === 404) {
@@ -971,16 +956,16 @@ export const useGetWorkspaceWorkflowIntegrationConfig = ({
return data;
},
- enabled: Boolean(workspaceId)
+ enabled: Boolean(projectId)
});
};
export const useGetProjectSshConfig = (projectId: string) => {
return useQuery({
- queryKey: workspaceKeys.getProjectSshConfig(projectId),
+ queryKey: projectKeys.getProjectSshConfig(projectId),
queryFn: async () => {
const { data } = await apiRequest.get<TProjectSshConfig>(
- `/api/v1/workspace/${projectId}/ssh-config`
+ `/api/v1/projects/${projectId}/ssh-config`
);
return data;
diff --git a/frontend/src/hooks/api/workspace/query-keys.tsx b/frontend/src/hooks/api/workspace/query-keys.tsx
index aca6f48b7d..2da17b3aac 100644
--- a/frontend/src/hooks/api/workspace/query-keys.tsx
+++ b/frontend/src/hooks/api/workspace/query-keys.tsx
@@ -3,47 +3,44 @@ import { TListProjectIdentitiesDTO, TSearchProjectsDTO } from "@app/hooks/api/wo
import type { CaStatus } from "../ca";
import { WorkflowIntegrationPlatform } from "../workflowIntegrations/types";
-export const workspaceKeys = {
- getWorkspaceById: (workspaceId: string) => ["workspaces", { workspaceId }] as const,
- getWorkspaceSecrets: (workspaceId: string) => [{ workspaceId }, "workspace-secrets"] as const,
- getWorkspaceIndexStatus: (workspaceId: string) =>
- [{ workspaceId }, "workspace-index-status"] as const,
- getProjectUpgradeStatus: (workspaceId: string) => [{ workspaceId }, "workspace-upgrade-status"],
- getWorkspaceMemberships: (orgId: string) => [{ orgId }, "workspace-memberships"],
- getWorkspaceAuthorization: (workspaceId: string) => [{ workspaceId }, "workspace-authorizations"],
- getWorkspaceIntegrations: (workspaceId: string) => [{ workspaceId }, "workspace-integrations"],
- getAllUserWorkspace: () => ["workspaces"] as const,
- getWorkspaceAuditLogs: (workspaceId: string) =>
- [{ workspaceId }, "workspace-audit-logs"] as const,
+export const projectKeys = {
+ getWorkspaceById: (projectId: string) => ["projects", { projectId }] as const,
+ getWorkspaceSecrets: (projectId: string) => [{ projectId }, "project-secrets"] as const,
+ getWorkspaceIndexStatus: (projectId: string) => [{ projectId }, "project-index-status"] as const,
+ getProjectUpgradeStatus: (projectId: string) => [{ projectId }, "project-upgrade-status"],
+ getWorkspaceMemberships: (orgId: string) => [{ orgId }, "project-memberships"],
+ getWorkspaceAuthorization: (projectId: string) => [{ projectId }, "project-authorizations"],
+ getWorkspaceIntegrations: (projectId: string) => [{ projectId }, "project-integrations"],
+ getAllUserWorkspace: () => ["projects"] as const,
+ getWorkspaceAuditLogs: (projectId: string) => [{ projectId }, "project-audit-logs"] as const,
getWorkspaceUsers: (
- workspaceId: string,
+ projectId: string,
includeGroupMembers: boolean = false,
roles: string[] = []
- ) => [{ workspaceId, includeGroupMembers, roles }, "workspace-users"] as const,
- getWorkspaceUserDetails: (workspaceId: string, membershipId: string) =>
- [{ workspaceId, membershipId }, "workspace-user-details"] as const,
- getWorkspaceIdentityMemberships: (workspaceId: string) =>
- [{ workspaceId }, "workspace-identity-memberships"] as const,
- getWorkspaceIdentityMembershipDetails: (workspaceId: string, identityId: string) =>
- [{ workspaceId, identityId }, "workspace-identity-membership-details"] as const,
+ ) => [{ projectId, includeGroupMembers, roles }, "project-users"] as const,
+ getWorkspaceUserDetails: (projectId: string, membershipId: string) =>
+ [{ projectId, membershipId }, "project-user-details"] as const,
+ getWorkspaceIdentityMemberships: (projectId: string) =>
+ [{ projectId }, "project-identity-memberships"] as const,
+ getWorkspaceIdentityMembershipDetails: (projectId: string, identityId: string) =>
+ [{ projectId, identityId }, "project-identity-membership-details"] as const,
// allows invalidation using above key without knowing params
getWorkspaceIdentityMembershipsWithParams: ({
- workspaceId,
+ projectId,
...params
}: TListProjectIdentitiesDTO) =>
- [...workspaceKeys.getWorkspaceIdentityMemberships(workspaceId), params] as const,
+ [...projectKeys.getWorkspaceIdentityMemberships(projectId), params] as const,
searchWorkspace: (dto: TSearchProjectsDTO) => ["search-projects", dto] as const,
- getWorkspaceGroupMemberships: (workspaceId: string) =>
- [{ workspaceId }, "workspace-groups"] as const,
- getWorkspaceGroupMembershipDetails: (workspaceId: string, groupId: string) =>
- [{ workspaceId, groupId }, "workspace-group-membership-details"] as const,
+ getWorkspaceGroupMemberships: (projectId: string) => [{ projectId }, "project-groups"] as const,
+ getWorkspaceGroupMembershipDetails: (projectId: string, groupId: string) =>
+ [{ projectId, groupId }, "project-group-membership-details"] as const,
getWorkspaceCas: ({ projectSlug }: { projectSlug: string }) =>
- [{ projectSlug }, "workspace-cas"] as const,
+ [{ projectSlug }, "project-cas"] as const,
specificWorkspaceCas: ({ projectSlug, status }: { projectSlug: string; status?: CaStatus }) =>
- [...workspaceKeys.getWorkspaceCas({ projectSlug }), { status }] as const,
- allWorkspaceCertificates: () => ["workspace-certificates"] as const,
+ [...projectKeys.getWorkspaceCas({ projectSlug }), { status }] as const,
+ allWorkspaceCertificates: () => ["project-certificates"] as const,
forWorkspaceCertificates: (slug: string) =>
- [...workspaceKeys.allWorkspaceCertificates(), slug] as const,
+ [...projectKeys.allWorkspaceCertificates(), slug] as const,
specificWorkspaceCertificates: ({
slug,
offset,
@@ -52,25 +49,24 @@ export const workspaceKeys = {
slug: string;
offset: number;
limit: number;
- }) => [...workspaceKeys.forWorkspaceCertificates(slug), { offset, limit }] as const,
- getWorkspacePkiAlerts: (workspaceId: string) =>
- [{ workspaceId }, "workspace-pki-alerts"] as const,
+ }) => [...projectKeys.forWorkspaceCertificates(slug), { offset, limit }] as const,
+ getWorkspacePkiAlerts: (projectId: string) => [{ projectId }, "project-pki-alerts"] as const,
getWorkspacePkiSubscribers: (projectId: string) =>
- [{ projectId }, "workspace-pki-subscribers"] as const,
- getWorkspacePkiCollections: (workspaceId: string) =>
- [{ workspaceId }, "workspace-pki-collections"] as const,
- getWorkspaceCertificateTemplates: (workspaceId: string) =>
- [{ workspaceId }, "workspace-certificate-templates"] as const,
+ [{ projectId }, "project-pki-subscribers"] as const,
+ getWorkspacePkiCollections: (projectId: string) =>
+ [{ projectId }, "project-pki-collections"] as const,
+ getWorkspaceCertificateTemplates: (projectId: string) =>
+ [{ projectId }, "project-certificate-templates"] as const,
getWorkspaceWorkflowIntegrationConfig: (
- workspaceId: string,
+ projectId: string,
integration: WorkflowIntegrationPlatform
- ) => [{ workspaceId, integration }, "workspace-workflow-integration-config"] as const,
- getWorkspaceSshCas: (projectId: string) => [{ projectId }, "workspace-ssh-cas"] as const,
+ ) => [{ projectId, integration }, "project-workflow-integration-config"] as const,
+ getWorkspaceSshCas: (projectId: string) => [{ projectId }, "project-ssh-cas"] as const,
allWorkspaceSshCertificates: (projectId: string) =>
- [{ projectId }, "workspace-ssh-certificates"] as const,
- getWorkspaceSshHosts: (projectId: string) => [{ projectId }, "workspace-ssh-hosts"] as const,
+ [{ projectId }, "project-ssh-certificates"] as const,
+ getWorkspaceSshHosts: (projectId: string) => [{ projectId }, "project-ssh-hosts"] as const,
getWorkspaceSshHostGroups: (projectId: string) =>
- [{ projectId }, "workspace-ssh-host-groups"] as const,
+ [{ projectId }, "project-ssh-host-groups"] as const,
specificWorkspaceSshCertificates: ({
offset,
limit,
@@ -79,8 +75,8 @@ export const workspaceKeys = {
offset: number;
limit: number;
projectId: string;
- }) => [...workspaceKeys.allWorkspaceSshCertificates(projectId), { offset, limit }] as const,
+ }) => [...projectKeys.allWorkspaceSshCertificates(projectId), { offset, limit }] as const,
getWorkspaceSshCertificateTemplates: (projectId: string) =>
- [{ projectId }, "workspace-ssh-certificate-templates"] as const,
+ [{ projectId }, "project-ssh-certificate-templates"] as const,
getProjectSshConfig: (projectId: string) => [{ projectId }, "project-ssh-config"] as const
};
diff --git a/frontend/src/hooks/api/workspace/types.ts b/frontend/src/hooks/api/workspace/types.ts
index 33eb0909f9..50dff83372 100644
--- a/frontend/src/hooks/api/workspace/types.ts
+++ b/frontend/src/hooks/api/workspace/types.ts
@@ -20,7 +20,7 @@ export enum ProjectUserMembershipTemporaryMode {
Relative = "relative"
}
-export type Workspace = {
+export type Project = {
__v: number;
id: string;
name: string;
@@ -52,7 +52,7 @@ export type WorkspaceEnv = {
export type WorkspaceTag = { id: string; name: string; slug: string };
export type NameWorkspaceSecretsDTO = {
- workspaceId: string;
+ projectId: string;
secretsToUpdate: {
secretName: string;
secretId: string;
@@ -87,19 +87,19 @@ export type UpdateProjectDTO = {
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 +107,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 +136,7 @@ export type TUpdateWorkspaceUserRoleDTO = {
export type TUpdateWorkspaceIdentityRoleDTO = {
identityId: string;
- workspaceId: string;
+ projectId: string;
roles: (
| {
role: string;
@@ -171,7 +171,7 @@ export type TUpdateWorkspaceGroupRoleDTO = {
};
export type TListProjectIdentitiesDTO = {
- workspaceId: string;
+ projectId: string;
offset?: number;
limit?: number;
orderBy?: ProjectIdentityOrderBy;
diff --git a/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ProjectSelect.tsx b/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ProjectSelect.tsx
index ebc28a2271..f566ab6ef7 100644
--- a/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ProjectSelect.tsx
+++ b/frontend/src/layouts/ProjectLayout/components/ProjectSelect/ProjectSelect.tsx
@@ -36,7 +36,7 @@ import { usePopUp } from "@app/hooks";
import { useGetUserWorkspaces } from "@app/hooks/api";
import { useUpdateUserProjectFavorites } from "@app/hooks/api/users/mutation";
import { useGetUserProjectFavorites } from "@app/hooks/api/users/queries";
-import { Workspace } from "@app/hooks/api/workspace/types";
+import { Project } from "@app/hooks/api/workspace/types";
export const ProjectSelect = () => {
const [searchProject, setSearchProject] = useState("");
@@ -88,7 +88,7 @@ export const ProjectSelect = () => {
const projects = useMemo(() => {
const projectOptions = workspaces
- .map((w): Workspace & { isFavorite: boolean } => ({
+ .map((w): Project & { isFavorite: boolean } => ({
...w,
isFavorite: Boolean(projectFavorites?.includes(w.id))
}))
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/LogsFilter.tsx b/frontend/src/pages/organization/AuditLogsPage/components/LogsFilter.tsx
index 715f9c0b23..bc469ba114 100644
--- a/frontend/src/pages/organization/AuditLogsPage/components/LogsFilter.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/components/LogsFilter.tsx
@@ -29,7 +29,7 @@ import {
} from "@app/hooks/api/auditLogs/constants";
import { EventType } from "@app/hooks/api/auditLogs/enums";
import { UserAgentType } from "@app/hooks/api/auth/types";
-import { Workspace } from "@app/hooks/api/workspace/types";
+import { Project } from "@app/hooks/api/workspace/types";
import { LogFilterItem } from "./LogFilterItem";
import { auditLogFilterFormSchema, Presets, TAuditLogFilterFormData } from "./types";
@@ -44,7 +44,7 @@ type Props = {
presets?: Presets;
setFilter: (data: TAuditLogFilterFormData) => void;
filter: TAuditLogFilterFormData;
- project?: Workspace;
+ project?: Project;
};
const getActiveFilterCount = (filter: TAuditLogFilterFormData) => {
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/LogsSection.tsx b/frontend/src/pages/organization/AuditLogsPage/components/LogsSection.tsx
index 5bbb42d329..c81ad70475 100644
--- a/frontend/src/pages/organization/AuditLogsPage/components/LogsSection.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/components/LogsSection.tsx
@@ -13,7 +13,7 @@ import {
} from "@app/context";
import { Timezone } from "@app/helpers/datetime";
import { withPermission, withProjectPermission } from "@app/hoc";
-import { Workspace } from "@app/hooks/api/workspace/types";
+import { Project } from "@app/hooks/api/workspace/types";
import { usePopUp } from "@app/hooks/usePopUp";
import { LogsDateFilter } from "./LogsDateFilter";
@@ -31,7 +31,7 @@ type Props = {
refetchInterval?: number;
showFilters?: boolean;
pageView?: boolean;
- project?: Workspace;
+ project?: Project;
};
const LogsSectionComponent = ({
diff --git a/frontend/src/pages/organization/ProjectsPage/components/AllProjectView.tsx b/frontend/src/pages/organization/ProjectsPage/components/AllProjectView.tsx
index 7b066a0996..3eb1431479 100644
--- a/frontend/src/pages/organization/ProjectsPage/components/AllProjectView.tsx
+++ b/frontend/src/pages/organization/ProjectsPage/components/AllProjectView.tsx
@@ -48,7 +48,7 @@ import {
useRequestProjectAccess,
useSearchProjects
} from "@app/hooks/api";
-import { ProjectType, Workspace, WorkspaceEnv } from "@app/hooks/api/workspace/types";
+import { ProjectType, Project, WorkspaceEnv } from "@app/hooks/api/workspace/types";
import {
ProjectListToggle,
ProjectListView
@@ -180,7 +180,7 @@ export const AllProjectView = ({
offset,
totalCount: searchedProjects?.totalCount || 0
});
- const requestedWorkspaceDetails = (popUp.requestAccessConfirmation.data || {}) as Workspace;
+ const requestedWorkspaceDetails = (popUp.requestAccessConfirmation.data || {}) as Project;
const handleToggleFilterByProjectType = (el: ProjectType) =>
setProjectTypeFilter((state) => (state === el ? undefined : el));
diff --git a/frontend/src/pages/organization/ProjectsPage/components/MyProjectView.tsx b/frontend/src/pages/organization/ProjectsPage/components/MyProjectView.tsx
index d63099273e..8987069ec4 100644
--- a/frontend/src/pages/organization/ProjectsPage/components/MyProjectView.tsx
+++ b/frontend/src/pages/organization/ProjectsPage/components/MyProjectView.tsx
@@ -43,7 +43,7 @@ import { useGetUserWorkspaces } from "@app/hooks/api";
import { OrderByDirection } from "@app/hooks/api/generic/types";
import { useUpdateUserProjectFavorites } from "@app/hooks/api/users/mutation";
import { useGetUserProjectFavorites } from "@app/hooks/api/users/queries";
-import { ProjectType, Workspace } from "@app/hooks/api/workspace/types";
+import { ProjectType, Project } from "@app/hooks/api/workspace/types";
import {
ProjectListToggle,
ProjectListView
@@ -136,7 +136,7 @@ export const MyProjectView = ({
const { workspacesWithFaveProp } = useMemo(() => {
const workspacesWithFav = filteredWorkspaces
- .map((w): Workspace & { isFavorite: boolean } => ({
+ .map((w): Project & { isFavorite: boolean } => ({
...w,
isFavorite: Boolean(projectFavorites?.includes(w.id))
}))
@@ -188,7 +188,7 @@ export const MyProjectView = ({
}
};
- const renderProjectGridItem = (workspace: Workspace, isFavorite: boolean) => (
+ const renderProjectGridItem = (workspace: Project, isFavorite: boolean) => (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
<div
onClick={() => {
@@ -242,7 +242,7 @@ export const MyProjectView = ({
</p>
</div>
);
- const renderProjectListItem = (workspace: Workspace, isFavorite: boolean, index: number) => (
+ const renderProjectListItem = (workspace: Project, isFavorite: boolean, index: number) => (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
<div
onClick={() => {
diff --git a/frontend/src/pages/secret-manager/CommitDetailsPage/components/RollbackPreviewTab/RollbackPreviewTab.tsx b/frontend/src/pages/secret-manager/CommitDetailsPage/components/RollbackPreviewTab/RollbackPreviewTab.tsx
index e06daea38e..682822503f 100644
--- a/frontend/src/pages/secret-manager/CommitDetailsPage/components/RollbackPreviewTab/RollbackPreviewTab.tsx
+++ b/frontend/src/pages/secret-manager/CommitDetailsPage/components/RollbackPreviewTab/RollbackPreviewTab.tsx
@@ -120,7 +120,7 @@ export const RollbackPreviewTab = (): JSX.Element => {
] as const);
const { mutateAsync: rollback } = useCommitRollback({
- workspaceId: currentWorkspace.id,
+ projectId: currentWorkspace.id,
commitId: selectedCommitId,
folderId,
deepRollback,
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
index b98ce31b0e..7407e7e24e 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
@@ -414,7 +414,7 @@ export const SecretListView = ({
queryKey: secretSnapshotKeys.count({ workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
- queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
+ queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
@@ -492,7 +492,7 @@ export const SecretListView = ({
queryKey: secretSnapshotKeys.count({ workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
- queryKey: commitKeys.count({ workspaceId, environment, directory: secretPath })
+ queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })