持久化认证状态到 SpacetimeDB 正式表

This commit is contained in:
2026-04-24 16:09:20 +08:00
parent 04288d4a40
commit 4e1c0462a4
29 changed files with 2271 additions and 7341 deletions

View File

@@ -0,0 +1,52 @@
# Auth SpacetimeDB 正式表恢复 Stage 3
## 1. 阶段目标
本阶段把认证持久化从“只依赖整包快照恢复”推进到“正式认证表优先恢复”。
落地口径:
- `user_account``auth_identity``refresh_session` 作为 SpacetimeDB 中的正式认证持久化表。
- API 启动时优先从正式表导出兼容 `module-auth` 的认证快照,再恢复到内存认证服务。
- 运行期认证变更仍先复用现有 `module-auth` 逻辑生成一致快照,随后同步快照并导入正式表,保证正式表与快照一致。
- 本阶段不重写登录、刷新、登出内部业务规则,避免在 JWT、refresh rotation、微信绑定合并等复杂语义中引入行为漂移。
## 2. 非目标
- 不在本阶段把 `PasswordEntryService``PhoneAuthService``RefreshSessionService` 改造成直接调用 SpacetimeDB reducer。
- 不在前端增加认证规则说明文案。
- 不删除 Stage 1 快照表;快照表继续作为导入载体与回滚兜底。
## 3. 运行流程
### 3.1 启动恢复
1. API 调用 `export_auth_store_snapshot_from_tables`
2. 若正式表已有用户、身份或会话数据,则返回兼容 `module-auth` 的 JSON 快照。
3. API 用 `InMemoryAuthStore::from_snapshot_json` 恢复认证服务。
4. 若正式表为空或调用失败,则回退到 Stage 1 的 `auth_store_snapshot`
5. 若 Stage 1 也不可用,则回退本地 JSON 热修复文件。
### 3.2 运行期同步
1. 登录、刷新、登出等路径继续调用当前内存认证服务。
2. 每次认证状态变更后调用 `upsert_auth_store_snapshot`
3. 快照写入成功后调用 `import_auth_store_snapshot`,覆盖导入正式表。
4. 导入失败时返回错误,避免用户误以为状态已经持久化。
## 4. 数据重建规则
- `users_by_username``user_account.username` 作为 key 重建。
- `phone_to_user_id` 由 provider 为 `phone``auth_identity` 重建。
- `wechat_identity_by_provider_uid` 由 provider 为 `wechat``auth_identity` 重建。
- `user_id_by_provider_union_id` 由微信身份中非空 `provider_union_id` 重建。
- `sessions_by_id``refresh_session.session_id` 重建。
- `session_id_by_refresh_token_hash``refresh_session.refresh_token_hash` 重建。
- `next_user_id` 取现有 `user_id``user_数字` 的最大值加一,若不存在则为 1。
## 5. 完成定义
- SpacetimeDB 模块能 wasm 编译。
- Rust bindings 已重新生成并包含正式表导出 procedure。
- `spacetime-client` 暴露正式表导出 facade。
- `api-server` 启动恢复优先正式表,认证变更同步后导入正式表。
- `module-auth` 测试保持通过。

View File

@@ -0,0 +1,97 @@
# Auth SpacetimeDB 拆表 Stage 2
日期:`2026-04-24`
## 1. 阶段目标
Stage 1 已把 Rust 鉴权快照同步到 SpacetimeDB 的 `auth_store_snapshot` 表。本阶段继续把该快照导入正式认证表,建立后续运行时细粒度读写的表结构基础。
本阶段落地范围:
1. 新增 `user_account` 表。
2. 新增 `auth_identity` 表。
3. 新增 `refresh_session` 表。
4. 新增 `import_auth_store_snapshot` procedure把当前 `auth_store_snapshot.snapshot_json` 拆入三张表。
5. 保留 Stage 1 快照表作为导入来源与回滚备份。
## 2. 非目标
本阶段不立即把 `api-server` 的登录、refresh、logout 写入切换到细粒度 reducer。原因是要避免同时改动认证业务语义、导入逻辑和运行时写路径。
运行时切换放到 Stage 3
1. `POST /api/auth/refresh` 改写 `refresh_session` 表。
2. 登录成功写 `user_account/auth_identity/refresh_session`
3. `logout/logout-all/revoke-session` 改写细粒度表。
4. `auth_store_snapshot` 退化为迁移备份。
## 3. 表设计落地口径
### 3.1 `user_account`
字段先覆盖当前 `module-auth` 快照可提供的账号主数据:
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `user_id` | `String` | 主键。 |
| `public_user_code` | `String` | 公开叙世号。 |
| `username` | `String` | 当前账号用户名。 |
| `display_name` | `String` | 展示名。 |
| `phone_number_masked` | `Option<String>` | 脱敏手机号。 |
| `phone_number_e164` | `Option<String>` | 内部手机号索引。 |
| `login_method` | `String` | `password/phone/wechat`。 |
| `binding_status` | `String` | `active/pending_bind_phone`。 |
| `wechat_bound` | `bool` | 是否绑定微信身份。 |
| `password_hash` | `String` | 密码哈希。 |
| `password_login_enabled` | `bool` | 是否允许密码登录。 |
| `token_version` | `u64` | access token 统一失效版本。 |
### 3.2 `auth_identity`
当前只导入已有快照中的微信身份与手机号身份:
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `identity_id` | `String` | 主键。 |
| `user_id` | `String` | 归属账号。 |
| `provider` | `String` | `phone/wechat`。 |
| `provider_uid` | `String` | provider 主体键。 |
| `provider_union_id` | `Option<String>` | 微信 unionid。 |
| `phone_e164` | `Option<String>` | 手机号身份。 |
| `display_name` | `Option<String>` | provider 显示名。 |
| `avatar_url` | `Option<String>` | provider 头像。 |
### 3.3 `refresh_session`
字段对齐现有 refresh session 记录:
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `session_id` | `String` | 主键。 |
| `user_id` | `String` | 归属账号。 |
| `refresh_token_hash` | `String` | 当前 refresh token hash。 |
| `issued_by_provider` | `String` | 创建来源。 |
| `client_info_json` | `String` | 当前客户端身份 JSON。 |
| `expires_at` | `String` | RFC3339。 |
| `revoked_at` | `Option<String>` | RFC3339。 |
| `created_at` | `String` | RFC3339。 |
| `updated_at` | `String` | RFC3339。 |
| `last_seen_at` | `String` | RFC3339。 |
## 4. 导入语义
`import_auth_store_snapshot` 固定行为:
1. 读取 `auth_store_snapshot/default`
2. JSON 解析失败返回 `ok=false` 和中文错误。
3. 导入前清空三张正式 auth 表,避免重复导入产生脏数据。
4. 按快照内容重建账号、身份、refresh session。
5. 返回导入计数,便于本地验证。
## 5. 完成定义
1. `spacetime-module` wasm check 通过。
2. Rust bindings 已刷新。
3. `spacetime-client` 暴露导入 procedure facade。
4. `api-server/spacetime-client/module-auth` 定向检查通过。

View File

@@ -217,6 +217,8 @@ impl AppState {
self.spacetime_client self.spacetime_client
.upsert_auth_store_snapshot(snapshot_json, updated_at_micros) .upsert_auth_store_snapshot(snapshot_json, updated_at_micros)
.await?; .await?;
// ?????????????????????????????????
self.spacetime_client.import_auth_store_snapshot().await?;
Ok(()) Ok(())
} }
@@ -229,19 +231,38 @@ impl AppState {
token: config.spacetime_token.clone(), token: config.spacetime_token.clone(),
pool_size: config.spacetime_pool_size, pool_size: config.spacetime_pool_size,
}); });
match spacetime_client
.export_auth_store_snapshot_from_tables()
.await
{
Ok(snapshot) => {
if let Some(snapshot_json) = snapshot.snapshot_json {
if !snapshot_json.trim().is_empty() {
let auth_store = InMemoryAuthStore::from_snapshot_json(&snapshot_json)
.map_err(AppStateInitError::AuthStore)?;
info!("?? SpacetimeDB ???????????");
return Self::new_with_auth_store(config, auth_store);
}
}
}
Err(error) => {
warn!(error = %error, "? SpacetimeDB ????????????????");
}
}
match spacetime_client.get_auth_store_snapshot().await { match spacetime_client.get_auth_store_snapshot().await {
Ok(snapshot) => { Ok(snapshot) => {
if let Some(snapshot_json) = snapshot.snapshot_json { if let Some(snapshot_json) = snapshot.snapshot_json {
if !snapshot_json.trim().is_empty() { if !snapshot_json.trim().is_empty() {
let auth_store = InMemoryAuthStore::from_snapshot_json(&snapshot_json) let auth_store = InMemoryAuthStore::from_snapshot_json(&snapshot_json)
.map_err(AppStateInitError::AuthStore)?; .map_err(AppStateInitError::AuthStore)?;
info!("已从 SpacetimeDB 恢复认证快照"); info!("?? SpacetimeDB ???????????");
return Self::new_with_auth_store(config, auth_store); return Self::new_with_auth_store(config, auth_store);
} }
} }
} }
Err(error) => { Err(error) => {
warn!(error = %error, " SpacetimeDB 恢复认证快照失败,回退到本地快照"); warn!(error = %error, "? SpacetimeDB ?????????????????");
} }
} }

View File

