mirror of
https://github.com/documenso/documenso.git
synced 2025-11-23 21:21:37 +10:00
chore: extract shared audit log query logic
This commit is contained in:
@ -12,34 +12,18 @@ export const findEnvelopeAuditLogsRoute = authenticatedProcedure
|
||||
.input(ZFindEnvelopeAuditLogsRequestSchema)
|
||||
.output(ZFindEnvelopeAuditLogsResponseSchema)
|
||||
.query(async ({ input, ctx }) => {
|
||||
const { teamId } = ctx;
|
||||
|
||||
const {
|
||||
page,
|
||||
perPage,
|
||||
envelopeId,
|
||||
cursor,
|
||||
filterForRecentActivity,
|
||||
eventTypes,
|
||||
orderByColumn,
|
||||
orderByDirection,
|
||||
} = input;
|
||||
const { orderByColumn, orderByDirection, ...auditLogParams } = input;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
envelopeId,
|
||||
envelopeId: input.envelopeId,
|
||||
},
|
||||
});
|
||||
|
||||
return await findEnvelopeAuditLogs({
|
||||
...auditLogParams,
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
page,
|
||||
perPage,
|
||||
envelopeId,
|
||||
cursor,
|
||||
filterForRecentActivity,
|
||||
eventTypes,
|
||||
teamId: ctx.teamId,
|
||||
orderBy: orderByColumn ? { column: orderByColumn, direction: orderByDirection } : undefined,
|
||||
});
|
||||
});
|
||||
|
||||
@ -22,10 +22,6 @@ export const ZFindEnvelopeAuditLogsRequestSchema = ZFindSearchParamsSchema.exten
|
||||
.describe('Envelope ID (e.g., envelope_xxx) or legacy document ID (e.g., 12345)'),
|
||||
cursor: z.string().optional(),
|
||||
filterForRecentActivity: z.boolean().optional(),
|
||||
eventTypes: z
|
||||
.array(z.string())
|
||||
.optional()
|
||||
.describe('Filter by specific event types (e.g., ["DOCUMENT_CREATED", "DOCUMENT_SENT"])'),
|
||||
orderByColumn: z.enum(['createdAt', 'type']).optional(),
|
||||
orderByDirection: z.enum(['asc', 'desc']).default('desc'),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user