Skip to content

feat(api)!: align frontend contracts with latest Wiki#79

Open
Alexander-Noah wants to merge 4 commits into
1024XEngineer:mainfrom
Alexander-Noah:main
Open

feat(api)!: align frontend contracts with latest Wiki#79
Alexander-Noah wants to merge 4 commits into
1024XEngineer:mainfrom
Alexander-Noah:main

Conversation

@Alexander-Noah

@Alexander-Noah Alexander-Noah commented Jul 24, 2026

Copy link
Copy Markdown

变更背景

根据最新版 TimeFlow Wiki,统一封装前端 HTTP API、WebSocket 协议和 DTO 字段,并增加严格的请求及响应运行时校验。

关联 Issue:
架构设计-主agent感知层接口设计(初稿):http://github.com/1024XEngineer/timeflow/issues/70
成员5TimeFlow MVP 函数级接口设计:#73
TimeFlow MVP 子 Agent 能力层统一接口:#74
全局数据、系统日志模块接口设计草案:http://github.com/1024XEngineer/timeflow/issues/75
关联wiki:
Architecture interface design(draft):https://github.com/1024XEngineer/timeflow/wiki/Architecture-interface-design(draft)

主要变更

  • 增加认证、会话、时间线、长目标、用户画像和写入确认 API 模块
  • 为所有接口定义 TypeScript 请求及响应 DTO
  • 为每个接口补充中文用途、路径和数据流注释
  • HTTP 请求自动注入 Bearer Token
  • 统一 JSON、FormData、查询参数及 ApiError 处理
  • 请求发送前校验必填字段、UUID、时间、枚举和额外字段
  • 响应必须经过对应 DTO 解析器,禁止绕过契约校验
  • WebSocket 信封统一为 type / timestamp / payload
  • 增加 WebSocket 鉴权、断线重连和 transport.resume
  • 补全并严格校验 TaskProfileSnapshot
  • Mock 契约测试保留在本地,不提交到仓库

提交说明

  • ecd1a95 feat(api)!:按照最新版 Wiki 完成 API、DTO、WebSocket 和响应校验封装
  • b200cf4 chore(test):将本地 Mock 契约测试排除在仓库提交之外
  • 6b40cd6 Merge:同步上游仓库最新 main
  • c8a66f9 fix(api)!:补充请求运行时校验、强制响应解析并完善任务画像契约

兼容性变化

  • /users/me/auth/me
  • /items/today/items/timeline
  • /goals/long-goals
  • 输入统一通过 POST /conversation/inputs 提交
  • WebSocket 从 event / sent_at 调整为 type / timestamp
  • HTTP 响应不再使用 Wiki 未声明的 success / data 外层信封
  • HttpClient.requestapiFetch 必须传入响应解析器

Breaking Changes

旧接口路径、DTO 字段、WebSocket 信封以及未传入响应解析器的调用方需要同步迁移。

验证结果

  • ESLint 通过
  • Prettier 通过
  • TypeScript 类型检查通过
  • git diff --check 通过
  • 本地 Mock 契约测试 28/28 通过
  • 非法请求可在网络调用前被拦截
  • 非法响应可转换为 CONTRACT_MISMATCH

验证边界

当前完成前端静态检查和本地 Mock 契约验证。由于后端业务接口尚未全部实现,暂未进行真实服务端端到端联调。

Replace legacy HTTP and WebSocket contracts with the latest TimeFlow MVP interface baseline. Add strict runtime validators, typed domain modules, mock data, and contract tests.

BREAKING CHANGE: frontend API paths, DTO fields, and WebSocket event envelopes now follow the 2026-07-24 Wiki contract.
Validate every business request before transport and require response parsers.
Define and validate the complete task profile snapshot returned by goal details.

BREAKING CHANGE: HttpClient.request and apiFetch now require a response parser.
@Alexander-Noah
Alexander-Noah marked this pull request as ready for review July 24, 2026 08:58

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found four concrete issues in the changed API contract/runtime layer. npm run check passes; the committed PR contains no runnable contract tests.

View job run

Comment thread frontend/src/api/core/http.ts
Comment thread frontend/src/api/core/ConversationSocket.ts
Comment thread frontend/src/api/core/validation.ts
Comment thread frontend/tsconfig.json
@1024XEngineer 1024XEngineer deleted a comment from gemini-code-assist Bot Jul 24, 2026
@1024XEngineer 1024XEngineer deleted a comment from gemini-code-assist Bot Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant