feat: project-independent log support

This commit is contained in:
Daniel Hougaard
2024-09-20 23:07:53 +04:00
parent 59b8e83476
commit 9f61177b62
5 changed files with 21 additions and 16 deletions
+6 -4
View File
@@ -122,10 +122,12 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
})
.merge(
z.object({
project: z.object({
name: z.string(),
slug: z.string()
}),
project: z
.object({
name: z.string(),
slug: z.string()
})
.optional(),
event: z.object({
type: z.string(),
metadata: z.any()
@@ -55,8 +55,7 @@ export const auditLogDALFactory = (db: TDbClient) => {
// eslint-disable-next-line func-names
.where(function () {
if (orgId) {
void this.where(`${TableName.Project}.orgId`, orgId);
// .orWhere(`${TableName.AuditLog}.orgId`, orgId);
void this.where(`${TableName.Project}.orgId`, orgId).orWhere(`${TableName.AuditLog}.orgId`, orgId);
} else if (projectId) {
void this.where(`${TableName.AuditLog}.projectId`, projectId);
}
@@ -114,10 +113,12 @@ export const auditLogDALFactory = (db: TDbClient) => {
return {
...AuditLogsSchema.parse(doc),
project: {
name: projectDoc.projectName,
slug: projectDoc.projectSlug
}
...(projectDoc?.projectSlug && {
project: {
name: projectDoc.projectName,
slug: projectDoc.projectSlug
}
})
};
});
} catch (error) {
@@ -120,10 +120,12 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
})
.merge(
z.object({
project: z.object({
name: z.string(),
slug: z.string()
}),
project: z
.object({
name: z.string(),
slug: z.string()
})
.optional(),
event: z.object({
type: z.string(),
metadata: z.any()