mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 19:28:09 +00:00
Update secret-version-dal.ts
This commit is contained in:
@@ -187,6 +187,17 @@ export const secretVersionV2BridgeDALFactory = (db: TDbClient) => {
|
|||||||
`${TableName.SecretVersionV2}.userActorId`
|
`${TableName.SecretVersionV2}.userActorId`
|
||||||
)
|
)
|
||||||
.leftJoin(TableName.Identity, `${TableName.Identity}.id`, `${TableName.SecretVersionV2}.identityActorId`)
|
.leftJoin(TableName.Identity, `${TableName.Identity}.id`, `${TableName.SecretVersionV2}.identityActorId`)
|
||||||
|
.leftJoin(TableName.SecretV2, `${TableName.SecretVersionV2}.secretId`, `${TableName.SecretV2}.id`)
|
||||||
|
.leftJoin(
|
||||||
|
TableName.SecretV2JnTag,
|
||||||
|
`${TableName.SecretV2}.id`,
|
||||||
|
`${TableName.SecretV2JnTag}.${TableName.SecretV2}Id`
|
||||||
|
)
|
||||||
|
.leftJoin(
|
||||||
|
TableName.SecretTag,
|
||||||
|
`${TableName.SecretV2JnTag}.${TableName.SecretTag}Id`,
|
||||||
|
`${TableName.SecretTag}.id`
|
||||||
|
)
|
||||||
.where((qb) => {
|
.where((qb) => {
|
||||||
void qb.where(`${TableName.SecretVersionV2}.secretId`, secretId);
|
void qb.where(`${TableName.SecretVersionV2}.secretId`, secretId);
|
||||||
void qb.where(`${TableName.ProjectMembership}.projectId`, projectId);
|
void qb.where(`${TableName.ProjectMembership}.projectId`, projectId);
|
||||||
@@ -197,9 +208,12 @@ export const secretVersionV2BridgeDALFactory = (db: TDbClient) => {
|
|||||||
})
|
})
|
||||||
.select(
|
.select(
|
||||||
selectAllTableCols(TableName.SecretVersionV2),
|
selectAllTableCols(TableName.SecretVersionV2),
|
||||||
`${TableName.Users}.username as userActorName`,
|
db.ref("username").withSchema(TableName.Users).as("userActorName"),
|
||||||
`${TableName.Identity}.name as identityActorName`,
|
db.ref("name").withSchema(TableName.Identity).as("identityActorName"),
|
||||||
`${TableName.ProjectMembership}.id as membershipId`
|
db.ref("id").withSchema(TableName.ProjectMembership).as("membershipId"),
|
||||||
|
db.ref("id").withSchema(TableName.SecretTag).as("tagId"),
|
||||||
|
db.ref("color").withSchema(TableName.SecretTag).as("tagColor"),
|
||||||
|
db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug")
|
||||||
);
|
);
|
||||||
|
|
||||||
if (limit) void query.limit(limit);
|
if (limit) void query.limit(limit);
|
||||||
@@ -214,14 +228,33 @@ export const secretVersionV2BridgeDALFactory = (db: TDbClient) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const docs: Array<
|
const docs = await query;
|
||||||
TSecretVersionsV2 & {
|
|
||||||
userActorName: string | undefined | null;
|
const data = sqlNestRelationships({
|
||||||
identityActorName: string | undefined | null;
|
data: docs,
|
||||||
membershipId: string | undefined | null;
|
key: "id",
|
||||||
}
|
parentMapper: (el) => ({
|
||||||
> = await query;
|
_id: el.id,
|
||||||
return docs;
|
...SecretVersionsV2Schema.parse(el),
|
||||||
|
userActorName: el.userActorName,
|
||||||
|
identityActorName: el.identityActorName,
|
||||||
|
membershipId: el.membershipId
|
||||||
|
}),
|
||||||
|
childrenMapper: [
|
||||||
|
{
|
||||||
|
key: "tagId",
|
||||||
|
label: "tags" as const,
|
||||||
|
mapper: ({ tagId: id, tagColor: color, tagSlug: slug }) => ({
|
||||||
|
id,
|
||||||
|
color,
|
||||||
|
slug,
|
||||||
|
name: slug
|
||||||
|
})
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new DatabaseError({ error, name: "FindVersionsBySecretIdWithActors" });
|
throw new DatabaseError({ error, name: "FindVersionsBySecretIdWithActors" });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user