Repository navigation
nav 场景可见性·后端实现:schema_v3 迁移 + visibility DTO 过滤 + 默认强制公开校验(引用合并规格) - #33
Merged
todosdev[bot] merged 2 commits intoNov 6, 2026
Merged
Conversation
added 2 commits
November 6, 2026 19:10
Adds scenes.visibility (public/private) via ledgered schema_v3, filters the public export and icon registry by scene AND category visibility, and enforces the default-scene-must-be-public guards on the admin scene API.
… scene filter Degrade listScenes failure in the icon registry to the pre-scene category rule so a schema_v1 database no longer 404s every public host, make buildSiteData the only place the two-layer rule is enforced (public route passes raw rows), and correct the contract wording about the category DTO.
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
visibility(public|private),落地「有效可见性 = 场景公开 AND 分类公开」的两层取与:私有场景整个空间(场景本身、其下全部分类与链接)对未登录访客完全不存在。visibility,并强制「默认场景必须公开」:默认场景改私有、私有场景设默认都以 400{error}拒绝。Changes
worker/src/lib/migrations.ts— 新增schema_v3:ALTER TABLE {prefix}scenes ADD COLUMN visibility TEXT NOT NULL DEFAULT 'public' CHECK (visibility IN ('public','private'))。存量行(含种子默认场景)取默认值即公开;重放安全由迁移账本保证,与schema_v2的ADD COLUMN同口径;表名随TABLE_PREFIX三态变化。worker/src/services/site-data.ts—buildSiteData成为两层取与的唯一执行点(要求传入全量scenes,publicScenes收为模块私有);新增publicCategories供公开出口与图标注册表复用;SceneDto输出补visibility。worker/src/routes/public.ts— 改为传入原始行,由buildSiteData统一裁剪,私有场景的名称/图标/id 不再出现在响应里。worker/src/routes/admin.ts— 场景创建/更新接收visibility(缺省public,非法值 400);默认场景改私有 → 400default scene cannot be private(整条更新不落库);私有场景设默认 → 400private scene cannot be set as default。isDefault在公开场景上仍按 ONE-448: 主题切换生效(settings.theme 三档 + system 跟随) #17 冻结契约静默忽略。worker/src/db/queries/content.ts/worker/src/types.ts— 场景行与 DTO 增加visibility,insertScene/updateScene白名单同步。worker/src/services/favicon.ts—/api/icon站点注册表按同一取与口径过滤;listScenes失败(库停在 schema_v1)时降级为分类口径,避免未迁移的库把全部公开 host 判成「未登记」。docs/api-contract.md— 新增「场景可见性(v1.2)」一节,更新/api/public、SceneDto、后台场景端点与/api/icon注册表描述;明确分类 DTO 形状不变。buildSiteData直喂全量行)、B2 两条校验与删除场景迁移、schema_v1 库上的图标注册表。Testing
pnpm test— worker 13 文件 / 193 条全过,web 19 文件 / 204 条全过pnpm typecheck、pnpm lint(0 error,30 条既有 warning)、pnpm format:check、pnpm build均通过/api/icon改回「listScenes进Promise.all」的旧实现,schema_v1 库用例失败;恢复修复版后全过2d06de3