import type { ColumnType, Insertable, Selectable, Updateable } from "kysely"
import type { ActionRunsId } from "./ActionRuns"
import type { ApiAccessTokensId } from "./ApiAccessTokens"
import type { Invites } from "./Invites"
import type { OperationType } from "./OperationType"
import type { UsersId } from "./Users"

import { z } from "zod"

import { actionRunsIdSchema } from "./ActionRuns"
import { apiAccessTokensIdSchema } from "./ApiAccessTokens"
import { operationTypeSchema } from "./OperationType"
import { usersIdSchema } from "./Users"

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

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

/** Represents the table public.invites_history */
export interface InvitesHistoryTable {
	id: ColumnType<InvitesHistoryId, InvitesHistoryId | undefined, InvitesHistoryId>

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

	operationType: ColumnType<OperationType, OperationType, OperationType>

	oldRowData: ColumnType<Invites, string | null, string | null>

	newRowData: ColumnType<Invites, string | null, string | null>

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

	userId: ColumnType<UsersId | null, UsersId | null, UsersId | null>

	apiAccessTokenId: ColumnType<
		ApiAccessTokensId | null,
		ApiAccessTokensId | null,
		ApiAccessTokensId | null
	>

	actionRunId: ColumnType<ActionRunsId | null, ActionRunsId | null, ActionRunsId | null>

	other: ColumnType<string | null, string | null, string | null>
}

export type InvitesHistory = Selectable<InvitesHistoryTable>

export type NewInvitesHistory = Insertable<InvitesHistoryTable>

export type InvitesHistoryUpdate = Updateable<InvitesHistoryTable>

export const invitesHistoryIdSchema = z.string().uuid() as unknown as z.Schema<InvitesHistoryId>

export const invitesHistorySchema = z.object({
	id: invitesHistoryIdSchema,
	createdAt: z.date(),
	operationType: operationTypeSchema,
	oldRowData: z.unknown().nullable(),
	newRowData: z.unknown().nullable(),
	inviteId: z.string().nullable(),
	userId: usersIdSchema.nullable(),
	apiAccessTokenId: apiAccessTokensIdSchema.nullable(),
	actionRunId: actionRunsIdSchema.nullable(),
	other: z.string().nullable(),
})

export const invitesHistoryInitializerSchema = z.object({
	id: invitesHistoryIdSchema.optional(),
	createdAt: z.date().optional(),
	operationType: operationTypeSchema,
	oldRowData: z.unknown().optional().nullable(),
	newRowData: z.unknown().optional().nullable(),
	inviteId: z.string().optional().nullable(),
	userId: usersIdSchema.optional().nullable(),
	apiAccessTokenId: apiAccessTokensIdSchema.optional().nullable(),
	actionRunId: actionRunsIdSchema.optional().nullable(),
	other: z.string().optional().nullable(),
})

export const invitesHistoryMutatorSchema = z.object({
	id: invitesHistoryIdSchema.optional(),
	createdAt: z.date().optional(),
	operationType: operationTypeSchema.optional(),
	oldRowData: z.unknown().optional().nullable(),
	newRowData: z.unknown().optional().nullable(),
	inviteId: z.string().optional().nullable(),
	userId: usersIdSchema.optional().nullable(),
	apiAccessTokenId: apiAccessTokensIdSchema.optional().nullable(),
	actionRunId: actionRunsIdSchema.optional().nullable(),
	other: z.string().optional().nullable(),
})
