// @generated
// This file is automatically generated by Kanel. Do not modify manually.

import type { ColumnType, Insertable, Selectable, Updateable } from "kysely"

import { z } from "zod"

/** Identifier type for public.users */
export type UsersId = string & { __brand: "UsersId" }

/** Represents the table public.users */
export interface UsersTable {
	id: ColumnType<UsersId, UsersId | undefined, UsersId>

	slug: ColumnType<string, string, string>

	email: ColumnType<string, string, string>

	firstName: ColumnType<string, string, string>

	avatar: ColumnType<string | null, string | null, string | null>

	createdAt: ColumnType<Date, Date | string | undefined, Date | string>

	updatedAt: ColumnType<Date, Date | string | undefined, Date | string>

	lastName: ColumnType<string | null, string | null, string | null>

	orcid: ColumnType<string | null, string | null, string | null>

	isSuperAdmin: ColumnType<boolean, boolean | undefined, boolean>

	passwordHash: ColumnType<string | null, string | null, string | null>

	isVerified: ColumnType<boolean, boolean | undefined, boolean>

	/** Indicates whether a user is provisional, meaning they were added through an invite and need to accept it to become a full user */
	isProvisional: ColumnType<boolean, boolean | undefined, boolean>
}

export type Users = Selectable<UsersTable>

export type NewUsers = Insertable<UsersTable>

export type UsersUpdate = Updateable<UsersTable>

export const usersIdSchema = z.string().uuid() as unknown as z.Schema<UsersId>

export const usersSchema = z.object({
	id: usersIdSchema,
	slug: z.string(),
	email: z.string(),
	firstName: z.string(),
	avatar: z.string().nullable(),
	createdAt: z.date(),
	updatedAt: z.date(),
	lastName: z.string().nullable(),
	orcid: z.string().nullable(),
	isSuperAdmin: z.boolean(),
	passwordHash: z.string().nullable(),
	isVerified: z.boolean(),
	isProvisional: z.boolean(),
})

export const usersInitializerSchema = z.object({
	id: usersIdSchema.optional(),
	slug: z.string(),
	email: z.string(),
	firstName: z.string(),
	avatar: z.string().optional().nullable(),
	createdAt: z.date().optional(),
	updatedAt: z.date().optional(),
	lastName: z.string().optional().nullable(),
	orcid: z.string().optional().nullable(),
	isSuperAdmin: z.boolean().optional(),
	passwordHash: z.string().optional().nullable(),
	isVerified: z.boolean().optional(),
	isProvisional: z.boolean().optional(),
})

export const usersMutatorSchema = z.object({
	id: usersIdSchema.optional(),
	slug: z.string().optional(),
	email: z.string().optional(),
	firstName: z.string().optional(),
	avatar: z.string().optional().nullable(),
	createdAt: z.date().optional(),
	updatedAt: z.date().optional(),
	lastName: z.string().optional().nullable(),
	orcid: z.string().optional().nullable(),
	isSuperAdmin: z.boolean().optional(),
	passwordHash: z.string().optional().nullable(),
	isVerified: z.boolean().optional(),
	isProvisional: z.boolean().optional(),
})
