cherry-studio/packages/shared/data/api
fullex 7cac5b55f6 feat: enhance cursor-based pagination in API documentation and types
- Added detailed explanations and examples for cursor semantics in `api-types.md`, clarifying the exclusive nature of cursors in pagination.
- Updated `CursorPaginationParams` interface to emphasize the cursor's role as an exclusive boundary in responses.
- Refactored `BranchMessagesQueryParams` to extend `CursorPaginationParams`, aligning with the new pagination logic.
- Modified `MessageService` to implement cursor-based pagination semantics, ensuring accurate message retrieval and response structure.
- Enhanced documentation throughout to provide clearer guidance on pagination behavior and usage patterns.
2026-01-04 22:31:15 +08:00
..
schemas feat: enhance cursor-based pagination in API documentation and types 2026-01-04 22:31:15 +08:00
apiErrors.ts feat(api): implement message branching API with tree structure support 2025-12-28 12:54:06 +08:00
apiPaths.ts refactor(dataApi): streamline Data API schema and type definitions 2025-12-26 12:52:32 +08:00
apiTypes.ts feat: enhance cursor-based pagination in API documentation and types 2026-01-04 22:31:15 +08:00
index.ts feat: implement new pagination types and enhance API documentation 2026-01-04 21:12:41 +08:00
README.md docs(data): update README and remove outdated API design guidelines 2025-12-29 17:15:06 +08:00

Data API Type System

This directory contains type definitions for the DataApi system.

Documentation

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

  1. Create schema file in schemas/ (e.g., topic.ts)
  2. Register in schemas/index.ts using intersection type
  3. Implement handlers in src/main/data/api/handlers/