feat(游戏共创): 公开目录补真游标分页(修「48 硬上限 + 无游标」导致最老作品永久不可见)
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
真实库实证:51 条 published 时**最老的 3 条**(含最关键的 A0/A1/A11 母版与主干)在公开目录里不可见
(AGC 共创页显示「已检查最新 48 个作品(1 页)」;数据本身没丢)。根因:handler 写死
`limit: MAX_LIST_LIMIT(48)`(并忽略客户端 `limit`),事务过滤排序后 `truncate(limit)`,**既无 has_more
也无游标**。
- **页大小**:默认 **48**(保持既有 AGC 共创页首屏语义——48 只该是默认值而非硬上限)、上限 **100**
(单响应体量);`0` 取默认、超界**截断**(不报错);api-server 与事务共用同一归一函数。
- **游标**:`"{created_at_micros}:{game_id}"`(复用仓库既有 `"{micros}:{id}"` 惯例,与主题列表同构);
排序键 `created_at` **倒序** + `game_id` **升序**兜底(与改前比较器逐字同序 ⇒ 首页顺序不变;全序 ⇒
翻页不重不漏);**先过滤再切页**;「多取一条」判 has_more;`nextCursor` 为真值、**末页为 `null`**。
- **非法游标**:模块产出 `CATALOG_INVALID_CURSOR: 目录游标格式无效` → api-server 新增 `CATALOG_` 前缀分支
(**排在 owner 不匹配 / 不存在 / 状态 等子串分支之前**)→ **400 + 稳定码 `CATALOG_INVALID_CURSOR`**,
并纳入「码由模块真实文案可达」的枚举测试(防上次那种不可达码);未登记的 `CATALOG_` 码兜底
`CATALOG_ERROR`(400)。
- **响应形状不变**:仍是 `{ games, nextCursor }`(`nextCursor` 从恒 `null` 变成真值);抽命名构建器
`public_games_payload` 并登记 parity(构建器 18→**19**,`mustEmit: ['games','nextCursor']`)。
- **生成绑定**:`game_distribution_public_game_list_input_type.rs`(+`cursor`)、
`game_distribution_game_list_procedure_result_type.rs`(+`next_cursor`);client facade 改返回
`(games, next_cursor)`,mapper 同步。
- **文档**(同批):主规范 HTTP 表 `GET /games` 行改为真游标分页;创作者主页工程设计两处「最多 48 / 不分页」
改写(并注明前端尚未消费游标);`docs/README.md` 索引行同步。
- **测试 +15**:纯函数 9(**51 条能翻到最老那条**、恰好整页不产生空游标、同 `created_at` 用 `game_id` 兜底、
**先过滤再切页**、游标指向页内最后一条、limit 0/超界、非法游标 7 种);事务结构断言 1;api-server 5
(形状、`limit` 默认与截断、非法游标 400 + 稳定码、码可达性枚举、**51 条走真实 handler 链路翻页且
未公开/已软删/无公开版本三种不可见行不出现**)。
门禁:wasm build 0;`cargo check --all-targets` 0;`cargo test -p module-game-distribution` **143 passed**;
`-p spacetime-module` **307 passed / 1 ignored**;`-p spacetime-client` 44 passed;`-p api-server game_distribution`
**112 passed**;DTO parity 0(66 组 / **19** 构建器 / 15 手拼类型);`check:spacetime-schema` 0(98 表);
`check:encoding` 0(5548 files);`cargo fmt --all --manifest-path server-rs/Cargo.toml -- --check` 0;
`git diff --check` 0。
This commit is contained in:
@@ -208,6 +208,14 @@ const RESPONSE_BUILDERS = [
|
||||
ts: 'GameDistributionMyCollectionsResponse',
|
||||
mustEmit: ['games', 'nextCursor'],
|
||||
},
|
||||
{
|
||||
// 公开游戏目录(游戏广场):`games` / `nextCursor` 两个键都必须发出(末页 `nextCursor: null`)。
|
||||
// 修正前这条路径是内联 `json!` 且把 `nextCursor` 写死 `null`——不在本清单里,所以「发不发
|
||||
// 游标」没有任何证据;现在它是命名构建器,键与 `GameDistributionListResponse` 逐键比对。
|
||||
fn: 'public_games_payload',
|
||||
ts: 'GameDistributionListResponse',
|
||||
mustEmit: ['games', 'nextCursor'],
|
||||
},
|
||||
{
|
||||
// 公开共创主题列表:`themes` / `nextCursor` 两个键都必须发出(末页 `nextCursor: null`)。
|
||||
// 单条的形状由 `public_theme_summary_payload` 拼,这里只证明顶层键与 TS 契约一致。
|
||||
|
||||
Reference in New Issue
Block a user