fix: made all update fields optional

This commit is contained in:
Daniel Hougaard
2024-10-02 20:09:31 +04:00
parent 67a6deed72
commit 8ed04d0b75
3 changed files with 18 additions and 13 deletions

View File

@@ -131,9 +131,9 @@ export const registerIntegrationRouter = async (server: FastifyZodProvider) => {
.default("/")
.transform(removeTrailingSlash)
.describe(INTEGRATION.UPDATE.secretPath),
targetEnvironment: z.string().trim().describe(INTEGRATION.UPDATE.targetEnvironment),
owner: z.string().trim().describe(INTEGRATION.UPDATE.owner),
environment: z.string().trim().describe(INTEGRATION.UPDATE.environment),
targetEnvironment: z.string().trim().optional().describe(INTEGRATION.UPDATE.targetEnvironment),
owner: z.string().trim().optional().describe(INTEGRATION.UPDATE.owner),
environment: z.string().trim().optional().describe(INTEGRATION.UPDATE.environment),
metadata: IntegrationMetadataSchema.optional()
}),
response: {

View File

@@ -150,12 +150,17 @@ export const integrationServiceFactory = ({
);
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Integrations);
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionActions.Read,
subject(ProjectPermissionSub.Secrets, { environment, secretPath })
);
const newEnvironment = environment || integration.environment.slug;
const newSecretPath = secretPath || integration.secretPath;
const folder = await folderDAL.findBySecretPath(integration.projectId, environment, secretPath);
if (environment || secretPath) {
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionActions.Read,
subject(ProjectPermissionSub.Secrets, { environment: newEnvironment, secretPath: newSecretPath })
);
}
const folder = await folderDAL.findBySecretPath(integration.projectId, newEnvironment, newSecretPath);
if (!folder) throw new NotFoundError({ message: "Folder path not found" });
const updatedIntegration = await integrationDAL.updateById(id, {
@@ -174,7 +179,7 @@ export const integrationServiceFactory = ({
await secretQueueService.syncIntegrations({
environment: folder.environment.slug,
secretPath,
secretPath: newSecretPath,
projectId: folder.projectId
});

View File

@@ -48,10 +48,10 @@ export type TUpdateIntegrationDTO = {
app?: string;
appId?: string;
isActive?: boolean;
secretPath: string;
targetEnvironment: string;
owner: string;
environment: string;
secretPath?: string;
targetEnvironment?: string;
owner?: string;
environment?: string;
metadata?: {
secretPrefix?: string;
secretSuffix?: string;