/**
 * Tag entity types
 *
 * Tags are user-defined labels that can be applied to various entities
 * (assistants, topics, sessions) via the entity_tag join table.
 */

import * as z from 'zod'

// ============================================================================
// Tag Entity
// ============================================================================

export const TagIdSchema = z.uuidv4()
export const TagNameSchema = z.string().trim().min(1).max(64)
export const TagColorSchema = z.string().regex(/^#[0-9a-fA-F]{6}$/)

/**
 * Complete Tag entity as returned by the API.
 */
export const TagSchema = z.strictObject({
  /** Tag ID (UUID v4, auto-generated by database) */
  id: TagIdSchema,
  /** Unique tag name */
  name: TagNameSchema,
  /** Display color (e.g. #FF5733), null if unset */
  color: TagColorSchema.nullable(),
  /** Creation timestamp (ISO string) */
  createdAt: z.iso.datetime(),
  /** Last update timestamp (ISO string) */
  updatedAt: z.iso.datetime()
})
export type Tag = z.infer<typeof TagSchema>
