import { objectId } from '@jig-software/zod-bson';
import { z } from 'zod';

export const EventTypeEnum = z.enum([
  'RequestToken',
  'RequestTokenRejected',
  'RequestUserCreation',
  'RequestUserRemoval',
  'RequestPasswordChange',
  'RequestPrivilegeChange',
  'AccountLocked',
  'AccountPreviouslyLocked',
]);
export type EventTypeEnum = z.infer<typeof EventTypeEnum>;

export const Event = z.object({
  _id: objectId(),
  type: EventTypeEnum,
  username: z.string(),
  connectingIp: z.string(),
  userAgent: z.string(),
  message: z.string().optional(),
  expiredAt: z.date().optional(),
  createdAt: z.date(),
  updatedAt: z.date(),
});
export type Event = z.infer<typeof Event>;
