mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-27 04:31:27 +08:00
- Removed outdated API model and schema files to simplify the structure. - Consolidated API types and schemas for better organization and clarity. - Updated import paths across the codebase to reflect the new structure. - Enhanced documentation in related README files to guide usage of the new API schema organization.
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
/**
|
|
* Schema Index - Composes all domain schemas into unified ApiSchemas
|
|
*
|
|
* This file has ONE responsibility: compose domain schemas into ApiSchemas.
|
|
*
|
|
* Import conventions (see api/README.md for details):
|
|
* - Infrastructure types: import from '@shared/data/api'
|
|
* - Domain DTOs: import directly from schema files (e.g., '@shared/data/api/schemas/topic')
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* // Infrastructure types via barrel export
|
|
* import type { ApiSchemas, DataRequest } from '@shared/data/api'
|
|
*
|
|
* // Domain DTOs directly from schema files
|
|
* import type { TestItem, CreateTestItemDto } from '@shared/data/api/schemas/test'
|
|
* import type { Topic, CreateTopicDto } from '@shared/data/api/schemas/topic'
|
|
* ```
|
|
*/
|
|
|
|
import type { AssertValidSchemas } from '../apiTypes'
|
|
import type { BatchSchemas } from './batch'
|
|
import type { TestSchemas } from './test'
|
|
|
|
/**
|
|
* Merged API Schemas - single source of truth for all API endpoints
|
|
*
|
|
* All domain schemas are composed here using intersection types.
|
|
* AssertValidSchemas provides compile-time validation:
|
|
* - Invalid HTTP methods become `never` type
|
|
* - Missing `response` field causes type errors
|
|
*
|
|
* When adding a new domain:
|
|
* 1. Create the schema file (e.g., topic.ts)
|
|
* 2. Import and add to intersection below
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* import type { TopicSchemas } from './topic'
|
|
* export type ApiSchemas = AssertValidSchemas<TestSchemas & BatchSchemas & TopicSchemas>
|
|
* ```
|
|
*/
|
|
export type ApiSchemas = AssertValidSchemas<TestSchemas & BatchSchemas>
|