mirror of
https://github.com/bitbaum/botsmann.git
synced 2026-12-04 04:27:47 +01:00
Tailwind 3.4 -> 4.3:
- tailwind.config.js DELETED; tokens now live in an @theme inline block in
app/globals.css (semantic names unchanged: action, paper, edge, ink...)
- postcss.config.js -> @tailwindcss/postcss; autoprefixer dropped (built in)
- @tailwind directives -> @import 'tailwindcss'; forms/typography via @plugin
- daisyui removed (no daisyui class used anywhere)
- next/font vars renamed --font-inter/--font-fraunces to break the circular
var() the old --font-sans binding would create inside @theme
- v4 deleted *-opacity-* utilities: every bg/text/ring-opacity-N rewritten to
slash syntax (bg-action/90, ring-black/5, ...); dynamic accent tint gets a
literal class map in lib/config/colors.ts so the scanner sees each class
- dead v3-era aspect-w/h custom utilities removed (unused; v4 has aspect-*)
Zod 3.24 -> 4.5:
- .errors -> .issues everywhere
- z.string().uuid( -> .guid( (v4 uuid() is RFC-variant-strict; DB ids aren't)
- z.record(z.unknown()) -> z.record(z.string(), z.unknown())
- object .default({}) -> .prefault({}) (v4 default takes the full output value)
ESLint 9 -> 10: eslint-plugin-react's version:'detect' calls the removed
context.getFilename; pin settings.react.version='19' AFTER the next configs.
Verify (format+lint+typecheck+selfhost+test+build) green: 272 tests pass.
Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
85 lines
2.4 KiB
TypeScript
85 lines
2.4 KiB
TypeScript
/**
|
|
* Conversation Validation Schemas
|
|
* @module lib/validations/conversation
|
|
*
|
|
* Zod schemas for validating conversation API inputs
|
|
*/
|
|
|
|
import { z } from 'zod';
|
|
import { getAllProfessionalSlugs } from '@/data/professionals';
|
|
|
|
/**
|
|
* Valid bot types for conversations
|
|
*/
|
|
export const ConversationBotTypeSchema = z.enum([
|
|
'documents',
|
|
'custom_bot',
|
|
'demo',
|
|
'professional',
|
|
]);
|
|
|
|
/**
|
|
* Valid professional slugs (derived from SSOT in professionals.ts)
|
|
*/
|
|
const professionalSlugs = getAllProfessionalSlugs();
|
|
export const ProfessionalSlugSchema = z.enum(professionalSlugs as [string, ...string[]]);
|
|
|
|
/**
|
|
* Message source schema
|
|
*/
|
|
export const MessageSourceSchema = z.object({
|
|
document_name: z.string(),
|
|
preview: z.string(),
|
|
chunk_id: z.string().guid().optional(),
|
|
document_id: z.string().guid().optional(),
|
|
similarity: z.number().min(0).max(1).optional(),
|
|
});
|
|
|
|
/**
|
|
* Schema for creating a new conversation
|
|
*/
|
|
export const CreateConversationSchema = z.object({
|
|
title: z.string().max(200, 'Title must be at most 200 characters').optional(),
|
|
bot_type: ConversationBotTypeSchema.optional().default('documents'),
|
|
bot_id: z.string().guid('Invalid bot ID').optional(),
|
|
document_id: z.string().guid('Invalid document ID').optional(),
|
|
professional_slug: ProfessionalSlugSchema.optional(),
|
|
});
|
|
|
|
/**
|
|
* Schema for updating a conversation
|
|
*/
|
|
export const UpdateConversationSchema = z.object({
|
|
title: z.string().min(1, 'Title is required').max(200, 'Title must be at most 200 characters'),
|
|
});
|
|
|
|
/**
|
|
* Schema for adding a message to a conversation
|
|
*/
|
|
export const AddMessageSchema = z.object({
|
|
role: z.enum(['user', 'assistant']),
|
|
content: z.string().min(1, 'Message content is required').max(50000, 'Message too long'),
|
|
sources: z.array(MessageSourceSchema).optional(),
|
|
});
|
|
|
|
/**
|
|
* Schema for onboarding step completion
|
|
*/
|
|
export const OnboardingStepSchema = z.object({
|
|
step_id: z.string().min(1, 'Step ID is required'),
|
|
});
|
|
|
|
/**
|
|
* Schema for completing onboarding
|
|
*/
|
|
export const CompleteOnboardingSchema = z.object({
|
|
completed: z.boolean(),
|
|
});
|
|
|
|
// Type exports inferred from schemas
|
|
export type CreateConversationInput = z.infer<typeof CreateConversationSchema>;
|
|
export type UpdateConversationInput = z.infer<typeof UpdateConversationSchema>;
|
|
export type AddMessageInput = z.infer<typeof AddMessageSchema>;
|
|
export type OnboardingStepInput = z.infer<typeof OnboardingStepSchema>;
|
|
export type CompleteOnboardingInput = z.infer<typeof CompleteOnboardingSchema>;
|