import type { ColumnType, Insertable, Selectable, Updateable } from "kysely"
import type { ApiAccessTokensId } from "./ApiAccessTokens"

import { z } from "zod"

import { apiAccessTokensIdSchema } from "./ApiAccessTokens"

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

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

/** Represents the table public.api_access_logs */
export interface ApiAccessLogsTable {
	id: ColumnType<ApiAccessLogsId, ApiAccessLogsId | undefined, ApiAccessLogsId>

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

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

	action: ColumnType<string, string, string>
}

export type ApiAccessLogs = Selectable<ApiAccessLogsTable>

export type NewApiAccessLogs = Insertable<ApiAccessLogsTable>

export type ApiAccessLogsUpdate = Updateable<ApiAccessLogsTable>

export const apiAccessLogsIdSchema = z.string().uuid() as unknown as z.Schema<ApiAccessLogsId>

export const apiAccessLogsSchema = z.object({
	id: apiAccessLogsIdSchema,
	accessTokenId: apiAccessTokensIdSchema.nullable(),
	timestamp: z.date(),
	action: z.string(),
})

export const apiAccessLogsInitializerSchema = z.object({
	id: apiAccessLogsIdSchema.optional(),
	accessTokenId: apiAccessTokensIdSchema.optional().nullable(),
	timestamp: z.date().optional(),
	action: z.string(),
})

export const apiAccessLogsMutatorSchema = z.object({
	id: apiAccessLogsIdSchema.optional(),
	accessTokenId: apiAccessTokensIdSchema.optional().nullable(),
	timestamp: z.date().optional(),
	action: z.string().optional(),
})
