Repository navigation
feat(api): 空间导出/导入·后端三端点:建空间 + 文件读回引用授权 + 文档同步 - #324
Merged
todosdev[bot] merged 2 commits intoNov 28, 2026
Merged
Conversation
- Add POST /api/write/spaces endpoint with admin role binding and slug collision resolution - Restrict space creation to unrestricted write tokens, returning 403 for scoped tokens - Refactor GET /api/read/files/:key to support dual authorization (referenced page read access and uploader fallback) - Prevent full-table scan on file reference check by scoping search to authorized spaces - Sync api-contract.md, openapi.ts, and agent-guide.md with export/import assembly protocols - Add comprehensive test coverage in write-api.test.ts and read-api.test.ts Checkpoint: BWkt59ifTMvnLPel7fm7S
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /api/write/spaces端点,支持无范围限制(spaceIds === null)的全局 write 令牌创建空间并自动绑定创建者为 admin,对受限令牌严格响应 403。GET /api/read/files/:key文件读回授权逻辑,实现「引用授权」与「上传者授权」双并列判定,根据令牌可读空间收窄检索候选集,彻底杜绝全表扫描。Changes
createSpace,统一处理 slug 派生与自增冲突解决、落库及空间 admin 成员关系绑定。createSpace核心例程。POST /api/write/spaces,校验全局 write 令牌,返回 201{ id, slug, title }。GET /api/read/files/:key,引入hasReferencedPageReadAccess辅助函数支持页面引用放行,头像维持上传者排他授权。POST /api/write/spaces端点与相关 Schema,更新读回接口授权描述。scripts/build-info.mjs自动更新内嵌常量。Testing
pnpm test(170 个测试文件、2173 项测试全部通过)。pnpm typecheck、pnpm lint、pnpm format:check均 0 错误。