推进 SpacetimeDB adapter 与 client 收口

This commit is contained in:
2026-04-29 16:53:54 +08:00
parent f82775b852
commit 62934b0809
17 changed files with 1023 additions and 597 deletions

View File

@@ -26,7 +26,7 @@ spacetime sql <db> "SELECT * FROM custom_world_gallery_entry"
| 运行时档案 | `runtime_setting`, `runtime_snapshot`, `user_browse_history`, `profile_dashboard_state`, `profile_wallet_ledger`, `profile_redeem_code`, `profile_redeem_code_usage`, `profile_played_world`, `profile_save_archive` |
| RPG 运行时 | `story_session`, `story_event`, `npc_state`, `inventory_slot`, `battle_state`, `treasure_record`, `quest_record`, `quest_log`, `player_progression`, `chapter_progression` |
| 世界创作 | `custom_world_profile`, `custom_world_session`, `custom_world_agent_session`, `custom_world_agent_message`, `custom_world_agent_operation`, `custom_world_draft_card`, `custom_world_gallery_entry` |
| 拼图 | `puzzle_agent_session`, `puzzle_agent_message`, `puzzle_work_profile`, `puzzle_runtime_run` |
| 拼图 | `puzzle_agent_session`, `puzzle_agent_message`, `puzzle_work_profile`, `puzzle_event`, `puzzle_runtime_run`, `puzzle_leaderboard_entry` |
| 大鱼吃小鱼 | `big_fish_creation_session`, `big_fish_agent_message`, `big_fish_asset_slot`, `big_fish_event`, `big_fish_runtime_run` |
| 资产 | `asset_object`, `asset_entity_binding` |
| AI 任务 | `ai_task`, `ai_task_stage`, `ai_text_chunk`, `ai_result_reference`, `ai_task_event` |
@@ -419,6 +419,18 @@ SELECT * FROM puzzle_work_profile WHERE owner_user_id = '<user_id>' ORDER BY upd
SELECT * FROM puzzle_work_profile WHERE publication_status = 'Published';
```
### `puzzle_event`
- 作用拼图创作事件表目前记录作品发布成功事实供订阅端、BFF 或审计流程感知创作流已产出公开作品;正式作品状态仍以 `puzzle_work_profile``puzzle_agent_session` 为准。
- 可见性:`public event`
- 结构:`event_id PK: String`, `profile_id: String`, `work_id: String`, `session_id: Option<String>`, `owner_user_id: String`, `event_kind: PuzzleEventKind`, `occurred_at: Timestamp`
- 索引:`profile_id`, `owner_user_id`
```sql
SELECT * FROM puzzle_event WHERE profile_id = '<profile_id>' ORDER BY occurred_at ASC;
SELECT * FROM puzzle_event WHERE owner_user_id = '<user_id>' ORDER BY occurred_at DESC;
```
### `puzzle_runtime_run`
- 作用:拼图游玩运行态,保存当前关卡、网格、已玩 profile 列表、标签和运行快照。
@@ -430,6 +442,17 @@ SELECT * FROM puzzle_runtime_run WHERE run_id = '<run_id>';
SELECT * FROM puzzle_runtime_run WHERE owner_user_id = '<user_id>' ORDER BY updated_at DESC;
```
### `puzzle_leaderboard_entry`
- 作用:拼图关卡真实成绩表,按用户、作品和网格规格保留最佳成绩,用于结算弹窗排行榜。
- 结构:`entry_id PK: String`, `profile_id: String`, `grid_size: u32`, `user_id: String`, `nickname: String`, `best_elapsed_ms: u64`, `last_run_id: String`, `updated_at: Timestamp`
- 索引:`profile_id + grid_size`, `user_id + profile_id + grid_size`
```sql
SELECT * FROM puzzle_leaderboard_entry WHERE profile_id = '<profile_id>' AND grid_size = 4 ORDER BY best_elapsed_ms ASC;
SELECT * FROM puzzle_leaderboard_entry WHERE user_id = '<user_id>' AND profile_id = '<profile_id>' AND grid_size = 4;
```
## 大鱼吃小鱼表
### `big_fish_creation_session`