import { account, deviceCode, invitation, member, organization, session, user, verification } from "./auth-schema.js";
import { z } from "@hono/zod-openapi";
import { createInsertSchema, createSelectSchema } from "drizzle-zod";

//#region src/auth/auth-validation-schemas.ts
const UserSelectSchema = createSelectSchema(user);
const UserInsertSchema = createInsertSchema(user);
const SessionSelectSchema = createSelectSchema(session);
const SessionInsertSchema = createInsertSchema(session);
const AccountSelectSchema = createSelectSchema(account);
const AccountInsertSchema = createInsertSchema(account);
const OrganizationSelectSchema = createSelectSchema(organization);
const OrganizationInsertSchema = createInsertSchema(organization);
const MemberSelectSchema = createSelectSchema(member);
const MemberInsertSchema = createInsertSchema(member);
const InvitationSelectSchema = createSelectSchema(invitation);
const InvitationInsertSchema = createInsertSchema(invitation);
const DeviceCodeSelectSchema = createSelectSchema(deviceCode);
const DeviceCodeInsertSchema = createInsertSchema(deviceCode);
const VerificationSelectSchema = createSelectSchema(verification);
const VerificationInsertSchema = createInsertSchema(verification);
const UserOrganizationSchema = z.object({
	id: z.string(),
	userId: z.string(),
	organizationId: z.string(),
	role: z.string(),
	createdAt: z.union([z.string(), z.date()]).transform((val) => val instanceof Date ? val.toISOString() : val),
	organizationName: z.string().nullable(),
	organizationSlug: z.string().nullable()
});
const UserOrganizationsResponseSchema = z.array(UserOrganizationSchema);
const AddUserToOrganizationRequestSchema = z.object({
	organizationId: z.string(),
	role: z.string().default("member")
});
const AddUserToOrganizationResponseSchema = z.object({
	organizationId: z.string(),
	role: z.string(),
	createdAt: z.string()
});

//#endregion
export { AccountInsertSchema, AccountSelectSchema, AddUserToOrganizationRequestSchema, AddUserToOrganizationResponseSchema, DeviceCodeInsertSchema, DeviceCodeSelectSchema, InvitationInsertSchema, InvitationSelectSchema, MemberInsertSchema, MemberSelectSchema, OrganizationInsertSchema, OrganizationSelectSchema, SessionInsertSchema, SessionSelectSchema, UserInsertSchema, UserOrganizationSchema, UserOrganizationsResponseSchema, UserSelectSchema, VerificationInsertSchema, VerificationSelectSchema };