chore(游戏共创): 主题注释失真修正 + 后台主题 payload 纳入契约门禁
Project CI / AI game creator shell Rust crates (pull_request) Successful in 5m53s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 6m48s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 7m42s
Project CI / Backend tests (pull_request) Successful in 9m47s
Project CI / Frontend tests (pull_request) Successful in 4m4s
Project CI / AI game creator shell web tests (pull_request) Successful in 2m56s
Project CI / Native shell tests (pull_request) Successful in 7m55s
Project CI / Repository checks (pull_request) Successful in 6m8s

1) 注释失真(独立复核 §B8):`module-game-distribution/src/theme.rs` 与
`spacetime-module/src/game_distribution.rs` 原先声称「api-server 与事务都调
`game_distribution_theme_text_violation`」,但全仓只有写入事务一处调用(HTTP 层没有预校验)。
选择**改注释**(单一判据来源就是事务),不给 HTTP 层再叠一层同名校验——否则「HTTP 挡住的」
与「落库挡住的」会重新长出两套判据。两处注释都改成明确写「只有事务调用 + api-server 不做预校验」。

2) 后台主题 payload 的契约门禁:`admin_theme_payload` / `admin_themes_payload` /
`admin_theme_mutation_payload` / `admin_theme_member_payload` 原先既无 TS 类型也未登记 parity,
形状只有 api-server 单测钉着 → 后台 UI 落地时容易与实现漂移。

- `packages/shared/src/contracts/gameDistribution.ts` 新增 5 个 TS 类型
  (`GameDistributionAdminTheme`、`…ListResponse`、`…MutationResponse`、`…MemberResponse`、
  `…MemberRemovalResponse`),注释里写清两处刻意差异:后台主题条目比公开摘要多出
  `sortOrder`/`status`/时间戳,且 `memberCount` 是**成员行总数**(含当前不可见成员),
  公开投影里同名键是**当前可见**成员数;后台列表**没有** `nextCursor`。
- `api-server`:把 handler 里内联的成员移除响应抽成命名构建器
  `admin_theme_member_removal_payload`——内联 `json!` 不在 parity 的证据范围内,抽出来这条
  形状的漂移才会被门禁抓住。
- parity 登记:`TS_ONLY_TYPES` +5(这些形状服务端同样是逐字段手拼 JSON,没有 Rust 结构体可对,
  要收口得先把响应改成结构化类型),`RESPONSE_BUILDERS` +5(响应键与 TS 字段逐键比对)。

门禁:`cargo test -p api-server game_distribution` 86 passed;`cargo test -p spacetime-module`
286 passed / 1 ignored;DTO parity 0(58 组类型 / **15** 个构建器 / **12** 个手拼类型);
`check:encoding` 0(5420 files);`cargo fmt --all -- --check` 0;`git diff --check` 0。
This commit is contained in:
2026-10-06 03:53:15 +08:00
parent e401963d3a
commit 4a33397822
5 changed files with 134 additions and 7 deletions
@@ -125,6 +125,13 @@ const TS_ONLY_TYPES = [
'GameDistributionVersionDetail',
'GameDistributionCancelVersionRequest',
'GameDistributionCancelVersionResponse',
// 后台主题的四个响应形状:服务端也是逐字段手拼 JSON(`admin_theme_payload` 一族),
// 因此同样只能走本清单 + `RESPONSE_BUILDERS` 登记,而不是 Rust↔TS 映射表。
'GameDistributionAdminTheme',
'GameDistributionAdminThemeListResponse',
'GameDistributionAdminThemeMutationResponse',
'GameDistributionAdminThemeMemberResponse',
'GameDistributionAdminThemeMemberRemovalResponse',
];
// 服务端逐字段手拼 JSON 的响应构建器:把「这个函数真的会发出的顶层键」与 TS 类型逐键比对。
@@ -199,6 +206,49 @@ const RESPONSE_BUILDERS = [
ts: 'GameDistributionThemeReference',
mustEmit: ['themeId', 'name', 'badge'],
},
{
// 后台主题条目:`admin_themes_payload` 逐条调用它,且它比公开的 `GameDistributionThemeSummary`
// 多出 `sortOrder` / `status` / 时间戳、`memberCount` 口径也不同(成员**行**总数),
// 因此单独建类型、单独登记——后台 UI 落地时形状漂移会被这里抓住。
fn: 'admin_theme_payload',
ts: 'GameDistributionAdminTheme',
mustEmit: [
'themeId',
'name',
'summary',
'badge',
'sortOrder',
'status',
'memberCount',
'createdAt',
'updatedAt',
],
},
{
// 后台主题列表:只有一个顶层键 `themes`(**没有** `nextCursor`:这条路径不分页)。
fn: 'admin_themes_payload',
ts: 'GameDistributionAdminThemeListResponse',
mustEmit: ['themes'],
},
{
// 后台创建 / 更新的响应:`{ theme, replayed }`。`theme` 的值是函数调用而不是对象字面量,
// 所以不能用 `nested` 比对;条目形状由上面 `admin_theme_payload` 那条独立覆盖。
fn: 'admin_theme_mutation_payload',
ts: 'GameDistributionAdminThemeMutationResponse',
mustEmit: ['theme', 'replayed'],
},
{
// 后台成员写入的响应:`{ themeId, rootGameId, sortOrder, createdAt }`。
fn: 'admin_theme_member_payload',
ts: 'GameDistributionAdminThemeMemberResponse',
mustEmit: ['themeId', 'rootGameId', 'sortOrder', 'createdAt'],
},
{
// 后台移除成员的响应:`{ themeId, rootGameId }`(刻意不含「之前存不存在」,重复调用逐字节相同)。
fn: 'admin_theme_member_removal_payload',
ts: 'GameDistributionAdminThemeMemberRemovalResponse',
mustEmit: ['themeId', 'rootGameId'],
},
];
function camelCase(value) {