Files
BIPMaterialManager/src/main/schemas/cleaner.schema.ts
Misaka a05c8a9037 feat: add TypeORM, logger, schemas, hooks and stores
- Add TypeORM integration with data-source, entities and repositories
- Add logger service for structured logging
- Add Zod validation schemas for auth, cleaner and extractor
- Add custom React hooks (useAuth, useCleaner, useExtractor, useValidation)
- Add Zustand stores (useAppStore, useUserStore)
- Add UI components (Button, Modal, Toast)
- Add error types and ErpBrowserManager
- Refactor IPC handlers and services
- Add unit tests for new modules

Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
2026-03-02 23:10:15 +08:00

48 lines
1.2 KiB
TypeScript

/**
* Zod schemas for Cleaner module validation
*/
import { z } from 'zod'
/**
* Schema for cleaner input validation
*/
export const CleanerInputSchema = z.object({
orderNumbers: z
.array(z.string().min(1, 'Order number cannot be empty'))
.min(1, 'At least one order number is required'),
materialCodes: z.array(z.string().min(1, 'Material code cannot be empty')),
dryRun: z.boolean()
// Note: onProgress is a function, not validated via Zod
})
export type CleanerInputZod = z.infer<typeof CleanerInputSchema>
/**
* Schema for cleaner result validation
*/
export const CleanerResultSchema = z.object({
processedCount: z.number().int().nonnegative(),
errors: z.array(z.string())
})
export type CleanerResultZod = z.infer<typeof CleanerResultSchema>
/**
* Validate cleaner input
*/
export function validateCleanerInput(input: unknown): {
success: boolean
data?: CleanerInputZod
error?: string
} {
const result = CleanerInputSchema.safeParse(input)
if (result.success) {
return { success: true, data: result.data }
}
return {
success: false,
error: result.error.issues.map((e) => `${e.path.join('.')}: ${e.message}`).join('; ')
}
}