import * as Sequelize from 'sequelize';
import { DataTypes, Model, Optional } from 'sequelize';
import type { User, UserId } from './User';
export interface RefreshTokenAuditLogsDefaultAttributes {
	id: string;
	outbox_event_id?: string | null;
	request_id?: string | null;
	trace_id?: string | null;
	user_id?: string | null;
	session_id?: string | null;
	action: string;
	ip_address?: string | null;
	user_agent?: string | null;
	platform?: string | null;
	device_id?: string | null;
	previous_token_hash?: string | null;
	new_token_hash?: string | null;
	reason?: string | null;
	event_version?: number | null;
	created_at: Date;
}
export type RefreshTokenAuditLogsDefaultPk = 'id' | 'created_at';
export type RefreshTokenAuditLogsDefaultId = RefreshTokenAuditLogsDefault[RefreshTokenAuditLogsDefaultPk];
export type RefreshTokenAuditLogsDefaultOptionalAttributes =
	| 'id'
	| 'outbox_event_id'
	| 'request_id'
	| 'trace_id'
	| 'user_id'
	| 'session_id'
	| 'ip_address'
	| 'user_agent'
	| 'platform'
	| 'device_id'
	| 'previous_token_hash'
	| 'new_token_hash'
	| 'reason'
	| 'event_version'
	| 'created_at';
export type RefreshTokenAuditLogsDefaultCreationAttributes = Optional<
	RefreshTokenAuditLogsDefaultAttributes,
	RefreshTokenAuditLogsDefaultOptionalAttributes
>;
export class RefreshTokenAuditLogsDefault
	extends Model<RefreshTokenAuditLogsDefaultAttributes>
	implements RefreshTokenAuditLogsDefaultAttributes
{
	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 session_id?: string | null;
	declare action: string;
	declare ip_address?: string | null;
	declare user_agent?: string | null;
	declare platform?: string | null;
	declare device_id?: string | null;
	declare previous_token_hash?: string | null;
	declare new_token_hash?: string | null;
	declare reason?: string | null;
	declare event_version?: number | null;
	declare created_at: Date;
	// RefreshTokenAuditLogsDefault 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 RefreshTokenAuditLogsDefault {
		return RefreshTokenAuditLogsDefault.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',
					},
				},
				session_id: {
					type: DataTypes.UUID,
					allowNull: true,
				},
				action: {
					type: DataTypes.STRING(50),
					allowNull: false,
				},
				ip_address: {
					type: DataTypes.INET,
					allowNull: true,
				},
				user_agent: {
					type: DataTypes.TEXT,
					allowNull: true,
				},
				platform: {
					type: DataTypes.STRING(50),
					allowNull: true,
				},
				device_id: {
					type: DataTypes.STRING(255),
					allowNull: true,
				},
				previous_token_hash: {
					type: DataTypes.STRING(255),
					allowNull: true,
				},
				new_token_hash: {
					type: DataTypes.STRING(255),
					allowNull: true,
				},
				reason: {
					type: DataTypes.TEXT,
					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: 'refresh_token_audit_logs_default',
				schema: 'audit',
				timestamps: false,
				indexes: [
					{
						name: 'refresh_token_audit_logs_default_action_idx',
						fields: [{ name: 'action' }],
					},
					{
						name: 'refresh_token_audit_logs_default_created_at_idx',
						fields: [{ name: 'created_at', order: 'DESC' }],
					},
					{
						name: 'refresh_token_audit_logs_default_created_at_idx1',
						fields: [{ name: 'created_at' }],
					},
					{
						name: 'refresh_token_audit_logs_default_pkey',
						unique: true,
						fields: [{ name: 'id' }, { name: 'created_at' }],
					},
					{
						name: 'refresh_token_audit_logs_default_session_id_idx',
						fields: [{ name: 'session_id' }],
					},
					{
						name: 'refresh_token_audit_logs_default_user_id_idx',
						fields: [{ name: 'user_id' }],
					},
				],
			},
		);
	}
}
