import {faker} from '@faker-js/faker'

import {Factory} from '../support/factory'
import {TEST_PASSWORD_HASH} from '../support/constants'

export interface UserAttributes {
	id: number | '{increment}';
	username: string;
	password?: string;
	status: number;
	issuer: string;
	language: string;
	created: string;
	updated: string;
}

export class UserFactory extends Factory {
	static table = 'users'

	static factory() {
		const now = new Date()

		return {
			id: '{increment}',
			username: faker.string.alphanumeric(10) + faker.string.uuid(),
			password: TEST_PASSWORD_HASH,
			status: 0,
			issuer: 'local',
			language: 'en',
			created: now.toISOString(),
			updated: now.toISOString(),
		}
	}
}
