audit-log-bulk-export.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import type { HasObjectId, IAttachment, IUser, Ref } from '@growi/core';
  2. import type { SupportedActionType } from '~/interfaces/activity';
  3. export const AuditLogBulkExportFormat = {
  4. json: 'json',
  5. } as const;
  6. export type AuditLogBulkExportFormat =
  7. (typeof AuditLogBulkExportFormat)[keyof typeof AuditLogBulkExportFormat];
  8. export const AuditLogBulkExportJobInProgressJobStatus = {
  9. exporting: 'exporting',
  10. uploading: 'uploading',
  11. } as const;
  12. export const AuditLogBulkExportJobStatus = {
  13. ...AuditLogBulkExportJobInProgressJobStatus,
  14. completed: 'completed',
  15. failed: 'failed',
  16. } as const;
  17. export type AuditLogBulkExportJobStatus =
  18. (typeof AuditLogBulkExportJobStatus)[keyof typeof AuditLogBulkExportJobStatus];
  19. export interface IAuditLogBulkExportFilters {
  20. users?: Array<Ref<IUser>>;
  21. actions?: SupportedActionType[];
  22. dateFrom?: Date;
  23. dateTo?: Date;
  24. }
  25. export interface IAuditLogBulkExportJob {
  26. user: Ref<IUser>; // user who initiated the audit log export job
  27. filters: IAuditLogBulkExportFilters; // filter conditions used for export (e.g. user, action, date range)
  28. filterHash: string; // hash string generated from the filter set to detect duplicate export jobs
  29. format: AuditLogBulkExportFormat; // export file format (currently only 'json' is supported)
  30. status: AuditLogBulkExportJobStatus; // current status of the export job
  31. lastExportedId?: string; // ID of the last exported audit log record
  32. completedAt?: Date | null; // the date when the job was completed
  33. restartFlag: boolean; // flag indicating whether this job is a restarted one
  34. totalExportedCount?: number; // total number of exported audit log entries
  35. createdAt?: Date;
  36. updatedAt?: Date;
  37. attachment?: Ref<IAttachment>;
  38. }
  39. export interface IAuditLogBulkExportJobHasId
  40. extends IAuditLogBulkExportJob,
  41. HasObjectId {}