feat: migrated secret router

This commit is contained in:
=
2025-09-16 00:08:40 +05:30
parent 02dc2e2106
commit 5f902229f6
12 changed files with 1472 additions and 269 deletions
@@ -431,7 +431,7 @@ export const secretRotationQueueFactory = ({
numberOfSecrets: numberOfSecretsRotated, numberOfSecrets: numberOfSecretsRotated,
environment: secretRotation.environment.slug, environment: secretRotation.environment.slug,
secretPath: secretRotation.secretPath, secretPath: secretRotation.secretPath,
workspaceId: secretRotation.projectId projectId: secretRotation.projectId
} }
}); });
+4 -4
View File
@@ -984,7 +984,7 @@ export const RAW_SECRETS = {
secretValue: "The value of the secret to create.", secretValue: "The value of the secret to create.",
skipMultilineEncoding: "Skip multiline encoding for the secret value.", skipMultilineEncoding: "Skip multiline encoding for the secret value.",
type: "The type of the secret to create.", type: "The type of the secret to create.",
workspaceId: "The ID of the project to create the secret in.", projectId: "The ID of the project to create the secret in.",
tagIds: "The ID of the tags to be attached to the created secret.", tagIds: "The ID of the tags to be attached to the created secret.",
secretReminderRepeatDays: "Interval for secret rotation notifications, measured in days.", secretReminderRepeatDays: "Interval for secret rotation notifications, measured in days.",
secretReminderNote: "Note to be attached in notification email." secretReminderNote: "Note to be attached in notification email."
@@ -992,7 +992,7 @@ export const RAW_SECRETS = {
GET: { GET: {
expand: "Whether or not to expand secret references.", expand: "Whether or not to expand secret references.",
secretName: "The name of the secret to get.", secretName: "The name of the secret to get.",
workspaceId: "The ID of the project to get the secret from.", projectId: "The ID of the project to get the secret from.",
workspaceSlug: "The slug of the project to get the secret from.", workspaceSlug: "The slug of the project to get the secret from.",
environment: "The slug of the environment to get the secret from.", environment: "The slug of the environment to get the secret from.",
secretPath: "The path of the secret to get.", secretPath: "The path of the secret to get.",
@@ -1011,7 +1011,7 @@ export const RAW_SECRETS = {
skipMultilineEncoding: "Skip multiline encoding for the secret value.", skipMultilineEncoding: "Skip multiline encoding for the secret value.",
type: "The type of the secret to update.", type: "The type of the secret to update.",
projectSlug: "The slug of the project to update the secret in.", projectSlug: "The slug of the project to update the secret in.",
workspaceId: "The ID of the project to update the secret in.", projectId: "The ID of the project to update the secret in.",
tagIds: "The ID of the tags to be attached to the updated secret.", tagIds: "The ID of the tags to be attached to the updated secret.",
secretReminderRepeatDays: "Interval for secret rotation notifications, measured in days.", secretReminderRepeatDays: "Interval for secret rotation notifications, measured in days.",
secretReminderNote: "Note to be attached in notification email.", secretReminderNote: "Note to be attached in notification email.",
@@ -1025,7 +1025,7 @@ export const RAW_SECRETS = {
secretPath: "The path of the secret.", secretPath: "The path of the secret.",
type: "The type of the secret to delete.", type: "The type of the secret to delete.",
projectSlug: "The slug of the project to delete the secret in.", projectSlug: "The slug of the project to delete the secret in.",
workspaceId: "The ID of the project where the secret is located." projectId: "The ID of the project where the secret is located."
}, },
GET_REFERENCE_TREE: { GET_REFERENCE_TREE: {
secretName: "The name of the secret to get the reference tree for.", secretName: "The name of the secret to get the reference tree for.",
+2
View File
@@ -328,6 +328,7 @@ import { registerV1Routes } from "./v1";
import { initializeOauthConfigSync } from "./v1/sso-router"; import { initializeOauthConfigSync } from "./v1/sso-router";
import { registerV2Routes } from "./v2"; import { registerV2Routes } from "./v2";
import { registerV3Routes } from "./v3"; import { registerV3Routes } from "./v3";
import { registerV4Routes } from "./v4";
const histogram = monitorEventLoopDelay({ resolution: 20 }); const histogram = monitorEventLoopDelay({ resolution: 20 });
histogram.enable(); histogram.enable();
@@ -2294,6 +2295,7 @@ export const registerRoutes = async (
{ prefix: "/api/v2" } { prefix: "/api/v2" }
); );
await server.register(registerV3Routes, { prefix: "/api/v3" }); await server.register(registerV3Routes, { prefix: "/api/v3" });
await server.register(registerV4Routes, { prefix: "/api/v4" });
server.addHook("onClose", async () => { server.addHook("onClose", async () => {
cronJobs.forEach((job) => job.stop()); cronJobs.forEach((job) => job.stop());
@@ -474,7 +474,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: secretCountFromEnv, numberOfSecrets: secretCountFromEnv,
workspaceId: projectId, projectId: projectId,
environment, environment,
secretPath, secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -1001,7 +1001,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: secretCount, numberOfSecrets: secretCount,
workspaceId: projectId, projectId: projectId,
environment, environment,
secretPath, secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -1168,7 +1168,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: secretCountForEnv, numberOfSecrets: secretCountForEnv,
workspaceId: projectId, projectId: projectId,
environment, environment,
secretPath, secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -1361,7 +1361,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: secrets.length, numberOfSecrets: secrets.length,
workspaceId: projectId, projectId: projectId,
environment, environment,
secretPath, secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
+23 -114
View File
@@ -336,7 +336,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: secrets.length, numberOfSecrets: secrets.length,
workspaceId, projectId: workspaceId,
environment, environment,
secretPath: req.query.secretPath, secretPath: req.query.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -405,7 +405,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
secretName: z.string().trim().describe(RAW_SECRETS.GET.secretName) secretName: z.string().trim().describe(RAW_SECRETS.GET.secretName)
}), }),
querystring: z.object({ querystring: z.object({
workspaceId: z.string().trim().optional().describe(RAW_SECRETS.GET.workspaceId), workspaceId: z.string().trim().optional().describe(RAW_SECRETS.GET.projectId),
workspaceSlug: z.string().trim().optional().describe(RAW_SECRETS.GET.workspaceSlug), workspaceSlug: z.string().trim().optional().describe(RAW_SECRETS.GET.workspaceSlug),
environment: z.string().trim().optional().describe(RAW_SECRETS.GET.environment), environment: z.string().trim().optional().describe(RAW_SECRETS.GET.environment),
secretPath: z.string().trim().default("/").transform(removeTrailingSlash).describe(RAW_SECRETS.GET.secretPath), secretPath: z.string().trim().default("/").transform(removeTrailingSlash).describe(RAW_SECRETS.GET.secretPath),
@@ -495,7 +495,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
distinctId: getTelemetryDistinctId(req), distinctId: getTelemetryDistinctId(req),
properties: { properties: {
numberOfSecrets: 1, numberOfSecrets: 1,
workspaceId: secret.workspace, projectId: secret.workspace,
environment, environment,
secretPath: req.query.secretPath, secretPath: req.query.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -526,7 +526,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
secretName: SecretNameSchema.describe(RAW_SECRETS.CREATE.secretName) secretName: SecretNameSchema.describe(RAW_SECRETS.CREATE.secretName)
}), }),
body: z.object({ body: z.object({
workspaceId: z.string().trim().optional().describe(RAW_SECRETS.CREATE.workspaceId), workspaceId: z.string().trim().optional().describe(RAW_SECRETS.CREATE.projectId),
projectSlug: z.string().trim().optional().describe(RAW_SECRETS.CREATE.projectSlug), projectSlug: z.string().trim().optional().describe(RAW_SECRETS.CREATE.projectSlug),
environment: z.string().trim().describe(RAW_SECRETS.CREATE.environment), environment: z.string().trim().describe(RAW_SECRETS.CREATE.environment),
secretPath: z secretPath: z
@@ -638,7 +638,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: 1, numberOfSecrets: 1,
workspaceId: projectId, projectId,
environment: req.body.environment, environment: req.body.environment,
secretPath: req.body.secretPath, secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -669,7 +669,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
secretName: BaseSecretNameSchema.describe(RAW_SECRETS.UPDATE.secretName) secretName: BaseSecretNameSchema.describe(RAW_SECRETS.UPDATE.secretName)
}), }),
body: z.object({ body: z.object({
workspaceId: z.string().trim().optional().describe(RAW_SECRETS.UPDATE.workspaceId), workspaceId: z.string().trim().optional().describe(RAW_SECRETS.UPDATE.projectId),
projectSlug: z.string().trim().optional().describe(RAW_SECRETS.UPDATE.projectSlug), projectSlug: z.string().trim().optional().describe(RAW_SECRETS.UPDATE.projectSlug),
environment: z.string().trim().describe(RAW_SECRETS.UPDATE.environment), environment: z.string().trim().describe(RAW_SECRETS.UPDATE.environment),
secretValue: z secretValue: z
@@ -791,7 +791,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: 1, numberOfSecrets: 1,
workspaceId: projectId, projectId,
environment: req.body.environment, environment: req.body.environment,
secretPath: req.body.secretPath, secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -821,7 +821,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
secretName: z.string().min(1).describe(RAW_SECRETS.DELETE.secretName) secretName: z.string().min(1).describe(RAW_SECRETS.DELETE.secretName)
}), }),
body: z.object({ body: z.object({
workspaceId: z.string().trim().optional().describe(RAW_SECRETS.DELETE.workspaceId), workspaceId: z.string().trim().optional().describe(RAW_SECRETS.DELETE.projectId),
projectSlug: z.string().trim().optional().describe(RAW_SECRETS.DELETE.projectSlug), projectSlug: z.string().trim().optional().describe(RAW_SECRETS.DELETE.projectSlug),
environment: z.string().trim().describe(RAW_SECRETS.DELETE.environment), environment: z.string().trim().describe(RAW_SECRETS.DELETE.environment),
secretPath: z secretPath: z
@@ -909,7 +909,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: 1, numberOfSecrets: 1,
workspaceId: projectId, projectId,
environment: req.body.environment, environment: req.body.environment,
secretPath: req.body.secretPath, secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -1017,7 +1017,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: secrets.length, numberOfSecrets: secrets.length,
workspaceId: req.query.workspaceId, projectId: req.query.workspaceId,
environment: req.query.environment, environment: req.query.environment,
secretPath: req.query.secretPath, secretPath: req.query.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -1097,7 +1097,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: 1, numberOfSecrets: 1,
workspaceId: req.query.workspaceId, projectId: req.query.workspaceId,
environment: req.query.environment, environment: req.query.environment,
secretPath: req.query.secretPath, secretPath: req.query.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -1272,7 +1272,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: 1, numberOfSecrets: 1,
workspaceId: req.body.workspaceId, projectId: req.body.workspaceId,
environment: req.body.environment, environment: req.body.environment,
secretPath: req.body.secretPath, secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -1466,7 +1466,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: 1, numberOfSecrets: 1,
workspaceId: req.body.workspaceId, projectId: req.body.workspaceId,
environment: req.body.environment, environment: req.body.environment,
secretPath: req.body.secretPath, secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -1594,7 +1594,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: 1, numberOfSecrets: 1,
workspaceId: req.body.workspaceId, projectId: req.body.workspaceId,
environment: req.body.environment, environment: req.body.environment,
secretPath: req.body.secretPath, secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -1781,7 +1781,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: secrets.length, numberOfSecrets: secrets.length,
workspaceId: req.body.workspaceId, projectId: req.body.workspaceId,
environment: req.body.environment, environment: req.body.environment,
secretPath: req.body.secretPath, secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -1914,7 +1914,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: secrets.length, numberOfSecrets: secrets.length,
workspaceId: req.body.workspaceId, projectId: req.body.workspaceId,
environment: req.body.environment, environment: req.body.environment,
secretPath: req.body.secretPath, secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -2039,7 +2039,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: secrets.length, numberOfSecrets: secrets.length,
workspaceId: req.body.workspaceId, projectId: req.body.workspaceId,
environment: req.body.environment, environment: req.body.environment,
secretPath: req.body.secretPath, secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -2067,7 +2067,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
], ],
body: z.object({ body: z.object({
projectSlug: z.string().trim().optional().describe(RAW_SECRETS.UPDATE.projectSlug), projectSlug: z.string().trim().optional().describe(RAW_SECRETS.UPDATE.projectSlug),
workspaceId: z.string().trim().optional().describe(RAW_SECRETS.UPDATE.workspaceId), workspaceId: z.string().trim().optional().describe(RAW_SECRETS.UPDATE.projectId),
environment: z.string().trim().describe(RAW_SECRETS.CREATE.environment), environment: z.string().trim().describe(RAW_SECRETS.CREATE.environment),
secretPath: z secretPath: z
.string() .string()
@@ -2166,7 +2166,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: secrets.length, numberOfSecrets: secrets.length,
workspaceId: secrets[0].workspace, projectId: secrets[0].workspace,
environment: req.body.environment, environment: req.body.environment,
secretPath: req.body.secretPath, secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -2194,7 +2194,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
], ],
body: z.object({ body: z.object({
projectSlug: z.string().trim().optional().describe(RAW_SECRETS.DELETE.projectSlug), projectSlug: z.string().trim().optional().describe(RAW_SECRETS.DELETE.projectSlug),
workspaceId: z.string().trim().optional().describe(RAW_SECRETS.DELETE.workspaceId), workspaceId: z.string().trim().optional().describe(RAW_SECRETS.DELETE.projectId),
environment: z.string().trim().describe(RAW_SECRETS.UPDATE.environment), environment: z.string().trim().describe(RAW_SECRETS.UPDATE.environment),
secretPath: z secretPath: z
.string() .string()
@@ -2341,7 +2341,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: secrets.length, numberOfSecrets: secrets.length,
workspaceId: secrets[0].workspace, projectId: secrets[0].workspace,
environment: req.body.environment, environment: req.body.environment,
secretPath: req.body.secretPath, secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -2369,7 +2369,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
], ],
body: z.object({ body: z.object({
projectSlug: z.string().trim().optional().describe(RAW_SECRETS.DELETE.projectSlug), projectSlug: z.string().trim().optional().describe(RAW_SECRETS.DELETE.projectSlug),
workspaceId: z.string().trim().optional().describe(RAW_SECRETS.DELETE.workspaceId), workspaceId: z.string().trim().optional().describe(RAW_SECRETS.DELETE.projectId),
environment: z.string().trim().describe(RAW_SECRETS.DELETE.environment), environment: z.string().trim().describe(RAW_SECRETS.DELETE.environment),
secretPath: z secretPath: z
.string() .string()
@@ -2459,7 +2459,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
organizationId: req.permission.orgId, organizationId: req.permission.orgId,
properties: { properties: {
numberOfSecrets: secrets.length, numberOfSecrets: secrets.length,
workspaceId: secrets[0].workspace, projectId: secrets[0].workspace,
environment: req.body.environment, environment: req.body.environment,
secretPath: req.body.secretPath, secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]), channel: getUserAgentType(req.headers["user-agent"]),
@@ -2469,95 +2469,4 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
return { secrets }; return { secrets };
} }
}); });
server.route({
method: "GET",
url: "/raw/:secretName/secret-reference-tree",
config: {
rateLimit: secretsLimit
},
schema: {
hide: false,
tags: [ApiDocsTags.Secrets],
description: "Get secret reference tree",
security: [
{
bearerAuth: []
}
],
params: z.object({
secretName: z.string().trim().describe(RAW_SECRETS.GET_REFERENCE_TREE.secretName)
}),
querystring: z.object({
workspaceId: z.string().trim().describe(RAW_SECRETS.GET_REFERENCE_TREE.workspaceId),
environment: z.string().trim().describe(RAW_SECRETS.GET_REFERENCE_TREE.environment),
secretPath: z
.string()
.trim()
.default("/")
.transform(removeTrailingSlash)
.describe(RAW_SECRETS.GET_REFERENCE_TREE.secretPath)
}),
response: {
200: z.object({
tree: SecretReferenceNodeTree,
value: z.string().optional()
})
}
},
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
const { secretName } = req.params;
const { secretPath, environment, workspaceId } = req.query;
const { tree, value } = await server.services.secret.getSecretReferenceTree({
actorId: req.permission.id,
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
projectId: workspaceId,
secretName,
secretPath,
environment
});
return { tree, value };
}
});
server.route({
method: "POST",
url: "/backfill-secret-references",
config: {
rateLimit: secretsLimit
},
schema: {
description: "Backfill secret references",
security: [
{
bearerAuth: []
}
],
body: z.object({
projectId: z.string().trim().min(1)
}),
response: {
200: z.object({
message: z.string()
})
}
},
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
const { projectId } = req.body;
const message = await server.services.secret.backfillSecretReferences({
actorId: req.permission.id,
actor: req.permission.type,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
projectId
});
return message;
}
});
}; };
+5
View File
@@ -0,0 +1,5 @@
import { registerSecretRouter } from "./secret-router";
export const registerV4Routes = async (server: FastifyZodProvider) => {
await server.register(registerSecretRouter, { prefix: "/secrets" });
};
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -534,7 +534,8 @@ export type TSyncSecretsDTO<T extends boolean = false> = {
}); });
export type TMoveSecretsDTO = { export type TMoveSecretsDTO = {
projectSlug: string; projectId?: string;
projectSlug?: string;
sourceEnvironment: string; sourceEnvironment: string;
sourceSecretPath: string; sourceSecretPath: string;
destinationEnvironment: string; destinationEnvironment: string;
@@ -46,7 +46,7 @@ export type TSecretModifiedEvent = {
properties: { properties: {
numberOfSecrets: number; numberOfSecrets: number;
environment: string; environment: string;
workspaceId: string; projectId: string;
secretPath: string; secretPath: string;
channel?: string; channel?: string;
userAgent?: string; userAgent?: string;
+84 -91
View File
@@ -33,18 +33,18 @@ export const useCreateSecretV3 = ({
secretPath = "/", secretPath = "/",
type, type,
environment, environment,
workspaceId, projectId,
secretKey, secretKey,
secretValue, secretValue,
secretComment, secretComment,
skipMultilineEncoding, skipMultilineEncoding,
tagIds tagIds
}) => { }) => {
const { data } = await apiRequest.post(`/api/v3/secrets/raw/${secretKey}`, { const { data } = await apiRequest.post(`/api/v4/secrets/${secretKey}`, {
secretPath, secretPath,
type, type,
environment, environment,
workspaceId, projectId,
secretValue, secretValue,
secretComment, secretComment,
skipMultilineEncoding, skipMultilineEncoding,
@@ -52,26 +52,26 @@ export const useCreateSecretV3 = ({
}); });
return data; return data;
}, },
onSuccess: (_, { workspaceId, environment, secretPath }) => { onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath }) queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath }) queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath }) queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath }) queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) }); queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
}, },
...options ...options
}); });
@@ -88,7 +88,7 @@ export const useUpdateSecretV3 = ({
secretPath = "/", secretPath = "/",
type, type,
environment, environment,
workspaceId, projectId,
secretKey, secretKey,
secretValue, secretValue,
tagIds, tagIds,
@@ -100,8 +100,8 @@ export const useUpdateSecretV3 = ({
skipMultilineEncoding, skipMultilineEncoding,
secretMetadata secretMetadata
}) => { }) => {
const { data } = await apiRequest.patch(`/api/v3/secrets/raw/${secretKey}`, { const { data } = await apiRequest.patch(`/api/v4/secrets/${secretKey}`, {
workspaceId, projectId,
environment, environment,
type, type,
secretReminderNote, secretReminderNote,
@@ -117,26 +117,26 @@ export const useUpdateSecretV3 = ({
}); });
return data; return data;
}, },
onSuccess: (_, { workspaceId, environment, secretPath }) => { onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath }) queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath }) queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath }) queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath }) queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) }); queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
}, },
...options ...options
}); });
@@ -150,17 +150,10 @@ export const useDeleteSecretV3 = ({
const queryClient = useQueryClient(); const queryClient = useQueryClient();
return useMutation<object, object, TDeleteSecretsV3DTO>({ return useMutation<object, object, TDeleteSecretsV3DTO>({
mutationFn: async ({ mutationFn: async ({ secretPath = "/", type, environment, projectId, secretKey, secretId }) => {
secretPath = "/", const { data } = await apiRequest.delete(`/api/v4/secrets/${secretKey}`, {
type,
environment,
workspaceId,
secretKey,
secretId
}) => {
const { data } = await apiRequest.delete(`/api/v3/secrets/raw/${secretKey}`, {
data: { data: {
workspaceId, projectId,
environment, environment,
type, type,
secretPath, secretPath,
@@ -169,26 +162,26 @@ export const useDeleteSecretV3 = ({
}); });
return data; return data;
}, },
onSuccess: (_, { workspaceId, environment, secretPath }) => { onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath }) queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath }) queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath }) queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath }) queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) }); queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
}, },
...options ...options
}); });
@@ -202,35 +195,35 @@ export const useCreateSecretBatch = ({
const queryClient = useQueryClient(); const queryClient = useQueryClient();
return useMutation<object, object, TCreateSecretBatchDTO>({ return useMutation<object, object, TCreateSecretBatchDTO>({
mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => { mutationFn: async ({ secretPath = "/", projectId, environment, secrets }) => {
const { data } = await apiRequest.post("/api/v3/secrets/batch/raw", { const { data } = await apiRequest.post("/api/v4/secrets/batch", {
workspaceId, projectId,
environment, environment,
secretPath, secretPath,
secrets secrets
}); });
return data; return data;
}, },
onSuccess: (_, { workspaceId, environment, secretPath }) => { onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath }) queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath }) queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath }) queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath }) queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) }); queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
}, },
...options ...options
}); });
@@ -244,35 +237,35 @@ export const useUpdateSecretBatch = ({
const queryClient = useQueryClient(); const queryClient = useQueryClient();
return useMutation<object, object, TUpdateSecretBatchDTO>({ return useMutation<object, object, TUpdateSecretBatchDTO>({
mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => { mutationFn: async ({ secretPath = "/", projectId, environment, secrets }) => {
const { data } = await apiRequest.patch("/api/v3/secrets/batch/raw", { const { data } = await apiRequest.patch("/api/v4/secrets/batch", {
workspaceId, projectId,
environment, environment,
secretPath, secretPath,
secrets secrets
}); });
return data; return data;
}, },
onSuccess: (_, { workspaceId, environment, secretPath }) => { onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath }) queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath }) queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath }) queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath }) queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) }); queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
}, },
...options ...options
}); });
@@ -286,10 +279,10 @@ export const useDeleteSecretBatch = ({
const queryClient = useQueryClient(); const queryClient = useQueryClient();
return useMutation<object, object, TDeleteSecretBatchDTO>({ return useMutation<object, object, TDeleteSecretBatchDTO>({
mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => { mutationFn: async ({ secretPath = "/", projectId, environment, secrets }) => {
const { data } = await apiRequest.delete("/api/v3/secrets/batch/raw", { const { data } = await apiRequest.delete("/api/v4/secrets/batch", {
data: { data: {
workspaceId, projectId,
environment, environment,
secretPath, secretPath,
secrets secrets
@@ -297,26 +290,26 @@ export const useDeleteSecretBatch = ({
}); });
return data; return data;
}, },
onSuccess: (_, { workspaceId, environment, secretPath }) => { onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath }) queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath }) queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath }) queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath }) queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) }); queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
}, },
...options ...options
}); });
@@ -349,7 +342,7 @@ export const useMoveSecrets = ({
const { data } = await apiRequest.post<{ const { data } = await apiRequest.post<{
isSourceUpdated: boolean; isSourceUpdated: boolean;
isDestinationUpdated: boolean; isDestinationUpdated: boolean;
}>("/api/v3/secrets/move", { }>("/api/v4/secrets/move", {
sourceEnvironment, sourceEnvironment,
sourceSecretPath, sourceSecretPath,
projectSlug, projectSlug,
@@ -370,7 +363,7 @@ export const useMoveSecrets = ({
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ queryKey: secretKeys.getProjectSecret({
workspaceId: projectId, projectId,
environment: sourceEnvironment, environment: sourceEnvironment,
secretPath: sourceSecretPath secretPath: sourceSecretPath
}) })
@@ -378,33 +371,33 @@ export const useMoveSecrets = ({
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ queryKey: secretSnapshotKeys.list({
environment: sourceEnvironment, environment: sourceEnvironment,
workspaceId: projectId, projectId,
directory: sourceSecretPath directory: sourceSecretPath
}) })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ queryKey: secretSnapshotKeys.count({
environment: sourceEnvironment, environment: sourceEnvironment,
workspaceId: projectId, projectId,
directory: sourceSecretPath directory: sourceSecretPath
}) })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.count({ queryKey: commitKeys.count({
projectId: projectId, projectId,
environment: sourceEnvironment, environment: sourceEnvironment,
directory: sourceSecretPath directory: sourceSecretPath
}) })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.history({ queryKey: commitKeys.history({
workspaceId: projectId, projectId,
environment: sourceEnvironment, environment: sourceEnvironment,
directory: sourceSecretPath directory: sourceSecretPath
}) })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretApprovalRequestKeys.count({ workspaceId: projectId }) queryKey: secretApprovalRequestKeys.count({ projectId })
}); });
}, },
...options ...options
@@ -432,16 +425,16 @@ export const useCreateCommit = () => {
object, object,
object, object,
{ {
workspaceId: string; projectId: string;
environment: string; environment: string;
secretPath: string; secretPath: string;
pendingChanges: PendingChanges; pendingChanges: PendingChanges;
message: string; message: string;
} }
>({ >({
mutationFn: async ({ workspaceId, environment, secretPath, pendingChanges, message }) => { mutationFn: async ({ projectId, environment, secretPath, pendingChanges, message }) => {
const { data } = await apiRequest.post("/api/v1/pit/batch/commit", { const { data } = await apiRequest.post("/api/v1/pit/batch/commit", {
projectId: workspaceId, projectId,
environment, environment,
secretPath, secretPath,
changes: { changes: {
@@ -501,26 +494,26 @@ export const useCreateCommit = () => {
}); });
return data; return data;
}, },
onSuccess: (_, { workspaceId, environment, secretPath }) => { onSuccess: (_, { projectId, environment, secretPath }) => {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath }) queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath }) queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.list({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ environment, workspaceId, directory: secretPath }) queryKey: secretSnapshotKeys.count({ environment, projectId, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath }) queryKey: commitKeys.count({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath }) queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
}); });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ workspaceId }) }); queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
} }
}); });
}; };
+18 -18
View File
@@ -27,35 +27,35 @@ import {
export const secretKeys = { export const secretKeys = {
// this is also used in secretSnapshot part // this is also used in secretSnapshot part
getProjectSecret: ({ getProjectSecret: ({
workspaceId, projectId,
environment, environment,
secretPath, secretPath,
viewSecretValue viewSecretValue
}: TGetProjectSecretsKey) => }: TGetProjectSecretsKey) =>
[{ workspaceId, environment, secretPath, viewSecretValue }, "secrets"] as const, [{ projectId, environment, secretPath, viewSecretValue }, "secrets"] as const,
getSecretVersion: (secretId: string) => [{ secretId }, "secret-versions"] as const, getSecretVersion: (secretId: string) => [{ secretId }, "secret-versions"] as const,
getSecretAccessList: ({ getSecretAccessList: ({
workspaceId, projectId,
environment, environment,
secretPath, secretPath,
secretKey secretKey
}: TGetSecretAccessListDTO) => }: TGetSecretAccessListDTO) =>
["secret-access-list", { workspaceId, environment, secretPath, secretKey }] as const, ["secret-access-list", { projectId, environment, secretPath, secretKey }] as const,
getSecretReferenceTree: (dto: TGetSecretReferenceTreeDTO) => ["secret-reference-tree", dto] getSecretReferenceTree: (dto: TGetSecretReferenceTreeDTO) => ["secret-reference-tree", dto]
}; };
export const fetchProjectSecrets = async ({ export const fetchProjectSecrets = async ({
workspaceId, projectId,
environment, environment,
secretPath, secretPath,
includeImports, includeImports,
expandSecretReferences, expandSecretReferences,
viewSecretValue viewSecretValue
}: TGetProjectSecretsKey) => { }: TGetProjectSecretsKey) => {
const { data } = await apiRequest.get<SecretV3RawResponse>("/api/v3/secrets/raw", { const { data } = await apiRequest.get<SecretV3RawResponse>("/api/v4/secrets", {
params: { params: {
environment, environment,
workspaceId, projectId,
secretPath, secretPath,
viewSecretValue, viewSecretValue,
expandSecretReferences, expandSecretReferences,
@@ -116,7 +116,7 @@ export const mergePersonalSecrets = (rawSecrets: SecretV3Raw[]) => {
}; };
export const useGetProjectSecrets = ({ export const useGetProjectSecrets = ({
workspaceId, projectId,
environment, environment,
secretPath, secretPath,
viewSecretValue, viewSecretValue,
@@ -135,14 +135,14 @@ export const useGetProjectSecrets = ({
useQuery({ useQuery({
...options, ...options,
// wait for all values to be available // wait for all values to be available
enabled: Boolean(workspaceId && environment) && (options?.enabled ?? true), enabled: Boolean(projectId && environment) && (options?.enabled ?? true),
queryKey: secretKeys.getProjectSecret({ queryKey: secretKeys.getProjectSecret({
workspaceId, projectId,
environment, environment,
secretPath, secretPath,
viewSecretValue viewSecretValue
}), }),
queryFn: () => fetchProjectSecrets({ workspaceId, environment, secretPath, viewSecretValue }), queryFn: () => fetchProjectSecrets({ projectId, environment, secretPath, viewSecretValue }),
select: useCallback( select: useCallback(
(data: Awaited<ReturnType<typeof fetchProjectSecrets>>) => mergePersonalSecrets(data.secrets), (data: Awaited<ReturnType<typeof fetchProjectSecrets>>) => mergePersonalSecrets(data.secrets),
[] []
@@ -150,7 +150,7 @@ export const useGetProjectSecrets = ({
}); });
export const useGetProjectSecretsAllEnv = ({ export const useGetProjectSecretsAllEnv = ({
workspaceId, projectId,
envs, envs,
secretPath secretPath
}: TGetProjectSecretsAllEnvDTO) => { }: TGetProjectSecretsAllEnvDTO) => {
@@ -159,11 +159,11 @@ export const useGetProjectSecretsAllEnv = ({
const secrets = useQueries({ const secrets = useQueries({
queries: envs.map((environment) => ({ queries: envs.map((environment) => ({
queryKey: secretKeys.getProjectSecret({ queryKey: secretKeys.getProjectSecret({
workspaceId, projectId,
environment, environment,
secretPath secretPath
}), }),
enabled: Boolean(workspaceId && environment), enabled: Boolean(projectId && environment),
onError: (error: unknown) => { onError: (error: unknown) => {
if (axios.isAxiosError(error) && !isErrorHandled) { if (axios.isAxiosError(error) && !isErrorHandled) {
const { message, requestId } = error.response?.data as { const { message, requestId } = error.response?.data as {
@@ -187,7 +187,7 @@ export const useGetProjectSecretsAllEnv = ({
setIsErrorHandled.on(); setIsErrorHandled.on();
} }
}, },
queryFn: () => fetchProjectSecrets({ workspaceId, environment, secretPath }), queryFn: () => fetchProjectSecrets({ projectId, environment, secretPath }),
staleTime: 60 * 1000, staleTime: 60 * 1000,
// eslint-disable-next-line react-hooks/rules-of-hooks // eslint-disable-next-line react-hooks/rules-of-hooks
select: useCallback( select: useCallback(
@@ -270,7 +270,7 @@ export const useGetSecretAccessList = (dto: TGetSecretAccessListDTO) =>
users: SecretAccessListEntry[]; users: SecretAccessListEntry[];
}>(`/api/v1/secrets/${dto.secretKey}/access-list`, { }>(`/api/v1/secrets/${dto.secretKey}/access-list`, {
params: { params: {
workspaceId: dto.workspaceId, projectId: dto.projectId,
environment: dto.environment, environment: dto.environment,
secretPath: dto.secretPath secretPath: dto.secretPath
} }
@@ -287,11 +287,11 @@ const fetchSecretReferenceTree = async ({
environmentSlug environmentSlug
}: TGetSecretReferenceTreeDTO) => { }: TGetSecretReferenceTreeDTO) => {
const { data } = await apiRequest.get<{ tree: TSecretReferenceTraceNode; value: string }>( const { data } = await apiRequest.get<{ tree: TSecretReferenceTraceNode; value: string }>(
`/api/v3/secrets/raw/${secretKey}/secret-reference-tree`, `/api/v4/secrets/${secretKey}/secret-reference-tree`,
{ {
params: { params: {
secretPath, secretPath,
workspaceId: projectId, projectId,
environment: environmentSlug environment: environmentSlug
} }
} }
+11 -35
View File
@@ -17,30 +17,6 @@ export type SecretReminderRecipient = {
}; };
id: string; id: string;
}; };
export type EncryptedSecret = {
id: string;
version: number;
workspace: string;
type: SecretType;
environment: string;
secretKeyCiphertext: string;
secretKeyIV: string;
secretKeyTag: string;
secretValueCiphertext: string;
secretValueIV: string;
secretValueTag: string;
secretValueHidden: boolean;
__v: number;
createdAt: string;
updatedAt: string;
skipMultilineEncoding?: boolean;
secretCommentCiphertext: string;
secretCommentIV: string;
secretCommentTag: string;
secretReminderRepeatDays?: number | null;
secretReminderNote?: string | null;
tags: WsTag[];
};
// both personal and shared secret stitched together for dashboard // both personal and shared secret stitched together for dashboard
export type SecretV3RawSanitized = { export type SecretV3RawSanitized = {
@@ -76,7 +52,7 @@ export type SecretV3RawSanitized = {
export type SecretV3Raw = { export type SecretV3Raw = {
id: string; id: string;
_id: string; _id: string;
workspace: string; project: string;
environment: string; environment: string;
version: number; version: number;
type: string; type: string;
@@ -113,7 +89,7 @@ export type SecretVersions = {
id: string; id: string;
secretId: string; secretId: string;
version: number; version: number;
workspace: string; project: string;
type: SecretType; type: SecretType;
isDeleted: boolean; isDeleted: boolean;
envId: string; envId: string;
@@ -136,7 +112,7 @@ export type SecretVersions = {
// dto // dto
export type TGetProjectSecretsKey = { export type TGetProjectSecretsKey = {
workspaceId: string; projectId: string;
environment: string; environment: string;
secretPath?: string; secretPath?: string;
includeImports?: boolean; includeImports?: boolean;
@@ -148,7 +124,7 @@ export type TGetProjectSecretsKey = {
export type TGetProjectSecretsDTO = TGetProjectSecretsKey; export type TGetProjectSecretsDTO = TGetProjectSecretsKey;
export type TGetProjectSecretsAllEnvDTO = { export type TGetProjectSecretsAllEnvDTO = {
workspaceId: string; projectId: string;
envs: string[]; envs: string[];
folderId?: string; folderId?: string;
secretPath?: string; secretPath?: string;
@@ -162,7 +138,7 @@ export type GetSecretVersionsDTO = {
}; };
export type TGetSecretAccessListDTO = { export type TGetSecretAccessListDTO = {
workspaceId: string; projectId: string;
environment: string; environment: string;
secretPath: string; secretPath: string;
secretKey: string; secretKey: string;
@@ -174,14 +150,14 @@ export type TCreateSecretsV3DTO = {
secretComment: string; secretComment: string;
skipMultilineEncoding?: boolean; skipMultilineEncoding?: boolean;
secretPath: string; secretPath: string;
workspaceId: string; projectId: string;
environment: string; environment: string;
type: SecretType; type: SecretType;
tagIds?: string[]; tagIds?: string[];
}; };
export type TUpdateSecretsV3DTO = { export type TUpdateSecretsV3DTO = {
workspaceId: string; projectId: string;
environment: string; environment: string;
secretPath: string; secretPath: string;
type: SecretType; type: SecretType;
@@ -198,7 +174,7 @@ export type TUpdateSecretsV3DTO = {
}; };
export type TDeleteSecretsV3DTO = { export type TDeleteSecretsV3DTO = {
workspaceId: string; projectId: string;
environment: string; environment: string;
type: SecretType; type: SecretType;
secretPath: string; secretPath: string;
@@ -207,7 +183,7 @@ export type TDeleteSecretsV3DTO = {
}; };
export type TCreateSecretBatchDTO = { export type TCreateSecretBatchDTO = {
workspaceId: string; projectId: string;
environment: string; environment: string;
secretPath: string; secretPath: string;
secrets: Array<{ secrets: Array<{
@@ -224,7 +200,7 @@ export type TCreateSecretBatchDTO = {
}; };
export type TUpdateSecretBatchDTO = { export type TUpdateSecretBatchDTO = {
workspaceId: string; projectId: string;
environment: string; environment: string;
secretPath: string; secretPath: string;
secrets: Array<{ secrets: Array<{
@@ -241,7 +217,7 @@ export type TUpdateSecretBatchDTO = {
}; };
export type TDeleteSecretBatchDTO = { export type TDeleteSecretBatchDTO = {
workspaceId: string; projectId: string;
environment: string; environment: string;
secretPath: string; secretPath: string;
secrets: Array<{ secrets: Array<{