@@ -1,11 +1,12 @@
use super::*; use super::*;
use crate::mapper::*;
impl SpacetimeClient { impl SpacetimeClient {
pub async fn create_ai_task( pub async fn create_ai_task(
&self, &self,
input: DomainAiTaskCreateInput, input: DomainAiTaskCreateInput,
) -> Result<AiTaskMutationRecord, SpacetimeClientError> { ) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
let procedure_input = map_ai_task_create_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().create_ai_task_and_return_then( connection.procedures().create_ai_task_and_return_then(
@@ -21,12 +22,11 @@ impl SpacetimeClient {
.await .await
} }
pub async fn start_ai_task( pub async fn start_ai_task(
&self, &self,
input: DomainAiTaskStartInput, input: DomainAiTaskStartInput,
) -> Result<(), SpacetimeClientError> { ) -> Result<(), SpacetimeClientError> {
let reducer_input = map_ai_task_start_input(input); let reducer_input = input.into();
self.call_reducer_after_connect(move |connection, sender| { self.call_reducer_after_connect(move |connection, sender| {
let callback_sender = sender.clone(); let callback_sender = sender.clone();
@@ -49,12 +49,11 @@ impl SpacetimeClient {
.await .await
} }
pub async fn start_ai_task_stage( pub async fn start_ai_task_stage(
&self, &self,
input: DomainAiTaskStageStartInput, input: DomainAiTaskStageStartInput,
) -> Result<(), SpacetimeClientError> { ) -> Result<(), SpacetimeClientError> {
let reducer_input = map_ai_task_stage_start_input(input); let reducer_input = input.into();
self.call_reducer_after_connect(move |connection, sender| { self.call_reducer_after_connect(move |connection, sender| {
let callback_sender = sender.clone(); let callback_sender = sender.clone();
@@ -77,12 +76,11 @@ impl SpacetimeClient {
.await .await
} }
pub async fn append_ai_text_chunk( pub async fn append_ai_text_chunk(
&self, &self,
input: DomainAiTextChunkAppendInput, input: DomainAiTextChunkAppendInput,
) -> Result<AiTaskMutationRecord, SpacetimeClientError> { ) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
let procedure_input = map_ai_text_chunk_append_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -97,12 +95,11 @@ impl SpacetimeClient {
.await .await
} }
pub async fn complete_ai_stage( pub async fn complete_ai_stage(
&self, &self,
input: DomainAiStageCompletionInput, input: DomainAiStageCompletionInput,
) -> Result<AiTaskMutationRecord, SpacetimeClientError> { ) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
let procedure_input = map_ai_stage_completion_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().complete_ai_stage_and_return_then( connection.procedures().complete_ai_stage_and_return_then(
@@ -118,12 +115,11 @@ impl SpacetimeClient {
.await .await
} }
pub async fn attach_ai_result_reference( pub async fn attach_ai_result_reference(
&self, &self,
input: DomainAiResultReferenceInput, input: DomainAiResultReferenceInput,
) -> Result<AiTaskMutationRecord, SpacetimeClientError> { ) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
let procedure_input = map_ai_result_reference_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -138,12 +134,11 @@ impl SpacetimeClient {
.await .await
} }
pub async fn complete_ai_task( pub async fn complete_ai_task(
&self, &self,
input: DomainAiTaskFinishInput, input: DomainAiTaskFinishInput,
) -> Result<AiTaskMutationRecord, SpacetimeClientError> { ) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
let procedure_input = map_ai_task_finish_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().complete_ai_task_and_return_then( connection.procedures().complete_ai_task_and_return_then(
@@ -159,12 +154,11 @@ impl SpacetimeClient {
.await .await
} }
pub async fn fail_ai_task( pub async fn fail_ai_task(
&self, &self,
input: DomainAiTaskFailureInput, input: DomainAiTaskFailureInput,
) -> Result<AiTaskMutationRecord, SpacetimeClientError> { ) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
let procedure_input = map_ai_task_failure_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().fail_ai_task_and_return_then( connection.procedures().fail_ai_task_and_return_then(
@@ -180,12 +174,11 @@ impl SpacetimeClient {
.await .await
} }
pub async fn cancel_ai_task( pub async fn cancel_ai_task(
&self, &self,
input: DomainAiTaskCancelInput, input: DomainAiTaskCancelInput,
) -> Result<AiTaskMutationRecord, SpacetimeClientError> { ) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
let procedure_input = map_ai_task_cancel_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().cancel_ai_task_and_return_then( connection.procedures().cancel_ai_task_and_return_then(
@@ -200,6 +193,4 @@ impl SpacetimeClient {
}) })
.await .await
} }
} }

View File

@@ -5,7 +5,7 @@ impl SpacetimeClient {
&self, &self,
input: module_assets::AssetObjectUpsertInput, input: module_assets::AssetObjectUpsertInput,
) -> Result<AssetObjectRecord, SpacetimeClientError> { ) -> Result<AssetObjectRecord, SpacetimeClientError> {
let procedure_input = map_upsert_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -20,12 +20,11 @@ impl SpacetimeClient {
.await .await
} }
pub async fn bind_asset_object_to_entity( pub async fn bind_asset_object_to_entity(
&self, &self,
input: module_assets::AssetEntityBindingInput, input: module_assets::AssetEntityBindingInput,
) -> Result<AssetEntityBindingRecord, SpacetimeClientError> { ) -> Result<AssetEntityBindingRecord, SpacetimeClientError> {
let procedure_input = map_entity_binding_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -39,6 +38,4 @@ impl SpacetimeClient {
}) })
.await .await
} }
} }

View File

@@ -1,6 +1,22 @@
use super::*; use super::*;
impl SpacetimeClient { impl SpacetimeClient {
pub async fn export_auth_store_snapshot_from_tables(
&self,
) -> Result<AuthStoreSnapshotRecord, SpacetimeClientError> {
self.call_after_connect(move |connection, sender| {
connection
.procedures()
.export_auth_store_snapshot_from_tables_then(move |_, result| {
let mapped = result
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
.and_then(map_auth_store_snapshot_procedure_result);
send_once(&sender, mapped);
});
})
.await
}
pub async fn get_auth_store_snapshot( pub async fn get_auth_store_snapshot(
&self, &self,
) -> Result<AuthStoreSnapshotRecord, SpacetimeClientError> { ) -> Result<AuthStoreSnapshotRecord, SpacetimeClientError> {
@@ -17,7 +33,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn upsert_auth_store_snapshot( pub async fn upsert_auth_store_snapshot(
&self, &self,
snapshot_json: String, snapshot_json: String,
@@ -42,5 +57,19 @@ impl SpacetimeClient {
.await .await
} }
pub async fn import_auth_store_snapshot(
&self,
) -> Result<AuthStoreSnapshotImportRecord, SpacetimeClientError> {
self.call_after_connect(move |connection, sender| {
connection
.procedures()
.import_auth_store_snapshot_then(move |_, result| {
let mapped = result
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
.and_then(map_auth_store_snapshot_import_procedure_result);
send_once(&sender, mapped);
});
})
.await
}
} }

View File

@@ -1,4 +1,5 @@
use super::*; use super::*;
use crate::mapper::*;
impl SpacetimeClient { impl SpacetimeClient {
pub async fn create_big_fish_session( pub async fn create_big_fish_session(
@@ -28,7 +29,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_big_fish_session( pub async fn get_big_fish_session(
&self, &self,
session_id: String, session_id: String,
@@ -52,7 +52,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn list_big_fish_works( pub async fn list_big_fish_works(
&self, &self,
owner_user_id: String, owner_user_id: String,
@@ -72,7 +71,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn submit_big_fish_message( pub async fn submit_big_fish_message(
&self, &self,
input: BigFishMessageSubmitRecordInput, input: BigFishMessageSubmitRecordInput,
@@ -100,6 +98,34 @@ impl SpacetimeClient {
.await .await
} }
pub async fn finalize_big_fish_agent_message(
&self,
input: BigFishMessageFinalizeRecordInput,
) -> Result<BigFishSessionRecord, SpacetimeClientError> {
let procedure_input = BigFishMessageFinalizeInput {
session_id: input.session_id,
owner_user_id: input.owner_user_id,
assistant_message_id: input.assistant_message_id,
assistant_reply_text: input.assistant_reply_text,
stage: parse_big_fish_creation_stage(&input.stage)?,
progress_percent: input.progress_percent,
anchor_pack_json: input.anchor_pack_json,
error_message: input.error_message,
updated_at_micros: input.updated_at_micros,
};
self.call_after_connect(move |connection, sender| {
connection
.procedures()
.finalize_big_fish_agent_message_turn_then(procedure_input, move |_, result| {
let mapped = result
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
.and_then(map_big_fish_session_procedure_result);
send_once(&sender, mapped);
});
})
.await
}
pub async fn compile_big_fish_draft( pub async fn compile_big_fish_draft(
&self, &self,
@@ -127,7 +153,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn generate_big_fish_asset( pub async fn generate_big_fish_asset(
&self, &self,
input: BigFishAssetGenerateRecordInput, input: BigFishAssetGenerateRecordInput,
@@ -135,7 +160,7 @@ impl SpacetimeClient {
let procedure_input = BigFishAssetGenerateInput { let procedure_input = BigFishAssetGenerateInput {
session_id: input.session_id, session_id: input.session_id,
owner_user_id: input.owner_user_id, owner_user_id: input.owner_user_id,
asset_kind: map_big_fish_asset_kind_input(input.asset_kind.as_str())?, asset_kind: input.asset_kind.as_str().try_into()?,
level: input.level, level: input.level,
motion_key: input.motion_key, motion_key: input.motion_key,
asset_url: input.asset_url, asset_url: input.asset_url,
@@ -156,7 +181,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn publish_big_fish_game( pub async fn publish_big_fish_game(
&self, &self,
session_id: String, session_id: String,
@@ -183,7 +207,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn start_big_fish_run( pub async fn start_big_fish_run(
&self, &self,
input: BigFishRunStartRecordInput, input: BigFishRunStartRecordInput,
@@ -208,7 +231,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn submit_big_fish_input( pub async fn submit_big_fish_input(
&self, &self,
input: BigFishRunInputSubmitRecordInput, input: BigFishRunInputSubmitRecordInput,
@@ -235,7 +257,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_big_fish_run( pub async fn get_big_fish_run(
&self, &self,
run_id: String, run_id: String,
@@ -258,6 +279,4 @@ impl SpacetimeClient {
}) })
.await .await
} }
} }

View File

@@ -1,4 +1,5 @@
use super::*; use super::*;
use crate::mapper::*;
impl SpacetimeClient { impl SpacetimeClient {
pub async fn create_battle_state( pub async fn create_battle_state(
@@ -7,7 +8,7 @@ impl SpacetimeClient {
) -> Result<BattleStateRecord, SpacetimeClientError> { ) -> Result<BattleStateRecord, SpacetimeClientError> {
validate_battle_state_input(&input) validate_battle_state_input(&input)
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?; .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?;
let procedure_input = map_battle_state_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().create_battle_state_and_return_then( connection.procedures().create_battle_state_and_return_then(
@@ -23,15 +24,13 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_battle_state( pub async fn get_battle_state(
&self, &self,
battle_state_id: String, battle_state_id: String,
) -> Result<BattleStateRecord, SpacetimeClientError> { ) -> Result<BattleStateRecord, SpacetimeClientError> {
let procedure_input = map_battle_state_query_input( let procedure_input = build_battle_state_query_input(battle_state_id)
build_battle_state_query_input(battle_state_id) .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .into();
);
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -46,14 +45,13 @@ impl SpacetimeClient {
.await .await
} }
pub async fn resolve_combat_action( pub async fn resolve_combat_action(
&self, &self,
input: DomainResolveCombatActionInput, input: DomainResolveCombatActionInput,
) -> Result<ResolveCombatActionRecord, SpacetimeClientError> { ) -> Result<ResolveCombatActionRecord, SpacetimeClientError> {
validate_resolve_combat_action_input(&input) validate_resolve_combat_action_input(&input)
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?; .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?;
let procedure_input = map_resolve_combat_action_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -67,6 +65,4 @@ impl SpacetimeClient {
}) })
.await .await
} }
} }

View File

@@ -1,4 +1,5 @@
use super::*; use super::*;
use crate::mapper::*;
impl SpacetimeClient { impl SpacetimeClient {
pub async fn list_custom_world_profiles( pub async fn list_custom_world_profiles(
@@ -21,7 +22,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_custom_world_library_detail( pub async fn get_custom_world_library_detail(
&self, &self,
owner_user_id: String, owner_user_id: String,
@@ -45,12 +45,11 @@ impl SpacetimeClient {
.await .await
} }
pub async fn upsert_custom_world_profile( pub async fn upsert_custom_world_profile(
&self, &self,
input: CustomWorldProfileUpsertRecordInput, input: CustomWorldProfileUpsertRecordInput,
) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> { ) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> {
let procedure_input = map_custom_world_profile_upsert_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -65,7 +64,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn publish_custom_world_profile( pub async fn publish_custom_world_profile(
&self, &self,
profile_id: String, profile_id: String,
@@ -97,7 +95,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn unpublish_custom_world_profile( pub async fn unpublish_custom_world_profile(
&self, &self,
profile_id: String, profile_id: String,
@@ -128,7 +125,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn delete_custom_world_profile( pub async fn delete_custom_world_profile(
&self, &self,
profile_id: String, profile_id: String,
@@ -154,7 +150,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn list_custom_world_gallery_entries( pub async fn list_custom_world_gallery_entries(
&self, &self,
) -> Result<Vec<CustomWorldGalleryEntryRecord>, SpacetimeClientError> { ) -> Result<Vec<CustomWorldGalleryEntryRecord>, SpacetimeClientError> {
@@ -171,7 +166,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_custom_world_gallery_detail( pub async fn get_custom_world_gallery_detail(
&self, &self,
owner_user_id: String, owner_user_id: String,
@@ -195,7 +189,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_custom_world_gallery_detail_by_code( pub async fn get_custom_world_gallery_detail_by_code(
&self, &self,
public_work_code: String, public_work_code: String,
@@ -215,12 +208,11 @@ impl SpacetimeClient {
.await .await
} }
pub async fn publish_custom_world_world( pub async fn publish_custom_world_world(
&self, &self,
input: CustomWorldPublishWorldRecordInput, input: CustomWorldPublishWorldRecordInput,
) -> Result<CustomWorldPublishWorldRecord, SpacetimeClientError> { ) -> Result<CustomWorldPublishWorldRecord, SpacetimeClientError> {
let procedure_input = map_custom_world_publish_world_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().publish_custom_world_world_then( connection.procedures().publish_custom_world_world_then(
@@ -236,7 +228,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn create_custom_world_agent_session( pub async fn create_custom_world_agent_session(
&self, &self,
input: CustomWorldAgentSessionCreateRecordInput, input: CustomWorldAgentSessionCreateRecordInput,
@@ -275,7 +266,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_custom_world_agent_session( pub async fn get_custom_world_agent_session(
&self, &self,
session_id: String, session_id: String,
@@ -300,7 +290,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn list_custom_world_works( pub async fn list_custom_world_works(
&self, &self,
owner_user_id: String, owner_user_id: String,
@@ -321,7 +310,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_custom_world_agent_card_detail( pub async fn get_custom_world_agent_card_detail(
&self, &self,
session_id: String, session_id: String,
@@ -347,7 +335,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn execute_custom_world_agent_action( pub async fn execute_custom_world_agent_action(
&self, &self,
input: CustomWorldAgentActionExecuteRecordInput, input: CustomWorldAgentActionExecuteRecordInput,
@@ -374,7 +361,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn submit_custom_world_agent_message( pub async fn submit_custom_world_agent_message(
&self, &self,
input: CustomWorldAgentMessageSubmitRecordInput, input: CustomWorldAgentMessageSubmitRecordInput,
@@ -401,7 +387,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn finalize_custom_world_agent_message( pub async fn finalize_custom_world_agent_message(
&self, &self,
input: CustomWorldAgentMessageFinalizeRecordInput, input: CustomWorldAgentMessageFinalizeRecordInput,
@@ -451,7 +436,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_custom_world_agent_operation( pub async fn get_custom_world_agent_operation(
&self, &self,
session_id: String, session_id: String,
@@ -476,6 +460,4 @@ impl SpacetimeClient {
}) })
.await .await
} }
} }

View File

@@ -6,10 +6,10 @@ impl SpacetimeClient {
runtime_session_id: String, runtime_session_id: String,
actor_user_id: String, actor_user_id: String,
) -> Result<RuntimeInventoryStateRecord, SpacetimeClientError> { ) -> Result<RuntimeInventoryStateRecord, SpacetimeClientError> {
let procedure_input = map_runtime_inventory_state_query_input( let procedure_input =
build_runtime_inventory_state_query_input(runtime_session_id, actor_user_id) build_runtime_inventory_state_query_input(runtime_session_id, actor_user_id)
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
); .into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().get_runtime_inventory_state_then( connection.procedures().get_runtime_inventory_state_then(
@@ -24,6 +24,4 @@ impl SpacetimeClient {
}) })
.await .await
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,8 @@
use super::*; use super::*;
pub(crate) fn map_entity_binding_input( impl From<module_assets::AssetEntityBindingInput> for AssetEntityBindingInput {
input: module_assets::AssetEntityBindingInput, fn from(input: module_assets::AssetEntityBindingInput) -> Self {
) -> AssetEntityBindingInput { Self {
AssetEntityBindingInput {
binding_id: input.binding_id, binding_id: input.binding_id,
asset_object_id: input.asset_object_id, asset_object_id: input.asset_object_id,
entity_kind: input.entity_kind, entity_kind: input.entity_kind,
@@ -15,9 +14,11 @@ pub(crate) fn map_entity_binding_input(
updated_at_micros: input.updated_at_micros, updated_at_micros: input.updated_at_micros,
} }
} }
}
pub(crate) fn map_upsert_input(input: module_assets::AssetObjectUpsertInput) -> AssetObjectUpsertInput { impl From<module_assets::AssetObjectUpsertInput> for AssetObjectUpsertInput {
AssetObjectUpsertInput { fn from(input: module_assets::AssetObjectUpsertInput) -> Self {
Self {
asset_object_id: input.asset_object_id, asset_object_id: input.asset_object_id,
bucket: input.bucket, bucket: input.bucket,
object_key: input.object_key, object_key: input.object_key,
@@ -34,60 +35,56 @@ pub(crate) fn map_upsert_input(input: module_assets::AssetObjectUpsertInput) ->
updated_at_micros: input.updated_at_micros, updated_at_micros: input.updated_at_micros,
} }
} }
}
pub(crate) fn map_runtime_setting_get_input( impl From<module_runtime::RuntimeSettingGetInput> for RuntimeSettingGetInput {
input: module_runtime::RuntimeSettingGetInput, fn from(input: module_runtime::RuntimeSettingGetInput) -> Self {
) -> RuntimeSettingGetInput { Self {
RuntimeSettingGetInput {
user_id: input.user_id, user_id: input.user_id,
} }
} }
}
pub(crate) fn map_runtime_setting_upsert_input( impl From<module_runtime::RuntimeSettingUpsertInput> for RuntimeSettingUpsertInput {
input: module_runtime::RuntimeSettingUpsertInput, fn from(input: module_runtime::RuntimeSettingUpsertInput) -> Self {
) -> RuntimeSettingUpsertInput { Self {
RuntimeSettingUpsertInput {
user_id: input.user_id, user_id: input.user_id,
music_volume: input.music_volume, music_volume: input.music_volume,
platform_theme: map_runtime_platform_theme(input.platform_theme), platform_theme: map_runtime_platform_theme(input.platform_theme),
updated_at_micros: input.updated_at_micros, updated_at_micros: input.updated_at_micros,
} }
} }
}
pub(crate) fn map_runtime_browse_history_list_input( impl From<module_runtime::RuntimeBrowseHistoryListInput> for RuntimeBrowseHistoryListInput {
input: module_runtime::RuntimeBrowseHistoryListInput, fn from(input: module_runtime::RuntimeBrowseHistoryListInput) -> Self {
) -> RuntimeBrowseHistoryListInput { Self {
RuntimeBrowseHistoryListInput {
user_id: input.user_id, user_id: input.user_id,
} }
} }
}
pub(crate) fn map_runtime_browse_history_clear_input( impl From<module_runtime::RuntimeBrowseHistoryClearInput> for RuntimeBrowseHistoryClearInput {
input: module_runtime::RuntimeBrowseHistoryClearInput, fn from(input: module_runtime::RuntimeBrowseHistoryClearInput) -> Self {
) -> RuntimeBrowseHistoryClearInput { Self {
RuntimeBrowseHistoryClearInput {
user_id: input.user_id, user_id: input.user_id,
} }
} }
}
pub(crate) fn map_runtime_browse_history_sync_input( impl From<module_runtime::RuntimeBrowseHistorySyncInput> for RuntimeBrowseHistorySyncInput {
input: module_runtime::RuntimeBrowseHistorySyncInput, fn from(input: module_runtime::RuntimeBrowseHistorySyncInput) -> Self {
) -> RuntimeBrowseHistorySyncInput { Self {
RuntimeBrowseHistorySyncInput {
user_id: input.user_id, user_id: input.user_id,
entries: input entries: input.entries.into_iter().map(Into::into).collect(),
.entries
.into_iter()
.map(map_runtime_browse_history_write_input)
.collect(),
updated_at_micros: input.updated_at_micros, updated_at_micros: input.updated_at_micros,
} }
} }
}
pub(crate) fn map_runtime_browse_history_write_input( impl From<module_runtime::RuntimeBrowseHistoryWriteInput> for RuntimeBrowseHistoryWriteInput {
input: module_runtime::RuntimeBrowseHistoryWriteInput, fn from(input: module_runtime::RuntimeBrowseHistoryWriteInput) -> Self {
) -> RuntimeBrowseHistoryWriteInput { Self {
RuntimeBrowseHistoryWriteInput {
owner_user_id: input.owner_user_id, owner_user_id: input.owner_user_id,
profile_id: input.profile_id, profile_id: input.profile_id,
world_name: input.world_name, world_name: input.world_name,
@@ -99,43 +96,45 @@ pub(crate) fn map_runtime_browse_history_write_input(
visited_at: input.visited_at, visited_at: input.visited_at,
} }
} }
}
pub(crate) fn map_runtime_profile_dashboard_get_input( impl From<module_runtime::RuntimeProfileDashboardGetInput> for RuntimeProfileDashboardGetInput {
input: module_runtime::RuntimeProfileDashboardGetInput, fn from(input: module_runtime::RuntimeProfileDashboardGetInput) -> Self {
) -> RuntimeProfileDashboardGetInput { Self {
RuntimeProfileDashboardGetInput {
user_id: input.user_id, user_id: input.user_id,
} }
} }
}
pub(crate) fn map_runtime_profile_wallet_ledger_list_input( impl From<module_runtime::RuntimeProfileWalletLedgerListInput>
input: module_runtime::RuntimeProfileWalletLedgerListInput, for RuntimeProfileWalletLedgerListInput
) -> RuntimeProfileWalletLedgerListInput { {
RuntimeProfileWalletLedgerListInput { fn from(input: module_runtime::RuntimeProfileWalletLedgerListInput) -> Self {
Self {
user_id: input.user_id, user_id: input.user_id,
} }
} }
}
pub(crate) fn map_runtime_profile_play_stats_get_input( impl From<module_runtime::RuntimeProfilePlayStatsGetInput> for RuntimeProfilePlayStatsGetInput {
input: module_runtime::RuntimeProfilePlayStatsGetInput, fn from(input: module_runtime::RuntimeProfilePlayStatsGetInput) -> Self {
) -> RuntimeProfilePlayStatsGetInput { Self {
RuntimeProfilePlayStatsGetInput {
user_id: input.user_id, user_id: input.user_id,
} }
} }
}
pub(crate) fn map_runtime_snapshot_get_input( impl From<module_runtime::RuntimeSnapshotGetInput> for RuntimeSnapshotGetInput {
input: module_runtime::RuntimeSnapshotGetInput, fn from(input: module_runtime::RuntimeSnapshotGetInput) -> Self {
) -> RuntimeSnapshotGetInput { Self {
RuntimeSnapshotGetInput {
user_id: input.user_id, user_id: input.user_id,
} }
} }
}
pub(crate) fn map_runtime_snapshot_upsert_input( impl From<module_runtime::RuntimeSnapshotUpsertInput> for RuntimeSnapshotUpsertInput {
input: module_runtime::RuntimeSnapshotUpsertInput, fn from(input: module_runtime::RuntimeSnapshotUpsertInput) -> Self {
) -> RuntimeSnapshotUpsertInput { Self {
RuntimeSnapshotUpsertInput {
user_id: input.user_id, user_id: input.user_id,
saved_at_micros: input.saved_at_micros, saved_at_micros: input.saved_at_micros,
bottom_tab: input.bottom_tab, bottom_tab: input.bottom_tab,
@@ -144,34 +143,40 @@ pub(crate) fn map_runtime_snapshot_upsert_input(
updated_at_micros: input.updated_at_micros, updated_at_micros: input.updated_at_micros,
} }
} }
}
pub(crate) fn map_runtime_snapshot_delete_input( impl From<module_runtime::RuntimeSnapshotDeleteInput> for RuntimeSnapshotDeleteInput {
input: module_runtime::RuntimeSnapshotDeleteInput, fn from(input: module_runtime::RuntimeSnapshotDeleteInput) -> Self {
) -> RuntimeSnapshotDeleteInput { Self {
RuntimeSnapshotDeleteInput {
user_id: input.user_id, user_id: input.user_id,
} }
} }
}
pub(crate) fn map_runtime_profile_save_archive_list_input( impl From<module_runtime::RuntimeProfileSaveArchiveListInput>
input: module_runtime::RuntimeProfileSaveArchiveListInput, for RuntimeProfileSaveArchiveListInput
) -> RuntimeProfileSaveArchiveListInput { {
RuntimeProfileSaveArchiveListInput { fn from(input: module_runtime::RuntimeProfileSaveArchiveListInput) -> Self {
Self {
user_id: input.user_id, user_id: input.user_id,
} }
} }
}
pub(crate) fn map_runtime_profile_save_archive_resume_input( impl From<module_runtime::RuntimeProfileSaveArchiveResumeInput>
input: module_runtime::RuntimeProfileSaveArchiveResumeInput, for RuntimeProfileSaveArchiveResumeInput
) -> RuntimeProfileSaveArchiveResumeInput { {
RuntimeProfileSaveArchiveResumeInput { fn from(input: module_runtime::RuntimeProfileSaveArchiveResumeInput) -> Self {
Self {
user_id: input.user_id, user_id: input.user_id,
world_key: input.world_key, world_key: input.world_key,
} }
} }
}
pub(crate) fn map_ai_task_create_input(input: DomainAiTaskCreateInput) -> AiTaskCreateInput { impl From<DomainAiTaskCreateInput> for AiTaskCreateInput {
AiTaskCreateInput { fn from(input: DomainAiTaskCreateInput) -> Self {
Self {
task_id: input.task_id, task_id: input.task_id,
task_kind: map_ai_task_kind(input.task_kind), task_kind: map_ai_task_kind(input.task_kind),
owner_user_id: input.owner_user_id, owner_user_id: input.owner_user_id,
@@ -179,36 +184,34 @@ pub(crate) fn map_ai_task_create_input(input: DomainAiTaskCreateInput) -> AiTask
source_module: input.source_module, source_module: input.source_module,
source_entity_id: input.source_entity_id, source_entity_id: input.source_entity_id,
request_payload_json: input.request_payload_json, request_payload_json: input.request_payload_json,
stages: input stages: input.stages.into_iter().map(Into::into).collect(),
.stages
.into_iter()
.map(map_ai_task_stage_blueprint)
.collect(),
created_at_micros: input.created_at_micros, created_at_micros: input.created_at_micros,
} }
} }
}
pub(crate) fn map_ai_task_start_input(input: DomainAiTaskStartInput) -> AiTaskStartInput { impl From<DomainAiTaskStartInput> for AiTaskStartInput {
AiTaskStartInput { fn from(input: DomainAiTaskStartInput) -> Self {
Self {
task_id: input.task_id, task_id: input.task_id,
started_at_micros: input.started_at_micros, started_at_micros: input.started_at_micros,
} }
} }
}
pub(crate) fn map_ai_task_stage_start_input( impl From<DomainAiTaskStageStartInput> for AiTaskStageStartInput {
input: DomainAiTaskStageStartInput, fn from(input: DomainAiTaskStageStartInput) -> Self {
) -> AiTaskStageStartInput { Self {
AiTaskStageStartInput {
task_id: input.task_id, task_id: input.task_id,
stage_kind: map_ai_task_stage_kind(input.stage_kind), stage_kind: map_ai_task_stage_kind(input.stage_kind),
started_at_micros: input.started_at_micros, started_at_micros: input.started_at_micros,
} }
} }
}
pub(crate) fn map_ai_text_chunk_append_input( impl From<DomainAiTextChunkAppendInput> for AiTextChunkAppendInput {
input: DomainAiTextChunkAppendInput, fn from(input: DomainAiTextChunkAppendInput) -> Self {
) -> AiTextChunkAppendInput { Self {
AiTextChunkAppendInput {
task_id: input.task_id, task_id: input.task_id,
stage_kind: map_ai_task_stage_kind(input.stage_kind), stage_kind: map_ai_task_stage_kind(input.stage_kind),
sequence: input.sequence, sequence: input.sequence,
@@ -216,11 +219,11 @@ pub(crate) fn map_ai_text_chunk_append_input(
created_at_micros: input.created_at_micros, created_at_micros: input.created_at_micros,
} }
} }
}
pub(crate) fn map_ai_stage_completion_input( impl From<DomainAiStageCompletionInput> for AiStageCompletionInput {
input: DomainAiStageCompletionInput, fn from(input: DomainAiStageCompletionInput) -> Self {
) -> AiStageCompletionInput { Self {
AiStageCompletionInput {
task_id: input.task_id, task_id: input.task_id,
stage_kind: map_ai_task_stage_kind(input.stage_kind), stage_kind: map_ai_task_stage_kind(input.stage_kind),
text_output: input.text_output, text_output: input.text_output,
@@ -229,11 +232,11 @@ pub(crate) fn map_ai_stage_completion_input(
completed_at_micros: input.completed_at_micros, completed_at_micros: input.completed_at_micros,
} }
} }
}
pub(crate) fn map_ai_result_reference_input( impl From<DomainAiResultReferenceInput> for AiResultReferenceInput {
input: DomainAiResultReferenceInput, fn from(input: DomainAiResultReferenceInput) -> Self {
) -> AiResultReferenceInput { Self {
AiResultReferenceInput {
task_id: input.task_id, task_id: input.task_id,
reference_kind: map_ai_result_reference_kind(input.reference_kind), reference_kind: map_ai_result_reference_kind(input.reference_kind),
reference_id: input.reference_id, reference_id: input.reference_id,
@@ -241,44 +244,50 @@ pub(crate) fn map_ai_result_reference_input(
created_at_micros: input.created_at_micros, created_at_micros: input.created_at_micros,
} }
} }
}
pub(crate) fn map_ai_task_finish_input(input: DomainAiTaskFinishInput) -> AiTaskFinishInput { impl From<DomainAiTaskFinishInput> for AiTaskFinishInput {
AiTaskFinishInput { fn from(input: DomainAiTaskFinishInput) -> Self {
Self {
task_id: input.task_id, task_id: input.task_id,
completed_at_micros: input.completed_at_micros, completed_at_micros: input.completed_at_micros,
} }
} }
}
pub(crate) fn map_ai_task_failure_input(input: DomainAiTaskFailureInput) -> AiTaskFailureInput { impl From<DomainAiTaskFailureInput> for AiTaskFailureInput {
AiTaskFailureInput { fn from(input: DomainAiTaskFailureInput) -> Self {
Self {
task_id: input.task_id, task_id: input.task_id,
failure_message: input.failure_message, failure_message: input.failure_message,
completed_at_micros: input.completed_at_micros, completed_at_micros: input.completed_at_micros,
} }
} }
}
pub(crate) fn map_ai_task_cancel_input(input: DomainAiTaskCancelInput) -> AiTaskCancelInput { impl From<DomainAiTaskCancelInput> for AiTaskCancelInput {
AiTaskCancelInput { fn from(input: DomainAiTaskCancelInput) -> Self {
Self {
task_id: input.task_id, task_id: input.task_id,
completed_at_micros: input.completed_at_micros, completed_at_micros: input.completed_at_micros,
} }
} }
}
pub(crate) fn map_ai_task_stage_blueprint( impl From<DomainAiTaskStageBlueprint> for AiTaskStageBlueprint {
blueprint: DomainAiTaskStageBlueprint, fn from(blueprint: DomainAiTaskStageBlueprint) -> Self {
) -> AiTaskStageBlueprint { Self {
AiTaskStageBlueprint {
stage_kind: map_ai_task_stage_kind(blueprint.stage_kind), stage_kind: map_ai_task_stage_kind(blueprint.stage_kind),
label: blueprint.label, label: blueprint.label,
detail: blueprint.detail, detail: blueprint.detail,
order: blueprint.order, order: blueprint.order,
} }
} }
}
pub(crate) fn map_custom_world_profile_upsert_input( impl From<CustomWorldProfileUpsertRecordInput> for CustomWorldProfileUpsertInput {
input: CustomWorldProfileUpsertRecordInput, fn from(input: CustomWorldProfileUpsertRecordInput) -> Self {
) -> CustomWorldProfileUpsertInput { Self {
CustomWorldProfileUpsertInput {
profile_id: input.profile_id, profile_id: input.profile_id,
owner_user_id: input.owner_user_id, owner_user_id: input.owner_user_id,
public_work_code: input.public_work_code, public_work_code: input.public_work_code,
@@ -296,11 +305,11 @@ pub(crate) fn map_custom_world_profile_upsert_input(
updated_at_micros: input.updated_at_micros, updated_at_micros: input.updated_at_micros,
} }
} }
}
pub(crate) fn map_custom_world_publish_world_input( impl From<CustomWorldPublishWorldRecordInput> for CustomWorldPublishWorldInput {
input: CustomWorldPublishWorldRecordInput, fn from(input: CustomWorldPublishWorldRecordInput) -> Self {
) -> CustomWorldPublishWorldInput { Self {
CustomWorldPublishWorldInput {
session_id: input.session_id, session_id: input.session_id,
profile_id: input.profile_id, profile_id: input.profile_id,
owner_user_id: input.owner_user_id, owner_user_id: input.owner_user_id,
@@ -313,9 +322,11 @@ pub(crate) fn map_custom_world_publish_world_input(
published_at_micros: input.published_at_micros, published_at_micros: input.published_at_micros,
} }
} }
}
pub(crate) fn map_story_session_input(input: DomainStorySessionInput) -> StorySessionInput { impl From<DomainStorySessionInput> for StorySessionInput {
StorySessionInput { fn from(input: DomainStorySessionInput) -> Self {
Self {
story_session_id: input.story_session_id, story_session_id: input.story_session_id,
runtime_session_id: input.runtime_session_id, runtime_session_id: input.runtime_session_id,
actor_user_id: input.actor_user_id, actor_user_id: input.actor_user_id,
@@ -325,9 +336,11 @@ pub(crate) fn map_story_session_input(input: DomainStorySessionInput) -> StorySe
created_at_micros: input.created_at_micros, created_at_micros: input.created_at_micros,
} }
} }
}
pub(crate) fn map_story_continue_input(input: DomainStoryContinueInput) -> StoryContinueInput { impl From<DomainStoryContinueInput> for StoryContinueInput {
StoryContinueInput { fn from(input: DomainStoryContinueInput) -> Self {
Self {
story_session_id: input.story_session_id, story_session_id: input.story_session_id,
event_id: input.event_id, event_id: input.event_id,
narrative_text: input.narrative_text, narrative_text: input.narrative_text,
@@ -335,34 +348,36 @@ pub(crate) fn map_story_continue_input(input: DomainStoryContinueInput) -> Story
updated_at_micros: input.updated_at_micros, updated_at_micros: input.updated_at_micros,
} }
} }
}
pub(crate) fn map_story_session_state_input( impl From<DomainStorySessionStateInput> for StorySessionStateInput {
input: DomainStorySessionStateInput, fn from(input: DomainStorySessionStateInput) -> Self {
) -> StorySessionStateInput { Self {
StorySessionStateInput {
story_session_id: input.story_session_id, story_session_id: input.story_session_id,
} }
} }
}
pub(crate) fn map_runtime_inventory_state_query_input( impl From<DomainRuntimeInventoryStateQueryInput> for RuntimeInventoryStateQueryInput {
input: DomainRuntimeInventoryStateQueryInput, fn from(input: DomainRuntimeInventoryStateQueryInput) -> Self {
) -> RuntimeInventoryStateQueryInput { Self {
RuntimeInventoryStateQueryInput {
runtime_session_id: input.runtime_session_id, runtime_session_id: input.runtime_session_id,
actor_user_id: input.actor_user_id, actor_user_id: input.actor_user_id,
} }
} }
}
pub(crate) fn map_battle_state_query_input( impl From<DomainBattleStateQueryInput> for BattleStateQueryInput {
input: DomainBattleStateQueryInput, fn from(input: DomainBattleStateQueryInput) -> Self {
) -> BattleStateQueryInput { Self {
BattleStateQueryInput {
battle_state_id: input.battle_state_id, battle_state_id: input.battle_state_id,
} }
} }
}
pub(crate) fn map_battle_state_input(input: DomainBattleStateInput) -> BattleStateInput { impl From<DomainBattleStateInput> for BattleStateInput {
BattleStateInput { fn from(input: DomainBattleStateInput) -> Self {
Self {
battle_state_id: input.battle_state_id, battle_state_id: input.battle_state_id,
story_session_id: input.story_session_id, story_session_id: input.story_session_id,
runtime_session_id: input.runtime_session_id, runtime_session_id: input.runtime_session_id,
@@ -386,11 +401,11 @@ pub(crate) fn map_battle_state_input(input: DomainBattleStateInput) -> BattleSta
created_at_micros: input.created_at_micros, created_at_micros: input.created_at_micros,
} }
} }
}
pub(crate) fn map_resolve_combat_action_input( impl From<DomainResolveCombatActionInput> for ResolveCombatActionInput {
input: DomainResolveCombatActionInput, fn from(input: DomainResolveCombatActionInput) -> Self {
) -> ResolveCombatActionInput { Self {
ResolveCombatActionInput {
battle_state_id: input.battle_state_id, battle_state_id: input.battle_state_id,
function_id: input.function_id, function_id: input.function_id,
action_text: input.action_text, action_text: input.action_text,
@@ -402,6 +417,7 @@ pub(crate) fn map_resolve_combat_action_input(
updated_at_micros: input.updated_at_micros, updated_at_micros: input.updated_at_micros,
} }
} }
}
pub(crate) fn map_procedure_result( pub(crate) fn map_procedure_result(
result: AssetObjectProcedureResult, result: AssetObjectProcedureResult,
@@ -482,14 +498,36 @@ pub(crate) fn map_auth_store_snapshot_procedure_result(
} }
pub(crate) fn map_auth_store_snapshot_record( pub(crate) fn map_auth_store_snapshot_record(
record: AuthStoreSnapshotRecord, record: crate::module_bindings::AuthStoreSnapshotRecord,
) -> AuthStoreSnapshotRecord { ) -> crate::AuthStoreSnapshotRecord {
AuthStoreSnapshotRecord { crate::AuthStoreSnapshotRecord {
snapshot_json: record.snapshot_json, snapshot_json: record.snapshot_json,
updated_at_micros: record.updated_at_micros, updated_at_micros: record.updated_at_micros,
} }
} }
pub(crate) fn map_auth_store_snapshot_import_procedure_result(
result: AuthStoreSnapshotImportProcedureResult,
) -> Result<AuthStoreSnapshotImportRecord, SpacetimeClientError> {
if !result.ok {
return Err(SpacetimeClientError::Procedure(
result
.error_message
.unwrap_or_else(|| "SpacetimeDB procedure ??????".to_string()),
));
}
let record = result.record.ok_or_else(|| {
SpacetimeClientError::Procedure("SpacetimeDB procedure ???????".to_string())
})?;
Ok(AuthStoreSnapshotImportRecord {
imported_user_count: record.imported_user_count,
imported_identity_count: record.imported_identity_count,
imported_refresh_session_count: record.imported_refresh_session_count,
})
}
pub(crate) fn map_runtime_browse_history_procedure_result( pub(crate) fn map_runtime_browse_history_procedure_result(
result: RuntimeBrowseHistoryProcedureResult, result: RuntimeBrowseHistoryProcedureResult,
) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> { ) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> {
@@ -1297,7 +1335,7 @@ pub(crate) fn map_runtime_profile_wallet_ledger_entry_snapshot(
user_id: snapshot.user_id, user_id: snapshot.user_id,
amount_delta: snapshot.amount_delta, amount_delta: snapshot.amount_delta,
balance_after: snapshot.balance_after, balance_after: snapshot.balance_after,
source_type: map_runtime_profile_wallet_ledger_source_type(snapshot.source_type), source_type: map_runtime_profile_wallet_ledger_source_type_back(snapshot.source_type),
created_at_micros: snapshot.created_at_micros, created_at_micros: snapshot.created_at_micros,
} }
} }
@@ -1699,7 +1737,9 @@ pub(crate) fn map_custom_world_draft_card_detail_section_snapshot(
} }
} }
pub(crate) fn map_big_fish_session_snapshot(snapshot: BigFishSessionSnapshot) -> BigFishSessionRecord { pub(crate) fn map_big_fish_session_snapshot(
snapshot: BigFishSessionSnapshot,
) -> BigFishSessionRecord {
BigFishSessionRecord { BigFishSessionRecord {
session_id: snapshot.session_id, session_id: snapshot.session_id,
current_turn: snapshot.current_turn, current_turn: snapshot.current_turn,
@@ -1770,7 +1810,9 @@ pub(crate) fn map_puzzle_anchor_item(snapshot: DomainPuzzleAnchorItem) -> Puzzle
} }
} }
pub(crate) fn map_puzzle_result_draft(snapshot: DomainPuzzleResultDraft) -> PuzzleResultDraftRecord { pub(crate) fn map_puzzle_result_draft(
snapshot: DomainPuzzleResultDraft,
) -> PuzzleResultDraftRecord {
PuzzleResultDraftRecord { PuzzleResultDraftRecord {
level_name: snapshot.level_name, level_name: snapshot.level_name,
summary: snapshot.summary, summary: snapshot.summary,
@@ -1790,7 +1832,9 @@ pub(crate) fn map_puzzle_result_draft(snapshot: DomainPuzzleResultDraft) -> Puzz
} }
} }
pub(crate) fn map_puzzle_creator_intent(snapshot: DomainPuzzleCreatorIntent) -> PuzzleCreatorIntentRecord { pub(crate) fn map_puzzle_creator_intent(
snapshot: DomainPuzzleCreatorIntent,
) -> PuzzleCreatorIntentRecord {
PuzzleCreatorIntentRecord { PuzzleCreatorIntentRecord {
source_mode: snapshot.source_mode, source_mode: snapshot.source_mode,
raw_messages_summary: snapshot.raw_messages_summary, raw_messages_summary: snapshot.raw_messages_summary,
@@ -1879,7 +1923,9 @@ pub(crate) fn map_puzzle_result_preview_finding(
} }
} }
pub(crate) fn map_puzzle_work_profile(snapshot: DomainPuzzleWorkProfile) -> PuzzleWorkProfileRecord { pub(crate) fn map_puzzle_work_profile(
snapshot: DomainPuzzleWorkProfile,
) -> PuzzleWorkProfileRecord {
PuzzleWorkProfileRecord { PuzzleWorkProfileRecord {
work_id: snapshot.work_id, work_id: snapshot.work_id,
profile_id: snapshot.profile_id, profile_id: snapshot.profile_id,
@@ -1977,7 +2023,9 @@ pub(crate) fn map_puzzle_merged_group_state(
} }
} }
pub(crate) fn map_puzzle_cell_position(snapshot: DomainPuzzleCellPosition) -> PuzzleCellPositionRecord { pub(crate) fn map_puzzle_cell_position(
snapshot: DomainPuzzleCellPosition,
) -> PuzzleCellPositionRecord {
PuzzleCellPositionRecord { PuzzleCellPositionRecord {
row: snapshot.row, row: snapshot.row,
col: snapshot.col, col: snapshot.col,
@@ -2107,7 +2155,9 @@ pub(crate) fn map_big_fish_agent_message_snapshot(
} }
} }
pub(crate) fn map_big_fish_runtime_snapshot(snapshot: BigFishRuntimeSnapshot) -> BigFishRuntimeRecord { pub(crate) fn map_big_fish_runtime_snapshot(
snapshot: BigFishRuntimeSnapshot,
) -> BigFishRuntimeRecord {
BigFishRuntimeRecord { BigFishRuntimeRecord {
run_id: snapshot.run_id, run_id: snapshot.run_id,
session_id: snapshot.session_id, session_id: snapshot.session_id,
@@ -2254,7 +2304,9 @@ pub(crate) fn map_story_event_snapshot(snapshot: StoryEventSnapshot) -> StoryEve
} }
} }
pub(crate) fn map_battle_state_snapshot(snapshot: BattleStateSnapshot) -> DomainBattleStateSnapshot { pub(crate) fn map_battle_state_snapshot(
snapshot: BattleStateSnapshot,
) -> DomainBattleStateSnapshot {
DomainBattleStateSnapshot { DomainBattleStateSnapshot {
battle_state_id: snapshot.battle_state_id, battle_state_id: snapshot.battle_state_id,
story_session_id: snapshot.story_session_id, story_session_id: snapshot.story_session_id,
@@ -2356,7 +2408,9 @@ pub(crate) fn map_inventory_slot_snapshot(
} }
} }
pub(crate) fn map_npc_interaction_result(result: NpcInteractionResult) -> DomainNpcInteractionResult { pub(crate) fn map_npc_interaction_result(
result: NpcInteractionResult,
) -> DomainNpcInteractionResult {
DomainNpcInteractionResult { DomainNpcInteractionResult {
npc_state: map_npc_state_snapshot(result.npc_state), npc_state: map_npc_state_snapshot(result.npc_state),
interaction_status: map_npc_interaction_status(result.interaction_status), interaction_status: map_npc_interaction_status(result.interaction_status),
@@ -2414,7 +2468,9 @@ pub(crate) fn map_npc_stance_profile(value: NpcStanceProfile) -> DomainNpcStance
} }
} }
pub(crate) fn map_npc_interaction_status(value: NpcInteractionStatus) -> DomainNpcInteractionStatus { pub(crate) fn map_npc_interaction_status(
value: NpcInteractionStatus,
) -> DomainNpcInteractionStatus {
match value { match value {
NpcInteractionStatus::Previewed => DomainNpcInteractionStatus::Previewed, NpcInteractionStatus::Previewed => DomainNpcInteractionStatus::Previewed,
NpcInteractionStatus::Dialogue => DomainNpcInteractionStatus::Dialogue, NpcInteractionStatus::Dialogue => DomainNpcInteractionStatus::Dialogue,
@@ -2470,20 +2526,12 @@ pub(crate) fn map_access_policy_back(
} }
} }
pub(crate) fn map_runtime_platform_theme(value: RuntimePlatformTheme) -> RuntimePlatformTheme { pub(crate) fn map_runtime_platform_theme(
value: DomainRuntimePlatformTheme,
) -> crate::module_bindings::RuntimePlatformTheme {
match value { match value {
RuntimePlatformTheme::Light => RuntimePlatformTheme::Light, DomainRuntimePlatformTheme::Light => crate::module_bindings::RuntimePlatformTheme::Light,
RuntimePlatformTheme::Dark => RuntimePlatformTheme::Dark, DomainRuntimePlatformTheme::Dark => crate::module_bindings::RuntimePlatformTheme::Dark,
}
}
pub(crate) fn map_runtime_profile_wallet_ledger_source_type(
value: RuntimeProfileWalletLedgerSourceType,
) -> RuntimeProfileWalletLedgerSourceType {
match value {
RuntimeProfileWalletLedgerSourceType::SnapshotSync => {
RuntimeProfileWalletLedgerSourceType::SnapshotSync
}
} }
} }
@@ -2495,9 +2543,7 @@ pub(crate) fn map_runtime_item_reward_item_rarity(
DomainRuntimeItemRewardItemRarity::Uncommon => RuntimeItemRewardItemRarity::Uncommon, DomainRuntimeItemRewardItemRarity::Uncommon => RuntimeItemRewardItemRarity::Uncommon,
DomainRuntimeItemRewardItemRarity::Rare => RuntimeItemRewardItemRarity::Rare, DomainRuntimeItemRewardItemRarity::Rare => RuntimeItemRewardItemRarity::Rare,
DomainRuntimeItemRewardItemRarity::Epic => RuntimeItemRewardItemRarity::Epic, DomainRuntimeItemRewardItemRarity::Epic => RuntimeItemRewardItemRarity::Epic,
DomainRuntimeItemRewardItemRarity::Legendary => { DomainRuntimeItemRewardItemRarity::Legendary => RuntimeItemRewardItemRarity::Legendary,
RuntimeItemRewardItemRarity::Legendary
}
} }
} }
@@ -2511,7 +2557,9 @@ pub(crate) fn map_runtime_item_equipment_slot(
} }
} }
pub(crate) fn map_custom_world_theme_mode(value: DomainCustomWorldThemeMode) -> CustomWorldThemeMode { pub(crate) fn map_custom_world_theme_mode(
value: DomainCustomWorldThemeMode,
) -> CustomWorldThemeMode {
match value { match value {
DomainCustomWorldThemeMode::Martial => CustomWorldThemeMode::Martial, DomainCustomWorldThemeMode::Martial => CustomWorldThemeMode::Martial,
DomainCustomWorldThemeMode::Arcane => CustomWorldThemeMode::Arcane, DomainCustomWorldThemeMode::Arcane => CustomWorldThemeMode::Arcane,
@@ -2529,10 +2577,12 @@ pub(crate) fn map_battle_mode(value: DomainBattleMode) -> BattleMode {
} }
} }
pub(crate) fn map_runtime_platform_theme_back(value: RuntimePlatformTheme) -> RuntimePlatformTheme { pub(crate) fn map_runtime_platform_theme_back(
value: crate::module_bindings::RuntimePlatformTheme,
) -> DomainRuntimePlatformTheme {
match value { match value {
RuntimePlatformTheme::Light => RuntimePlatformTheme::Light, crate::module_bindings::RuntimePlatformTheme::Light => DomainRuntimePlatformTheme::Light,
RuntimePlatformTheme::Dark => RuntimePlatformTheme::Dark, crate::module_bindings::RuntimePlatformTheme::Dark => DomainRuntimePlatformTheme::Dark,
} }
} }
@@ -2544,9 +2594,7 @@ pub(crate) fn map_runtime_item_reward_item_rarity_back(
RuntimeItemRewardItemRarity::Uncommon => DomainRuntimeItemRewardItemRarity::Uncommon, RuntimeItemRewardItemRarity::Uncommon => DomainRuntimeItemRewardItemRarity::Uncommon,
RuntimeItemRewardItemRarity::Rare => DomainRuntimeItemRewardItemRarity::Rare, RuntimeItemRewardItemRarity::Rare => DomainRuntimeItemRewardItemRarity::Rare,
RuntimeItemRewardItemRarity::Epic => DomainRuntimeItemRewardItemRarity::Epic, RuntimeItemRewardItemRarity::Epic => DomainRuntimeItemRewardItemRarity::Epic,
RuntimeItemRewardItemRarity::Legendary => { RuntimeItemRewardItemRarity::Legendary => DomainRuntimeItemRewardItemRarity::Legendary,
DomainRuntimeItemRewardItemRarity::Legendary
}
} }
} }
@@ -2573,7 +2621,9 @@ pub(crate) fn map_custom_world_theme_mode_back(
} }
} }
pub(crate) fn map_custom_world_publication_status(value: CustomWorldPublicationStatus) -> &'static str { pub(crate) fn map_custom_world_publication_status(
value: CustomWorldPublicationStatus,
) -> &'static str {
match value { match value {
CustomWorldPublicationStatus::Draft => "draft", CustomWorldPublicationStatus::Draft => "draft",
CustomWorldPublicationStatus::Published => "published", CustomWorldPublicationStatus::Published => "published",
@@ -2671,6 +2721,8 @@ pub(crate) fn format_rpg_agent_operation_type(
crate::module_bindings::RpgAgentOperationType::ExpandLongTail => "expand_long_tail", crate::module_bindings::RpgAgentOperationType::ExpandLongTail => "expand_long_tail",
crate::module_bindings::RpgAgentOperationType::PublishWorld => "publish_world", crate::module_bindings::RpgAgentOperationType::PublishWorld => "publish_world",
crate::module_bindings::RpgAgentOperationType::RevertCheckpoint => "revert_checkpoint", crate::module_bindings::RpgAgentOperationType::RevertCheckpoint => "revert_checkpoint",
crate::module_bindings::RpgAgentOperationType::DeleteCharacters => "delete_characters",
crate::module_bindings::RpgAgentOperationType::DeleteLandmarks => "delete_landmarks",
} }
} }
@@ -2739,18 +2791,51 @@ pub(crate) fn format_custom_world_role_asset_status_back(
.to_string() .to_string()
} }
pub(crate) fn map_big_fish_asset_kind_input( impl TryFrom<&str> for BigFishAssetKind {
value: &str, type Error = SpacetimeClientError;
) -> Result<BigFishAssetKind, SpacetimeClientError> {
fn try_from(value: &str) -> Result<Self, Self::Error> {
match value.trim() { match value.trim() {
"level_main_image" => Ok(BigFishAssetKind::LevelMainImage), "level_main_image" => Ok(Self::LevelMainImage),
"level_motion" => Ok(BigFishAssetKind::LevelMotion), "level_motion" => Ok(Self::LevelMotion),
"stage_background" => Ok(BigFishAssetKind::StageBackground), "stage_background" => Ok(Self::StageBackground),
other => Err(SpacetimeClientError::Runtime(format!( other => Err(SpacetimeClientError::Runtime(format!(
"big fish asset kind `{other}` 当前尚未支持" "big fish asset kind `{other}` 当前尚未支持"
))), ))),
} }
} }
}
pub(crate) fn map_big_fish_creation_stage(
value: module_big_fish::BigFishCreationStage,
) -> BigFishCreationStage {
match value {
module_big_fish::BigFishCreationStage::CollectingAnchors => {
BigFishCreationStage::CollectingAnchors
}
module_big_fish::BigFishCreationStage::DraftReady => BigFishCreationStage::DraftReady,
module_big_fish::BigFishCreationStage::AssetRefining => BigFishCreationStage::AssetRefining,
module_big_fish::BigFishCreationStage::ReadyToPublish => {
BigFishCreationStage::ReadyToPublish
}
module_big_fish::BigFishCreationStage::Published => BigFishCreationStage::Published,
}
}
pub(crate) fn parse_big_fish_creation_stage(
value: &str,
) -> Result<BigFishCreationStage, SpacetimeClientError> {
match value.trim() {
"collecting_anchors" => Ok(BigFishCreationStage::CollectingAnchors),
"draft_ready" => Ok(BigFishCreationStage::DraftReady),
"asset_refining" => Ok(BigFishCreationStage::AssetRefining),
"ready_to_publish" => Ok(BigFishCreationStage::ReadyToPublish),
"published" => Ok(BigFishCreationStage::Published),
other => Err(SpacetimeClientError::Runtime(format!(
"big fish creation stage `{other}` ??????"
))),
}
}
pub(crate) fn format_big_fish_creation_stage(value: BigFishCreationStage) -> &'static str { pub(crate) fn format_big_fish_creation_stage(value: BigFishCreationStage) -> &'static str {
match value { match value {
@@ -2830,15 +2915,37 @@ pub(crate) fn map_battle_mode_back(value: BattleMode) -> DomainBattleMode {
} }
pub(crate) fn map_runtime_browse_history_theme_mode_back( pub(crate) fn map_runtime_browse_history_theme_mode_back(
value: RuntimeBrowseHistoryThemeMode, value: crate::module_bindings::RuntimeBrowseHistoryThemeMode,
) -> RuntimeBrowseHistoryThemeMode { ) -> module_runtime::RuntimeBrowseHistoryThemeMode {
match value { match value {
RuntimeBrowseHistoryThemeMode::Martial => RuntimeBrowseHistoryThemeMode::Martial, crate::module_bindings::RuntimeBrowseHistoryThemeMode::Martial => {
RuntimeBrowseHistoryThemeMode::Arcane => RuntimeBrowseHistoryThemeMode::Arcane, module_runtime::RuntimeBrowseHistoryThemeMode::Martial
RuntimeBrowseHistoryThemeMode::Machina => RuntimeBrowseHistoryThemeMode::Machina, }
RuntimeBrowseHistoryThemeMode::Tide => RuntimeBrowseHistoryThemeMode::Tide, crate::module_bindings::RuntimeBrowseHistoryThemeMode::Arcane => {
RuntimeBrowseHistoryThemeMode::Rift => RuntimeBrowseHistoryThemeMode::Rift, module_runtime::RuntimeBrowseHistoryThemeMode::Arcane
RuntimeBrowseHistoryThemeMode::Mythic => RuntimeBrowseHistoryThemeMode::Mythic, }
crate::module_bindings::RuntimeBrowseHistoryThemeMode::Machina => {
module_runtime::RuntimeBrowseHistoryThemeMode::Machina
}
crate::module_bindings::RuntimeBrowseHistoryThemeMode::Tide => {
module_runtime::RuntimeBrowseHistoryThemeMode::Tide
}
crate::module_bindings::RuntimeBrowseHistoryThemeMode::Rift => {
module_runtime::RuntimeBrowseHistoryThemeMode::Rift
}
crate::module_bindings::RuntimeBrowseHistoryThemeMode::Mythic => {
module_runtime::RuntimeBrowseHistoryThemeMode::Mythic
}
}
}
pub(crate) fn map_runtime_profile_wallet_ledger_source_type_back(
value: crate::module_bindings::RuntimeProfileWalletLedgerSourceType,
) -> module_runtime::RuntimeProfileWalletLedgerSourceType {
match value {
crate::module_bindings::RuntimeProfileWalletLedgerSourceType::SnapshotSync => {
module_runtime::RuntimeProfileWalletLedgerSourceType::SnapshotSync
}
} }
} }
@@ -2896,9 +3003,7 @@ pub(crate) fn map_ai_result_reference_kind(
AiResultReferenceKind::CustomWorldProfile AiResultReferenceKind::CustomWorldProfile
} }
DomainAiResultReferenceKind::QuestRecord => AiResultReferenceKind::QuestRecord, DomainAiResultReferenceKind::QuestRecord => AiResultReferenceKind::QuestRecord,
DomainAiResultReferenceKind::RuntimeItemRecord => { DomainAiResultReferenceKind::RuntimeItemRecord => AiResultReferenceKind::RuntimeItemRecord,
AiResultReferenceKind::RuntimeItemRecord
}
DomainAiResultReferenceKind::AssetObject => AiResultReferenceKind::AssetObject, DomainAiResultReferenceKind::AssetObject => AiResultReferenceKind::AssetObject,
} }
} }
@@ -3001,7 +3106,10 @@ pub(crate) fn map_runtime_item_reward_item_snapshot_back(
} }
} }
pub(crate) fn parse_json_value(value: &str, label: &str) -> Result<serde_json::Value, SpacetimeClientError> { pub(crate) fn parse_json_value(
value: &str,
label: &str,
) -> Result<serde_json::Value, SpacetimeClientError> {
serde_json::from_str::<serde_json::Value>(value) serde_json::from_str::<serde_json::Value>(value)
.map_err(|error| SpacetimeClientError::Runtime(format!("{label} 非法: {error}"))) .map_err(|error| SpacetimeClientError::Runtime(format!("{label} 非法: {error}")))
} }
@@ -3029,7 +3137,10 @@ pub(crate) fn parse_json_array(
} }
} }
pub(crate) fn parse_json_string_array(value: &str, label: &str) -> Result<Vec<String>, SpacetimeClientError> { pub(crate) fn parse_json_string_array(
value: &str,
label: &str,
) -> Result<Vec<String>, SpacetimeClientError> {
parse_json_array(value, label)? parse_json_array(value, label)?
.into_iter() .into_iter()
.map(|entry| match entry { .map(|entry| match entry {
@@ -3907,6 +4018,19 @@ pub struct BigFishMessageSubmitRecordInput {
pub submitted_at_micros: i64, pub submitted_at_micros: i64,
} }
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct BigFishMessageFinalizeRecordInput {
pub session_id: String,
pub owner_user_id: String,
pub assistant_message_id: Option<String>,
pub assistant_reply_text: Option<String>,
pub stage: String,
pub progress_percent: u32,
pub anchor_pack_json: String,
pub error_message: Option<String>,
pub updated_at_micros: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub struct BigFishAssetGenerateRecordInput { pub struct BigFishAssetGenerateRecordInput {
pub session_id: String, pub session_id: String,
@@ -4274,11 +4398,12 @@ pub(crate) fn build_resolve_combat_action_record(
} }
} }
pub(crate) fn map_resolve_npc_battle_interaction_input( impl From<ResolveNpcBattleInteractionInput>
input: ResolveNpcBattleInteractionInput, for crate::module_bindings::ResolveNpcBattleInteractionInput
) -> ResolveNpcBattleInteractionInput { {
ResolveNpcBattleInteractionInput { fn from(input: ResolveNpcBattleInteractionInput) -> Self {
npc_interaction: ResolveNpcInteractionInput { Self {
npc_interaction: crate::module_bindings::ResolveNpcInteractionInput {
runtime_session_id: input.npc_interaction.runtime_session_id, runtime_session_id: input.npc_interaction.runtime_session_id,
npc_id: input.npc_interaction.npc_id, npc_id: input.npc_interaction.npc_id,
npc_name: input.npc_interaction.npc_name, npc_name: input.npc_interaction.npc_name,
@@ -4303,6 +4428,7 @@ pub(crate) fn map_resolve_npc_battle_interaction_input(
.collect(), .collect(),
} }
} }
}
pub(crate) fn validate_npc_battle_interaction_input( pub(crate) fn validate_npc_battle_interaction_input(
input: &ResolveNpcBattleInteractionInput, input: &ResolveNpcBattleInteractionInput,
@@ -4369,7 +4495,9 @@ pub(crate) fn build_npc_state_record(snapshot: DomainNpcStateSnapshot) -> NpcSta
} }
} }
pub(crate) fn build_npc_interaction_record(result: DomainNpcInteractionResult) -> NpcInteractionRecord { pub(crate) fn build_npc_interaction_record(
result: DomainNpcInteractionResult,
) -> NpcInteractionRecord {
NpcInteractionRecord { NpcInteractionRecord {
npc_state: build_npc_state_record(result.npc_state), npc_state: build_npc_state_record(result.npc_state),
interaction_status: format_npc_interaction_status(result.interaction_status).to_string(), interaction_status: format_npc_interaction_status(result.interaction_status).to_string(),
@@ -4416,7 +4544,9 @@ pub(crate) fn format_npc_interaction_status(value: DomainNpcInteractionStatus) -
} }
} }
pub(crate) fn format_npc_interaction_battle_mode(value: DomainNpcInteractionBattleMode) -> &'static str { pub(crate) fn format_npc_interaction_battle_mode(
value: DomainNpcInteractionBattleMode,
) -> &'static str {
match value { match value {
DomainNpcInteractionBattleMode::Fight => "fight", DomainNpcInteractionBattleMode::Fight => "fight",
DomainNpcInteractionBattleMode::Spar => "spar", DomainNpcInteractionBattleMode::Spar => "spar",
@@ -4427,12 +4557,8 @@ pub(crate) fn map_inventory_container_kind(
value: InventoryContainerKind, value: InventoryContainerKind,
) -> module_inventory::InventoryContainerKind { ) -> module_inventory::InventoryContainerKind {
match value { match value {
InventoryContainerKind::Backpack => { InventoryContainerKind::Backpack => module_inventory::InventoryContainerKind::Backpack,
module_inventory::InventoryContainerKind::Backpack InventoryContainerKind::Equipment => module_inventory::InventoryContainerKind::Equipment,
}
InventoryContainerKind::Equipment => {
module_inventory::InventoryContainerKind::Equipment
}
} }
} }
@@ -4471,12 +4597,8 @@ pub(crate) fn map_inventory_item_source_kind(
InventoryItemSourceKind::TreasureReward => { InventoryItemSourceKind::TreasureReward => {
module_inventory::InventoryItemSourceKind::TreasureReward module_inventory::InventoryItemSourceKind::TreasureReward
} }
InventoryItemSourceKind::NpcGift => { InventoryItemSourceKind::NpcGift => module_inventory::InventoryItemSourceKind::NpcGift,
module_inventory::InventoryItemSourceKind::NpcGift InventoryItemSourceKind::NpcTrade => module_inventory::InventoryItemSourceKind::NpcTrade,
}
InventoryItemSourceKind::NpcTrade => {
module_inventory::InventoryItemSourceKind::NpcTrade
}
InventoryItemSourceKind::CombatDrop => { InventoryItemSourceKind::CombatDrop => {
module_inventory::InventoryItemSourceKind::CombatDrop module_inventory::InventoryItemSourceKind::CombatDrop
} }
@@ -4491,4 +4613,3 @@ pub(crate) fn map_inventory_item_source_kind(
} }
} }
} }

View File

@@ -0,0 +1,163 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::auth_identity_type::AuthIdentity;
/// Table handle for the table `auth_identity`.
///
/// Obtain a handle from the [`AuthIdentityTableAccess::auth_identity`] method on [`super::RemoteTables`],
/// like `ctx.db.auth_identity()`.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.auth_identity().on_insert(...)`.
pub struct AuthIdentityTableHandle<'ctx> {
imp: __sdk::TableHandle<AuthIdentity>,
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the table `auth_identity`.
///
/// Implemented for [`super::RemoteTables`].
pub trait AuthIdentityTableAccess {
#[allow(non_snake_case)]
/// Obtain a [`AuthIdentityTableHandle`], which mediates access to the table `auth_identity`.
fn auth_identity(&self) -> AuthIdentityTableHandle<'_>;
}
impl AuthIdentityTableAccess for super::RemoteTables {
fn auth_identity(&self) -> AuthIdentityTableHandle<'_> {
AuthIdentityTableHandle {
imp: self.imp.get_table::<AuthIdentity>("auth_identity"),
ctx: std::marker::PhantomData,
}
}
}
pub struct AuthIdentityInsertCallbackId(__sdk::CallbackId);
pub struct AuthIdentityDeleteCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::Table for AuthIdentityTableHandle<'ctx> {
type Row = AuthIdentity;
type EventContext = super::EventContext;
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = AuthIdentity> + '_ { self.imp.iter() }
type InsertCallbackId = AuthIdentityInsertCallbackId;
fn on_insert(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> AuthIdentityInsertCallbackId {
AuthIdentityInsertCallbackId(self.imp.on_insert(Box::new(callback)))
}
fn remove_on_insert(&self, callback: AuthIdentityInsertCallbackId) {
self.imp.remove_on_insert(callback.0)
}
type DeleteCallbackId = AuthIdentityDeleteCallbackId;
fn on_delete(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> AuthIdentityDeleteCallbackId {
AuthIdentityDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
}
fn remove_on_delete(&self, callback: AuthIdentityDeleteCallbackId) {
self.imp.remove_on_delete(callback.0)
}
}
pub struct AuthIdentityUpdateCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::TableWithPrimaryKey for AuthIdentityTableHandle<'ctx> {
type UpdateCallbackId = AuthIdentityUpdateCallbackId;
fn on_update(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
) -> AuthIdentityUpdateCallbackId {
AuthIdentityUpdateCallbackId(self.imp.on_update(Box::new(callback)))
}
fn remove_on_update(&self, callback: AuthIdentityUpdateCallbackId) {
self.imp.remove_on_update(callback.0)
}
}
/// Access to the `identity_id` unique index on the table `auth_identity`,
/// which allows point queries on the field of the same name
/// via the [`AuthIdentityIdentityIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.auth_identity().identity_id().find(...)`.
pub struct AuthIdentityIdentityIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<AuthIdentity, String>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> AuthIdentityTableHandle<'ctx> {
/// Get a handle on the `identity_id` unique index on the table `auth_identity`.
pub fn identity_id(&self) -> AuthIdentityIdentityIdUnique<'ctx> {
AuthIdentityIdentityIdUnique {
imp: self.imp.get_unique_constraint::<String>("identity_id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> AuthIdentityIdentityIdUnique<'ctx> {
/// Find the subscribed row whose `identity_id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &String) -> Option<AuthIdentity> {
self.imp.find(col_val)
}
}
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<AuthIdentity>("auth_identity");
_table.add_unique_constraint::<String>("identity_id", |row| &row.identity_id);
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::v2::TableUpdate,
) -> __sdk::Result<__sdk::TableUpdate<AuthIdentity>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse(
"TableUpdate<AuthIdentity>",
"TableUpdate",
).with_cause(e).into()
})
}
#[allow(non_camel_case_types)]
/// Extension trait for query builder access to the table `AuthIdentity`.
///
/// Implemented for [`__sdk::QueryTableAccessor`].
pub trait auth_identityQueryTableAccess {
#[allow(non_snake_case)]
/// Get a query builder for the table `AuthIdentity`.
fn auth_identity(&self) -> __sdk::__query_builder::Table<AuthIdentity>;
}
impl auth_identityQueryTableAccess for __sdk::QueryTableAccessor {
fn auth_identity(&self) -> __sdk::__query_builder::Table<AuthIdentity> {
__sdk::__query_builder::Table::new("auth_identity")
}
}

View File

@@ -0,0 +1,83 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub struct AuthIdentity {
pub identity_id: String,
pub user_id: String,
pub provider: String,
pub provider_uid: String,
pub provider_union_id: Option::<String>,
pub phone_e_164: Option::<String>,
pub display_name: Option::<String>,
pub avatar_url: Option::<String>,
}
impl __sdk::InModule for AuthIdentity {
type Module = super::RemoteModule;
}
/// Column accessor struct for the table `AuthIdentity`.
///
/// Provides typed access to columns for query building.
pub struct AuthIdentityCols {
pub identity_id: __sdk::__query_builder::Col<AuthIdentity, String>,
pub user_id: __sdk::__query_builder::Col<AuthIdentity, String>,
pub provider: __sdk::__query_builder::Col<AuthIdentity, String>,
pub provider_uid: __sdk::__query_builder::Col<AuthIdentity, String>,
pub provider_union_id: __sdk::__query_builder::Col<AuthIdentity, Option::<String>>,
pub phone_e_164: __sdk::__query_builder::Col<AuthIdentity, Option::<String>>,
pub display_name: __sdk::__query_builder::Col<AuthIdentity, Option::<String>>,
pub avatar_url: __sdk::__query_builder::Col<AuthIdentity, Option::<String>>,
}
impl __sdk::__query_builder::HasCols for AuthIdentity {
type Cols = AuthIdentityCols;
fn cols(table_name: &'static str) -> Self::Cols {
AuthIdentityCols {
identity_id: __sdk::__query_builder::Col::new(table_name, "identity_id"),
user_id: __sdk::__query_builder::Col::new(table_name, "user_id"),
provider: __sdk::__query_builder::Col::new(table_name, "provider"),
provider_uid: __sdk::__query_builder::Col::new(table_name, "provider_uid"),
provider_union_id: __sdk::__query_builder::Col::new(table_name, "provider_union_id"),
phone_e_164: __sdk::__query_builder::Col::new(table_name, "phone_e_164"),
display_name: __sdk::__query_builder::Col::new(table_name, "display_name"),
avatar_url: __sdk::__query_builder::Col::new(table_name, "avatar_url"),
}
}
}
/// Indexed column accessor struct for the table `AuthIdentity`.
///
/// Provides typed access to indexed columns for query building.
pub struct AuthIdentityIxCols {
pub identity_id: __sdk::__query_builder::IxCol<AuthIdentity, String>,
pub user_id: __sdk::__query_builder::IxCol<AuthIdentity, String>,
}
impl __sdk::__query_builder::HasIxCols for AuthIdentity {
type IxCols = AuthIdentityIxCols;
fn ix_cols(table_name: &'static str) -> Self::IxCols {
AuthIdentityIxCols {
identity_id: __sdk::__query_builder::IxCol::new(table_name, "identity_id"),
user_id: __sdk::__query_builder::IxCol::new(table_name, "user_id"),
}
}
}
impl __sdk::__query_builder::CanBeLookupTable for AuthIdentity {}

View File

@@ -0,0 +1,26 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::auth_store_snapshot_import_record_type::AuthStoreSnapshotImportRecord;
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub struct AuthStoreSnapshotImportProcedureResult {
pub ok: bool,
pub record: Option::<AuthStoreSnapshotImportRecord>,
pub error_message: Option::<String>,
}
impl __sdk::InModule for AuthStoreSnapshotImportProcedureResult {
type Module = super::RemoteModule;
}

View File

@@ -0,0 +1,25 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub struct AuthStoreSnapshotImportRecord {
pub imported_user_count: u32,
pub imported_identity_count: u32,
pub imported_refresh_session_count: u32,
}
impl __sdk::InModule for AuthStoreSnapshotImportRecord {
type Module = super::RemoteModule;
}

View File

@@ -0,0 +1,53 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::auth_store_snapshot_procedure_result_type::AuthStoreSnapshotProcedureResult;
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
struct ExportAuthStoreSnapshotFromTablesArgs {
}
impl __sdk::InModule for ExportAuthStoreSnapshotFromTablesArgs {
type Module = super::RemoteModule;
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the procedure `export_auth_store_snapshot_from_tables`.
///
/// Implemented for [`super::RemoteProcedures`].
pub trait export_auth_store_snapshot_from_tables {
fn export_auth_store_snapshot_from_tables(&self, ) {
self.export_auth_store_snapshot_from_tables_then( |_, _| {});
}
fn export_auth_store_snapshot_from_tables_then(
&self,
__callback: impl FnOnce(&super::ProcedureEventContext, Result<AuthStoreSnapshotProcedureResult, __sdk::InternalError>) + Send + 'static,
);
}
impl export_auth_store_snapshot_from_tables for super::RemoteProcedures {
fn export_auth_store_snapshot_from_tables_then(
&self,
__callback: impl FnOnce(&super::ProcedureEventContext, Result<AuthStoreSnapshotProcedureResult, __sdk::InternalError>) + Send + 'static,
) {
self.imp.invoke_procedure_with_callback::<_, AuthStoreSnapshotProcedureResult>(
"export_auth_store_snapshot_from_tables",
ExportAuthStoreSnapshotFromTablesArgs { },
__callback,
);
}
}

View File

@@ -0,0 +1,53 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::auth_store_snapshot_import_procedure_result_type::AuthStoreSnapshotImportProcedureResult;
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
struct ImportAuthStoreSnapshotArgs {
}
impl __sdk::InModule for ImportAuthStoreSnapshotArgs {
type Module = super::RemoteModule;
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the procedure `import_auth_store_snapshot`.
///
/// Implemented for [`super::RemoteProcedures`].
pub trait import_auth_store_snapshot {
fn import_auth_store_snapshot(&self, ) {
self.import_auth_store_snapshot_then( |_, _| {});
}
fn import_auth_store_snapshot_then(
&self,
__callback: impl FnOnce(&super::ProcedureEventContext, Result<AuthStoreSnapshotImportProcedureResult, __sdk::InternalError>) + Send + 'static,
);
}
impl import_auth_store_snapshot for super::RemoteProcedures {
fn import_auth_store_snapshot_then(
&self,
__callback: impl FnOnce(&super::ProcedureEventContext, Result<AuthStoreSnapshotImportProcedureResult, __sdk::InternalError>) + Send + 'static,
) {
self.imp.invoke_procedure_with_callback::<_, AuthStoreSnapshotImportProcedureResult>(
"import_auth_store_snapshot",
ImportAuthStoreSnapshotArgs { },
__callback,
);
}
}

View File

@@ -44,13 +44,13 @@ pub mod asset_object_access_policy_type;
pub mod asset_object_procedure_result_type; pub mod asset_object_procedure_result_type;
pub mod asset_object_upsert_input_type; pub mod asset_object_upsert_input_type;
pub mod asset_object_upsert_snapshot_type; pub mod asset_object_upsert_snapshot_type;
<<<<<<< HEAD pub mod auth_identity_type;
=======
pub mod auth_store_snapshot_type; pub mod auth_store_snapshot_type;
pub mod auth_store_snapshot_import_procedure_result_type;
pub mod auth_store_snapshot_import_record_type;
pub mod auth_store_snapshot_procedure_result_type; pub mod auth_store_snapshot_procedure_result_type;
pub mod auth_store_snapshot_record_type; pub mod auth_store_snapshot_record_type;
pub mod auth_store_snapshot_upsert_input_type; pub mod auth_store_snapshot_upsert_input_type;
>>>>>>> 4f272a50 ( Spacetime )
pub mod battle_mode_type; pub mod battle_mode_type;
pub mod battle_state_type; pub mod battle_state_type;
pub mod battle_state_input_type; pub mod battle_state_input_type;
@@ -245,6 +245,7 @@ pub mod quest_status_type;
pub mod quest_step_snapshot_type; pub mod quest_step_snapshot_type;
pub mod quest_treasure_inspected_signal_type; pub mod quest_treasure_inspected_signal_type;
pub mod quest_turn_in_input_type; pub mod quest_turn_in_input_type;
pub mod refresh_session_type;
pub mod resolve_combat_action_input_type; pub mod resolve_combat_action_input_type;
pub mod resolve_combat_action_procedure_result_type; pub mod resolve_combat_action_procedure_result_type;
pub mod resolve_combat_action_result_type; pub mod resolve_combat_action_result_type;
@@ -315,6 +316,7 @@ pub mod treasure_record_procedure_result_type;
pub mod treasure_record_snapshot_type; pub mod treasure_record_snapshot_type;
pub mod treasure_resolve_input_type; pub mod treasure_resolve_input_type;
pub mod unequip_inventory_item_input_type; pub mod unequip_inventory_item_input_type;
pub mod user_account_type;
pub mod user_browse_history_type; pub mod user_browse_history_type;
pub mod accept_quest_reducer; pub mod accept_quest_reducer;
pub mod acknowledge_quest_completion_reducer; pub mod acknowledge_quest_completion_reducer;
@@ -346,10 +348,8 @@ pub mod ai_task_stage_table;
pub mod ai_text_chunk_table; pub mod ai_text_chunk_table;
pub mod asset_entity_binding_table; pub mod asset_entity_binding_table;
pub mod asset_object_table; pub mod asset_object_table;
<<<<<<< HEAD pub mod auth_identity_table;
=======
pub mod auth_store_snapshot_table; pub mod auth_store_snapshot_table;
>>>>>>> 4f272a50 ( Spacetime )
pub mod battle_state_table; pub mod battle_state_table;
pub mod big_fish_agent_message_table; pub mod big_fish_agent_message_table;
pub mod big_fish_asset_slot_table; pub mod big_fish_asset_slot_table;
@@ -376,11 +376,13 @@ pub mod puzzle_runtime_run_table;
pub mod puzzle_work_profile_table; pub mod puzzle_work_profile_table;
pub mod quest_log_table; pub mod quest_log_table;
pub mod quest_record_table; pub mod quest_record_table;
pub mod refresh_session_table;
pub mod runtime_setting_table; pub mod runtime_setting_table;
pub mod runtime_snapshot_table; pub mod runtime_snapshot_table;
pub mod story_event_table; pub mod story_event_table;
pub mod story_session_table; pub mod story_session_table;
pub mod treasure_record_table; pub mod treasure_record_table;
pub mod user_account_table;
pub mod user_browse_history_table; pub mod user_browse_history_table;
pub mod advance_puzzle_next_level_procedure; pub mod advance_puzzle_next_level_procedure;
pub mod append_ai_text_chunk_and_return_procedure; pub mod append_ai_text_chunk_and_return_procedure;
@@ -406,18 +408,13 @@ pub mod delete_custom_world_profile_and_return_procedure;
pub mod delete_runtime_snapshot_and_return_procedure; pub mod delete_runtime_snapshot_and_return_procedure;
pub mod drag_puzzle_piece_or_group_procedure; pub mod drag_puzzle_piece_or_group_procedure;
pub mod execute_custom_world_agent_action_procedure; pub mod execute_custom_world_agent_action_procedure;
pub mod export_auth_store_snapshot_from_tables_procedure;
pub mod fail_ai_task_and_return_procedure; pub mod fail_ai_task_and_return_procedure;
<<<<<<< HEAD
pub mod finalize_big_fish_agent_message_turn_procedure; pub mod finalize_big_fish_agent_message_turn_procedure;
pub mod finalize_custom_world_agent_message_turn_procedure; pub mod finalize_custom_world_agent_message_turn_procedure;
pub mod finalize_puzzle_agent_message_turn_procedure; pub mod finalize_puzzle_agent_message_turn_procedure;
pub mod generate_big_fish_asset_procedure; pub mod generate_big_fish_asset_procedure;
=======
pub mod finalize_custom_world_agent_message_turn_procedure;
pub mod finalize_puzzle_agent_message_turn_procedure;
pub mod generate_big_fish_asset_procedure;
pub mod get_auth_store_snapshot_procedure; pub mod get_auth_store_snapshot_procedure;
>>>>>>> 4f272a50 ( Spacetime )
pub mod get_battle_state_procedure; pub mod get_battle_state_procedure;
pub mod get_big_fish_run_procedure; pub mod get_big_fish_run_procedure;
pub mod get_big_fish_session_procedure; pub mod get_big_fish_session_procedure;
@@ -440,6 +437,7 @@ pub mod get_runtime_setting_or_default_procedure;
pub mod get_runtime_snapshot_procedure; pub mod get_runtime_snapshot_procedure;
pub mod get_story_session_state_procedure; pub mod get_story_session_state_procedure;
pub mod grant_player_progression_experience_and_return_procedure; pub mod grant_player_progression_experience_and_return_procedure;
pub mod import_auth_store_snapshot_procedure;
pub mod list_big_fish_works_procedure; pub mod list_big_fish_works_procedure;
pub mod list_custom_world_gallery_entries_procedure; pub mod list_custom_world_gallery_entries_procedure;
pub mod list_custom_world_profiles_procedure; pub mod list_custom_world_profiles_procedure;
@@ -511,13 +509,13 @@ pub use asset_object_access_policy_type::AssetObjectAccessPolicy;
pub use asset_object_procedure_result_type::AssetObjectProcedureResult; pub use asset_object_procedure_result_type::AssetObjectProcedureResult;
pub use asset_object_upsert_input_type::AssetObjectUpsertInput; pub use asset_object_upsert_input_type::AssetObjectUpsertInput;
pub use asset_object_upsert_snapshot_type::AssetObjectUpsertSnapshot; pub use asset_object_upsert_snapshot_type::AssetObjectUpsertSnapshot;
<<<<<<< HEAD pub use auth_identity_type::AuthIdentity;
=======
pub use auth_store_snapshot_type::AuthStoreSnapshot; pub use auth_store_snapshot_type::AuthStoreSnapshot;
pub use auth_store_snapshot_import_procedure_result_type::AuthStoreSnapshotImportProcedureResult;
pub use auth_store_snapshot_import_record_type::AuthStoreSnapshotImportRecord;
pub use auth_store_snapshot_procedure_result_type::AuthStoreSnapshotProcedureResult; pub use auth_store_snapshot_procedure_result_type::AuthStoreSnapshotProcedureResult;
pub use auth_store_snapshot_record_type::AuthStoreSnapshotRecord; pub use auth_store_snapshot_record_type::AuthStoreSnapshotRecord;
pub use auth_store_snapshot_upsert_input_type::AuthStoreSnapshotUpsertInput; pub use auth_store_snapshot_upsert_input_type::AuthStoreSnapshotUpsertInput;
>>>>>>> 4f272a50 ( Spacetime )
pub use battle_mode_type::BattleMode; pub use battle_mode_type::BattleMode;
pub use battle_state_type::BattleState; pub use battle_state_type::BattleState;
pub use battle_state_input_type::BattleStateInput; pub use battle_state_input_type::BattleStateInput;
@@ -712,6 +710,7 @@ pub use quest_status_type::QuestStatus;
pub use quest_step_snapshot_type::QuestStepSnapshot; pub use quest_step_snapshot_type::QuestStepSnapshot;
pub use quest_treasure_inspected_signal_type::QuestTreasureInspectedSignal; pub use quest_treasure_inspected_signal_type::QuestTreasureInspectedSignal;
pub use quest_turn_in_input_type::QuestTurnInInput; pub use quest_turn_in_input_type::QuestTurnInInput;
pub use refresh_session_type::RefreshSession;
pub use resolve_combat_action_input_type::ResolveCombatActionInput; pub use resolve_combat_action_input_type::ResolveCombatActionInput;
pub use resolve_combat_action_procedure_result_type::ResolveCombatActionProcedureResult; pub use resolve_combat_action_procedure_result_type::ResolveCombatActionProcedureResult;
pub use resolve_combat_action_result_type::ResolveCombatActionResult; pub use resolve_combat_action_result_type::ResolveCombatActionResult;
@@ -782,6 +781,7 @@ pub use treasure_record_procedure_result_type::TreasureRecordProcedureResult;
pub use treasure_record_snapshot_type::TreasureRecordSnapshot; pub use treasure_record_snapshot_type::TreasureRecordSnapshot;
pub use treasure_resolve_input_type::TreasureResolveInput; pub use treasure_resolve_input_type::TreasureResolveInput;
pub use unequip_inventory_item_input_type::UnequipInventoryItemInput; pub use unequip_inventory_item_input_type::UnequipInventoryItemInput;
pub use user_account_type::UserAccount;
pub use user_browse_history_type::UserBrowseHistory; pub use user_browse_history_type::UserBrowseHistory;
pub use ai_result_reference_table::*; pub use ai_result_reference_table::*;
pub use ai_task_table::*; pub use ai_task_table::*;
@@ -789,10 +789,8 @@ pub use ai_task_stage_table::*;
pub use ai_text_chunk_table::*; pub use ai_text_chunk_table::*;
pub use asset_entity_binding_table::*; pub use asset_entity_binding_table::*;
pub use asset_object_table::*; pub use asset_object_table::*;
<<<<<<< HEAD pub use auth_identity_table::*;
=======
pub use auth_store_snapshot_table::*; pub use auth_store_snapshot_table::*;
>>>>>>> 4f272a50 ( Spacetime )
pub use battle_state_table::*; pub use battle_state_table::*;
pub use big_fish_agent_message_table::*; pub use big_fish_agent_message_table::*;
pub use big_fish_asset_slot_table::*; pub use big_fish_asset_slot_table::*;
@@ -819,11 +817,13 @@ pub use puzzle_runtime_run_table::*;
pub use puzzle_work_profile_table::*; pub use puzzle_work_profile_table::*;
pub use quest_log_table::*; pub use quest_log_table::*;
pub use quest_record_table::*; pub use quest_record_table::*;
pub use refresh_session_table::*;
pub use runtime_setting_table::*; pub use runtime_setting_table::*;
pub use runtime_snapshot_table::*; pub use runtime_snapshot_table::*;
pub use story_event_table::*; pub use story_event_table::*;
pub use story_session_table::*; pub use story_session_table::*;
pub use treasure_record_table::*; pub use treasure_record_table::*;
pub use user_account_table::*;
pub use user_browse_history_table::*; pub use user_browse_history_table::*;
pub use accept_quest_reducer::accept_quest; pub use accept_quest_reducer::accept_quest;
pub use acknowledge_quest_completion_reducer::acknowledge_quest_completion; pub use acknowledge_quest_completion_reducer::acknowledge_quest_completion;
@@ -873,18 +873,13 @@ pub use delete_custom_world_profile_and_return_procedure::delete_custom_world_pr
pub use delete_runtime_snapshot_and_return_procedure::delete_runtime_snapshot_and_return; pub use delete_runtime_snapshot_and_return_procedure::delete_runtime_snapshot_and_return;
pub use drag_puzzle_piece_or_group_procedure::drag_puzzle_piece_or_group; pub use drag_puzzle_piece_or_group_procedure::drag_puzzle_piece_or_group;
pub use execute_custom_world_agent_action_procedure::execute_custom_world_agent_action; pub use execute_custom_world_agent_action_procedure::execute_custom_world_agent_action;
pub use export_auth_store_snapshot_from_tables_procedure::export_auth_store_snapshot_from_tables;
pub use fail_ai_task_and_return_procedure::fail_ai_task_and_return; pub use fail_ai_task_and_return_procedure::fail_ai_task_and_return;
<<<<<<< HEAD
pub use finalize_big_fish_agent_message_turn_procedure::finalize_big_fish_agent_message_turn; pub use finalize_big_fish_agent_message_turn_procedure::finalize_big_fish_agent_message_turn;
pub use finalize_custom_world_agent_message_turn_procedure::finalize_custom_world_agent_message_turn; pub use finalize_custom_world_agent_message_turn_procedure::finalize_custom_world_agent_message_turn;
pub use finalize_puzzle_agent_message_turn_procedure::finalize_puzzle_agent_message_turn; pub use finalize_puzzle_agent_message_turn_procedure::finalize_puzzle_agent_message_turn;
pub use generate_big_fish_asset_procedure::generate_big_fish_asset; pub use generate_big_fish_asset_procedure::generate_big_fish_asset;
=======
pub use finalize_custom_world_agent_message_turn_procedure::finalize_custom_world_agent_message_turn;
pub use finalize_puzzle_agent_message_turn_procedure::finalize_puzzle_agent_message_turn;
pub use generate_big_fish_asset_procedure::generate_big_fish_asset;
pub use get_auth_store_snapshot_procedure::get_auth_store_snapshot; pub use get_auth_store_snapshot_procedure::get_auth_store_snapshot;
>>>>>>> 4f272a50 ( Spacetime )
pub use get_battle_state_procedure::get_battle_state; pub use get_battle_state_procedure::get_battle_state;
pub use get_big_fish_run_procedure::get_big_fish_run; pub use get_big_fish_run_procedure::get_big_fish_run;
pub use get_big_fish_session_procedure::get_big_fish_session; pub use get_big_fish_session_procedure::get_big_fish_session;
@@ -907,6 +902,7 @@ pub use get_runtime_setting_or_default_procedure::get_runtime_setting_or_default
pub use get_runtime_snapshot_procedure::get_runtime_snapshot; pub use get_runtime_snapshot_procedure::get_runtime_snapshot;
pub use get_story_session_state_procedure::get_story_session_state; pub use get_story_session_state_procedure::get_story_session_state;
pub use grant_player_progression_experience_and_return_procedure::grant_player_progression_experience_and_return; pub use grant_player_progression_experience_and_return_procedure::grant_player_progression_experience_and_return;
pub use import_auth_store_snapshot_procedure::import_auth_store_snapshot;
pub use list_big_fish_works_procedure::list_big_fish_works; pub use list_big_fish_works_procedure::list_big_fish_works;
pub use list_custom_world_gallery_entries_procedure::list_custom_world_gallery_entries; pub use list_custom_world_gallery_entries_procedure::list_custom_world_gallery_entries;
pub use list_custom_world_profiles_procedure::list_custom_world_profiles; pub use list_custom_world_profiles_procedure::list_custom_world_profiles;
@@ -1200,6 +1196,7 @@ pub struct DbUpdate {
ai_text_chunk: __sdk::TableUpdate<AiTextChunk>, ai_text_chunk: __sdk::TableUpdate<AiTextChunk>,
asset_entity_binding: __sdk::TableUpdate<AssetEntityBinding>, asset_entity_binding: __sdk::TableUpdate<AssetEntityBinding>,
asset_object: __sdk::TableUpdate<AssetObject>, asset_object: __sdk::TableUpdate<AssetObject>,
auth_identity: __sdk::TableUpdate<AuthIdentity>,
auth_store_snapshot: __sdk::TableUpdate<AuthStoreSnapshot>, auth_store_snapshot: __sdk::TableUpdate<AuthStoreSnapshot>,
battle_state: __sdk::TableUpdate<BattleState>, battle_state: __sdk::TableUpdate<BattleState>,
big_fish_agent_message: __sdk::TableUpdate<BigFishAgentMessage>, big_fish_agent_message: __sdk::TableUpdate<BigFishAgentMessage>,
@@ -1227,11 +1224,13 @@ pub struct DbUpdate {
puzzle_work_profile: __sdk::TableUpdate<PuzzleWorkProfileRow>, puzzle_work_profile: __sdk::TableUpdate<PuzzleWorkProfileRow>,
quest_log: __sdk::TableUpdate<QuestLog>, quest_log: __sdk::TableUpdate<QuestLog>,
quest_record: __sdk::TableUpdate<QuestRecord>, quest_record: __sdk::TableUpdate<QuestRecord>,
refresh_session: __sdk::TableUpdate<RefreshSession>,
runtime_setting: __sdk::TableUpdate<RuntimeSetting>, runtime_setting: __sdk::TableUpdate<RuntimeSetting>,
runtime_snapshot: __sdk::TableUpdate<RuntimeSnapshotRow>, runtime_snapshot: __sdk::TableUpdate<RuntimeSnapshotRow>,
story_event: __sdk::TableUpdate<StoryEvent>, story_event: __sdk::TableUpdate<StoryEvent>,
story_session: __sdk::TableUpdate<StorySession>, story_session: __sdk::TableUpdate<StorySession>,
treasure_record: __sdk::TableUpdate<TreasureRecord>, treasure_record: __sdk::TableUpdate<TreasureRecord>,
user_account: __sdk::TableUpdate<UserAccount>,
user_browse_history: __sdk::TableUpdate<UserBrowseHistory>, user_browse_history: __sdk::TableUpdate<UserBrowseHistory>,
} }
@@ -1249,10 +1248,8 @@ impl TryFrom<__ws::v2::TransactionUpdate> for DbUpdate {
"ai_text_chunk" => db_update.ai_text_chunk.append(ai_text_chunk_table::parse_table_update(table_update)?), "ai_text_chunk" => db_update.ai_text_chunk.append(ai_text_chunk_table::parse_table_update(table_update)?),
"asset_entity_binding" => db_update.asset_entity_binding.append(asset_entity_binding_table::parse_table_update(table_update)?), "asset_entity_binding" => db_update.asset_entity_binding.append(asset_entity_binding_table::parse_table_update(table_update)?),
"asset_object" => db_update.asset_object.append(asset_object_table::parse_table_update(table_update)?), "asset_object" => db_update.asset_object.append(asset_object_table::parse_table_update(table_update)?),
<<<<<<< HEAD "auth_identity" => db_update.auth_identity.append(auth_identity_table::parse_table_update(table_update)?),
=======
"auth_store_snapshot" => db_update.auth_store_snapshot.append(auth_store_snapshot_table::parse_table_update(table_update)?), "auth_store_snapshot" => db_update.auth_store_snapshot.append(auth_store_snapshot_table::parse_table_update(table_update)?),
>>>>>>> 4f272a50 ( Spacetime )
"battle_state" => db_update.battle_state.append(battle_state_table::parse_table_update(table_update)?), "battle_state" => db_update.battle_state.append(battle_state_table::parse_table_update(table_update)?),
"big_fish_agent_message" => db_update.big_fish_agent_message.append(big_fish_agent_message_table::parse_table_update(table_update)?), "big_fish_agent_message" => db_update.big_fish_agent_message.append(big_fish_agent_message_table::parse_table_update(table_update)?),
"big_fish_asset_slot" => db_update.big_fish_asset_slot.append(big_fish_asset_slot_table::parse_table_update(table_update)?), "big_fish_asset_slot" => db_update.big_fish_asset_slot.append(big_fish_asset_slot_table::parse_table_update(table_update)?),
@@ -1279,11 +1276,13 @@ impl TryFrom<__ws::v2::TransactionUpdate> for DbUpdate {
"puzzle_work_profile" => db_update.puzzle_work_profile.append(puzzle_work_profile_table::parse_table_update(table_update)?), "puzzle_work_profile" => db_update.puzzle_work_profile.append(puzzle_work_profile_table::parse_table_update(table_update)?),
"quest_log" => db_update.quest_log.append(quest_log_table::parse_table_update(table_update)?), "quest_log" => db_update.quest_log.append(quest_log_table::parse_table_update(table_update)?),
"quest_record" => db_update.quest_record.append(quest_record_table::parse_table_update(table_update)?), "quest_record" => db_update.quest_record.append(quest_record_table::parse_table_update(table_update)?),
"refresh_session" => db_update.refresh_session.append(refresh_session_table::parse_table_update(table_update)?),
"runtime_setting" => db_update.runtime_setting.append(runtime_setting_table::parse_table_update(table_update)?), "runtime_setting" => db_update.runtime_setting.append(runtime_setting_table::parse_table_update(table_update)?),
"runtime_snapshot" => db_update.runtime_snapshot.append(runtime_snapshot_table::parse_table_update(table_update)?), "runtime_snapshot" => db_update.runtime_snapshot.append(runtime_snapshot_table::parse_table_update(table_update)?),
"story_event" => db_update.story_event.append(story_event_table::parse_table_update(table_update)?), "story_event" => db_update.story_event.append(story_event_table::parse_table_update(table_update)?),
"story_session" => db_update.story_session.append(story_session_table::parse_table_update(table_update)?), "story_session" => db_update.story_session.append(story_session_table::parse_table_update(table_update)?),
"treasure_record" => db_update.treasure_record.append(treasure_record_table::parse_table_update(table_update)?), "treasure_record" => db_update.treasure_record.append(treasure_record_table::parse_table_update(table_update)?),
"user_account" => db_update.user_account.append(user_account_table::parse_table_update(table_update)?),
"user_browse_history" => db_update.user_browse_history.append(user_browse_history_table::parse_table_update(table_update)?), "user_browse_history" => db_update.user_browse_history.append(user_browse_history_table::parse_table_update(table_update)?),
unknown => { unknown => {
@@ -1313,10 +1312,8 @@ impl __sdk::DbUpdate for DbUpdate {
diff.ai_text_chunk = cache.apply_diff_to_table::<AiTextChunk>("ai_text_chunk", &self.ai_text_chunk).with_updates_by_pk(|row| &row.text_chunk_row_id); diff.ai_text_chunk = cache.apply_diff_to_table::<AiTextChunk>("ai_text_chunk", &self.ai_text_chunk).with_updates_by_pk(|row| &row.text_chunk_row_id);
diff.asset_entity_binding = cache.apply_diff_to_table::<AssetEntityBinding>("asset_entity_binding", &self.asset_entity_binding).with_updates_by_pk(|row| &row.binding_id); diff.asset_entity_binding = cache.apply_diff_to_table::<AssetEntityBinding>("asset_entity_binding", &self.asset_entity_binding).with_updates_by_pk(|row| &row.binding_id);
diff.asset_object = cache.apply_diff_to_table::<AssetObject>("asset_object", &self.asset_object).with_updates_by_pk(|row| &row.asset_object_id); diff.asset_object = cache.apply_diff_to_table::<AssetObject>("asset_object", &self.asset_object).with_updates_by_pk(|row| &row.asset_object_id);
<<<<<<< HEAD diff.auth_identity = cache.apply_diff_to_table::<AuthIdentity>("auth_identity", &self.auth_identity).with_updates_by_pk(|row| &row.identity_id);
=======
diff.auth_store_snapshot = cache.apply_diff_to_table::<AuthStoreSnapshot>("auth_store_snapshot", &self.auth_store_snapshot).with_updates_by_pk(|row| &row.snapshot_id); diff.auth_store_snapshot = cache.apply_diff_to_table::<AuthStoreSnapshot>("auth_store_snapshot", &self.auth_store_snapshot).with_updates_by_pk(|row| &row.snapshot_id);
>>>>>>> 4f272a50 ( Spacetime )
diff.battle_state = cache.apply_diff_to_table::<BattleState>("battle_state", &self.battle_state).with_updates_by_pk(|row| &row.battle_state_id); diff.battle_state = cache.apply_diff_to_table::<BattleState>("battle_state", &self.battle_state).with_updates_by_pk(|row| &row.battle_state_id);
diff.big_fish_agent_message = cache.apply_diff_to_table::<BigFishAgentMessage>("big_fish_agent_message", &self.big_fish_agent_message).with_updates_by_pk(|row| &row.message_id); diff.big_fish_agent_message = cache.apply_diff_to_table::<BigFishAgentMessage>("big_fish_agent_message", &self.big_fish_agent_message).with_updates_by_pk(|row| &row.message_id);
diff.big_fish_asset_slot = cache.apply_diff_to_table::<BigFishAssetSlot>("big_fish_asset_slot", &self.big_fish_asset_slot).with_updates_by_pk(|row| &row.slot_id); diff.big_fish_asset_slot = cache.apply_diff_to_table::<BigFishAssetSlot>("big_fish_asset_slot", &self.big_fish_asset_slot).with_updates_by_pk(|row| &row.slot_id);
@@ -1343,11 +1340,13 @@ impl __sdk::DbUpdate for DbUpdate {
diff.puzzle_work_profile = cache.apply_diff_to_table::<PuzzleWorkProfileRow>("puzzle_work_profile", &self.puzzle_work_profile).with_updates_by_pk(|row| &row.profile_id); diff.puzzle_work_profile = cache.apply_diff_to_table::<PuzzleWorkProfileRow>("puzzle_work_profile", &self.puzzle_work_profile).with_updates_by_pk(|row| &row.profile_id);
diff.quest_log = cache.apply_diff_to_table::<QuestLog>("quest_log", &self.quest_log).with_updates_by_pk(|row| &row.log_id); diff.quest_log = cache.apply_diff_to_table::<QuestLog>("quest_log", &self.quest_log).with_updates_by_pk(|row| &row.log_id);
diff.quest_record = cache.apply_diff_to_table::<QuestRecord>("quest_record", &self.quest_record).with_updates_by_pk(|row| &row.quest_id); diff.quest_record = cache.apply_diff_to_table::<QuestRecord>("quest_record", &self.quest_record).with_updates_by_pk(|row| &row.quest_id);
diff.refresh_session = cache.apply_diff_to_table::<RefreshSession>("refresh_session", &self.refresh_session).with_updates_by_pk(|row| &row.session_id);
diff.runtime_setting = cache.apply_diff_to_table::<RuntimeSetting>("runtime_setting", &self.runtime_setting).with_updates_by_pk(|row| &row.user_id); diff.runtime_setting = cache.apply_diff_to_table::<RuntimeSetting>("runtime_setting", &self.runtime_setting).with_updates_by_pk(|row| &row.user_id);
diff.runtime_snapshot = cache.apply_diff_to_table::<RuntimeSnapshotRow>("runtime_snapshot", &self.runtime_snapshot).with_updates_by_pk(|row| &row.user_id); diff.runtime_snapshot = cache.apply_diff_to_table::<RuntimeSnapshotRow>("runtime_snapshot", &self.runtime_snapshot).with_updates_by_pk(|row| &row.user_id);
diff.story_event = cache.apply_diff_to_table::<StoryEvent>("story_event", &self.story_event).with_updates_by_pk(|row| &row.event_id); diff.story_event = cache.apply_diff_to_table::<StoryEvent>("story_event", &self.story_event).with_updates_by_pk(|row| &row.event_id);
diff.story_session = cache.apply_diff_to_table::<StorySession>("story_session", &self.story_session).with_updates_by_pk(|row| &row.story_session_id); diff.story_session = cache.apply_diff_to_table::<StorySession>("story_session", &self.story_session).with_updates_by_pk(|row| &row.story_session_id);
diff.treasure_record = cache.apply_diff_to_table::<TreasureRecord>("treasure_record", &self.treasure_record).with_updates_by_pk(|row| &row.treasure_record_id); diff.treasure_record = cache.apply_diff_to_table::<TreasureRecord>("treasure_record", &self.treasure_record).with_updates_by_pk(|row| &row.treasure_record_id);
diff.user_account = cache.apply_diff_to_table::<UserAccount>("user_account", &self.user_account).with_updates_by_pk(|row| &row.user_id);
diff.user_browse_history = cache.apply_diff_to_table::<UserBrowseHistory>("user_browse_history", &self.user_browse_history).with_updates_by_pk(|row| &row.browse_history_id); diff.user_browse_history = cache.apply_diff_to_table::<UserBrowseHistory>("user_browse_history", &self.user_browse_history).with_updates_by_pk(|row| &row.browse_history_id);
diff diff
@@ -1362,10 +1361,8 @@ for table_rows in raw.tables {
"ai_text_chunk" => db_update.ai_text_chunk.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "ai_text_chunk" => db_update.ai_text_chunk.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"asset_entity_binding" => db_update.asset_entity_binding.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "asset_entity_binding" => db_update.asset_entity_binding.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"asset_object" => db_update.asset_object.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "asset_object" => db_update.asset_object.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
<<<<<<< HEAD "auth_identity" => db_update.auth_identity.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
=======
"auth_store_snapshot" => db_update.auth_store_snapshot.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "auth_store_snapshot" => db_update.auth_store_snapshot.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
>>>>>>> 4f272a50 ( Spacetime )
"battle_state" => db_update.battle_state.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "battle_state" => db_update.battle_state.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"big_fish_agent_message" => db_update.big_fish_agent_message.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "big_fish_agent_message" => db_update.big_fish_agent_message.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"big_fish_asset_slot" => db_update.big_fish_asset_slot.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "big_fish_asset_slot" => db_update.big_fish_asset_slot.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
@@ -1392,11 +1389,13 @@ for table_rows in raw.tables {
"puzzle_work_profile" => db_update.puzzle_work_profile.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "puzzle_work_profile" => db_update.puzzle_work_profile.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"quest_log" => db_update.quest_log.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "quest_log" => db_update.quest_log.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"quest_record" => db_update.quest_record.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "quest_record" => db_update.quest_record.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"refresh_session" => db_update.refresh_session.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"runtime_setting" => db_update.runtime_setting.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "runtime_setting" => db_update.runtime_setting.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"runtime_snapshot" => db_update.runtime_snapshot.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "runtime_snapshot" => db_update.runtime_snapshot.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"story_event" => db_update.story_event.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "story_event" => db_update.story_event.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"story_session" => db_update.story_session.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "story_session" => db_update.story_session.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"treasure_record" => db_update.treasure_record.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "treasure_record" => db_update.treasure_record.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"user_account" => db_update.user_account.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
"user_browse_history" => db_update.user_browse_history.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "user_browse_history" => db_update.user_browse_history.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
unknown => { return Err(__sdk::InternalError::unknown_name("table", unknown, "QueryRows").into()); } unknown => { return Err(__sdk::InternalError::unknown_name("table", unknown, "QueryRows").into()); }
}} Ok(db_update) }} Ok(db_update)
@@ -1411,10 +1410,8 @@ for table_rows in raw.tables {
"ai_text_chunk" => db_update.ai_text_chunk.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "ai_text_chunk" => db_update.ai_text_chunk.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"asset_entity_binding" => db_update.asset_entity_binding.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "asset_entity_binding" => db_update.asset_entity_binding.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"asset_object" => db_update.asset_object.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "asset_object" => db_update.asset_object.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
<<<<<<< HEAD "auth_identity" => db_update.auth_identity.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
=======
"auth_store_snapshot" => db_update.auth_store_snapshot.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "auth_store_snapshot" => db_update.auth_store_snapshot.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
>>>>>>> 4f272a50 ( Spacetime )
"battle_state" => db_update.battle_state.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "battle_state" => db_update.battle_state.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"big_fish_agent_message" => db_update.big_fish_agent_message.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "big_fish_agent_message" => db_update.big_fish_agent_message.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"big_fish_asset_slot" => db_update.big_fish_asset_slot.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "big_fish_asset_slot" => db_update.big_fish_asset_slot.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
@@ -1441,11 +1438,13 @@ for table_rows in raw.tables {
"puzzle_work_profile" => db_update.puzzle_work_profile.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "puzzle_work_profile" => db_update.puzzle_work_profile.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"quest_log" => db_update.quest_log.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "quest_log" => db_update.quest_log.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"quest_record" => db_update.quest_record.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "quest_record" => db_update.quest_record.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"refresh_session" => db_update.refresh_session.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"runtime_setting" => db_update.runtime_setting.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "runtime_setting" => db_update.runtime_setting.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"runtime_snapshot" => db_update.runtime_snapshot.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "runtime_snapshot" => db_update.runtime_snapshot.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"story_event" => db_update.story_event.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "story_event" => db_update.story_event.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"story_session" => db_update.story_session.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "story_session" => db_update.story_session.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"treasure_record" => db_update.treasure_record.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "treasure_record" => db_update.treasure_record.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"user_account" => db_update.user_account.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
"user_browse_history" => db_update.user_browse_history.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "user_browse_history" => db_update.user_browse_history.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
unknown => { return Err(__sdk::InternalError::unknown_name("table", unknown, "QueryRows").into()); } unknown => { return Err(__sdk::InternalError::unknown_name("table", unknown, "QueryRows").into()); }
}} Ok(db_update) }} Ok(db_update)
@@ -1462,6 +1461,7 @@ pub struct AppliedDiff<'r> {
ai_text_chunk: __sdk::TableAppliedDiff<'r, AiTextChunk>, ai_text_chunk: __sdk::TableAppliedDiff<'r, AiTextChunk>,
asset_entity_binding: __sdk::TableAppliedDiff<'r, AssetEntityBinding>, asset_entity_binding: __sdk::TableAppliedDiff<'r, AssetEntityBinding>,
asset_object: __sdk::TableAppliedDiff<'r, AssetObject>, asset_object: __sdk::TableAppliedDiff<'r, AssetObject>,
auth_identity: __sdk::TableAppliedDiff<'r, AuthIdentity>,
auth_store_snapshot: __sdk::TableAppliedDiff<'r, AuthStoreSnapshot>, auth_store_snapshot: __sdk::TableAppliedDiff<'r, AuthStoreSnapshot>,
battle_state: __sdk::TableAppliedDiff<'r, BattleState>, battle_state: __sdk::TableAppliedDiff<'r, BattleState>,
big_fish_agent_message: __sdk::TableAppliedDiff<'r, BigFishAgentMessage>, big_fish_agent_message: __sdk::TableAppliedDiff<'r, BigFishAgentMessage>,
@@ -1489,11 +1489,13 @@ pub struct AppliedDiff<'r> {
puzzle_work_profile: __sdk::TableAppliedDiff<'r, PuzzleWorkProfileRow>, puzzle_work_profile: __sdk::TableAppliedDiff<'r, PuzzleWorkProfileRow>,
quest_log: __sdk::TableAppliedDiff<'r, QuestLog>, quest_log: __sdk::TableAppliedDiff<'r, QuestLog>,
quest_record: __sdk::TableAppliedDiff<'r, QuestRecord>, quest_record: __sdk::TableAppliedDiff<'r, QuestRecord>,
refresh_session: __sdk::TableAppliedDiff<'r, RefreshSession>,
runtime_setting: __sdk::TableAppliedDiff<'r, RuntimeSetting>, runtime_setting: __sdk::TableAppliedDiff<'r, RuntimeSetting>,
runtime_snapshot: __sdk::TableAppliedDiff<'r, RuntimeSnapshotRow>, runtime_snapshot: __sdk::TableAppliedDiff<'r, RuntimeSnapshotRow>,
story_event: __sdk::TableAppliedDiff<'r, StoryEvent>, story_event: __sdk::TableAppliedDiff<'r, StoryEvent>,
story_session: __sdk::TableAppliedDiff<'r, StorySession>, story_session: __sdk::TableAppliedDiff<'r, StorySession>,
treasure_record: __sdk::TableAppliedDiff<'r, TreasureRecord>, treasure_record: __sdk::TableAppliedDiff<'r, TreasureRecord>,
user_account: __sdk::TableAppliedDiff<'r, UserAccount>,
user_browse_history: __sdk::TableAppliedDiff<'r, UserBrowseHistory>, user_browse_history: __sdk::TableAppliedDiff<'r, UserBrowseHistory>,
__unused: std::marker::PhantomData<&'r ()>, __unused: std::marker::PhantomData<&'r ()>,
} }
@@ -1511,10 +1513,8 @@ impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> {
callbacks.invoke_table_row_callbacks::<AiTextChunk>("ai_text_chunk", &self.ai_text_chunk, event); callbacks.invoke_table_row_callbacks::<AiTextChunk>("ai_text_chunk", &self.ai_text_chunk, event);
callbacks.invoke_table_row_callbacks::<AssetEntityBinding>("asset_entity_binding", &self.asset_entity_binding, event); callbacks.invoke_table_row_callbacks::<AssetEntityBinding>("asset_entity_binding", &self.asset_entity_binding, event);
callbacks.invoke_table_row_callbacks::<AssetObject>("asset_object", &self.asset_object, event); callbacks.invoke_table_row_callbacks::<AssetObject>("asset_object", &self.asset_object, event);
<<<<<<< HEAD callbacks.invoke_table_row_callbacks::<AuthIdentity>("auth_identity", &self.auth_identity, event);
=======
callbacks.invoke_table_row_callbacks::<AuthStoreSnapshot>("auth_store_snapshot", &self.auth_store_snapshot, event); callbacks.invoke_table_row_callbacks::<AuthStoreSnapshot>("auth_store_snapshot", &self.auth_store_snapshot, event);
>>>>>>> 4f272a50 ( Spacetime )
callbacks.invoke_table_row_callbacks::<BattleState>("battle_state", &self.battle_state, event); callbacks.invoke_table_row_callbacks::<BattleState>("battle_state", &self.battle_state, event);
callbacks.invoke_table_row_callbacks::<BigFishAgentMessage>("big_fish_agent_message", &self.big_fish_agent_message, event); callbacks.invoke_table_row_callbacks::<BigFishAgentMessage>("big_fish_agent_message", &self.big_fish_agent_message, event);
callbacks.invoke_table_row_callbacks::<BigFishAssetSlot>("big_fish_asset_slot", &self.big_fish_asset_slot, event); callbacks.invoke_table_row_callbacks::<BigFishAssetSlot>("big_fish_asset_slot", &self.big_fish_asset_slot, event);
@@ -1541,11 +1541,13 @@ impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> {
callbacks.invoke_table_row_callbacks::<PuzzleWorkProfileRow>("puzzle_work_profile", &self.puzzle_work_profile, event); callbacks.invoke_table_row_callbacks::<PuzzleWorkProfileRow>("puzzle_work_profile", &self.puzzle_work_profile, event);
callbacks.invoke_table_row_callbacks::<QuestLog>("quest_log", &self.quest_log, event); callbacks.invoke_table_row_callbacks::<QuestLog>("quest_log", &self.quest_log, event);
callbacks.invoke_table_row_callbacks::<QuestRecord>("quest_record", &self.quest_record, event); callbacks.invoke_table_row_callbacks::<QuestRecord>("quest_record", &self.quest_record, event);
callbacks.invoke_table_row_callbacks::<RefreshSession>("refresh_session", &self.refresh_session, event);
callbacks.invoke_table_row_callbacks::<RuntimeSetting>("runtime_setting", &self.runtime_setting, event); callbacks.invoke_table_row_callbacks::<RuntimeSetting>("runtime_setting", &self.runtime_setting, event);
callbacks.invoke_table_row_callbacks::<RuntimeSnapshotRow>("runtime_snapshot", &self.runtime_snapshot, event); callbacks.invoke_table_row_callbacks::<RuntimeSnapshotRow>("runtime_snapshot", &self.runtime_snapshot, event);
callbacks.invoke_table_row_callbacks::<StoryEvent>("story_event", &self.story_event, event); callbacks.invoke_table_row_callbacks::<StoryEvent>("story_event", &self.story_event, event);
callbacks.invoke_table_row_callbacks::<StorySession>("story_session", &self.story_session, event); callbacks.invoke_table_row_callbacks::<StorySession>("story_session", &self.story_session, event);
callbacks.invoke_table_row_callbacks::<TreasureRecord>("treasure_record", &self.treasure_record, event); callbacks.invoke_table_row_callbacks::<TreasureRecord>("treasure_record", &self.treasure_record, event);
callbacks.invoke_table_row_callbacks::<UserAccount>("user_account", &self.user_account, event);
callbacks.invoke_table_row_callbacks::<UserBrowseHistory>("user_browse_history", &self.user_browse_history, event); callbacks.invoke_table_row_callbacks::<UserBrowseHistory>("user_browse_history", &self.user_browse_history, event);
} }
} }
@@ -2204,6 +2206,7 @@ fn register_tables(client_cache: &mut __sdk::ClientCache<Self>) {
ai_text_chunk_table::register_table(client_cache); ai_text_chunk_table::register_table(client_cache);
asset_entity_binding_table::register_table(client_cache); asset_entity_binding_table::register_table(client_cache);
asset_object_table::register_table(client_cache); asset_object_table::register_table(client_cache);
auth_identity_table::register_table(client_cache);
auth_store_snapshot_table::register_table(client_cache); auth_store_snapshot_table::register_table(client_cache);
battle_state_table::register_table(client_cache); battle_state_table::register_table(client_cache);
big_fish_agent_message_table::register_table(client_cache); big_fish_agent_message_table::register_table(client_cache);
@@ -2231,11 +2234,13 @@ fn register_tables(client_cache: &mut __sdk::ClientCache<Self>) {
puzzle_work_profile_table::register_table(client_cache); puzzle_work_profile_table::register_table(client_cache);
quest_log_table::register_table(client_cache); quest_log_table::register_table(client_cache);
quest_record_table::register_table(client_cache); quest_record_table::register_table(client_cache);
refresh_session_table::register_table(client_cache);
runtime_setting_table::register_table(client_cache); runtime_setting_table::register_table(client_cache);
runtime_snapshot_table::register_table(client_cache); runtime_snapshot_table::register_table(client_cache);
story_event_table::register_table(client_cache); story_event_table::register_table(client_cache);
story_session_table::register_table(client_cache); story_session_table::register_table(client_cache);
treasure_record_table::register_table(client_cache); treasure_record_table::register_table(client_cache);
user_account_table::register_table(client_cache);
user_browse_history_table::register_table(client_cache); user_browse_history_table::register_table(client_cache);
} }
const ALL_TABLE_NAMES: &'static [&'static str] = &[ const ALL_TABLE_NAMES: &'static [&'static str] = &[
@@ -2245,6 +2250,7 @@ const ALL_TABLE_NAMES: &'static [&'static str] = &[
"ai_text_chunk", "ai_text_chunk",
"asset_entity_binding", "asset_entity_binding",
"asset_object", "asset_object",
"auth_identity",
"auth_store_snapshot", "auth_store_snapshot",
"battle_state", "battle_state",
"big_fish_agent_message", "big_fish_agent_message",
@@ -2272,11 +2278,13 @@ const ALL_TABLE_NAMES: &'static [&'static str] = &[
"puzzle_work_profile", "puzzle_work_profile",
"quest_log", "quest_log",
"quest_record", "quest_record",
"refresh_session",
"runtime_setting", "runtime_setting",
"runtime_snapshot", "runtime_snapshot",
"story_event", "story_event",
"story_session", "story_session",
"treasure_record", "treasure_record",
"user_account",
"user_browse_history", "user_browse_history",
]; ];
} }

View File

@@ -0,0 +1,163 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::refresh_session_type::RefreshSession;
/// Table handle for the table `refresh_session`.
///
/// Obtain a handle from the [`RefreshSessionTableAccess::refresh_session`] method on [`super::RemoteTables`],
/// like `ctx.db.refresh_session()`.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.refresh_session().on_insert(...)`.
pub struct RefreshSessionTableHandle<'ctx> {
imp: __sdk::TableHandle<RefreshSession>,
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the table `refresh_session`.
///
/// Implemented for [`super::RemoteTables`].
pub trait RefreshSessionTableAccess {
#[allow(non_snake_case)]
/// Obtain a [`RefreshSessionTableHandle`], which mediates access to the table `refresh_session`.
fn refresh_session(&self) -> RefreshSessionTableHandle<'_>;
}
impl RefreshSessionTableAccess for super::RemoteTables {
fn refresh_session(&self) -> RefreshSessionTableHandle<'_> {
RefreshSessionTableHandle {
imp: self.imp.get_table::<RefreshSession>("refresh_session"),
ctx: std::marker::PhantomData,
}
}
}
pub struct RefreshSessionInsertCallbackId(__sdk::CallbackId);
pub struct RefreshSessionDeleteCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::Table for RefreshSessionTableHandle<'ctx> {
type Row = RefreshSession;
type EventContext = super::EventContext;
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = RefreshSession> + '_ { self.imp.iter() }
type InsertCallbackId = RefreshSessionInsertCallbackId;
fn on_insert(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> RefreshSessionInsertCallbackId {
RefreshSessionInsertCallbackId(self.imp.on_insert(Box::new(callback)))
}
fn remove_on_insert(&self, callback: RefreshSessionInsertCallbackId) {
self.imp.remove_on_insert(callback.0)
}
type DeleteCallbackId = RefreshSessionDeleteCallbackId;
fn on_delete(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> RefreshSessionDeleteCallbackId {
RefreshSessionDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
}
fn remove_on_delete(&self, callback: RefreshSessionDeleteCallbackId) {
self.imp.remove_on_delete(callback.0)
}
}
pub struct RefreshSessionUpdateCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::TableWithPrimaryKey for RefreshSessionTableHandle<'ctx> {
type UpdateCallbackId = RefreshSessionUpdateCallbackId;
fn on_update(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
) -> RefreshSessionUpdateCallbackId {
RefreshSessionUpdateCallbackId(self.imp.on_update(Box::new(callback)))
}
fn remove_on_update(&self, callback: RefreshSessionUpdateCallbackId) {
self.imp.remove_on_update(callback.0)
}
}
/// Access to the `session_id` unique index on the table `refresh_session`,
/// which allows point queries on the field of the same name
/// via the [`RefreshSessionSessionIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.refresh_session().session_id().find(...)`.
pub struct RefreshSessionSessionIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<RefreshSession, String>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> RefreshSessionTableHandle<'ctx> {
/// Get a handle on the `session_id` unique index on the table `refresh_session`.
pub fn session_id(&self) -> RefreshSessionSessionIdUnique<'ctx> {
RefreshSessionSessionIdUnique {
imp: self.imp.get_unique_constraint::<String>("session_id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> RefreshSessionSessionIdUnique<'ctx> {
/// Find the subscribed row whose `session_id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &String) -> Option<RefreshSession> {
self.imp.find(col_val)
}
}
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<RefreshSession>("refresh_session");
_table.add_unique_constraint::<String>("session_id", |row| &row.session_id);
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::v2::TableUpdate,
) -> __sdk::Result<__sdk::TableUpdate<RefreshSession>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse(
"TableUpdate<RefreshSession>",
"TableUpdate",
).with_cause(e).into()
})
}
#[allow(non_camel_case_types)]
/// Extension trait for query builder access to the table `RefreshSession`.
///
/// Implemented for [`__sdk::QueryTableAccessor`].
pub trait refresh_sessionQueryTableAccess {
#[allow(non_snake_case)]
/// Get a query builder for the table `RefreshSession`.
fn refresh_session(&self) -> __sdk::__query_builder::Table<RefreshSession>;
}
impl refresh_sessionQueryTableAccess for __sdk::QueryTableAccessor {
fn refresh_session(&self) -> __sdk::__query_builder::Table<RefreshSession> {
__sdk::__query_builder::Table::new("refresh_session")
}
}

View File

@@ -0,0 +1,91 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub struct RefreshSession {
pub session_id: String,
pub user_id: String,
pub refresh_token_hash: String,
pub issued_by_provider: String,
pub client_info_json: String,
pub expires_at: String,
pub revoked_at: Option::<String>,
pub created_at: String,
pub updated_at: String,
pub last_seen_at: String,
}
impl __sdk::InModule for RefreshSession {
type Module = super::RemoteModule;
}
/// Column accessor struct for the table `RefreshSession`.
///
/// Provides typed access to columns for query building.
pub struct RefreshSessionCols {
pub session_id: __sdk::__query_builder::Col<RefreshSession, String>,
pub user_id: __sdk::__query_builder::Col<RefreshSession, String>,
pub refresh_token_hash: __sdk::__query_builder::Col<RefreshSession, String>,
pub issued_by_provider: __sdk::__query_builder::Col<RefreshSession, String>,
pub client_info_json: __sdk::__query_builder::Col<RefreshSession, String>,
pub expires_at: __sdk::__query_builder::Col<RefreshSession, String>,
pub revoked_at: __sdk::__query_builder::Col<RefreshSession, Option::<String>>,
pub created_at: __sdk::__query_builder::Col<RefreshSession, String>,
pub updated_at: __sdk::__query_builder::Col<RefreshSession, String>,
pub last_seen_at: __sdk::__query_builder::Col<RefreshSession, String>,
}
impl __sdk::__query_builder::HasCols for RefreshSession {
type Cols = RefreshSessionCols;
fn cols(table_name: &'static str) -> Self::Cols {
RefreshSessionCols {
session_id: __sdk::__query_builder::Col::new(table_name, "session_id"),
user_id: __sdk::__query_builder::Col::new(table_name, "user_id"),
refresh_token_hash: __sdk::__query_builder::Col::new(table_name, "refresh_token_hash"),
issued_by_provider: __sdk::__query_builder::Col::new(table_name, "issued_by_provider"),
client_info_json: __sdk::__query_builder::Col::new(table_name, "client_info_json"),
expires_at: __sdk::__query_builder::Col::new(table_name, "expires_at"),
revoked_at: __sdk::__query_builder::Col::new(table_name, "revoked_at"),
created_at: __sdk::__query_builder::Col::new(table_name, "created_at"),
updated_at: __sdk::__query_builder::Col::new(table_name, "updated_at"),
last_seen_at: __sdk::__query_builder::Col::new(table_name, "last_seen_at"),
}
}
}
/// Indexed column accessor struct for the table `RefreshSession`.
///
/// Provides typed access to indexed columns for query building.
pub struct RefreshSessionIxCols {
pub refresh_token_hash: __sdk::__query_builder::IxCol<RefreshSession, String>,
pub session_id: __sdk::__query_builder::IxCol<RefreshSession, String>,
pub user_id: __sdk::__query_builder::IxCol<RefreshSession, String>,
}
impl __sdk::__query_builder::HasIxCols for RefreshSession {
type IxCols = RefreshSessionIxCols;
fn ix_cols(table_name: &'static str) -> Self::IxCols {
RefreshSessionIxCols {
refresh_token_hash: __sdk::__query_builder::IxCol::new(table_name, "refresh_token_hash"),
session_id: __sdk::__query_builder::IxCol::new(table_name, "session_id"),
user_id: __sdk::__query_builder::IxCol::new(table_name, "user_id"),
}
}
}
impl __sdk::__query_builder::CanBeLookupTable for RefreshSession {}

View File

@@ -25,6 +25,10 @@ pub enum RpgAgentOperationType {
GenerateLandmarks, GenerateLandmarks,
DeleteCharacters,
DeleteLandmarks,
GenerateRoleAssets, GenerateRoleAssets,
SyncRoleAssets, SyncRoleAssets,

View File

@@ -0,0 +1,163 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::user_account_type::UserAccount;
/// Table handle for the table `user_account`.
///
/// Obtain a handle from the [`UserAccountTableAccess::user_account`] method on [`super::RemoteTables`],
/// like `ctx.db.user_account()`.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.user_account().on_insert(...)`.
pub struct UserAccountTableHandle<'ctx> {
imp: __sdk::TableHandle<UserAccount>,
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the table `user_account`.
///
/// Implemented for [`super::RemoteTables`].
pub trait UserAccountTableAccess {
#[allow(non_snake_case)]
/// Obtain a [`UserAccountTableHandle`], which mediates access to the table `user_account`.
fn user_account(&self) -> UserAccountTableHandle<'_>;
}
impl UserAccountTableAccess for super::RemoteTables {
fn user_account(&self) -> UserAccountTableHandle<'_> {
UserAccountTableHandle {
imp: self.imp.get_table::<UserAccount>("user_account"),
ctx: std::marker::PhantomData,
}
}
}
pub struct UserAccountInsertCallbackId(__sdk::CallbackId);
pub struct UserAccountDeleteCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::Table for UserAccountTableHandle<'ctx> {
type Row = UserAccount;
type EventContext = super::EventContext;
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = UserAccount> + '_ { self.imp.iter() }
type InsertCallbackId = UserAccountInsertCallbackId;
fn on_insert(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> UserAccountInsertCallbackId {
UserAccountInsertCallbackId(self.imp.on_insert(Box::new(callback)))
}
fn remove_on_insert(&self, callback: UserAccountInsertCallbackId) {
self.imp.remove_on_insert(callback.0)
}
type DeleteCallbackId = UserAccountDeleteCallbackId;
fn on_delete(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> UserAccountDeleteCallbackId {
UserAccountDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
}
fn remove_on_delete(&self, callback: UserAccountDeleteCallbackId) {
self.imp.remove_on_delete(callback.0)
}
}
pub struct UserAccountUpdateCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::TableWithPrimaryKey for UserAccountTableHandle<'ctx> {
type UpdateCallbackId = UserAccountUpdateCallbackId;
fn on_update(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
) -> UserAccountUpdateCallbackId {
UserAccountUpdateCallbackId(self.imp.on_update(Box::new(callback)))
}
fn remove_on_update(&self, callback: UserAccountUpdateCallbackId) {
self.imp.remove_on_update(callback.0)
}
}
/// Access to the `user_id` unique index on the table `user_account`,
/// which allows point queries on the field of the same name
/// via the [`UserAccountUserIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.user_account().user_id().find(...)`.
pub struct UserAccountUserIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<UserAccount, String>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> UserAccountTableHandle<'ctx> {
/// Get a handle on the `user_id` unique index on the table `user_account`.
pub fn user_id(&self) -> UserAccountUserIdUnique<'ctx> {
UserAccountUserIdUnique {
imp: self.imp.get_unique_constraint::<String>("user_id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> UserAccountUserIdUnique<'ctx> {
/// Find the subscribed row whose `user_id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &String) -> Option<UserAccount> {
self.imp.find(col_val)
}
}
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<UserAccount>("user_account");
_table.add_unique_constraint::<String>("user_id", |row| &row.user_id);
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::v2::TableUpdate,
) -> __sdk::Result<__sdk::TableUpdate<UserAccount>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse(
"TableUpdate<UserAccount>",
"TableUpdate",
).with_cause(e).into()
})
}
#[allow(non_camel_case_types)]
/// Extension trait for query builder access to the table `UserAccount`.
///
/// Implemented for [`__sdk::QueryTableAccessor`].
pub trait user_accountQueryTableAccess {
#[allow(non_snake_case)]
/// Get a query builder for the table `UserAccount`.
fn user_account(&self) -> __sdk::__query_builder::Table<UserAccount>;
}
impl user_accountQueryTableAccess for __sdk::QueryTableAccessor {
fn user_account(&self) -> __sdk::__query_builder::Table<UserAccount> {
__sdk::__query_builder::Table::new("user_account")
}
}

View File

@@ -0,0 +1,97 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub struct UserAccount {
pub user_id: String,
pub public_user_code: String,
pub username: String,
pub display_name: String,
pub phone_number_masked: Option::<String>,
pub phone_number_e_164: Option::<String>,
pub login_method: String,
pub binding_status: String,
pub wechat_bound: bool,
pub password_hash: String,
pub password_login_enabled: bool,
pub token_version: u64,
}
impl __sdk::InModule for UserAccount {
type Module = super::RemoteModule;
}
/// Column accessor struct for the table `UserAccount`.
///
/// Provides typed access to columns for query building.
pub struct UserAccountCols {
pub user_id: __sdk::__query_builder::Col<UserAccount, String>,
pub public_user_code: __sdk::__query_builder::Col<UserAccount, String>,
pub username: __sdk::__query_builder::Col<UserAccount, String>,
pub display_name: __sdk::__query_builder::Col<UserAccount, String>,
pub phone_number_masked: __sdk::__query_builder::Col<UserAccount, Option::<String>>,
pub phone_number_e_164: __sdk::__query_builder::Col<UserAccount, Option::<String>>,
pub login_method: __sdk::__query_builder::Col<UserAccount, String>,
pub binding_status: __sdk::__query_builder::Col<UserAccount, String>,
pub wechat_bound: __sdk::__query_builder::Col<UserAccount, bool>,
pub password_hash: __sdk::__query_builder::Col<UserAccount, String>,
pub password_login_enabled: __sdk::__query_builder::Col<UserAccount, bool>,
pub token_version: __sdk::__query_builder::Col<UserAccount, u64>,
}
impl __sdk::__query_builder::HasCols for UserAccount {
type Cols = UserAccountCols;
fn cols(table_name: &'static str) -> Self::Cols {
UserAccountCols {
user_id: __sdk::__query_builder::Col::new(table_name, "user_id"),
public_user_code: __sdk::__query_builder::Col::new(table_name, "public_user_code"),
username: __sdk::__query_builder::Col::new(table_name, "username"),
display_name: __sdk::__query_builder::Col::new(table_name, "display_name"),
phone_number_masked: __sdk::__query_builder::Col::new(table_name, "phone_number_masked"),
phone_number_e_164: __sdk::__query_builder::Col::new(table_name, "phone_number_e_164"),
login_method: __sdk::__query_builder::Col::new(table_name, "login_method"),
binding_status: __sdk::__query_builder::Col::new(table_name, "binding_status"),
wechat_bound: __sdk::__query_builder::Col::new(table_name, "wechat_bound"),
password_hash: __sdk::__query_builder::Col::new(table_name, "password_hash"),
password_login_enabled: __sdk::__query_builder::Col::new(table_name, "password_login_enabled"),
token_version: __sdk::__query_builder::Col::new(table_name, "token_version"),
}
}
}
/// Indexed column accessor struct for the table `UserAccount`.
///
/// Provides typed access to indexed columns for query building.
pub struct UserAccountIxCols {
pub public_user_code: __sdk::__query_builder::IxCol<UserAccount, String>,
pub user_id: __sdk::__query_builder::IxCol<UserAccount, String>,
pub username: __sdk::__query_builder::IxCol<UserAccount, String>,
}
impl __sdk::__query_builder::HasIxCols for UserAccount {
type IxCols = UserAccountIxCols;
fn ix_cols(table_name: &'static str) -> Self::IxCols {
UserAccountIxCols {
public_user_code: __sdk::__query_builder::IxCol::new(table_name, "public_user_code"),
user_id: __sdk::__query_builder::IxCol::new(table_name, "user_id"),
username: __sdk::__query_builder::IxCol::new(table_name, "username"),
}
}
}
impl __sdk::__query_builder::CanBeLookupTable for UserAccount {}

View File

@@ -1,12 +1,13 @@
use super::*; use super::*;
use crate::mapper::*;
impl SpacetimeClient { impl SpacetimeClient {
pub async fn resolve_npc_battle_interaction( pub async fn resolve_npc_battle_interaction(
&self, &self,
input: ResolveNpcBattleInteractionInput, input: crate::mapper::ResolveNpcBattleInteractionInput,
) -> Result<NpcBattleInteractionRecord, SpacetimeClientError> { ) -> Result<NpcBattleInteractionRecord, SpacetimeClientError> {
validate_npc_battle_interaction_input(&input)?; validate_npc_battle_interaction_input(&input)?;
let procedure_input = map_resolve_npc_battle_interaction_input(input); let procedure_input = input.into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -23,6 +24,4 @@ impl SpacetimeClient {
}) })
.await .await
} }
} }

View File

@@ -1,4 +1,5 @@
use super::*; use super::*;
use crate::mapper::*;
impl SpacetimeClient { impl SpacetimeClient {
pub async fn create_puzzle_agent_session( pub async fn create_puzzle_agent_session(
@@ -28,7 +29,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_puzzle_agent_session( pub async fn get_puzzle_agent_session(
&self, &self,
session_id: String, session_id: String,
@@ -53,7 +53,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn submit_puzzle_agent_message( pub async fn submit_puzzle_agent_message(
&self, &self,
input: PuzzleAgentMessageSubmitRecordInput, input: PuzzleAgentMessageSubmitRecordInput,
@@ -80,7 +79,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn finalize_puzzle_agent_message( pub async fn finalize_puzzle_agent_message(
&self, &self,
input: PuzzleAgentMessageFinalizeRecordInput, input: PuzzleAgentMessageFinalizeRecordInput,
@@ -110,7 +108,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn compile_puzzle_agent_draft( pub async fn compile_puzzle_agent_draft(
&self, &self,
session_id: String, session_id: String,
@@ -137,7 +134,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn save_puzzle_generated_images( pub async fn save_puzzle_generated_images(
&self, &self,
input: PuzzleGeneratedImagesSaveRecordInput, input: PuzzleGeneratedImagesSaveRecordInput,
@@ -163,7 +159,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn select_puzzle_cover_image( pub async fn select_puzzle_cover_image(
&self, &self,
input: PuzzleSelectCoverImageRecordInput, input: PuzzleSelectCoverImageRecordInput,
@@ -189,7 +184,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn publish_puzzle_work( pub async fn publish_puzzle_work(
&self, &self,
input: PuzzlePublishRecordInput, input: PuzzlePublishRecordInput,
@@ -219,7 +213,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn list_puzzle_works( pub async fn list_puzzle_works(
&self, &self,
owner_user_id: String, owner_user_id: String,
@@ -239,7 +232,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_puzzle_work_detail( pub async fn get_puzzle_work_detail(
&self, &self,
profile_id: String, profile_id: String,
@@ -260,7 +252,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn update_puzzle_work( pub async fn update_puzzle_work(
&self, &self,
input: PuzzleWorkUpsertRecordInput, input: PuzzleWorkUpsertRecordInput,
@@ -289,7 +280,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn list_puzzle_gallery( pub async fn list_puzzle_gallery(
&self, &self,
) -> Result<Vec<PuzzleWorkProfileRecord>, SpacetimeClientError> { ) -> Result<Vec<PuzzleWorkProfileRecord>, SpacetimeClientError> {
@@ -306,7 +296,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_puzzle_gallery_detail( pub async fn get_puzzle_gallery_detail(
&self, &self,
profile_id: String, profile_id: String,
@@ -327,7 +316,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn start_puzzle_run( pub async fn start_puzzle_run(
&self, &self,
input: PuzzleRunStartRecordInput, input: PuzzleRunStartRecordInput,
@@ -352,7 +340,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_puzzle_run( pub async fn get_puzzle_run(
&self, &self,
run_id: String, run_id: String,
@@ -376,7 +363,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn swap_puzzle_pieces( pub async fn swap_puzzle_pieces(
&self, &self,
input: PuzzleRunSwapRecordInput, input: PuzzleRunSwapRecordInput,
@@ -402,7 +388,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn drag_puzzle_piece_or_group( pub async fn drag_puzzle_piece_or_group(
&self, &self,
input: PuzzleRunDragRecordInput, input: PuzzleRunDragRecordInput,
@@ -430,7 +415,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn advance_puzzle_next_level( pub async fn advance_puzzle_next_level(
&self, &self,
input: PuzzleRunNextLevelRecordInput, input: PuzzleRunNextLevelRecordInput,
@@ -454,6 +438,4 @@ impl SpacetimeClient {
}) })
.await .await
} }
} }

View File

@@ -5,10 +5,9 @@ impl SpacetimeClient {
&self, &self,
user_id: String, user_id: String,
) -> Result<RuntimeSettingsRecord, SpacetimeClientError> { ) -> Result<RuntimeSettingsRecord, SpacetimeClientError> {
let procedure_input = map_runtime_setting_get_input( let procedure_input = build_runtime_setting_get_input(user_id)
build_runtime_setting_get_input(user_id) .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .into();
);
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().get_runtime_setting_or_default_then( connection.procedures().get_runtime_setting_or_default_then(
@@ -24,15 +23,13 @@ impl SpacetimeClient {
.await .await
} }
pub async fn list_platform_browse_history( pub async fn list_platform_browse_history(
&self, &self,
user_id: String, user_id: String,
) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> { ) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> {
let procedure_input = map_runtime_browse_history_list_input( let procedure_input = build_runtime_browse_history_list_input(user_id)
build_runtime_browse_history_list_input(user_id) .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .into();
);
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().list_platform_browse_history_then( connection.procedures().list_platform_browse_history_then(
@@ -48,15 +45,13 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_profile_dashboard( pub async fn get_profile_dashboard(
&self, &self,
user_id: String, user_id: String,
) -> Result<RuntimeProfileDashboardRecord, SpacetimeClientError> { ) -> Result<RuntimeProfileDashboardRecord, SpacetimeClientError> {
let procedure_input = map_runtime_profile_dashboard_get_input( let procedure_input = build_runtime_profile_dashboard_get_input(user_id)
build_runtime_profile_dashboard_get_input(user_id) .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .into();
);
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().get_profile_dashboard_then( connection.procedures().get_profile_dashboard_then(
@@ -72,15 +67,13 @@ impl SpacetimeClient {
.await .await
} }
pub async fn list_profile_wallet_ledger( pub async fn list_profile_wallet_ledger(
&self, &self,
user_id: String, user_id: String,
) -> Result<Vec<RuntimeProfileWalletLedgerEntryRecord>, SpacetimeClientError> { ) -> Result<Vec<RuntimeProfileWalletLedgerEntryRecord>, SpacetimeClientError> {
let procedure_input = map_runtime_profile_wallet_ledger_list_input( let procedure_input = build_runtime_profile_wallet_ledger_list_input(user_id)
build_runtime_profile_wallet_ledger_list_input(user_id) .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .into();
);
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().list_profile_wallet_ledger_then( connection.procedures().list_profile_wallet_ledger_then(
@@ -96,15 +89,13 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_profile_play_stats( pub async fn get_profile_play_stats(
&self, &self,
user_id: String, user_id: String,
) -> Result<RuntimeProfilePlayStatsRecord, SpacetimeClientError> { ) -> Result<RuntimeProfilePlayStatsRecord, SpacetimeClientError> {
let procedure_input = map_runtime_profile_play_stats_get_input( let procedure_input = build_runtime_profile_play_stats_get_input(user_id)
build_runtime_profile_play_stats_get_input(user_id) .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .into();
);
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().get_profile_play_stats_then( connection.procedures().get_profile_play_stats_then(
@@ -120,15 +111,13 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_runtime_snapshot( pub async fn get_runtime_snapshot(
&self, &self,
user_id: String, user_id: String,
) -> Result<Option<RuntimeSnapshotRecord>, SpacetimeClientError> { ) -> Result<Option<RuntimeSnapshotRecord>, SpacetimeClientError> {
let procedure_input = map_runtime_snapshot_get_input( let procedure_input = build_runtime_snapshot_get_input(user_id)
build_runtime_snapshot_get_input(user_id) .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .into();
);
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -143,7 +132,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn put_runtime_snapshot( pub async fn put_runtime_snapshot(
&self, &self,
user_id: String, user_id: String,
@@ -153,8 +141,7 @@ impl SpacetimeClient {
current_story: Option<serde_json::Value>, current_story: Option<serde_json::Value>,
updated_at_micros: i64, updated_at_micros: i64,
) -> Result<RuntimeSnapshotRecord, SpacetimeClientError> { ) -> Result<RuntimeSnapshotRecord, SpacetimeClientError> {
let procedure_input = map_runtime_snapshot_upsert_input( let procedure_input = build_runtime_snapshot_upsert_input(
build_runtime_snapshot_upsert_input(
user_id, user_id,
saved_at_micros, saved_at_micros,
bottom_tab, bottom_tab,
@@ -162,8 +149,8 @@ impl SpacetimeClient {
current_story, current_story,
updated_at_micros, updated_at_micros,
) )
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
); .into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -178,15 +165,13 @@ impl SpacetimeClient {
.await .await
} }
pub async fn delete_runtime_snapshot( pub async fn delete_runtime_snapshot(
&self, &self,
user_id: String, user_id: String,
) -> Result<bool, SpacetimeClientError> { ) -> Result<bool, SpacetimeClientError> {
let procedure_input = map_runtime_snapshot_delete_input( let procedure_input = build_runtime_snapshot_delete_input(user_id)
build_runtime_snapshot_delete_input(user_id) .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .into();
);
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -201,15 +186,13 @@ impl SpacetimeClient {
.await .await
} }
pub async fn list_profile_save_archives( pub async fn list_profile_save_archives(
&self, &self,
user_id: String, user_id: String,
) -> Result<Vec<RuntimeProfileSaveArchiveRecord>, SpacetimeClientError> { ) -> Result<Vec<RuntimeProfileSaveArchiveRecord>, SpacetimeClientError> {
let procedure_input = map_runtime_profile_save_archive_list_input( let procedure_input = build_runtime_profile_save_archive_list_input(user_id)
build_runtime_profile_save_archive_list_input(user_id) .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .into();
);
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().list_profile_save_archives_then( connection.procedures().list_profile_save_archives_then(
@@ -225,17 +208,15 @@ impl SpacetimeClient {
.await .await
} }
pub async fn resume_profile_save_archive( pub async fn resume_profile_save_archive(
&self, &self,
user_id: String, user_id: String,
world_key: String, world_key: String,
) -> Result<(RuntimeProfileSaveArchiveRecord, RuntimeSnapshotRecord), SpacetimeClientError> ) -> Result<(RuntimeProfileSaveArchiveRecord, RuntimeSnapshotRecord), SpacetimeClientError>
{ {
let procedure_input = map_runtime_profile_save_archive_resume_input( let procedure_input = build_runtime_profile_save_archive_resume_input(user_id, world_key)
build_runtime_profile_save_archive_resume_input(user_id, world_key) .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .into();
);
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -250,23 +231,21 @@ impl SpacetimeClient {
.await .await
} }
pub async fn put_runtime_settings( pub async fn put_runtime_settings(
&self, &self,
user_id: String, user_id: String,
music_volume: f32, music_volume: f32,
platform_theme: RuntimePlatformTheme, platform_theme: DomainRuntimePlatformTheme,
updated_at_micros: i64, updated_at_micros: i64,
) -> Result<RuntimeSettingsRecord, SpacetimeClientError> { ) -> Result<RuntimeSettingsRecord, SpacetimeClientError> {
let procedure_input = map_runtime_setting_upsert_input( let procedure_input = build_runtime_setting_upsert_input(
build_runtime_setting_upsert_input(
user_id, user_id,
music_volume, music_volume,
platform_theme, platform_theme,
updated_at_micros, updated_at_micros,
) )
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
); .into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -281,17 +260,16 @@ impl SpacetimeClient {
.await .await
} }
pub async fn upsert_platform_browse_history_entries( pub async fn upsert_platform_browse_history_entries(
&self, &self,
user_id: String, user_id: String,
entries: Vec<module_runtime::RuntimeBrowseHistoryWriteInput>, entries: Vec<module_runtime::RuntimeBrowseHistoryWriteInput>,
updated_at_micros: i64, updated_at_micros: i64,
) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> { ) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> {
let procedure_input = map_runtime_browse_history_sync_input( let procedure_input =
build_runtime_browse_history_sync_input(user_id, entries, updated_at_micros) build_runtime_browse_history_sync_input(user_id, entries, updated_at_micros)
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
); .into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -309,15 +287,13 @@ impl SpacetimeClient {
.await .await
} }
pub async fn clear_platform_browse_history( pub async fn clear_platform_browse_history(
&self, &self,
user_id: String, user_id: String,
) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> { ) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> {
let procedure_input = map_runtime_browse_history_clear_input( let procedure_input = build_runtime_browse_history_clear_input(user_id)
build_runtime_browse_history_clear_input(user_id) .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .into();
);
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection connection
@@ -334,6 +310,4 @@ impl SpacetimeClient {
}) })
.await .await
} }
} }

View File

@@ -11,8 +11,7 @@ impl SpacetimeClient {
opening_summary: Option<String>, opening_summary: Option<String>,
created_at_micros: i64, created_at_micros: i64,
) -> Result<StorySessionResultRecord, SpacetimeClientError> { ) -> Result<StorySessionResultRecord, SpacetimeClientError> {
let procedure_input = map_story_session_input( let procedure_input = build_story_session_input(
build_story_session_input(
story_session_id, story_session_id,
runtime_session_id, runtime_session_id,
actor_user_id, actor_user_id,
@@ -21,8 +20,8 @@ impl SpacetimeClient {
opening_summary, opening_summary,
created_at_micros, created_at_micros,
) )
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
); .into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().begin_story_session_and_return_then( connection.procedures().begin_story_session_and_return_then(
@@ -38,7 +37,6 @@ impl SpacetimeClient {
.await .await
} }
pub async fn continue_story( pub async fn continue_story(
&self, &self,
story_session_id: String, story_session_id: String,
@@ -47,16 +45,15 @@ impl SpacetimeClient {
choice_function_id: Option<String>, choice_function_id: Option<String>,
updated_at_micros: i64, updated_at_micros: i64,
) -> Result<StorySessionResultRecord, SpacetimeClientError> { ) -> Result<StorySessionResultRecord, SpacetimeClientError> {
let procedure_input = map_story_continue_input( let procedure_input = build_story_continue_input(
build_story_continue_input(
story_session_id, story_session_id,
event_id, event_id,
narrative_text, narrative_text,
choice_function_id, choice_function_id,
updated_at_micros, updated_at_micros,
) )
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
); .into();
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().continue_story_and_return_then( connection.procedures().continue_story_and_return_then(
@@ -72,15 +69,13 @@ impl SpacetimeClient {
.await .await
} }
pub async fn get_story_session_state( pub async fn get_story_session_state(
&self, &self,
story_session_id: String, story_session_id: String,
) -> Result<StorySessionStateRecord, SpacetimeClientError> { ) -> Result<StorySessionStateRecord, SpacetimeClientError> {
let procedure_input = map_story_session_state_input( let procedure_input = build_story_session_state_input(story_session_id)
build_story_session_state_input(story_session_id) .map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?, .into();
);
self.call_after_connect(move |connection, sender| { self.call_after_connect(move |connection, sender| {
connection.procedures().get_story_session_state_then( connection.procedures().get_story_session_state_then(
@@ -95,6 +90,4 @@ impl SpacetimeClient {
}) })
.await .await
} }
} }

View File

@@ -1,4 +1,6 @@
use crate::*; use crate::*;
use serde::{Deserialize, Serialize};
use serde_json::Value;
const AUTH_STORE_SNAPSHOT_ID: &str = "default"; const AUTH_STORE_SNAPSHOT_ID: &str = "default";
@@ -21,6 +23,20 @@ pub struct AuthStoreSnapshotProcedureResult {
pub error_message: Option<String>, pub error_message: Option<String>,
} }
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct AuthStoreSnapshotImportRecord {
pub imported_user_count: u32,
pub imported_identity_count: u32,
pub imported_refresh_session_count: u32,
}
#[derive(Clone, Debug, PartialEq, Eq, SpacetimeType)]
pub struct AuthStoreSnapshotImportProcedureResult {
pub ok: bool,
pub record: Option<AuthStoreSnapshotImportRecord>,
pub error_message: Option<String>,
}
#[spacetimedb::table(accessor = auth_store_snapshot)] #[spacetimedb::table(accessor = auth_store_snapshot)]
pub struct AuthStoreSnapshot { pub struct AuthStoreSnapshot {
#[primary_key] #[primary_key]
@@ -29,6 +45,63 @@ pub struct AuthStoreSnapshot {
pub(crate) updated_at: Timestamp, pub(crate) updated_at: Timestamp,
} }
#[spacetimedb::table(
accessor = user_account,
index(accessor = by_user_account_username, btree(columns = [username])),
index(accessor = by_user_account_public_code, btree(columns = [public_user_code]))
)]
pub struct UserAccount {
#[primary_key]
pub(crate) user_id: String,
pub(crate) public_user_code: String,
pub(crate) username: String,
pub(crate) display_name: String,
pub(crate) phone_number_masked: Option<String>,
pub(crate) phone_number_e164: Option<String>,
pub(crate) login_method: String,
pub(crate) binding_status: String,
pub(crate) wechat_bound: bool,
pub(crate) password_hash: String,
pub(crate) password_login_enabled: bool,
pub(crate) token_version: u64,
}
#[spacetimedb::table(
accessor = auth_identity,
index(accessor = by_auth_identity_user_id, btree(columns = [user_id])),
index(accessor = by_auth_identity_provider_uid, btree(columns = [provider, provider_uid]))
)]
pub struct AuthIdentity {
#[primary_key]
pub(crate) identity_id: String,
pub(crate) user_id: String,
pub(crate) provider: String,
pub(crate) provider_uid: String,
pub(crate) provider_union_id: Option<String>,
pub(crate) phone_e164: Option<String>,
pub(crate) display_name: Option<String>,
pub(crate) avatar_url: Option<String>,
}
#[spacetimedb::table(
accessor = refresh_session,
index(accessor = by_refresh_session_user_id, btree(columns = [user_id])),
index(accessor = by_refresh_session_token_hash, btree(columns = [refresh_token_hash]))
)]
pub struct RefreshSession {
#[primary_key]
pub(crate) session_id: String,
pub(crate) user_id: String,
pub(crate) refresh_token_hash: String,
pub(crate) issued_by_provider: String,
pub(crate) client_info_json: String,
pub(crate) expires_at: String,
pub(crate) revoked_at: Option<String>,
pub(crate) created_at: String,
pub(crate) updated_at: String,
pub(crate) last_seen_at: String,
}
// Axum 启动恢复认证状态时读取当前快照;记录不存在代表尚未产生登录态。 // Axum 启动恢复认证状态时读取当前快照;记录不存在代表尚未产生登录态。
#[spacetimedb::procedure] #[spacetimedb::procedure]
pub fn get_auth_store_snapshot(ctx: &mut ProcedureContext) -> AuthStoreSnapshotProcedureResult { pub fn get_auth_store_snapshot(ctx: &mut ProcedureContext) -> AuthStoreSnapshotProcedureResult {
@@ -66,6 +139,43 @@ pub fn upsert_auth_store_snapshot(
} }
} }
#[spacetimedb::procedure]
pub fn import_auth_store_snapshot(
ctx: &mut ProcedureContext,
) -> AuthStoreSnapshotImportProcedureResult {
match ctx.try_with_tx(|tx| import_auth_store_snapshot_tx(tx)) {
Ok(record) => AuthStoreSnapshotImportProcedureResult {
ok: true,
record: Some(record),
error_message: None,
},
Err(message) => AuthStoreSnapshotImportProcedureResult {
ok: false,
record: None,
error_message: Some(message),
},
}
}
// Axum ??????????????? module-auth ????????????????
#[spacetimedb::procedure]
pub fn export_auth_store_snapshot_from_tables(
ctx: &mut ProcedureContext,
) -> AuthStoreSnapshotProcedureResult {
match ctx.try_with_tx(|tx| export_auth_store_snapshot_from_tables_tx(tx)) {
Ok(record) => AuthStoreSnapshotProcedureResult {
ok: true,
record: Some(record),
error_message: None,
},
Err(message) => AuthStoreSnapshotProcedureResult {
ok: false,
record: None,
error_message: Some(message),
},
}
}
fn get_auth_store_snapshot_tx(ctx: &ReducerContext) -> Result<AuthStoreSnapshotRecord, String> { fn get_auth_store_snapshot_tx(ctx: &ReducerContext) -> Result<AuthStoreSnapshotRecord, String> {
Ok( Ok(
match ctx match ctx
@@ -120,3 +230,326 @@ fn upsert_auth_store_snapshot_tx(
updated_at_micros: Some(input.updated_at_micros), updated_at_micros: Some(input.updated_at_micros),
}) })
} }
fn import_auth_store_snapshot_tx(
ctx: &ReducerContext,
) -> Result<AuthStoreSnapshotImportRecord, String> {
let snapshot = ctx
.db
.auth_store_snapshot()
.snapshot_id()
.find(&AUTH_STORE_SNAPSHOT_ID.to_string())
.ok_or_else(|| "认证快照不存在,无法导入正式表".to_string())?;
let parsed = serde_json::from_str::<PersistentAuthStoreSnapshot>(&snapshot.snapshot_json)
.map_err(|error| format!("认证快照 JSON 解析失败:{error}"))?;
clear_auth_target_tables(ctx);
let mut imported_user_count = 0_u32;
let mut imported_identity_count = 0_u32;
let mut imported_refresh_session_count = 0_u32;
for stored_user in parsed.users_by_username.into_values() {
let user = stored_user.user;
ctx.db.user_account().insert(UserAccount {
user_id: user.id.clone(),
public_user_code: user.public_user_code,
username: user.username,
display_name: user.display_name,
phone_number_masked: user.phone_number_masked,
phone_number_e164: stored_user.phone_number.clone(),
login_method: user.login_method,
binding_status: user.binding_status,
wechat_bound: user.wechat_bound,
password_hash: stored_user.password_hash,
password_login_enabled: stored_user.password_login_enabled,
token_version: user.token_version,
});
imported_user_count += 1;
if let Some(phone_number) = stored_user.phone_number {
ctx.db.auth_identity().insert(AuthIdentity {
identity_id: format!("authi_phone_{}", sanitize_identity_component(&phone_number)),
user_id: user.id,
provider: "phone".to_string(),
provider_uid: phone_number.clone(),
provider_union_id: None,
phone_e164: Some(phone_number),
display_name: None,
avatar_url: None,
});
imported_identity_count += 1;
}
}
for identity in parsed.wechat_identity_by_provider_uid.into_values() {
ctx.db.auth_identity().insert(AuthIdentity {
identity_id: format!(
"authi_wechat_{}",
sanitize_identity_component(&identity.provider_uid)
),
user_id: identity.user_id,
provider: "wechat".to_string(),
provider_uid: identity.provider_uid,
provider_union_id: identity.provider_union_id,
phone_e164: None,
display_name: identity.display_name,
avatar_url: identity.avatar_url,
});
imported_identity_count += 1;
}
for stored_session in parsed.sessions_by_id.into_values() {
let session = stored_session.session;
let client_info_json = serde_json::to_string(&session.client_info)
.map_err(|error| format!("客户端身份序列化失败:{error}"))?;
ctx.db.refresh_session().insert(RefreshSession {
session_id: session.session_id,
user_id: session.user_id,
refresh_token_hash: session.refresh_token_hash,
issued_by_provider: session.issued_by_provider,
client_info_json,
expires_at: session.expires_at,
revoked_at: session.revoked_at,
created_at: session.created_at,
updated_at: session.updated_at,
last_seen_at: session.last_seen_at,
});
imported_refresh_session_count += 1;
}
Ok(AuthStoreSnapshotImportRecord {
imported_user_count,
imported_identity_count,
imported_refresh_session_count,
})
}
fn export_auth_store_snapshot_from_tables_tx(
ctx: &ReducerContext,
) -> Result<AuthStoreSnapshotRecord, String> {
let users = ctx.db.user_account().iter().collect::<Vec<_>>();
let identities = ctx.db.auth_identity().iter().collect::<Vec<_>>();
let sessions = ctx.db.refresh_session().iter().collect::<Vec<_>>();
if users.is_empty() && identities.is_empty() && sessions.is_empty() {
return Ok(AuthStoreSnapshotRecord {
snapshot_json: None,
updated_at_micros: None,
});
}
let mut phone_identity_by_user_id = std::collections::HashMap::new();
let mut phone_to_user_id = std::collections::HashMap::new();
let mut wechat_identity_by_provider_uid = std::collections::HashMap::new();
let mut user_id_by_provider_union_id = std::collections::HashMap::new();
for identity in identities {
match identity.provider.as_str() {
"phone" => {
let phone_number = identity
.phone_e164
.clone()
.unwrap_or_else(|| identity.provider_uid.clone());
phone_to_user_id.insert(phone_number.clone(), identity.user_id.clone());
phone_identity_by_user_id.insert(identity.user_id, phone_number);
}
"wechat" => {
if let Some(union_id) = identity.provider_union_id.clone() {
user_id_by_provider_union_id.insert(union_id, identity.user_id.clone());
}
wechat_identity_by_provider_uid.insert(
identity.provider_uid.clone(),
StoredWechatIdentitySnapshot {
user_id: identity.user_id,
provider_uid: identity.provider_uid,
provider_union_id: identity.provider_union_id,
display_name: identity.display_name,
avatar_url: identity.avatar_url,
},
);
}
_ => {}
}
}
let mut next_user_id = 1_u64;
let mut users_by_username = std::collections::HashMap::new();
for user in users {
if let Some(numeric_id) = user
.user_id
.strip_prefix("user_")
.and_then(|value| value.parse::<u64>().ok())
{
next_user_id = next_user_id.max(numeric_id.saturating_add(1));
}
let auth_user = AuthUserSnapshot {
id: user.user_id.clone(),
public_user_code: user.public_user_code,
username: user.username.clone(),
display_name: user.display_name,
phone_number_masked: user.phone_number_masked,
login_method: user.login_method,
binding_status: user.binding_status,
wechat_bound: user.wechat_bound,
token_version: user.token_version,
};
users_by_username.insert(
user.username,
StoredPasswordUserSnapshot {
user: auth_user,
password_hash: user.password_hash,
password_login_enabled: user.password_login_enabled,
phone_number: user
.phone_number_e164
.or_else(|| phone_identity_by_user_id.remove(&user.user_id)),
},
);
}
let mut sessions_by_id = std::collections::HashMap::new();
let mut session_id_by_refresh_token_hash = std::collections::HashMap::new();
for session in sessions {
let client_info = serde_json::from_str::<Value>(&session.client_info_json)
.map_err(|error| format!("refresh session ????? JSON ?????{error}"))?;
session_id_by_refresh_token_hash.insert(
session.refresh_token_hash.clone(),
session.session_id.clone(),
);
sessions_by_id.insert(
session.session_id.clone(),
StoredRefreshSessionSnapshot {
session: RefreshSessionSnapshot {
session_id: session.session_id,
user_id: session.user_id,
refresh_token_hash: session.refresh_token_hash,
issued_by_provider: session.issued_by_provider,
client_info,
expires_at: session.expires_at,
revoked_at: session.revoked_at,
created_at: session.created_at,
updated_at: session.updated_at,
last_seen_at: session.last_seen_at,
},
},
);
}
let snapshot = PersistentAuthStoreSnapshot {
next_user_id,
users_by_username,
phone_to_user_id,
sessions_by_id,
session_id_by_refresh_token_hash,
wechat_identity_by_provider_uid,
user_id_by_provider_union_id,
};
let snapshot_json =
serde_json::to_string_pretty(&snapshot).map_err(|error| format!("?????????????{error}"))?;
Ok(AuthStoreSnapshotRecord {
snapshot_json: Some(snapshot_json),
updated_at_micros: None,
})
}
fn clear_auth_target_tables(ctx: &ReducerContext) {
for row in ctx.db.refresh_session().iter().collect::<Vec<_>>() {
ctx.db
.refresh_session()
.session_id()
.delete(&row.session_id);
}
for row in ctx.db.auth_identity().iter().collect::<Vec<_>>() {
ctx.db
.auth_identity()
.identity_id()
.delete(&row.identity_id);
}
for row in ctx.db.user_account().iter().collect::<Vec<_>>() {
ctx.db.user_account().user_id().delete(&row.user_id);
}
}
fn sanitize_identity_component(value: &str) -> String {
let sanitized = value
.chars()
.map(|character| {
if character.is_ascii_alphanumeric() {
character
} else {
'_'
}
})
.collect::<String>();
sanitized.trim_matches('_').to_string()
}
#[derive(Deserialize, Serialize)]
struct PersistentAuthStoreSnapshot {
#[serde(default = "default_next_user_id")]
next_user_id: u64,
users_by_username: std::collections::HashMap<String, StoredPasswordUserSnapshot>,
#[serde(default)]
phone_to_user_id: std::collections::HashMap<String, String>,
sessions_by_id: std::collections::HashMap<String, StoredRefreshSessionSnapshot>,
#[serde(default)]
session_id_by_refresh_token_hash: std::collections::HashMap<String, String>,
wechat_identity_by_provider_uid:
std::collections::HashMap<String, StoredWechatIdentitySnapshot>,
#[serde(default)]
user_id_by_provider_union_id: std::collections::HashMap<String, String>,
}
fn default_next_user_id() -> u64 {
1
}
#[derive(Deserialize, Serialize)]
struct StoredPasswordUserSnapshot {
user: AuthUserSnapshot,
password_hash: String,
#[serde(default)]
password_login_enabled: bool,
phone_number: Option<String>,
}
#[derive(Deserialize, Serialize)]
struct AuthUserSnapshot {
id: String,
public_user_code: String,
username: String,
display_name: String,
phone_number_masked: Option<String>,
login_method: String,
binding_status: String,
wechat_bound: bool,
token_version: u64,
}
#[derive(Deserialize, Serialize)]
struct StoredWechatIdentitySnapshot {
user_id: String,
provider_uid: String,
provider_union_id: Option<String>,
display_name: Option<String>,
avatar_url: Option<String>,
}
#[derive(Deserialize, Serialize)]
struct StoredRefreshSessionSnapshot {
session: RefreshSessionSnapshot,
}
#[derive(Deserialize, Serialize)]
struct RefreshSessionSnapshot {
session_id: String,
user_id: String,
refresh_token_hash: String,
issued_by_provider: String,
client_info: Value,
expires_at: String,
revoked_at: Option<String>,
created_at: String,
updated_at: String,
last_seen_at: String,
}