1
This commit is contained in:
@@ -484,4 +484,39 @@ impl SpacetimeClient {
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn upsert_custom_world_agent_operation_progress(
|
||||
&self,
|
||||
input: CustomWorldAgentOperationProgressRecordInput,
|
||||
) -> Result<CustomWorldAgentOperationRecord, SpacetimeClientError> {
|
||||
let procedure_input = CustomWorldAgentOperationProgressInput {
|
||||
session_id: input.session_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
operation_id: input.operation_id,
|
||||
operation_type: parse_rpg_agent_operation_type_record(input.operation_type.as_str())?,
|
||||
operation_status: parse_rpg_agent_operation_status_record(
|
||||
input.operation_status.as_str(),
|
||||
)?,
|
||||
phase_label: input.phase_label,
|
||||
phase_detail: input.phase_detail,
|
||||
operation_progress: input.operation_progress,
|
||||
error_message: input.error_message,
|
||||
updated_at_micros: input.updated_at_micros,
|
||||
};
|
||||
|
||||
self.call_after_connect(move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.upsert_custom_world_agent_operation_progress_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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@ pub use mapper::{
|
||||
BigFishWorkSummaryRecord, CustomWorldAgentActionExecuteRecord,
|
||||
CustomWorldAgentActionExecuteRecordInput, CustomWorldAgentCheckpointRecord,
|
||||
CustomWorldAgentMessageFinalizeRecordInput, CustomWorldAgentMessageRecord,
|
||||
CustomWorldAgentMessageSubmitRecordInput, CustomWorldAgentOperationRecord,
|
||||
CustomWorldAgentSessionCreateRecordInput, CustomWorldAgentSessionRecord,
|
||||
CustomWorldAgentMessageSubmitRecordInput, CustomWorldAgentOperationProgressRecordInput,
|
||||
CustomWorldAgentOperationRecord, CustomWorldAgentSessionCreateRecordInput,
|
||||
CustomWorldAgentSessionRecord,
|
||||
CustomWorldCheckpointRecord, CustomWorldDraftCardDetailRecord,
|
||||
CustomWorldDraftCardDetailSectionRecord, CustomWorldDraftCardRecord,
|
||||
CustomWorldGalleryEntryRecord, CustomWorldLibraryEntryRecord, CustomWorldLibraryMutationRecord,
|
||||
|
||||
@@ -2726,6 +2726,31 @@ pub(crate) fn format_rpg_agent_operation_type(
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn parse_rpg_agent_operation_type_record(
|
||||
value: &str,
|
||||
) -> Result<crate::module_bindings::RpgAgentOperationType, SpacetimeClientError> {
|
||||
match value.trim() {
|
||||
"process_message" => Ok(crate::module_bindings::RpgAgentOperationType::ProcessMessage),
|
||||
"draft_foundation" => Ok(crate::module_bindings::RpgAgentOperationType::DraftFoundation),
|
||||
"update_draft_card" => Ok(crate::module_bindings::RpgAgentOperationType::UpdateDraftCard),
|
||||
"sync_result_profile" => Ok(crate::module_bindings::RpgAgentOperationType::SyncResultProfile),
|
||||
"generate_characters" => Ok(crate::module_bindings::RpgAgentOperationType::GenerateCharacters),
|
||||
"generate_landmarks" => Ok(crate::module_bindings::RpgAgentOperationType::GenerateLandmarks),
|
||||
"generate_role_assets" => Ok(crate::module_bindings::RpgAgentOperationType::GenerateRoleAssets),
|
||||
"sync_role_assets" => Ok(crate::module_bindings::RpgAgentOperationType::SyncRoleAssets),
|
||||
"generate_scene_assets" => Ok(crate::module_bindings::RpgAgentOperationType::GenerateSceneAssets),
|
||||
"sync_scene_assets" => Ok(crate::module_bindings::RpgAgentOperationType::SyncSceneAssets),
|
||||
"expand_long_tail" => Ok(crate::module_bindings::RpgAgentOperationType::ExpandLongTail),
|
||||
"publish_world" => Ok(crate::module_bindings::RpgAgentOperationType::PublishWorld),
|
||||
"revert_checkpoint" => Ok(crate::module_bindings::RpgAgentOperationType::RevertCheckpoint),
|
||||
"delete_characters" => Ok(crate::module_bindings::RpgAgentOperationType::DeleteCharacters),
|
||||
"delete_landmarks" => Ok(crate::module_bindings::RpgAgentOperationType::DeleteLandmarks),
|
||||
other => Err(SpacetimeClientError::Runtime(format!(
|
||||
"未知 rpg agent operation type: {other}"
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn format_rpg_agent_operation_status(
|
||||
value: crate::module_bindings::RpgAgentOperationStatus,
|
||||
) -> &'static str {
|
||||
@@ -2806,22 +2831,6 @@ impl TryFrom<&str> for BigFishAssetKind {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn map_big_fish_creation_stage(
|
||||
value: module_big_fish::BigFishCreationStage,
|
||||
) -> BigFishCreationStage {
|
||||
match value {
|
||||
module_big_fish::BigFishCreationStage::CollectingAnchors => {
|
||||
BigFishCreationStage::CollectingAnchors
|
||||
}
|
||||
module_big_fish::BigFishCreationStage::DraftReady => BigFishCreationStage::DraftReady,
|
||||
module_big_fish::BigFishCreationStage::AssetRefining => BigFishCreationStage::AssetRefining,
|
||||
module_big_fish::BigFishCreationStage::ReadyToPublish => {
|
||||
BigFishCreationStage::ReadyToPublish
|
||||
}
|
||||
module_big_fish::BigFishCreationStage::Published => BigFishCreationStage::Published,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn parse_big_fish_creation_stage(
|
||||
value: &str,
|
||||
) -> Result<BigFishCreationStage, SpacetimeClientError> {
|
||||
@@ -3466,6 +3475,21 @@ pub struct CustomWorldAgentOperationRecord {
|
||||
pub error_message: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CustomWorldAgentOperationProgressRecordInput {
|
||||
pub session_id: String,
|
||||
pub owner_user_id: String,
|
||||
pub operation_id: String,
|
||||
// SpacetimeDB 模块侧使用枚举存储操作类型,这里保留字符串给 API 层做轻量传参。
|
||||
pub operation_type: String,
|
||||
pub operation_status: String,
|
||||
pub phase_label: String,
|
||||
pub phase_detail: String,
|
||||
pub operation_progress: u32,
|
||||
pub error_message: Option<String>,
|
||||
pub updated_at_micros: i64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct CustomWorldDraftCardRecord {
|
||||
pub card_id: String,
|
||||
|
||||
@@ -116,6 +116,7 @@ pub mod custom_world_agent_message_submit_input_type;
|
||||
pub mod custom_world_agent_operation_type;
|
||||
pub mod custom_world_agent_operation_get_input_type;
|
||||
pub mod custom_world_agent_operation_procedure_result_type;
|
||||
pub mod custom_world_agent_operation_progress_input_type;
|
||||
pub mod custom_world_agent_operation_snapshot_type;
|
||||
pub mod custom_world_agent_session_type;
|
||||
pub mod custom_world_agent_session_create_input_type;
|
||||
@@ -475,6 +476,7 @@ 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_agent_operation_progress_procedure;
|
||||
pub mod upsert_custom_world_profile_and_return_procedure;
|
||||
pub mod upsert_npc_state_and_return_procedure;
|
||||
pub mod upsert_platform_browse_history_and_return_procedure;
|
||||
@@ -586,6 +588,7 @@ pub use custom_world_agent_message_submit_input_type::CustomWorldAgentMessageSub
|
||||
pub use custom_world_agent_operation_type::CustomWorldAgentOperation;
|
||||
pub use custom_world_agent_operation_get_input_type::CustomWorldAgentOperationGetInput;
|
||||
pub use custom_world_agent_operation_procedure_result_type::CustomWorldAgentOperationProcedureResult;
|
||||
pub use custom_world_agent_operation_progress_input_type::CustomWorldAgentOperationProgressInput;
|
||||
pub use custom_world_agent_operation_snapshot_type::CustomWorldAgentOperationSnapshot;
|
||||
pub use custom_world_agent_session_type::CustomWorldAgentSession;
|
||||
pub use custom_world_agent_session_create_input_type::CustomWorldAgentSessionCreateInput;
|
||||
@@ -942,6 +945,7 @@ pub use unpublish_custom_world_profile_and_return_procedure::unpublish_custom_wo
|
||||
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_agent_operation_progress_procedure::upsert_custom_world_agent_operation_progress;
|
||||
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;
|
||||
pub use upsert_platform_browse_history_and_return_procedure::upsert_platform_browse_history_and_return;
|
||||
|
||||
Reference in New Issue
Block a user