mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-12 00:49:14 +08:00
- Introduced new pagination types and interfaces, including `PaginationMode`, `BasePaginatedResponse`, `OffsetPaginatedResponse`, and `CursorPaginatedResponse`, to standardize pagination handling. - Updated `useDataApi` hook to support both offset and cursor-based pagination, improving data fetching capabilities. - Added `useInfiniteQuery` and `usePaginatedQuery` hooks for better management of paginated data, including loading states and pagination controls. - Refactored existing pagination logic to improve clarity and maintainability, ensuring consistent handling of pagination across the application. |
||
|---|---|---|
| .. | ||
| schemas | ||
| apiErrors.ts | ||
| apiPaths.ts | ||
| apiTypes.ts | ||
| index.ts | ||
| README.md | ||
Data API Type System
This directory contains type definitions for the DataApi system.
Documentation
- DataApi Overview: docs/en/references/data/data-api-overview.md
- API Types: api-types.md
- API Design Guidelines: api-design-guidelines.md
Directory Structure
packages/shared/data/api/
├── index.ts # Barrel exports
├── apiTypes.ts # Core request/response types
├── apiPaths.ts # Path template utilities
├── apiErrors.ts # Error handling
└── schemas/
├── index.ts # Schema composition
└── *.ts # Domain-specific schemas
Quick Reference
Import Conventions
// Infrastructure types (via barrel)
import type { DataRequest, DataResponse, ApiClient } from '@shared/data/api'
import { ErrorCode, DataApiError, DataApiErrorFactory } from '@shared/data/api'
// Domain DTOs (directly from schema files)
import type { Topic, CreateTopicDto } from '@shared/data/api/schemas/topic'
import type { Message, CreateMessageDto } from '@shared/data/api/schemas/message'
Adding New Schemas
- Create schema file in
schemas/(e.g.,topic.ts) - Register in
schemas/index.tsusing intersection type - Implement handlers in
src/main/data/api/handlers/