import * as Sequelize from 'sequelize';
import { DataTypes, Model, Optional } from 'sequelize';
import type { User, UserId } from './User';
export interface AuthAuditLogsDefaultAttributes {
	id: string;
	outbox_event_id?: string | null;
	request_id?: string | null;
	trace_id?: string | null;
	user_id?: string | null;
	action: string;
	ip_address?: string | null;
	user_agent?: string | null;
	device_info?: object | null;
	success?: boolean | null;
	failure_reason?: string | null;
	session_id?: string | null;
	event_version?: number | null;
	created_at: Date;
}
export type AuthAuditLogsDefaultPk = 'id' | 'created_at';
export type AuthAuditLogsDefaultId = AuthAuditLogsDefault[AuthAuditLogsDefaultPk];
export type AuthAuditLogsDefaultOptionalAttributes =
	| 'id'
	| 'outbox_event_id'
	| 'request_id'
	| 'trace_id'
	| 'user_id'
	| 'ip_address'
	| 'user_agent'
	| 'device_info'
	| 'success'
	| 'failure_reason'
	| 'session_id'
	| 'event_version'
	| 'created_at';
export type AuthAuditLogsDefaultCreationAttributes = Optional<
	AuthAuditLogsDefaultAttributes,
	AuthAuditLogsDefaultOptionalAttributes
>;
export class AuthAuditLogsDefault
	extends Model<AuthAuditLogsDefaultAttributes>
	implements AuthAuditLogsDefaultAttributes
{
	declare id: string;
	declare outbox_event_id?: string | null;
	declare request_id?: string | null;
	declare trace_id?: string | null;
	declare user_id?: string | null;
	declare action: string;
	declare ip_address?: string | null;
	declare user_agent?: string | null;
	declare device_info?: object | null;
	declare success?: boolean | null;
	declare failure_reason?: string | null;
	declare session_id?: string | null;
	declare event_version?: number | null;
	declare created_at: Date;
	// AuthAuditLogsDefault belongsTo User via user_id
	declare user: User;
	declare getUser: Sequelize.BelongsToGetAssociationMixin<User>;
	declare setUser: Sequelize.BelongsToSetAssociationMixin<User, UserId>;
	declare createUser: Sequelize.BelongsToCreateAssociationMixin<User>;
	static initModel(sequelize: Sequelize.Sequelize): typeof AuthAuditLogsDefault {
		return AuthAuditLogsDefault.init(
			{
				id: {
					type: DataTypes.UUID,
					allowNull: false,
					defaultValue: DataTypes.UUIDV4,
					primaryKey: true,
				},
				outbox_event_id: {
					type: DataTypes.UUID,
					allowNull: true,
				},
				request_id: {
					type: DataTypes.UUID,
					allowNull: true,
				},
				trace_id: {
					type: DataTypes.UUID,
					allowNull: true,
				},
				user_id: {
					type: DataTypes.UUID,
					allowNull: true,
					references: {
						model: 'users',
						key: 'id',
					},
				},
				action: {
					type: DataTypes.STRING(50),
					allowNull: false,
				},
				ip_address: {
					type: DataTypes.INET,
					allowNull: true,
				},
				user_agent: {
					type: DataTypes.TEXT,
					allowNull: true,
				},
				device_info: {
					type: DataTypes.JSONB,
					allowNull: true,
				},
				success: {
					type: DataTypes.BOOLEAN,
					allowNull: true,
					defaultValue: true,
				},
				failure_reason: {
					type: DataTypes.TEXT,
					allowNull: true,
				},
				session_id: {
					type: DataTypes.UUID,
					allowNull: true,
				},
				event_version: {
					type: DataTypes.INTEGER,
					allowNull: true,
					defaultValue: 1,
				},
				created_at: {
					type: DataTypes.DATE,
					allowNull: false,
					defaultValue: Sequelize.Sequelize.literal('CURRENT_TIMESTAMP'),
					primaryKey: true,
				},
			},
			{
				sequelize,
				tableName: 'auth_audit_logs_default',
				schema: 'audit',
				timestamps: false,
				indexes: [
					{
						name: 'auth_audit_logs_default_created_at_idx',
						fields: [{ name: 'created_at' }],
					},
					{
						name: 'auth_audit_logs_default_pkey',
						unique: true,
						fields: [{ name: 'id' }, { name: 'created_at' }],
					},
				],
			},
		);
	}
}
