迁移后端认证与拆分 Spacetime 客户端
This commit is contained in:
205
server-rs/crates/spacetime-client/src/ai.rs
Normal file
205
server-rs/crates/spacetime-client/src/ai.rs
Normal file
@@ -0,0 +1,205 @@
|
||||
use super::*;
|
||||
|
||||
impl SpacetimeClient {
|
||||
pub async fn create_ai_task(
|
||||
&self,
|
||||
input: DomainAiTaskCreateInput,
|
||||
) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_ai_task_create_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().create_ai_task_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_ai_task_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn start_ai_task(
|
||||
&self,
|
||||
input: DomainAiTaskStartInput,
|
||||
) -> Result<(), SpacetimeClientError> {
|
||||
let reducer_input = map_ai_task_start_input(input);
|
||||
|
||||
self.call_reducer_after_connect(move |connection, sender| {
|
||||
let callback_sender = sender.clone();
|
||||
if let Err(error) =
|
||||
connection
|
||||
.reducers
|
||||
.start_ai_task_then(reducer_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(|inner| inner.map_err(SpacetimeClientError::Runtime));
|
||||
send_reducer_once(&callback_sender, mapped);
|
||||
})
|
||||
{
|
||||
send_reducer_once(
|
||||
&sender,
|
||||
Err(SpacetimeClientError::Procedure(error.to_string())),
|
||||
);
|
||||
}
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn start_ai_task_stage(
|
||||
&self,
|
||||
input: DomainAiTaskStageStartInput,
|
||||
) -> Result<(), SpacetimeClientError> {
|
||||
let reducer_input = map_ai_task_stage_start_input(input);
|
||||
|
||||
self.call_reducer_after_connect(move |connection, sender| {
|
||||
let callback_sender = sender.clone();
|
||||
if let Err(error) =
|
||||
connection
|
||||
.reducers
|
||||
.start_ai_task_stage_then(reducer_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(|inner| inner.map_err(SpacetimeClientError::Runtime));
|
||||
send_reducer_once(&callback_sender, mapped);
|
||||
})
|
||||
{
|
||||
send_reducer_once(
|
||||
&sender,
|
||||
Err(SpacetimeClientError::Procedure(error.to_string())),
|
||||
);
|
||||
}
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn append_ai_text_chunk(
|
||||
&self,
|
||||
input: DomainAiTextChunkAppendInput,
|
||||
) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_ai_text_chunk_append_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.append_ai_text_chunk_and_return_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_ai_task_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn complete_ai_stage(
|
||||
&self,
|
||||
input: DomainAiStageCompletionInput,
|
||||
) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_ai_stage_completion_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().complete_ai_stage_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_ai_task_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn attach_ai_result_reference(
|
||||
&self,
|
||||
input: DomainAiResultReferenceInput,
|
||||
) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_ai_result_reference_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.attach_ai_result_reference_and_return_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_ai_task_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn complete_ai_task(
|
||||
&self,
|
||||
input: DomainAiTaskFinishInput,
|
||||
) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_ai_task_finish_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().complete_ai_task_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_ai_task_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn fail_ai_task(
|
||||
&self,
|
||||
input: DomainAiTaskFailureInput,
|
||||
) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_ai_task_failure_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().fail_ai_task_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_ai_task_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn cancel_ai_task(
|
||||
&self,
|
||||
input: DomainAiTaskCancelInput,
|
||||
) -> Result<AiTaskMutationRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_ai_task_cancel_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().cancel_ai_task_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_ai_task_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
44
server-rs/crates/spacetime-client/src/assets.rs
Normal file
44
server-rs/crates/spacetime-client/src/assets.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
use super::*;
|
||||
|
||||
impl SpacetimeClient {
|
||||
pub async fn confirm_asset_object(
|
||||
&self,
|
||||
input: module_assets::AssetObjectUpsertInput,
|
||||
) -> Result<AssetObjectRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_upsert_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.confirm_asset_object_and_return_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn bind_asset_object_to_entity(
|
||||
&self,
|
||||
input: module_assets::AssetEntityBindingInput,
|
||||
) -> Result<AssetEntityBindingRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_entity_binding_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.bind_asset_object_to_entity_and_return_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_entity_binding_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
46
server-rs/crates/spacetime-client/src/auth.rs
Normal file
46
server-rs/crates/spacetime-client/src/auth.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
use super::*;
|
||||
|
||||
impl SpacetimeClient {
|
||||
pub async fn get_auth_store_snapshot(
|
||||
&self,
|
||||
) -> Result<AuthStoreSnapshotRecord, SpacetimeClientError> {
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.get_auth_store_snapshot_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 upsert_auth_store_snapshot(
|
||||
&self,
|
||||
snapshot_json: String,
|
||||
updated_at_micros: i64,
|
||||
) -> Result<AuthStoreSnapshotRecord, SpacetimeClientError> {
|
||||
let procedure_input = AuthStoreSnapshotUpsertInput {
|
||||
snapshot_json,
|
||||
updated_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().upsert_auth_store_snapshot_then(
|
||||
procedure_input,
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
263
server-rs/crates/spacetime-client/src/big_fish.rs
Normal file
263
server-rs/crates/spacetime-client/src/big_fish.rs
Normal file
@@ -0,0 +1,263 @@
|
||||
use super::*;
|
||||
|
||||
impl SpacetimeClient {
|
||||
pub async fn create_big_fish_session(
|
||||
&self,
|
||||
input: BigFishSessionCreateRecordInput,
|
||||
) -> Result<BigFishSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = BigFishSessionCreateInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
seed_text: input.seed_text,
|
||||
welcome_message_id: input.welcome_message_id,
|
||||
welcome_message_text: input.welcome_message_text,
|
||||
created_at_micros: input.created_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().create_big_fish_session_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 get_big_fish_session(
|
||||
&self,
|
||||
session_id: String,
|
||||
owner_user_id: String,
|
||||
) -> Result<BigFishSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = BigFishSessionGetInput {
|
||||
session_id,
|
||||
owner_user_id,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.get_big_fish_session_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 list_big_fish_works(
|
||||
&self,
|
||||
owner_user_id: String,
|
||||
) -> Result<Vec<BigFishWorkSummaryRecord>, SpacetimeClientError> {
|
||||
let procedure_input = BigFishWorksListInput { owner_user_id };
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.list_big_fish_works_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_big_fish_works_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn submit_big_fish_message(
|
||||
&self,
|
||||
input: BigFishMessageSubmitRecordInput,
|
||||
) -> Result<BigFishSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = BigFishMessageSubmitInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
user_message_id: input.user_message_id,
|
||||
user_message_text: input.user_message_text,
|
||||
assistant_message_id: input.assistant_message_id,
|
||||
submitted_at_micros: input.submitted_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().submit_big_fish_message_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(
|
||||
&self,
|
||||
session_id: String,
|
||||
owner_user_id: String,
|
||||
compiled_at_micros: i64,
|
||||
) -> Result<BigFishSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = BigFishDraftCompileInput {
|
||||
session_id,
|
||||
owner_user_id,
|
||||
compiled_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().compile_big_fish_draft_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 generate_big_fish_asset(
|
||||
&self,
|
||||
input: BigFishAssetGenerateRecordInput,
|
||||
) -> Result<BigFishSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = BigFishAssetGenerateInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
asset_kind: map_big_fish_asset_kind_input(input.asset_kind.as_str())?,
|
||||
level: input.level,
|
||||
motion_key: input.motion_key,
|
||||
asset_url: input.asset_url,
|
||||
generated_at_micros: input.generated_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().generate_big_fish_asset_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 publish_big_fish_game(
|
||||
&self,
|
||||
session_id: String,
|
||||
owner_user_id: String,
|
||||
published_at_micros: i64,
|
||||
) -> Result<BigFishSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = BigFishPublishInput {
|
||||
session_id,
|
||||
owner_user_id,
|
||||
published_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().publish_big_fish_game_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 start_big_fish_run(
|
||||
&self,
|
||||
input: BigFishRunStartRecordInput,
|
||||
) -> Result<BigFishRuntimeRecord, SpacetimeClientError> {
|
||||
let procedure_input = BigFishRunStartInput {
|
||||
run_id: input.run_id,
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
started_at_micros: input.started_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.start_big_fish_run_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_big_fish_run_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn submit_big_fish_input(
|
||||
&self,
|
||||
input: BigFishRunInputSubmitRecordInput,
|
||||
) -> Result<BigFishRuntimeRecord, SpacetimeClientError> {
|
||||
let procedure_input = BigFishRunInputSubmitInput {
|
||||
run_id: input.run_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
input_x: input.input_x,
|
||||
input_y: input.input_y,
|
||||
submitted_at_micros: input.submitted_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().submit_big_fish_input_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_big_fish_run_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_big_fish_run(
|
||||
&self,
|
||||
run_id: String,
|
||||
owner_user_id: String,
|
||||
) -> Result<BigFishRuntimeRecord, SpacetimeClientError> {
|
||||
let procedure_input = BigFishRunGetInput {
|
||||
run_id,
|
||||
owner_user_id,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.get_big_fish_run_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_big_fish_run_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
72
server-rs/crates/spacetime-client/src/combat.rs
Normal file
72
server-rs/crates/spacetime-client/src/combat.rs
Normal file
@@ -0,0 +1,72 @@
|
||||
use super::*;
|
||||
|
||||
impl SpacetimeClient {
|
||||
pub async fn create_battle_state(
|
||||
&self,
|
||||
input: DomainBattleStateInput,
|
||||
) -> Result<BattleStateRecord, SpacetimeClientError> {
|
||||
validate_battle_state_input(&input)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?;
|
||||
let procedure_input = map_battle_state_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().create_battle_state_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_battle_state_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_battle_state(
|
||||
&self,
|
||||
battle_state_id: String,
|
||||
) -> Result<BattleStateRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_battle_state_query_input(
|
||||
build_battle_state_query_input(battle_state_id)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.get_battle_state_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_battle_state_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn resolve_combat_action(
|
||||
&self,
|
||||
input: DomainResolveCombatActionInput,
|
||||
) -> Result<ResolveCombatActionRecord, SpacetimeClientError> {
|
||||
validate_resolve_combat_action_input(&input)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?;
|
||||
let procedure_input = map_resolve_combat_action_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.resolve_combat_action_and_return_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_resolve_combat_action_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
481
server-rs/crates/spacetime-client/src/custom_world.rs
Normal file
481
server-rs/crates/spacetime-client/src/custom_world.rs
Normal file
@@ -0,0 +1,481 @@
|
||||
use super::*;
|
||||
|
||||
impl SpacetimeClient {
|
||||
pub async fn list_custom_world_profiles(
|
||||
&self,
|
||||
owner_user_id: String,
|
||||
) -> Result<Vec<CustomWorldLibraryEntryRecord>, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldProfileListInput { owner_user_id };
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().list_custom_world_profiles_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_profile_list_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_custom_world_library_detail(
|
||||
&self,
|
||||
owner_user_id: String,
|
||||
profile_id: String,
|
||||
) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldLibraryDetailInput {
|
||||
owner_user_id,
|
||||
profile_id,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.get_custom_world_library_detail_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_library_detail_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn upsert_custom_world_profile(
|
||||
&self,
|
||||
input: CustomWorldProfileUpsertRecordInput,
|
||||
) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_custom_world_profile_upsert_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.upsert_custom_world_profile_and_return_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_library_mutation_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn publish_custom_world_profile(
|
||||
&self,
|
||||
profile_id: String,
|
||||
owner_user_id: String,
|
||||
public_work_code: Option<String>,
|
||||
author_public_user_code: String,
|
||||
author_display_name: String,
|
||||
published_at_micros: i64,
|
||||
) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldProfilePublishInput {
|
||||
profile_id,
|
||||
owner_user_id,
|
||||
public_work_code,
|
||||
author_public_user_code,
|
||||
author_display_name,
|
||||
published_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.publish_custom_world_profile_and_return_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_library_mutation_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn unpublish_custom_world_profile(
|
||||
&self,
|
||||
profile_id: String,
|
||||
owner_user_id: String,
|
||||
author_display_name: String,
|
||||
updated_at_micros: i64,
|
||||
) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldProfileUnpublishInput {
|
||||
profile_id,
|
||||
owner_user_id,
|
||||
author_display_name,
|
||||
updated_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.unpublish_custom_world_profile_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_library_mutation_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn delete_custom_world_profile(
|
||||
&self,
|
||||
profile_id: String,
|
||||
owner_user_id: String,
|
||||
deleted_at_micros: i64,
|
||||
) -> Result<Vec<CustomWorldLibraryEntryRecord>, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldProfileDeleteInput {
|
||||
profile_id,
|
||||
owner_user_id,
|
||||
deleted_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.delete_custom_world_profile_and_return_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_profile_list_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn list_custom_world_gallery_entries(
|
||||
&self,
|
||||
) -> Result<Vec<CustomWorldGalleryEntryRecord>, SpacetimeClientError> {
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.list_custom_world_gallery_entries_then(move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_gallery_list_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_custom_world_gallery_detail(
|
||||
&self,
|
||||
owner_user_id: String,
|
||||
profile_id: String,
|
||||
) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldGalleryDetailInput {
|
||||
owner_user_id,
|
||||
profile_id,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.get_custom_world_gallery_detail_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_library_mutation_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_custom_world_gallery_detail_by_code(
|
||||
&self,
|
||||
public_work_code: String,
|
||||
) -> Result<CustomWorldLibraryMutationRecord, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldGalleryDetailByCodeInput { public_work_code };
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.get_custom_world_gallery_detail_by_code_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_library_mutation_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn publish_custom_world_world(
|
||||
&self,
|
||||
input: CustomWorldPublishWorldRecordInput,
|
||||
) -> Result<CustomWorldPublishWorldRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_custom_world_publish_world_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().publish_custom_world_world_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_publish_world_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn create_custom_world_agent_session(
|
||||
&self,
|
||||
input: CustomWorldAgentSessionCreateRecordInput,
|
||||
) -> Result<CustomWorldAgentSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldAgentSessionCreateInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
seed_text: input.seed_text,
|
||||
welcome_message_id: input.welcome_message_id,
|
||||
welcome_message_text: input.welcome_message_text,
|
||||
anchor_content_json: input.anchor_content_json,
|
||||
creator_intent_json: input.creator_intent_json,
|
||||
creator_intent_readiness_json: input.creator_intent_readiness_json,
|
||||
anchor_pack_json: input.anchor_pack_json,
|
||||
lock_state_json: input.lock_state_json,
|
||||
draft_profile_json: input.draft_profile_json,
|
||||
pending_clarifications_json: input.pending_clarifications_json,
|
||||
suggested_actions_json: input.suggested_actions_json,
|
||||
recommended_replies_json: input.recommended_replies_json,
|
||||
quality_findings_json: input.quality_findings_json,
|
||||
asset_coverage_json: input.asset_coverage_json,
|
||||
checkpoints_json: input.checkpoints_json,
|
||||
created_at_micros: input.created_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.create_custom_world_agent_session_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_agent_session_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_custom_world_agent_session(
|
||||
&self,
|
||||
session_id: String,
|
||||
owner_user_id: String,
|
||||
) -> Result<CustomWorldAgentSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldAgentSessionGetInput {
|
||||
session_id,
|
||||
owner_user_id,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().get_custom_world_agent_session_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_agent_session_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn list_custom_world_works(
|
||||
&self,
|
||||
owner_user_id: String,
|
||||
) -> Result<Vec<CustomWorldWorkSummaryRecord>, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldWorksListInput { owner_user_id };
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().list_custom_world_works_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_works_list_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_custom_world_agent_card_detail(
|
||||
&self,
|
||||
session_id: String,
|
||||
owner_user_id: String,
|
||||
card_id: String,
|
||||
) -> Result<CustomWorldDraftCardDetailRecord, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldAgentCardDetailGetInput {
|
||||
session_id,
|
||||
owner_user_id,
|
||||
card_id,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.get_custom_world_agent_card_detail_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_draft_card_detail_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn execute_custom_world_agent_action(
|
||||
&self,
|
||||
input: CustomWorldAgentActionExecuteRecordInput,
|
||||
) -> Result<CustomWorldAgentActionExecuteRecord, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldAgentActionExecuteInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
operation_id: input.operation_id,
|
||||
action: input.action,
|
||||
payload_json: input.payload_json,
|
||||
submitted_at_micros: input.submitted_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.execute_custom_world_agent_action_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_agent_action_execute_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn submit_custom_world_agent_message(
|
||||
&self,
|
||||
input: CustomWorldAgentMessageSubmitRecordInput,
|
||||
) -> Result<CustomWorldAgentOperationRecord, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldAgentMessageSubmitInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
user_message_id: input.user_message_id,
|
||||
user_message_text: input.user_message_text,
|
||||
operation_id: input.operation_id,
|
||||
submitted_at_micros: input.submitted_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.submit_custom_world_agent_message_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_agent_operation_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn finalize_custom_world_agent_message(
|
||||
&self,
|
||||
input: CustomWorldAgentMessageFinalizeRecordInput,
|
||||
) -> Result<CustomWorldAgentOperationRecord, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldAgentMessageFinalizeInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
operation_id: input.operation_id,
|
||||
assistant_message_id: input.assistant_message_id,
|
||||
assistant_reply_text: input.assistant_reply_text,
|
||||
phase_label: input.phase_label,
|
||||
phase_detail: input.phase_detail,
|
||||
operation_status: parse_rpg_agent_operation_status_record(
|
||||
input.operation_status.as_str(),
|
||||
)?,
|
||||
operation_progress: input.operation_progress,
|
||||
stage: parse_rpg_agent_stage_record(input.stage.as_str())?,
|
||||
progress_percent: input.progress_percent,
|
||||
focus_card_id: input.focus_card_id,
|
||||
anchor_content_json: input.anchor_content_json,
|
||||
creator_intent_json: input.creator_intent_json,
|
||||
creator_intent_readiness_json: input.creator_intent_readiness_json,
|
||||
anchor_pack_json: input.anchor_pack_json,
|
||||
draft_profile_json: input.draft_profile_json,
|
||||
pending_clarifications_json: input.pending_clarifications_json,
|
||||
suggested_actions_json: input.suggested_actions_json,
|
||||
recommended_replies_json: input.recommended_replies_json,
|
||||
quality_findings_json: input.quality_findings_json,
|
||||
asset_coverage_json: input.asset_coverage_json,
|
||||
error_message: input.error_message,
|
||||
updated_at_micros: input.updated_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.finalize_custom_world_agent_message_turn_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_agent_operation_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_custom_world_agent_operation(
|
||||
&self,
|
||||
session_id: String,
|
||||
owner_user_id: String,
|
||||
operation_id: String,
|
||||
) -> Result<CustomWorldAgentOperationRecord, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldAgentOperationGetInput {
|
||||
session_id,
|
||||
owner_user_id,
|
||||
operation_id,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.get_custom_world_agent_operation_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_custom_world_agent_operation_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
29
server-rs/crates/spacetime-client/src/inventory.rs
Normal file
29
server-rs/crates/spacetime-client/src/inventory.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use super::*;
|
||||
|
||||
impl SpacetimeClient {
|
||||
pub async fn get_runtime_inventory_state(
|
||||
&self,
|
||||
runtime_session_id: String,
|
||||
actor_user_id: String,
|
||||
) -> Result<RuntimeInventoryStateRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_runtime_inventory_state_query_input(
|
||||
build_runtime_inventory_state_query_input(runtime_session_id, actor_user_id)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().get_runtime_inventory_state_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_inventory_state_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,6 +2,21 @@
|
||||
#[rustfmt::skip]
|
||||
pub mod module_bindings;
|
||||
|
||||
mod mapper;
|
||||
pub use mapper::*;
|
||||
|
||||
pub mod ai;
|
||||
pub mod assets;
|
||||
pub mod auth;
|
||||
pub mod big_fish;
|
||||
pub mod combat;
|
||||
pub mod custom_world;
|
||||
pub mod inventory;
|
||||
pub mod npc;
|
||||
pub mod puzzle;
|
||||
pub mod runtime;
|
||||
pub mod story;
|
||||
|
||||
use std::{
|
||||
error::Error,
|
||||
fmt,
|
||||
@@ -69,9 +84,11 @@ use module_puzzle::{
|
||||
PuzzleWorkProfile as DomainPuzzleWorkProfile,
|
||||
};
|
||||
use module_runtime::{
|
||||
RuntimeBrowseHistoryRecord, RuntimeBrowseHistoryThemeMode, RuntimePlatformTheme,
|
||||
RuntimeBrowseHistoryRecord, RuntimeBrowseHistoryThemeMode as DomainRuntimeBrowseHistoryThemeMode,
|
||||
RuntimePlatformTheme as DomainRuntimePlatformTheme,
|
||||
RuntimeProfileDashboardRecord, RuntimeProfilePlayStatsRecord, RuntimeProfileSaveArchiveRecord,
|
||||
RuntimeProfileWalletLedgerEntryRecord, RuntimeProfileWalletLedgerSourceType,
|
||||
RuntimeProfileWalletLedgerEntryRecord,
|
||||
RuntimeProfileWalletLedgerSourceType as DomainRuntimeProfileWalletLedgerSourceType,
|
||||
RuntimeSettingsRecord, RuntimeSnapshotRecord, build_runtime_browse_history_clear_input,
|
||||
build_runtime_browse_history_list_input, build_runtime_browse_history_record,
|
||||
build_runtime_browse_history_sync_input, build_runtime_profile_dashboard_get_input,
|
||||
@@ -104,6 +121,7 @@ use tokio::{
|
||||
time::timeout,
|
||||
};
|
||||
|
||||
<<<<<<< HEAD
|
||||
use crate::module_bindings::{
|
||||
AiResultReferenceInput as BindingAiResultReferenceInput,
|
||||
AiResultReferenceKind as BindingAiResultReferenceKind,
|
||||
@@ -360,6 +378,9 @@ use crate::module_bindings::{
|
||||
upsert_runtime_setting_and_return_procedure::upsert_runtime_setting_and_return as _,
|
||||
upsert_runtime_snapshot_and_return_procedure::upsert_runtime_snapshot_and_return as _,
|
||||
};
|
||||
=======
|
||||
use crate::module_bindings::*;
|
||||
>>>>>>> 4f272a50 (迁移后端认证与拆分 Spacetime 客户端)
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SpacetimeClientConfig {
|
||||
@@ -369,6 +390,12 @@ pub struct SpacetimeClientConfig {
|
||||
pub pool_size: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct AuthStoreSnapshotRecord {
|
||||
pub snapshot_json: Option<String>,
|
||||
pub updated_at_micros: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SpacetimeClient {
|
||||
config: SpacetimeClientConfig,
|
||||
@@ -431,6 +458,7 @@ impl SpacetimeClient {
|
||||
Self { config, pool }
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub async fn create_ai_task(
|
||||
&self,
|
||||
input: DomainAiTaskCreateInput,
|
||||
@@ -2362,6 +2390,8 @@ impl SpacetimeClient {
|
||||
.await
|
||||
}
|
||||
|
||||
=======
|
||||
>>>>>>> 4f272a50 (迁移后端认证与拆分 Spacetime 客户端)
|
||||
async fn call_after_connect<T>(
|
||||
&self,
|
||||
call: impl FnOnce(&DbConnection, ProcedureResultSender<T>) + Send + 'static,
|
||||
@@ -2596,6 +2626,7 @@ fn send_connect_once(
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
fn map_entity_binding_input(
|
||||
input: module_assets::AssetEntityBindingInput,
|
||||
) -> BindingAssetEntityBindingInput {
|
||||
@@ -7089,6 +7120,8 @@ fn map_inventory_item_source_kind(
|
||||
}
|
||||
}
|
||||
|
||||
=======
|
||||
>>>>>>> 4f272a50 (迁移后端认证与拆分 Spacetime 客户端)
|
||||
impl fmt::Display for SpacetimeClientError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
|
||||
4494
server-rs/crates/spacetime-client/src/mapper.rs
Normal file
4494
server-rs/crates/spacetime-client/src/mapper.rs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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_record_type::AuthStoreSnapshotRecord;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct AuthStoreSnapshotProcedureResult {
|
||||
pub ok: bool,
|
||||
pub record: Option::<AuthStoreSnapshotRecord>,
|
||||
pub error_message: Option::<String>,
|
||||
}
|
||||
|
||||
|
||||
impl __sdk::InModule for AuthStoreSnapshotProcedureResult {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// 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 AuthStoreSnapshotRecord {
|
||||
pub snapshot_json: Option::<String>,
|
||||
pub updated_at_micros: Option::<i64>,
|
||||
}
|
||||
|
||||
|
||||
impl __sdk::InModule for AuthStoreSnapshotRecord {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
@@ -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_store_snapshot_type::AuthStoreSnapshot;
|
||||
|
||||
/// Table handle for the table `auth_store_snapshot`.
|
||||
///
|
||||
/// Obtain a handle from the [`AuthStoreSnapshotTableAccess::auth_store_snapshot`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.auth_store_snapshot()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.auth_store_snapshot().on_insert(...)`.
|
||||
pub struct AuthStoreSnapshotTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<AuthStoreSnapshot>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `auth_store_snapshot`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait AuthStoreSnapshotTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`AuthStoreSnapshotTableHandle`], which mediates access to the table `auth_store_snapshot`.
|
||||
fn auth_store_snapshot(&self) -> AuthStoreSnapshotTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl AuthStoreSnapshotTableAccess for super::RemoteTables {
|
||||
fn auth_store_snapshot(&self) -> AuthStoreSnapshotTableHandle<'_> {
|
||||
AuthStoreSnapshotTableHandle {
|
||||
imp: self.imp.get_table::<AuthStoreSnapshot>("auth_store_snapshot"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AuthStoreSnapshotInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct AuthStoreSnapshotDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for AuthStoreSnapshotTableHandle<'ctx> {
|
||||
type Row = AuthStoreSnapshot;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 { self.imp.count() }
|
||||
fn iter(&self) -> impl Iterator<Item = AuthStoreSnapshot> + '_ { self.imp.iter() }
|
||||
|
||||
type InsertCallbackId = AuthStoreSnapshotInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AuthStoreSnapshotInsertCallbackId {
|
||||
AuthStoreSnapshotInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: AuthStoreSnapshotInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = AuthStoreSnapshotDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> AuthStoreSnapshotDeleteCallbackId {
|
||||
AuthStoreSnapshotDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: AuthStoreSnapshotDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AuthStoreSnapshotUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for AuthStoreSnapshotTableHandle<'ctx> {
|
||||
type UpdateCallbackId = AuthStoreSnapshotUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> AuthStoreSnapshotUpdateCallbackId {
|
||||
AuthStoreSnapshotUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: AuthStoreSnapshotUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `snapshot_id` unique index on the table `auth_store_snapshot`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`AuthStoreSnapshotSnapshotIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.auth_store_snapshot().snapshot_id().find(...)`.
|
||||
pub struct AuthStoreSnapshotSnapshotIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<AuthStoreSnapshot, String>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> AuthStoreSnapshotTableHandle<'ctx> {
|
||||
/// Get a handle on the `snapshot_id` unique index on the table `auth_store_snapshot`.
|
||||
pub fn snapshot_id(&self) -> AuthStoreSnapshotSnapshotIdUnique<'ctx> {
|
||||
AuthStoreSnapshotSnapshotIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<String>("snapshot_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> AuthStoreSnapshotSnapshotIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `snapshot_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<AuthStoreSnapshot> {
|
||||
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::<AuthStoreSnapshot>("auth_store_snapshot");
|
||||
_table.add_unique_constraint::<String>("snapshot_id", |row| &row.snapshot_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<AuthStoreSnapshot>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse(
|
||||
"TableUpdate<AuthStoreSnapshot>",
|
||||
"TableUpdate",
|
||||
).with_cause(e).into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `AuthStoreSnapshot`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait auth_store_snapshotQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `AuthStoreSnapshot`.
|
||||
fn auth_store_snapshot(&self) -> __sdk::__query_builder::Table<AuthStoreSnapshot>;
|
||||
}
|
||||
|
||||
impl auth_store_snapshotQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn auth_store_snapshot(&self) -> __sdk::__query_builder::Table<AuthStoreSnapshot> {
|
||||
__sdk::__query_builder::Table::new("auth_store_snapshot")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
// 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 AuthStoreSnapshot {
|
||||
pub snapshot_id: String,
|
||||
pub snapshot_json: String,
|
||||
pub updated_at: __sdk::Timestamp,
|
||||
}
|
||||
|
||||
|
||||
impl __sdk::InModule for AuthStoreSnapshot {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
|
||||
/// Column accessor struct for the table `AuthStoreSnapshot`.
|
||||
///
|
||||
/// Provides typed access to columns for query building.
|
||||
pub struct AuthStoreSnapshotCols {
|
||||
pub snapshot_id: __sdk::__query_builder::Col<AuthStoreSnapshot, String>,
|
||||
pub snapshot_json: __sdk::__query_builder::Col<AuthStoreSnapshot, String>,
|
||||
pub updated_at: __sdk::__query_builder::Col<AuthStoreSnapshot, __sdk::Timestamp>,
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::HasCols for AuthStoreSnapshot {
|
||||
type Cols = AuthStoreSnapshotCols;
|
||||
fn cols(table_name: &'static str) -> Self::Cols {
|
||||
AuthStoreSnapshotCols {
|
||||
snapshot_id: __sdk::__query_builder::Col::new(table_name, "snapshot_id"),
|
||||
snapshot_json: __sdk::__query_builder::Col::new(table_name, "snapshot_json"),
|
||||
updated_at: __sdk::__query_builder::Col::new(table_name, "updated_at"),
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Indexed column accessor struct for the table `AuthStoreSnapshot`.
|
||||
///
|
||||
/// Provides typed access to indexed columns for query building.
|
||||
pub struct AuthStoreSnapshotIxCols {
|
||||
pub snapshot_id: __sdk::__query_builder::IxCol<AuthStoreSnapshot, String>,
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::HasIxCols for AuthStoreSnapshot {
|
||||
type IxCols = AuthStoreSnapshotIxCols;
|
||||
fn ix_cols(table_name: &'static str) -> Self::IxCols {
|
||||
AuthStoreSnapshotIxCols {
|
||||
snapshot_id: __sdk::__query_builder::IxCol::new(table_name, "snapshot_id"),
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::CanBeLookupTable for AuthStoreSnapshot {}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// 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 AuthStoreSnapshotUpsertInput {
|
||||
pub snapshot_json: String,
|
||||
pub updated_at_micros: i64,
|
||||
}
|
||||
|
||||
|
||||
impl __sdk::InModule for AuthStoreSnapshotUpsertInput {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
@@ -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 GetAuthStoreSnapshotArgs {
|
||||
}
|
||||
|
||||
|
||||
impl __sdk::InModule for GetAuthStoreSnapshotArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the procedure `get_auth_store_snapshot`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteProcedures`].
|
||||
pub trait get_auth_store_snapshot {
|
||||
fn get_auth_store_snapshot(&self, ) {
|
||||
self.get_auth_store_snapshot_then( |_, _| {});
|
||||
}
|
||||
|
||||
fn get_auth_store_snapshot_then(
|
||||
&self,
|
||||
|
||||
__callback: impl FnOnce(&super::ProcedureEventContext, Result<AuthStoreSnapshotProcedureResult, __sdk::InternalError>) + Send + 'static,
|
||||
);
|
||||
}
|
||||
|
||||
impl get_auth_store_snapshot for super::RemoteProcedures {
|
||||
fn get_auth_store_snapshot_then(
|
||||
&self,
|
||||
|
||||
__callback: impl FnOnce(&super::ProcedureEventContext, Result<AuthStoreSnapshotProcedureResult, __sdk::InternalError>) + Send + 'static,
|
||||
) {
|
||||
self.imp.invoke_procedure_with_callback::<_, AuthStoreSnapshotProcedureResult>(
|
||||
"get_auth_store_snapshot",
|
||||
GetAuthStoreSnapshotArgs { },
|
||||
__callback,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,13 @@ pub mod asset_object_access_policy_type;
|
||||
pub mod asset_object_procedure_result_type;
|
||||
pub mod asset_object_upsert_input_type;
|
||||
pub mod asset_object_upsert_snapshot_type;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
pub mod auth_store_snapshot_type;
|
||||
pub mod auth_store_snapshot_procedure_result_type;
|
||||
pub mod auth_store_snapshot_record_type;
|
||||
pub mod auth_store_snapshot_upsert_input_type;
|
||||
>>>>>>> 4f272a50 (迁移后端认证与拆分 Spacetime 客户端)
|
||||
pub mod battle_mode_type;
|
||||
pub mod battle_state_type;
|
||||
pub mod battle_state_input_type;
|
||||
@@ -339,6 +346,10 @@ pub mod ai_task_stage_table;
|
||||
pub mod ai_text_chunk_table;
|
||||
pub mod asset_entity_binding_table;
|
||||
pub mod asset_object_table;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
pub mod auth_store_snapshot_table;
|
||||
>>>>>>> 4f272a50 (迁移后端认证与拆分 Spacetime 客户端)
|
||||
pub mod battle_state_table;
|
||||
pub mod big_fish_agent_message_table;
|
||||
pub mod big_fish_asset_slot_table;
|
||||
@@ -396,10 +407,17 @@ pub mod delete_runtime_snapshot_and_return_procedure;
|
||||
pub mod drag_puzzle_piece_or_group_procedure;
|
||||
pub mod execute_custom_world_agent_action_procedure;
|
||||
pub mod fail_ai_task_and_return_procedure;
|
||||
<<<<<<< HEAD
|
||||
pub mod finalize_big_fish_agent_message_turn_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 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;
|
||||
>>>>>>> 4f272a50 (迁移后端认证与拆分 Spacetime 客户端)
|
||||
pub mod get_battle_state_procedure;
|
||||
pub mod get_big_fish_run_procedure;
|
||||
pub mod get_big_fish_session_procedure;
|
||||
@@ -452,6 +470,7 @@ pub mod submit_puzzle_agent_message_procedure;
|
||||
pub mod swap_puzzle_pieces_procedure;
|
||||
pub mod unpublish_custom_world_profile_and_return_procedure;
|
||||
pub mod update_puzzle_work_procedure;
|
||||
pub mod upsert_auth_store_snapshot_procedure;
|
||||
pub mod upsert_chapter_progression_and_return_procedure;
|
||||
pub mod upsert_custom_world_profile_and_return_procedure;
|
||||
pub mod upsert_npc_state_and_return_procedure;
|
||||
@@ -492,6 +511,13 @@ pub use asset_object_access_policy_type::AssetObjectAccessPolicy;
|
||||
pub use asset_object_procedure_result_type::AssetObjectProcedureResult;
|
||||
pub use asset_object_upsert_input_type::AssetObjectUpsertInput;
|
||||
pub use asset_object_upsert_snapshot_type::AssetObjectUpsertSnapshot;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
pub use auth_store_snapshot_type::AuthStoreSnapshot;
|
||||
pub use auth_store_snapshot_procedure_result_type::AuthStoreSnapshotProcedureResult;
|
||||
pub use auth_store_snapshot_record_type::AuthStoreSnapshotRecord;
|
||||
pub use auth_store_snapshot_upsert_input_type::AuthStoreSnapshotUpsertInput;
|
||||
>>>>>>> 4f272a50 (迁移后端认证与拆分 Spacetime 客户端)
|
||||
pub use battle_mode_type::BattleMode;
|
||||
pub use battle_state_type::BattleState;
|
||||
pub use battle_state_input_type::BattleStateInput;
|
||||
@@ -763,6 +789,10 @@ pub use ai_task_stage_table::*;
|
||||
pub use ai_text_chunk_table::*;
|
||||
pub use asset_entity_binding_table::*;
|
||||
pub use asset_object_table::*;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
pub use auth_store_snapshot_table::*;
|
||||
>>>>>>> 4f272a50 (迁移后端认证与拆分 Spacetime 客户端)
|
||||
pub use battle_state_table::*;
|
||||
pub use big_fish_agent_message_table::*;
|
||||
pub use big_fish_asset_slot_table::*;
|
||||
@@ -844,10 +874,17 @@ pub use delete_runtime_snapshot_and_return_procedure::delete_runtime_snapshot_an
|
||||
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 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_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 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;
|
||||
>>>>>>> 4f272a50 (迁移后端认证与拆分 Spacetime 客户端)
|
||||
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_session_procedure::get_big_fish_session;
|
||||
@@ -900,6 +937,7 @@ pub use submit_puzzle_agent_message_procedure::submit_puzzle_agent_message;
|
||||
pub use swap_puzzle_pieces_procedure::swap_puzzle_pieces;
|
||||
pub use unpublish_custom_world_profile_and_return_procedure::unpublish_custom_world_profile_and_return;
|
||||
pub use update_puzzle_work_procedure::update_puzzle_work;
|
||||
pub use upsert_auth_store_snapshot_procedure::upsert_auth_store_snapshot;
|
||||
pub use upsert_chapter_progression_and_return_procedure::upsert_chapter_progression_and_return;
|
||||
pub use upsert_custom_world_profile_and_return_procedure::upsert_custom_world_profile_and_return;
|
||||
pub use upsert_npc_state_and_return_procedure::upsert_npc_state_and_return;
|
||||
@@ -1162,6 +1200,7 @@ pub struct DbUpdate {
|
||||
ai_text_chunk: __sdk::TableUpdate<AiTextChunk>,
|
||||
asset_entity_binding: __sdk::TableUpdate<AssetEntityBinding>,
|
||||
asset_object: __sdk::TableUpdate<AssetObject>,
|
||||
auth_store_snapshot: __sdk::TableUpdate<AuthStoreSnapshot>,
|
||||
battle_state: __sdk::TableUpdate<BattleState>,
|
||||
big_fish_agent_message: __sdk::TableUpdate<BigFishAgentMessage>,
|
||||
big_fish_asset_slot: __sdk::TableUpdate<BigFishAssetSlot>,
|
||||
@@ -1210,6 +1249,10 @@ 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)?),
|
||||
"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)?),
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
"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)?),
|
||||
"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)?),
|
||||
@@ -1270,6 +1313,10 @@ 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.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);
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
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.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);
|
||||
@@ -1315,6 +1362,10 @@ for table_rows in raw.tables {
|
||||
"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_object" => db_update.asset_object.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
"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)?),
|
||||
"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)?),
|
||||
@@ -1360,6 +1411,10 @@ for table_rows in raw.tables {
|
||||
"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_object" => db_update.asset_object.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
"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)?),
|
||||
"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)?),
|
||||
@@ -1407,6 +1462,7 @@ pub struct AppliedDiff<'r> {
|
||||
ai_text_chunk: __sdk::TableAppliedDiff<'r, AiTextChunk>,
|
||||
asset_entity_binding: __sdk::TableAppliedDiff<'r, AssetEntityBinding>,
|
||||
asset_object: __sdk::TableAppliedDiff<'r, AssetObject>,
|
||||
auth_store_snapshot: __sdk::TableAppliedDiff<'r, AuthStoreSnapshot>,
|
||||
battle_state: __sdk::TableAppliedDiff<'r, BattleState>,
|
||||
big_fish_agent_message: __sdk::TableAppliedDiff<'r, BigFishAgentMessage>,
|
||||
big_fish_asset_slot: __sdk::TableAppliedDiff<'r, BigFishAssetSlot>,
|
||||
@@ -1455,6 +1511,10 @@ 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::<AssetEntityBinding>("asset_entity_binding", &self.asset_entity_binding, event);
|
||||
callbacks.invoke_table_row_callbacks::<AssetObject>("asset_object", &self.asset_object, event);
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
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::<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);
|
||||
@@ -2144,6 +2204,7 @@ fn register_tables(client_cache: &mut __sdk::ClientCache<Self>) {
|
||||
ai_text_chunk_table::register_table(client_cache);
|
||||
asset_entity_binding_table::register_table(client_cache);
|
||||
asset_object_table::register_table(client_cache);
|
||||
auth_store_snapshot_table::register_table(client_cache);
|
||||
battle_state_table::register_table(client_cache);
|
||||
big_fish_agent_message_table::register_table(client_cache);
|
||||
big_fish_asset_slot_table::register_table(client_cache);
|
||||
@@ -2184,6 +2245,7 @@ const ALL_TABLE_NAMES: &'static [&'static str] = &[
|
||||
"ai_text_chunk",
|
||||
"asset_entity_binding",
|
||||
"asset_object",
|
||||
"auth_store_snapshot",
|
||||
"battle_state",
|
||||
"big_fish_agent_message",
|
||||
"big_fish_asset_slot",
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// 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;
|
||||
use super::auth_store_snapshot_upsert_input_type::AuthStoreSnapshotUpsertInput;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
struct UpsertAuthStoreSnapshotArgs {
|
||||
pub input: AuthStoreSnapshotUpsertInput,
|
||||
}
|
||||
|
||||
|
||||
impl __sdk::InModule for UpsertAuthStoreSnapshotArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the procedure `upsert_auth_store_snapshot`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteProcedures`].
|
||||
pub trait upsert_auth_store_snapshot {
|
||||
fn upsert_auth_store_snapshot(&self, input: AuthStoreSnapshotUpsertInput,
|
||||
) {
|
||||
self.upsert_auth_store_snapshot_then(input, |_, _| {});
|
||||
}
|
||||
|
||||
fn upsert_auth_store_snapshot_then(
|
||||
&self,
|
||||
input: AuthStoreSnapshotUpsertInput,
|
||||
|
||||
__callback: impl FnOnce(&super::ProcedureEventContext, Result<AuthStoreSnapshotProcedureResult, __sdk::InternalError>) + Send + 'static,
|
||||
);
|
||||
}
|
||||
|
||||
impl upsert_auth_store_snapshot for super::RemoteProcedures {
|
||||
fn upsert_auth_store_snapshot_then(
|
||||
&self,
|
||||
input: AuthStoreSnapshotUpsertInput,
|
||||
|
||||
__callback: impl FnOnce(&super::ProcedureEventContext, Result<AuthStoreSnapshotProcedureResult, __sdk::InternalError>) + Send + 'static,
|
||||
) {
|
||||
self.imp.invoke_procedure_with_callback::<_, AuthStoreSnapshotProcedureResult>(
|
||||
"upsert_auth_store_snapshot",
|
||||
UpsertAuthStoreSnapshotArgs { input, },
|
||||
__callback,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
28
server-rs/crates/spacetime-client/src/npc.rs
Normal file
28
server-rs/crates/spacetime-client/src/npc.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use super::*;
|
||||
|
||||
impl SpacetimeClient {
|
||||
pub async fn resolve_npc_battle_interaction(
|
||||
&self,
|
||||
input: ResolveNpcBattleInteractionInput,
|
||||
) -> Result<NpcBattleInteractionRecord, SpacetimeClientError> {
|
||||
validate_npc_battle_interaction_input(&input)?;
|
||||
let procedure_input = map_resolve_npc_battle_interaction_input(input);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.resolve_npc_battle_interaction_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_npc_battle_interaction_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
459
server-rs/crates/spacetime-client/src/puzzle.rs
Normal file
459
server-rs/crates/spacetime-client/src/puzzle.rs
Normal file
@@ -0,0 +1,459 @@
|
||||
use super::*;
|
||||
|
||||
impl SpacetimeClient {
|
||||
pub async fn create_puzzle_agent_session(
|
||||
&self,
|
||||
input: PuzzleAgentSessionCreateRecordInput,
|
||||
) -> Result<PuzzleAgentSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleAgentSessionCreateInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
seed_text: input.seed_text,
|
||||
welcome_message_id: input.welcome_message_id,
|
||||
welcome_message_text: input.welcome_message_text,
|
||||
created_at_micros: input.created_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().create_puzzle_agent_session_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_agent_session_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_puzzle_agent_session(
|
||||
&self,
|
||||
session_id: String,
|
||||
owner_user_id: String,
|
||||
) -> Result<PuzzleAgentSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleAgentSessionGetInput {
|
||||
session_id,
|
||||
owner_user_id,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().get_puzzle_agent_session_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_agent_session_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn submit_puzzle_agent_message(
|
||||
&self,
|
||||
input: PuzzleAgentMessageSubmitRecordInput,
|
||||
) -> Result<PuzzleAgentSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleAgentMessageSubmitInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
user_message_id: input.user_message_id,
|
||||
user_message_text: input.user_message_text,
|
||||
submitted_at_micros: input.submitted_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().submit_puzzle_agent_message_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_agent_session_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn finalize_puzzle_agent_message(
|
||||
&self,
|
||||
input: PuzzleAgentMessageFinalizeRecordInput,
|
||||
) -> Result<PuzzleAgentSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleAgentMessageFinalizeInput {
|
||||
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_puzzle_agent_stage_record(input.stage.as_str())?,
|
||||
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_puzzle_agent_message_turn_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_agent_session_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn compile_puzzle_agent_draft(
|
||||
&self,
|
||||
session_id: String,
|
||||
owner_user_id: String,
|
||||
compiled_at_micros: i64,
|
||||
) -> Result<PuzzleAgentSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleDraftCompileInput {
|
||||
session_id,
|
||||
owner_user_id,
|
||||
compiled_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().compile_puzzle_agent_draft_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_agent_session_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn save_puzzle_generated_images(
|
||||
&self,
|
||||
input: PuzzleGeneratedImagesSaveRecordInput,
|
||||
) -> Result<PuzzleAgentSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleGeneratedImagesSaveInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
candidates_json: input.candidates_json,
|
||||
saved_at_micros: input.saved_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().save_puzzle_generated_images_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_agent_session_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn select_puzzle_cover_image(
|
||||
&self,
|
||||
input: PuzzleSelectCoverImageRecordInput,
|
||||
) -> Result<PuzzleAgentSessionRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleSelectCoverImageInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
candidate_id: input.candidate_id,
|
||||
selected_at_micros: input.selected_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().select_puzzle_cover_image_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_agent_session_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn publish_puzzle_work(
|
||||
&self,
|
||||
input: PuzzlePublishRecordInput,
|
||||
) -> Result<PuzzleWorkProfileRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzlePublishInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
work_id: input.work_id,
|
||||
profile_id: input.profile_id,
|
||||
author_display_name: input.author_display_name,
|
||||
level_name: input.level_name,
|
||||
summary: input.summary,
|
||||
theme_tags: input.theme_tags,
|
||||
published_at_micros: input.published_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.publish_puzzle_work_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_work_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn list_puzzle_works(
|
||||
&self,
|
||||
owner_user_id: String,
|
||||
) -> Result<Vec<PuzzleWorkProfileRecord>, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleWorksListInput { owner_user_id };
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.list_puzzle_works_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_works_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_puzzle_work_detail(
|
||||
&self,
|
||||
profile_id: String,
|
||||
) -> Result<PuzzleWorkProfileRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleWorkGetInput { profile_id };
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().get_puzzle_work_detail_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_work_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn update_puzzle_work(
|
||||
&self,
|
||||
input: PuzzleWorkUpsertRecordInput,
|
||||
) -> Result<PuzzleWorkProfileRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleWorkUpsertInput {
|
||||
profile_id: input.profile_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
level_name: input.level_name,
|
||||
summary: input.summary,
|
||||
theme_tags: input.theme_tags,
|
||||
cover_image_src: input.cover_image_src,
|
||||
cover_asset_id: input.cover_asset_id,
|
||||
updated_at_micros: input.updated_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.update_puzzle_work_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_work_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn list_puzzle_gallery(
|
||||
&self,
|
||||
) -> Result<Vec<PuzzleWorkProfileRecord>, SpacetimeClientError> {
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.list_puzzle_gallery_then(move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_works_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_puzzle_gallery_detail(
|
||||
&self,
|
||||
profile_id: String,
|
||||
) -> Result<PuzzleWorkProfileRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleWorkGetInput { profile_id };
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().get_puzzle_gallery_detail_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_work_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn start_puzzle_run(
|
||||
&self,
|
||||
input: PuzzleRunStartRecordInput,
|
||||
) -> Result<PuzzleRunRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleRunStartInput {
|
||||
run_id: input.run_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
profile_id: input.profile_id,
|
||||
started_at_micros: input.started_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.start_puzzle_run_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_run_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_puzzle_run(
|
||||
&self,
|
||||
run_id: String,
|
||||
owner_user_id: String,
|
||||
) -> Result<PuzzleRunRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleRunGetInput {
|
||||
run_id,
|
||||
owner_user_id,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.get_puzzle_run_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_run_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn swap_puzzle_pieces(
|
||||
&self,
|
||||
input: PuzzleRunSwapRecordInput,
|
||||
) -> Result<PuzzleRunRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleRunSwapInput {
|
||||
run_id: input.run_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
first_piece_id: input.first_piece_id,
|
||||
second_piece_id: input.second_piece_id,
|
||||
swapped_at_micros: input.swapped_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.swap_puzzle_pieces_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_run_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn drag_puzzle_piece_or_group(
|
||||
&self,
|
||||
input: PuzzleRunDragRecordInput,
|
||||
) -> Result<PuzzleRunRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleRunDragInput {
|
||||
run_id: input.run_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
piece_id: input.piece_id,
|
||||
target_row: input.target_row,
|
||||
target_col: input.target_col,
|
||||
dragged_at_micros: input.dragged_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().drag_puzzle_piece_or_group_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_run_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn advance_puzzle_next_level(
|
||||
&self,
|
||||
input: PuzzleRunNextLevelRecordInput,
|
||||
) -> Result<PuzzleRunRecord, SpacetimeClientError> {
|
||||
let procedure_input = PuzzleRunNextLevelInput {
|
||||
run_id: input.run_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
advanced_at_micros: input.advanced_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().advance_puzzle_next_level_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_puzzle_run_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
339
server-rs/crates/spacetime-client/src/runtime.rs
Normal file
339
server-rs/crates/spacetime-client/src/runtime.rs
Normal file
@@ -0,0 +1,339 @@
|
||||
use super::*;
|
||||
|
||||
impl SpacetimeClient {
|
||||
pub async fn get_runtime_settings(
|
||||
&self,
|
||||
user_id: String,
|
||||
) -> Result<RuntimeSettingsRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_runtime_setting_get_input(
|
||||
build_runtime_setting_get_input(user_id)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().get_runtime_setting_or_default_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_setting_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn list_platform_browse_history(
|
||||
&self,
|
||||
user_id: String,
|
||||
) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> {
|
||||
let procedure_input = map_runtime_browse_history_list_input(
|
||||
build_runtime_browse_history_list_input(user_id)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().list_platform_browse_history_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_browse_history_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_profile_dashboard(
|
||||
&self,
|
||||
user_id: String,
|
||||
) -> Result<RuntimeProfileDashboardRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_runtime_profile_dashboard_get_input(
|
||||
build_runtime_profile_dashboard_get_input(user_id)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().get_profile_dashboard_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_profile_dashboard_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn list_profile_wallet_ledger(
|
||||
&self,
|
||||
user_id: String,
|
||||
) -> Result<Vec<RuntimeProfileWalletLedgerEntryRecord>, SpacetimeClientError> {
|
||||
let procedure_input = map_runtime_profile_wallet_ledger_list_input(
|
||||
build_runtime_profile_wallet_ledger_list_input(user_id)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().list_profile_wallet_ledger_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_profile_wallet_ledger_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_profile_play_stats(
|
||||
&self,
|
||||
user_id: String,
|
||||
) -> Result<RuntimeProfilePlayStatsRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_runtime_profile_play_stats_get_input(
|
||||
build_runtime_profile_play_stats_get_input(user_id)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().get_profile_play_stats_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_profile_play_stats_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_runtime_snapshot(
|
||||
&self,
|
||||
user_id: String,
|
||||
) -> Result<Option<RuntimeSnapshotRecord>, SpacetimeClientError> {
|
||||
let procedure_input = map_runtime_snapshot_get_input(
|
||||
build_runtime_snapshot_get_input(user_id)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.get_runtime_snapshot_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_snapshot_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn put_runtime_snapshot(
|
||||
&self,
|
||||
user_id: String,
|
||||
saved_at_micros: i64,
|
||||
bottom_tab: String,
|
||||
game_state: serde_json::Value,
|
||||
current_story: Option<serde_json::Value>,
|
||||
updated_at_micros: i64,
|
||||
) -> Result<RuntimeSnapshotRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_runtime_snapshot_upsert_input(
|
||||
build_runtime_snapshot_upsert_input(
|
||||
user_id,
|
||||
saved_at_micros,
|
||||
bottom_tab,
|
||||
game_state,
|
||||
current_story,
|
||||
updated_at_micros,
|
||||
)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.upsert_runtime_snapshot_and_return_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_snapshot_required_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn delete_runtime_snapshot(
|
||||
&self,
|
||||
user_id: String,
|
||||
) -> Result<bool, SpacetimeClientError> {
|
||||
let procedure_input = map_runtime_snapshot_delete_input(
|
||||
build_runtime_snapshot_delete_input(user_id)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.delete_runtime_snapshot_and_return_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_snapshot_delete_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn list_profile_save_archives(
|
||||
&self,
|
||||
user_id: String,
|
||||
) -> Result<Vec<RuntimeProfileSaveArchiveRecord>, SpacetimeClientError> {
|
||||
let procedure_input = map_runtime_profile_save_archive_list_input(
|
||||
build_runtime_profile_save_archive_list_input(user_id)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().list_profile_save_archives_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_profile_save_archive_list_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn resume_profile_save_archive(
|
||||
&self,
|
||||
user_id: String,
|
||||
world_key: String,
|
||||
) -> Result<(RuntimeProfileSaveArchiveRecord, RuntimeSnapshotRecord), SpacetimeClientError>
|
||||
{
|
||||
let procedure_input = map_runtime_profile_save_archive_resume_input(
|
||||
build_runtime_profile_save_archive_resume_input(user_id, world_key)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.resume_profile_save_archive_and_return_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_profile_save_archive_resume_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn put_runtime_settings(
|
||||
&self,
|
||||
user_id: String,
|
||||
music_volume: f32,
|
||||
platform_theme: RuntimePlatformTheme,
|
||||
updated_at_micros: i64,
|
||||
) -> Result<RuntimeSettingsRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_runtime_setting_upsert_input(
|
||||
build_runtime_setting_upsert_input(
|
||||
user_id,
|
||||
music_volume,
|
||||
platform_theme,
|
||||
updated_at_micros,
|
||||
)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.upsert_runtime_setting_and_return_then(procedure_input, move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_setting_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
});
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn upsert_platform_browse_history_entries(
|
||||
&self,
|
||||
user_id: String,
|
||||
entries: Vec<module_runtime::RuntimeBrowseHistoryWriteInput>,
|
||||
updated_at_micros: i64,
|
||||
) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> {
|
||||
let procedure_input = map_runtime_browse_history_sync_input(
|
||||
build_runtime_browse_history_sync_input(user_id, entries, updated_at_micros)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.upsert_platform_browse_history_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_browse_history_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn clear_platform_browse_history(
|
||||
&self,
|
||||
user_id: String,
|
||||
) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> {
|
||||
let procedure_input = map_runtime_browse_history_clear_input(
|
||||
build_runtime_browse_history_clear_input(user_id)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.clear_platform_browse_history_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_runtime_browse_history_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
100
server-rs/crates/spacetime-client/src/story.rs
Normal file
100
server-rs/crates/spacetime-client/src/story.rs
Normal file
@@ -0,0 +1,100 @@
|
||||
use super::*;
|
||||
|
||||
impl SpacetimeClient {
|
||||
pub async fn begin_story_session(
|
||||
&self,
|
||||
story_session_id: String,
|
||||
runtime_session_id: String,
|
||||
actor_user_id: String,
|
||||
world_profile_id: String,
|
||||
initial_prompt: String,
|
||||
opening_summary: Option<String>,
|
||||
created_at_micros: i64,
|
||||
) -> Result<StorySessionResultRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_story_session_input(
|
||||
build_story_session_input(
|
||||
story_session_id,
|
||||
runtime_session_id,
|
||||
actor_user_id,
|
||||
world_profile_id,
|
||||
initial_prompt,
|
||||
opening_summary,
|
||||
created_at_micros,
|
||||
)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().begin_story_session_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_story_session_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn continue_story(
|
||||
&self,
|
||||
story_session_id: String,
|
||||
event_id: String,
|
||||
narrative_text: String,
|
||||
choice_function_id: Option<String>,
|
||||
updated_at_micros: i64,
|
||||
) -> Result<StorySessionResultRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_story_continue_input(
|
||||
build_story_continue_input(
|
||||
story_session_id,
|
||||
event_id,
|
||||
narrative_text,
|
||||
choice_function_id,
|
||||
updated_at_micros,
|
||||
)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().continue_story_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_story_session_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
pub async fn get_story_session_state(
|
||||
&self,
|
||||
story_session_id: String,
|
||||
) -> Result<StorySessionStateRecord, SpacetimeClientError> {
|
||||
let procedure_input = map_story_session_state_input(
|
||||
build_story_session_state_input(story_session_id)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?,
|
||||
);
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection.procedures().get_story_session_state_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
||||
.and_then(map_story_session_state_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user