mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
PIT: add description to folder versioning
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { Knex } from "knex";
|
||||
|
||||
import { TableName } from "../schemas";
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
if (!(await knex.schema.hasColumn(TableName.SecretFolderVersion, "description"))) {
|
||||
await knex.schema.alterTable(TableName.SecretFolderVersion, (t) => {
|
||||
t.string("description").nullable();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function down(knex: Knex): Promise<void> {
|
||||
if (await knex.schema.hasColumn(TableName.SecretFolderVersion, "description")) {
|
||||
await knex.schema.alterTable(TableName.SecretFolderVersion, (t) => {
|
||||
t.dropColumn("description");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,8 @@ export const SecretFolderVersionsSchema = z.object({
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
envId: z.string().uuid(),
|
||||
folderId: z.string().uuid()
|
||||
folderId: z.string().uuid(),
|
||||
description: z.string().nullable().optional()
|
||||
});
|
||||
|
||||
export type TSecretFolderVersions = z.infer<typeof SecretFolderVersionsSchema>;
|
||||
|
||||
@@ -532,11 +532,12 @@ export const secretSnapshotServiceFactory = ({
|
||||
});
|
||||
await secretTagDAL.saveTagsToSecretV2(secretTagsToBeInsert, tx);
|
||||
const folderVersions = await folderVersionDAL.insertMany(
|
||||
folders.map(({ version, name, id, envId }) => ({
|
||||
folders.map(({ version, name, id, envId, description }) => ({
|
||||
name,
|
||||
version,
|
||||
folderId: id,
|
||||
envId
|
||||
envId,
|
||||
description
|
||||
})),
|
||||
tx
|
||||
);
|
||||
@@ -743,11 +744,12 @@ export const secretSnapshotServiceFactory = ({
|
||||
});
|
||||
await secretTagDAL.saveTagsToSecret(secretTagsToBeInsert, tx);
|
||||
const folderVersions = await folderVersionDAL.insertMany(
|
||||
folders.map(({ version, name, id, envId }) => ({
|
||||
folders.map(({ version, name, id, envId, description }) => ({
|
||||
name,
|
||||
version,
|
||||
folderId: id,
|
||||
envId
|
||||
envId,
|
||||
description
|
||||
})),
|
||||
tx
|
||||
);
|
||||
|
||||
@@ -37,7 +37,8 @@ const secretVersionSchema = z.object({
|
||||
// Folder-specific versions schema
|
||||
const folderVersionSchema = z.object({
|
||||
version: z.string().optional(),
|
||||
name: z.string().optional()
|
||||
name: z.string().optional(),
|
||||
description: z.string().optional().nullable()
|
||||
});
|
||||
|
||||
// Secret commit change schema
|
||||
|
||||
@@ -115,6 +115,7 @@ type FolderChange = BaseChange & {
|
||||
folderVersion: string;
|
||||
versions?: {
|
||||
name: string;
|
||||
description?: string | null;
|
||||
}[];
|
||||
};
|
||||
|
||||
@@ -604,8 +605,19 @@ export const folderCommitServiceFactory = ({
|
||||
version: [Number(change.folderVersion), Number(change.fromVersion)]
|
||||
}
|
||||
});
|
||||
const versionsShaped = [...new Set(versions.map((version) => version.name))];
|
||||
if (versionsShaped.length === 1) {
|
||||
const versionsShaped = versions.map((version) => ({
|
||||
name: version.name,
|
||||
description: version.description
|
||||
}));
|
||||
const uniqueVersions = versionsShaped.filter(
|
||||
(item, index, arr) =>
|
||||
arr.findIndex((other) =>
|
||||
Object.entries(item).every(
|
||||
([key, value]) => JSON.stringify(value) === JSON.stringify(other[key as keyof typeof other])
|
||||
)
|
||||
) === index
|
||||
);
|
||||
if (uniqueVersions.length === 1) {
|
||||
removeNoChangeUpdate.push(change.id);
|
||||
}
|
||||
} else if (change.type === ResourceType.SECRET && change.secretVersion && change.fromVersion) {
|
||||
@@ -1108,7 +1120,8 @@ export const folderCommitServiceFactory = ({
|
||||
parentId: folderId,
|
||||
envId: folderVersion.envId,
|
||||
version: (folderVersion.version || 1) + 1,
|
||||
name: folderVersion.name
|
||||
name: folderVersion.name,
|
||||
description: folderVersion.description
|
||||
};
|
||||
await folderDAL.create(newFolder, tx);
|
||||
|
||||
@@ -1117,6 +1130,7 @@ export const folderCommitServiceFactory = ({
|
||||
folderId: change.id,
|
||||
version: (folderVersion.version || 1) + 1,
|
||||
name: folderVersion.name,
|
||||
description: folderVersion.description,
|
||||
envId: folderVersion.envId
|
||||
},
|
||||
tx
|
||||
@@ -1170,7 +1184,8 @@ export const folderCommitServiceFactory = ({
|
||||
parentId: folderId,
|
||||
envId: versionDetails.envId,
|
||||
version: (versionDetails.version || 1) + 1,
|
||||
name: versionDetails.name
|
||||
name: versionDetails.name,
|
||||
description: versionDetails.description
|
||||
},
|
||||
tx
|
||||
);
|
||||
@@ -1180,6 +1195,7 @@ export const folderCommitServiceFactory = ({
|
||||
folderId: change.id,
|
||||
version: (versionDetails.version || 1) + 1,
|
||||
name: versionDetails.name,
|
||||
description: versionDetails.description,
|
||||
envId: versionDetails.envId
|
||||
},
|
||||
tx
|
||||
|
||||
@@ -119,7 +119,8 @@ export const secretFolderServiceFactory = ({
|
||||
name: doc.name,
|
||||
envId: doc.envId,
|
||||
version: doc.version,
|
||||
folderId: doc.id
|
||||
folderId: doc.id,
|
||||
description: doc.description
|
||||
})),
|
||||
tx
|
||||
);
|
||||
@@ -152,7 +153,8 @@ export const secretFolderServiceFactory = ({
|
||||
name: doc.name,
|
||||
envId: doc.envId,
|
||||
version: doc.version,
|
||||
folderId: doc.id
|
||||
folderId: doc.id,
|
||||
description: doc.description
|
||||
},
|
||||
tx
|
||||
);
|
||||
@@ -269,7 +271,8 @@ export const secretFolderServiceFactory = ({
|
||||
name: doc.name,
|
||||
envId: doc.envId,
|
||||
version: doc.version,
|
||||
folderId: doc.id
|
||||
folderId: doc.id,
|
||||
description: doc.description
|
||||
},
|
||||
tx
|
||||
);
|
||||
@@ -385,7 +388,8 @@ export const secretFolderServiceFactory = ({
|
||||
name: doc.name,
|
||||
envId: doc.envId,
|
||||
version: doc.version,
|
||||
folderId: doc.id
|
||||
folderId: doc.id,
|
||||
description: doc.description
|
||||
},
|
||||
tx
|
||||
);
|
||||
@@ -802,7 +806,8 @@ export const secretFolderServiceFactory = ({
|
||||
});
|
||||
return versions.map((v) => ({
|
||||
version: v.version?.toString() || "1",
|
||||
name: v.name
|
||||
name: v.name,
|
||||
description: v.description
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user