code: nextjs,frontends,validate (14 files)

This commit is contained in:
2025-12-25 19:35:28 +00:00
parent fa0a275ca4
commit 9162bd01a2
14 changed files with 134 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import type { ComponentHierarchy } from '../types'
import { isPlainObject } from './is-plain-object'
import { isValidUuid } from './is-valid-uuid'
export function validateComponentHierarchyUpdate(data: Partial<ComponentHierarchy>): string[] {
const errors: string[] = []
if (data.pageId !== undefined) {
if (typeof data.pageId !== 'string' || !isValidUuid(data.pageId)) {
errors.push('pageId must be a valid UUID')
}
}
if (data.parentId !== undefined) {
if (typeof data.parentId !== 'string' || !isValidUuid(data.parentId)) {
errors.push('parentId must be a valid UUID')
}
}
if (data.componentType !== undefined) {
if (typeof data.componentType !== 'string' || data.componentType.length === 0 || data.componentType.length > 100) {
errors.push('componentType must be 1-100 characters')
}
}
if (data.order !== undefined) {
if (!Number.isInteger(data.order) || data.order < 0) {
errors.push('order must be a non-negative integer')
}
}
if (data.props !== undefined && !isPlainObject(data.props)) {
errors.push('props must be an object')
}
return errors
}

View File

@@ -0,0 +1,26 @@
import type { Credential } from '../types'
import { isValidUsername } from './is-valid-username'
export function validateCredentialCreate(data: Partial<Credential>): string[] {
const errors: string[] = []
if (!data.username) {
errors.push('username is required')
} else if (!isValidUsername(data.username)) {
errors.push('username must be 3-50 characters (alphanumeric, underscore, hyphen)')
}
if (!data.passwordHash) {
errors.push('passwordHash is required')
} else if (typeof data.passwordHash !== 'string' || data.passwordHash.trim().length === 0) {
errors.push('passwordHash must be a non-empty string')
}
if (data.firstLogin === undefined) {
errors.push('firstLogin is required')
} else if (typeof data.firstLogin !== 'boolean') {
errors.push('firstLogin must be a boolean')
}
return errors
}

View File

@@ -0,0 +1,13 @@
// Re-export for backward compatibility
// TODO: Update imports to use @/components/ui directly
export {
AlertDialog,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogCancel,
AlertDialogAction,
} from './organisms/AlertDialog'

View File

@@ -0,0 +1,3 @@
// Re-export for backward compatibility
// TODO: Update imports to use @/components/ui directly
export { Avatar, AvatarImage, AvatarFallback, type AvatarProps } from './atoms/Avatar'

View File

@@ -0,0 +1,3 @@
// Re-export for backward compatibility
// TODO: Update imports to use @/components/ui directly
export { Checkbox, type CheckboxProps } from './atoms/Checkbox'

View File

@@ -0,0 +1,19 @@
// Re-export for backward compatibility
// TODO: Update imports to use @/components/ui directly
export {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuGroup,
DropdownMenuPortal,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuCheckboxItem,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
} from './molecules/DropdownMenu'

View File

@@ -0,0 +1,3 @@
// Re-export for backward compatibility
// TODO: Update imports to use @/components/ui directly
export { Progress, type ProgressProps } from './atoms/Progress'

View File

@@ -0,0 +1,3 @@
// Re-export for backward compatibility
// TODO: Update imports to use @/components/ui directly
export { RadioGroup, RadioGroupItem } from './molecules/RadioGroup'

View File

@@ -0,0 +1,12 @@
// Re-export for backward compatibility
// TODO: Update imports to use @/components/ui directly
export {
Sheet,
SheetTrigger,
SheetContent,
SheetHeader,
SheetFooter,
SheetTitle,
SheetDescription,
SheetClose,
} from './organisms/Sheet'

View File

@@ -0,0 +1,3 @@
// Re-export for backward compatibility
// TODO: Update imports to use @/components/ui directly
export { Skeleton, type SkeletonProps } from './atoms/Skeleton'

View File

@@ -0,0 +1,3 @@
// Re-export for backward compatibility
// TODO: Update imports to use @/components/ui directly
export { Slider, type SliderProps } from './atoms/Slider'

View File

@@ -0,0 +1,3 @@
// Re-export for backward compatibility
// TODO: Update imports to use @/components/ui directly
export { Switch, type SwitchProps } from './atoms/Switch'

View File

@@ -0,0 +1,3 @@
// Re-export for backward compatibility
// TODO: Update imports to use @/components/ui directly
export { Table, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell, TableCaption } from './organisms/Table'

View File

@@ -0,0 +1,3 @@
// Re-export for backward compatibility
// TODO: Update imports to use @/components/ui directly
export { Textarea, type TextareaProps } from './atoms/Textarea'