Files
BIPMaterialManager/src/main/schemas/extractor.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

47 lines
1.2 KiB
TypeScript

/**
* Zod schemas for Extractor module validation
*/
import { z } from 'zod'
/**
* Schema for extractor input validation
*/
export const ExtractorInputSchema = z.object({
orderNumbers: z
.array(z.string().min(1, 'Order number cannot be empty'))
.min(1, 'At least one order number is required'),
batchSize: z.number().int().positive().optional().default(10)
// Note: onProgress is a function, not validated via Zod
})
export type ExtractorInputZod = z.infer<typeof ExtractorInputSchema>
/**
* Schema for extractor result validation
*/
export const ExtractorResultSchema = z.object({
data: z.array(z.record(z.string(), z.unknown())),
errors: z.array(z.string())
})
export type ExtractorResultZod = z.infer<typeof ExtractorResultSchema>
/**
* Validate extractor input
*/
export function validateExtractorInput(input: unknown): {
success: boolean
data?: ExtractorInputZod
error?: string
} {
const result = ExtractorInputSchema.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('; ')
}
}