import type { ColumnType, Insertable, Selectable, Updateable } from "kysely"
import type { Action } from "./Action"
import type { CommunitiesId } from "./Communities"

import { z } from "zod"

import { actionSchema } from "./Action"
import { communitiesIdSchema } from "./Communities"

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

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

/** Represents the table public.action_config_defaults */
export interface ActionConfigDefaultsTable {
	id: ColumnType<
		ActionConfigDefaultsId,
		ActionConfigDefaultsId | undefined,
		ActionConfigDefaultsId
	>

	communityId: ColumnType<CommunitiesId, CommunitiesId, CommunitiesId>

	action: ColumnType<Action, Action, Action>

	config: ColumnType<unknown | null, unknown | null, unknown | null>

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

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

export type ActionConfigDefaults = Selectable<ActionConfigDefaultsTable>

export type NewActionConfigDefaults = Insertable<ActionConfigDefaultsTable>

export type ActionConfigDefaultsUpdate = Updateable<ActionConfigDefaultsTable>

export const actionConfigDefaultsIdSchema = z
	.string()
	.uuid() as unknown as z.Schema<ActionConfigDefaultsId>

export const actionConfigDefaultsSchema = z.object({
	id: actionConfigDefaultsIdSchema,
	communityId: communitiesIdSchema,
	action: actionSchema,
	config: z.unknown().nullable(),
	createdAt: z.date(),
	updatedAt: z.date(),
})

export const actionConfigDefaultsInitializerSchema = z.object({
	id: actionConfigDefaultsIdSchema.optional(),
	communityId: communitiesIdSchema,
	action: actionSchema,
	config: z.unknown().optional().nullable(),
	createdAt: z.date().optional(),
	updatedAt: z.date().optional(),
})

export const actionConfigDefaultsMutatorSchema = z.object({
	id: actionConfigDefaultsIdSchema.optional(),
	communityId: communitiesIdSchema.optional(),
	action: actionSchema.optional(),
	config: z.unknown().optional().nullable(),
	createdAt: z.date().optional(),
	updatedAt: z.date().optional(),
})
