import type { z } from "zod";
import type {
	categories,
	globalItems,
	globalItemTags,
	items,
	setupItems,
	setups,
	tags,
	threadCandidates,
	threads,
} from "../db/schema.ts";
import type {
	bulkUpsertGlobalItemsSchema,
	changeEmailSchema,
	changePasswordSchema,
	createCandidateSchema,
	createCategorySchema,
	createItemSchema,
	createSetupSchema,
	createThreadSchema,
	deleteAccountSchema,
	reorderCandidatesSchema,
	resolveThreadSchema,
	searchGlobalItemsSchema,
	syncSetupItemsSchema,
	updateCandidateSchema,
	updateCategorySchema,
	updateClassificationSchema,
	updateItemSchema,
	updateProfileSchema,
	updateSetupSchema,
	updateThreadSchema,
	upsertGlobalItemSchema,
} from "./schemas.ts";

// Types inferred from Zod schemas
export type CreateItem = z.infer<typeof createItemSchema>;
export type UpdateItem = z.infer<typeof updateItemSchema>;
export type CreateCategory = z.infer<typeof createCategorySchema>;
export type UpdateCategory = z.infer<typeof updateCategorySchema>;
export type CreateThread = z.infer<typeof createThreadSchema>;
export type UpdateThread = z.infer<typeof updateThreadSchema>;
export type CreateCandidate = z.infer<typeof createCandidateSchema>;
export type UpdateCandidate = z.infer<typeof updateCandidateSchema>;
export type ResolveThread = z.infer<typeof resolveThreadSchema>;
export type ReorderCandidates = z.infer<typeof reorderCandidatesSchema>;

// Setup types
export type CreateSetup = z.infer<typeof createSetupSchema>;
export type UpdateSetup = z.infer<typeof updateSetupSchema>;
export type SyncSetupItems = z.infer<typeof syncSetupItemsSchema>;
export type UpdateClassification = z.infer<typeof updateClassificationSchema>;

// Global item types
export type SearchGlobalItems = z.infer<typeof searchGlobalItemsSchema>;
export type UpdateProfile = z.infer<typeof updateProfileSchema>;
export type UpsertGlobalItemInput = z.infer<typeof upsertGlobalItemSchema>;
export type BulkUpsertGlobalItemsInput = z.infer<
	typeof bulkUpsertGlobalItemsSchema
>;

// Types inferred from Drizzle schema
export type Item = typeof items.$inferSelect;
export type Category = typeof categories.$inferSelect;
export type Thread = typeof threads.$inferSelect;
export type ThreadCandidate = typeof threadCandidates.$inferSelect;
export type Setup = typeof setups.$inferSelect;
export type SetupItem = typeof setupItems.$inferSelect;
export type GlobalItem = typeof globalItems.$inferSelect;
export type Tag = typeof tags.$inferSelect;
export type GlobalItemTag = typeof globalItemTags.$inferSelect;

// Account management types
export type ChangePassword = z.infer<typeof changePasswordSchema>;
export type ChangeEmail = z.infer<typeof changeEmailSchema>;
export type DeleteAccount = z.infer<typeof deleteAccountSchema>;
