mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-25 03:10:08 +08:00
feat(ocr): implement ocr providers list endpoint
Add DbOcrProviderSchema and update response schemas for list and get endpoints Implement the GET /ocr/providers endpoint using ocrService
This commit is contained in:
parent
8ac9344fef
commit
1e9014b080
@ -1,6 +1,6 @@
|
||||
// NOTE: Types are defined inline in the schema for simplicity
|
||||
// If needed, specific types can be imported from './apiModels'
|
||||
import type { OcrProvider } from '@types'
|
||||
import type { GetOcrProviderResponse, ListOcrProvidersResponse } from '@types'
|
||||
|
||||
import type { BodyForPath, ConcreteApiPaths, QueryParamsForPath, ResponseForPath } from './apiPaths'
|
||||
import type { HttpMethod, PaginatedResponse, PaginationParams } from './apiTypes'
|
||||
@ -350,7 +350,7 @@ export interface ApiSchemas {
|
||||
|
||||
'/ocr/providers': {
|
||||
GET: {
|
||||
response: OcrProvider[]
|
||||
response: ListOcrProvidersResponse
|
||||
}
|
||||
POST: {
|
||||
body: {
|
||||
@ -361,7 +361,7 @@ export interface ApiSchemas {
|
||||
|
||||
'/ocr/providers/:id': {
|
||||
GET: {
|
||||
response: OcrProvider
|
||||
response: GetOcrProviderResponse
|
||||
}
|
||||
PATCH: {
|
||||
// TODO
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
* TypeScript will error if any endpoint is missing.
|
||||
*/
|
||||
|
||||
import { ocrService } from '@main/services/ocr/OcrService'
|
||||
import type { ApiImplementation } from '@shared/data/api/apiSchemas'
|
||||
|
||||
import { TestService } from '../services/TestService'
|
||||
@ -212,9 +213,7 @@ export const apiHandlers: ApiImplementation = {
|
||||
|
||||
'/ocr/providers': {
|
||||
GET: async () => {
|
||||
// We should implement it when user data migration completed.
|
||||
// OcrProvider should be migrate to db, because the data objects contains user settings.
|
||||
throw new Error('Not implemented')
|
||||
return ocrService.listProviders()
|
||||
},
|
||||
POST: async () => {
|
||||
throw new Error('Not implemented')
|
||||
|
||||
@ -258,8 +258,16 @@ const TimestampExtendShape = {
|
||||
updatedAt: z.number().nullable()
|
||||
}
|
||||
|
||||
const DbOcrProviderSchema = OcrProviderSchema.extend(TimestampExtendShape)
|
||||
|
||||
export const ListOcrProvidersResponseSchema = z.object({
|
||||
data: z.array(OcrProviderSchema.extend(TimestampExtendShape))
|
||||
data: z.array(DbOcrProviderSchema)
|
||||
})
|
||||
|
||||
export type ListOcrProvidersResponse = z.infer<typeof ListOcrProvidersResponseSchema>
|
||||
|
||||
export const GetOcrProviderResponseSchema = z.object({
|
||||
data: DbOcrProviderSchema
|
||||
})
|
||||
|
||||
export type GetOcrProviderResponse = z.infer<typeof GetOcrProviderResponseSchema>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user