mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-06 05:09:09 +08:00
refactor(ocr): convert OcrProviderBaseConfig to zod schema
Use zod schema for type validation and inference to improve type safety
This commit is contained in:
parent
ed791a3bb3
commit
2e400d3f1c
@ -71,14 +71,16 @@ export const isOcrProviderApiConfig = (config: unknown): config is OcrProviderAp
|
|||||||
*
|
*
|
||||||
* Extend this type to define provider-specific config types.
|
* Extend this type to define provider-specific config types.
|
||||||
*/
|
*/
|
||||||
export type OcrProviderBaseConfig = {
|
export const OcrProviderBaseConfigSchema = z.object({
|
||||||
/** Not used for now. Could safely remove. */
|
/** Not used for now. Could safely remove. */
|
||||||
api?: OcrProviderApiConfig
|
api: OcrProviderApiConfigSchema.optional(),
|
||||||
/** Not used for now. Could safely remove. */
|
/** Not used for now. Could safely remove. */
|
||||||
models?: OcrModel[]
|
models: z.array(OcrModelSchema).optional(),
|
||||||
/** Not used for now. Could safely remove. */
|
/** Not used for now. Could safely remove. */
|
||||||
enabled?: boolean
|
enabled: z.boolean().optional()
|
||||||
}
|
})
|
||||||
|
|
||||||
|
export type OcrProviderBaseConfig = z.infer<typeof OcrProviderBaseConfigSchema>
|
||||||
|
|
||||||
export type OcrProviderConfig = OcrApiProviderConfig | OcrTesseractConfig | OcrSystemConfig | OcrPpocrConfig
|
export type OcrProviderConfig = OcrApiProviderConfig | OcrTesseractConfig | OcrSystemConfig | OcrPpocrConfig
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user