扩展外部生成Worker队列
新增外部生成队列概览和单任务状态契约 将跳一跳、拼消消、敲木鱼图片生成动作接入worker队列 前端生成等待页展示当前任务和队列数量 更新外部生成worker运维文档和团队决策记录
This commit is contained in:
@@ -127,6 +127,31 @@ impl SpacetimeClient {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_external_generation_job(
|
||||
&self,
|
||||
input: ExternalGenerationJobGetRecordInput,
|
||||
) -> Result<ExternalGenerationJobRecord, SpacetimeClientError> {
|
||||
let procedure_input = input.into();
|
||||
|
||||
self.call_after_connect(
|
||||
"get_external_generation_job_and_return",
|
||||
move |connection, sender| {
|
||||
connection
|
||||
.procedures()
|
||||
.get_external_generation_job_and_return_then(
|
||||
procedure_input,
|
||||
move |_, result| {
|
||||
let mapped = result
|
||||
.map_err(SpacetimeClientError::from_sdk_error)
|
||||
.and_then(map_external_generation_job_procedure_result);
|
||||
send_once(&sender, mapped);
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_external_generation_queue_stats(
|
||||
&self,
|
||||
) -> Result<ExternalGenerationQueueStatsRecord, SpacetimeClientError> {
|
||||
|
||||
@@ -113,6 +113,55 @@ impl SpacetimeClient {
|
||||
action_type: payload.action_type,
|
||||
session,
|
||||
work,
|
||||
queue_state: None,
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn mark_jump_hop_generation_queued(
|
||||
&self,
|
||||
session_id: String,
|
||||
owner_user_id: String,
|
||||
payload: JumpHopActionRequest,
|
||||
) -> Result<JumpHopActionResponse, SpacetimeClientError> {
|
||||
let current = self
|
||||
.get_jump_hop_session(session_id.clone(), owner_user_id.clone())
|
||||
.await?;
|
||||
let action_type = payload.action_type.clone();
|
||||
let scope = match action_type {
|
||||
JumpHopActionType::CompileDraft => JumpHopDraftMergeScope::CompileDraft,
|
||||
JumpHopActionType::RegenerateTiles => JumpHopDraftMergeScope::RegenerateTiles,
|
||||
_ => {
|
||||
return Err(SpacetimeClientError::validation_failed(
|
||||
"jump-hop queued generation 只支持 compile-draft/regenerate-tiles",
|
||||
));
|
||||
}
|
||||
};
|
||||
let mut base_draft = current.draft.clone();
|
||||
if matches!(action_type, JumpHopActionType::RegenerateTiles)
|
||||
&& let Some(draft) = base_draft.as_mut()
|
||||
{
|
||||
draft.tile_atlas_asset = None;
|
||||
draft.tile_assets.clear();
|
||||
}
|
||||
let mut draft = merge_action_into_draft(base_draft, &payload, scope)?;
|
||||
let profile_id = resolve_jump_hop_profile_id(&draft, &action_type)?;
|
||||
draft.profile_id = Some(profile_id.clone());
|
||||
draft.generation_status = JumpHopGenerationStatus::Generating;
|
||||
let session = self
|
||||
.compile_jump_hop_draft(build_generating_compile_input(
|
||||
¤t,
|
||||
&owner_user_id,
|
||||
&profile_id,
|
||||
&draft,
|
||||
current_unix_micros(),
|
||||
)?)
|
||||
.await?;
|
||||
|
||||
Ok(JumpHopActionResponse {
|
||||
action_type,
|
||||
session,
|
||||
work: None,
|
||||
queue_state: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -804,6 +853,50 @@ fn build_compile_input(
|
||||
})
|
||||
}
|
||||
|
||||
fn build_generating_compile_input(
|
||||
current: &JumpHopSessionSnapshotResponse,
|
||||
owner_user_id: &str,
|
||||
profile_id: &str,
|
||||
draft: &JumpHopDraftResponse,
|
||||
now_micros: i64,
|
||||
) -> Result<JumpHopDraftCompileInput, SpacetimeClientError> {
|
||||
Ok(JumpHopDraftCompileInput {
|
||||
session_id: current.session_id.clone(),
|
||||
owner_user_id: owner_user_id.to_string(),
|
||||
profile_id: profile_id.to_string(),
|
||||
author_display_name: "跳一跳玩家".to_string(),
|
||||
seed_text: draft.work_title.clone(),
|
||||
work_title: draft.work_title.clone(),
|
||||
work_description: draft.work_description.clone(),
|
||||
theme_tags_json: Some(json_string(&draft.theme_tags)?),
|
||||
theme_text: Some(draft.theme_text.clone()),
|
||||
difficulty: Some(difficulty_to_str(&draft.difficulty).to_string()),
|
||||
style_preset: Some(style_to_str(&draft.style_preset).to_string()),
|
||||
character_prompt: Some(draft.character_prompt.clone()),
|
||||
tile_prompt: Some(draft.tile_prompt.clone()),
|
||||
end_mood_prompt: draft.end_mood_prompt.clone(),
|
||||
character_asset_json: draft
|
||||
.character_asset
|
||||
.as_ref()
|
||||
.map(json_string)
|
||||
.transpose()?,
|
||||
tile_atlas_asset_json: draft
|
||||
.tile_atlas_asset
|
||||
.as_ref()
|
||||
.map(json_string)
|
||||
.transpose()?,
|
||||
tile_assets_json: Some(json_string(&draft.tile_assets)?),
|
||||
cover_composite: draft.cover_composite.clone(),
|
||||
back_button_asset_json: draft
|
||||
.back_button_asset
|
||||
.as_ref()
|
||||
.map(json_string)
|
||||
.transpose()?,
|
||||
generation_status: Some("generating".to_string()),
|
||||
compiled_at_micros: now_micros,
|
||||
})
|
||||
}
|
||||
|
||||
fn build_update_input(
|
||||
owner_user_id: &str,
|
||||
profile_id: &str,
|
||||
|
||||
@@ -32,14 +32,14 @@ pub use mapper::{
|
||||
CustomWorldResultPreviewBlockerRecord, CustomWorldSupportedActionRecord,
|
||||
CustomWorldWorkSummaryRecord, ExternalGenerationJobClaimRecordInput,
|
||||
ExternalGenerationJobCompleteRecordInput, ExternalGenerationJobEnqueueRecordInput,
|
||||
ExternalGenerationJobFailRecordInput, ExternalGenerationJobRecord,
|
||||
ExternalGenerationJobRenewLeaseRecordInput, ExternalGenerationQueueStatsRecord,
|
||||
JumpHopActionRequest, JumpHopActionResponse, JumpHopActionType, JumpHopCharacterAsset,
|
||||
JumpHopDifficulty, JumpHopDraftResponse, JumpHopGalleryCardResponse,
|
||||
JumpHopGalleryDetailResponse, JumpHopGalleryResponse, JumpHopGenerationStatus,
|
||||
JumpHopJumpRequest, JumpHopJumpResponse, JumpHopJumpResult, JumpHopLastJump, JumpHopPath,
|
||||
JumpHopPlatform, JumpHopRestartRunRequest, JumpHopRunResponse, JumpHopRunStatus,
|
||||
JumpHopRuntimeRunSnapshotResponse, JumpHopScoring, JumpHopSessionResponse,
|
||||
ExternalGenerationJobFailRecordInput, ExternalGenerationJobGetRecordInput,
|
||||
ExternalGenerationJobRecord, ExternalGenerationJobRenewLeaseRecordInput,
|
||||
ExternalGenerationQueueStatsRecord, JumpHopActionRequest, JumpHopActionResponse,
|
||||
JumpHopActionType, JumpHopCharacterAsset, JumpHopDifficulty, JumpHopDraftResponse,
|
||||
JumpHopGalleryCardResponse, JumpHopGalleryDetailResponse, JumpHopGalleryResponse,
|
||||
JumpHopGenerationStatus, JumpHopJumpRequest, JumpHopJumpResponse, JumpHopJumpResult,
|
||||
JumpHopLastJump, JumpHopPath, JumpHopPlatform, JumpHopRestartRunRequest, JumpHopRunResponse,
|
||||
JumpHopRunStatus, JumpHopRuntimeRunSnapshotResponse, JumpHopScoring, JumpHopSessionResponse,
|
||||
JumpHopSessionSnapshotResponse, JumpHopStartRunRequest, JumpHopStylePreset, JumpHopTileAsset,
|
||||
JumpHopTileType, JumpHopWorkDetailResponse, JumpHopWorkMutationResponse,
|
||||
JumpHopWorkProfileResponse, JumpHopWorkSummaryResponse, JumpHopWorksResponse,
|
||||
|
||||
@@ -72,8 +72,8 @@ pub use self::common::{
|
||||
pub use self::external_generation::{
|
||||
ExternalGenerationJobClaimRecordInput, ExternalGenerationJobCompleteRecordInput,
|
||||
ExternalGenerationJobEnqueueRecordInput, ExternalGenerationJobFailRecordInput,
|
||||
ExternalGenerationJobRecord, ExternalGenerationJobRenewLeaseRecordInput,
|
||||
ExternalGenerationQueueStatsRecord,
|
||||
ExternalGenerationJobGetRecordInput, ExternalGenerationJobRecord,
|
||||
ExternalGenerationJobRenewLeaseRecordInput, ExternalGenerationQueueStatsRecord,
|
||||
};
|
||||
pub use self::jump_hop::{
|
||||
JumpHopActionRequest, JumpHopActionResponse, JumpHopActionType, JumpHopCharacterAsset,
|
||||
|
||||
@@ -66,6 +66,15 @@ impl From<ExternalGenerationJobFailRecordInput> for ExternalGenerationJobFailInp
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ExternalGenerationJobGetRecordInput> for ExternalGenerationJobGetInput {
|
||||
fn from(input: ExternalGenerationJobGetRecordInput) -> Self {
|
||||
Self {
|
||||
job_id: input.job_id,
|
||||
owner_user_id: input.owner_user_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn map_external_generation_job_procedure_result(
|
||||
result: ExternalGenerationJobProcedureResult,
|
||||
) -> Result<ExternalGenerationJobRecord, SpacetimeClientError> {
|
||||
@@ -144,6 +153,7 @@ fn map_external_generation_job_snapshot(
|
||||
started_at: snapshot.started_at_micros.map(format_timestamp_micros),
|
||||
completed_at: snapshot.completed_at_micros.map(format_timestamp_micros),
|
||||
updated_at: format_timestamp_micros(snapshot.updated_at_micros),
|
||||
updated_at_micros: snapshot.updated_at_micros,
|
||||
lease_token: snapshot.lease_token,
|
||||
}
|
||||
}
|
||||
@@ -199,6 +209,12 @@ pub struct ExternalGenerationJobFailRecordInput {
|
||||
pub failed_at_micros: i64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ExternalGenerationJobGetRecordInput {
|
||||
pub job_id: String,
|
||||
pub owner_user_id: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ExternalGenerationJobRecord {
|
||||
pub job_id: String,
|
||||
@@ -221,6 +237,7 @@ pub struct ExternalGenerationJobRecord {
|
||||
pub started_at: Option<String>,
|
||||
pub completed_at: Option<String>,
|
||||
pub updated_at: String,
|
||||
pub updated_at_micros: i64,
|
||||
pub lease_token: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
@@ -355,6 +355,7 @@ pub mod external_generation_job_claim_input_type;
|
||||
pub mod external_generation_job_complete_input_type;
|
||||
pub mod external_generation_job_enqueue_input_type;
|
||||
pub mod external_generation_job_fail_input_type;
|
||||
pub mod external_generation_job_get_input_type;
|
||||
pub mod external_generation_job_procedure_result_type;
|
||||
pub mod external_generation_job_renew_lease_input_type;
|
||||
pub mod external_generation_job_snapshot_type;
|
||||
@@ -388,6 +389,7 @@ pub mod get_custom_world_agent_session_procedure;
|
||||
pub mod get_custom_world_gallery_detail_by_code_procedure;
|
||||
pub mod get_custom_world_gallery_detail_procedure;
|
||||
pub mod get_custom_world_library_detail_procedure;
|
||||
pub mod get_external_generation_job_and_return_procedure;
|
||||
pub mod get_external_generation_queue_stats_and_return_procedure;
|
||||
pub mod get_jump_hop_agent_session_procedure;
|
||||
pub mod get_jump_hop_leaderboard_procedure;
|
||||
@@ -1489,6 +1491,7 @@ pub use external_generation_job_claim_input_type::ExternalGenerationJobClaimInpu
|
||||
pub use external_generation_job_complete_input_type::ExternalGenerationJobCompleteInput;
|
||||
pub use external_generation_job_enqueue_input_type::ExternalGenerationJobEnqueueInput;
|
||||
pub use external_generation_job_fail_input_type::ExternalGenerationJobFailInput;
|
||||
pub use external_generation_job_get_input_type::ExternalGenerationJobGetInput;
|
||||
pub use external_generation_job_procedure_result_type::ExternalGenerationJobProcedureResult;
|
||||
pub use external_generation_job_renew_lease_input_type::ExternalGenerationJobRenewLeaseInput;
|
||||
pub use external_generation_job_snapshot_type::ExternalGenerationJobSnapshot;
|
||||
@@ -1522,6 +1525,7 @@ pub use get_custom_world_agent_session_procedure::get_custom_world_agent_session
|
||||
pub use get_custom_world_gallery_detail_by_code_procedure::get_custom_world_gallery_detail_by_code;
|
||||
pub use get_custom_world_gallery_detail_procedure::get_custom_world_gallery_detail;
|
||||
pub use get_custom_world_library_detail_procedure::get_custom_world_library_detail;
|
||||
pub use get_external_generation_job_and_return_procedure::get_external_generation_job_and_return;
|
||||
pub use get_external_generation_queue_stats_and_return_procedure::get_external_generation_queue_stats_and_return;
|
||||
pub use get_jump_hop_agent_session_procedure::get_jump_hop_agent_session;
|
||||
pub use get_jump_hop_leaderboard_procedure::get_jump_hop_leaderboard;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// 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 ExternalGenerationJobGetInput {
|
||||
pub job_id: String,
|
||||
pub owner_user_id: String,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for ExternalGenerationJobGetInput {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
// 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::external_generation_job_get_input_type::ExternalGenerationJobGetInput;
|
||||
use super::external_generation_job_procedure_result_type::ExternalGenerationJobProcedureResult;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
struct GetExternalGenerationJobAndReturnArgs {
|
||||
pub input: ExternalGenerationJobGetInput,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for GetExternalGenerationJobAndReturnArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the procedure `get_external_generation_job_and_return`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteProcedures`].
|
||||
pub trait get_external_generation_job_and_return {
|
||||
fn get_external_generation_job_and_return(&self, input: ExternalGenerationJobGetInput) {
|
||||
self.get_external_generation_job_and_return_then(input, |_, _| {});
|
||||
}
|
||||
|
||||
fn get_external_generation_job_and_return_then(
|
||||
&self,
|
||||
input: ExternalGenerationJobGetInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<ExternalGenerationJobProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
);
|
||||
}
|
||||
|
||||
impl get_external_generation_job_and_return for super::RemoteProcedures {
|
||||
fn get_external_generation_job_and_return_then(
|
||||
&self,
|
||||
input: ExternalGenerationJobGetInput,
|
||||
|
||||
__callback: impl FnOnce(
|
||||
&super::ProcedureEventContext,
|
||||
Result<ExternalGenerationJobProcedureResult, __sdk::InternalError>,
|
||||
) + Send
|
||||
+ 'static,
|
||||
) {
|
||||
self.imp
|
||||
.invoke_procedure_with_callback::<_, ExternalGenerationJobProcedureResult>(
|
||||
"get_external_generation_job_and_return",
|
||||
GetExternalGenerationJobAndReturnArgs { input },
|
||||
__callback,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -124,6 +124,51 @@ impl SpacetimeClient {
|
||||
action_type: payload.action_type,
|
||||
session,
|
||||
work,
|
||||
queue_state: None,
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn mark_puzzle_clear_generation_queued(
|
||||
&self,
|
||||
session_id: String,
|
||||
owner_user_id: String,
|
||||
author_display_name: String,
|
||||
payload: PuzzleClearActionRequest,
|
||||
) -> Result<PuzzleClearActionResponse, SpacetimeClientError> {
|
||||
let current = self
|
||||
.get_puzzle_clear_session(session_id.clone(), owner_user_id.clone())
|
||||
.await?;
|
||||
let action_type = payload.action_type.clone();
|
||||
let scope = match action_type {
|
||||
PuzzleClearActionType::CompileDraft => PuzzleClearDraftMergeScope::CompileDraft,
|
||||
PuzzleClearActionType::RegenerateAtlas => PuzzleClearDraftMergeScope::RegenerateAtlas,
|
||||
_ => {
|
||||
return Err(SpacetimeClientError::validation_failed(
|
||||
"puzzle-clear queued generation 只支持 compile-draft/regenerate-atlas",
|
||||
));
|
||||
}
|
||||
};
|
||||
let mut draft = merge_action_into_draft(current.draft.clone(), &payload, scope)?;
|
||||
let profile_id =
|
||||
resolve_puzzle_clear_profile_id(&draft, &action_type, payload.profile_id.as_deref())?;
|
||||
draft.profile_id = Some(profile_id.clone());
|
||||
draft.generation_status = PuzzleClearGenerationStatus::Generating;
|
||||
let session = self
|
||||
.compile_puzzle_clear_draft(build_generating_compile_input(
|
||||
¤t,
|
||||
&owner_user_id,
|
||||
&author_display_name,
|
||||
&profile_id,
|
||||
&draft,
|
||||
current_unix_micros(),
|
||||
)?)
|
||||
.await?;
|
||||
|
||||
Ok(PuzzleClearActionResponse {
|
||||
action_type,
|
||||
session,
|
||||
work: None,
|
||||
queue_state: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -647,6 +692,38 @@ fn build_compile_input(
|
||||
})
|
||||
}
|
||||
|
||||
fn build_generating_compile_input(
|
||||
current: &PuzzleClearSessionSnapshotResponse,
|
||||
owner_user_id: &str,
|
||||
author_display_name: &str,
|
||||
profile_id: &str,
|
||||
draft: &PuzzleClearDraftResponse,
|
||||
now_micros: i64,
|
||||
) -> Result<PuzzleClearDraftCompileInput, SpacetimeClientError> {
|
||||
Ok(PuzzleClearDraftCompileInput {
|
||||
session_id: current.session_id.clone(),
|
||||
owner_user_id: owner_user_id.to_string(),
|
||||
profile_id: profile_id.to_string(),
|
||||
author_display_name: non_empty_str(author_display_name)
|
||||
.unwrap_or_else(|| "拼消消玩家".to_string()),
|
||||
work_title: draft.work_title.clone(),
|
||||
work_description: draft.work_description.clone(),
|
||||
theme_prompt: draft.theme_prompt.clone(),
|
||||
board_background_prompt: draft.board_background_prompt.clone(),
|
||||
generate_board_background: draft.generate_board_background,
|
||||
board_background_asset_json: draft
|
||||
.board_background_asset
|
||||
.as_ref()
|
||||
.map(json_string)
|
||||
.transpose()?,
|
||||
atlas_asset_json: draft.atlas_asset.as_ref().map(json_string).transpose()?,
|
||||
pattern_groups_json: Some(json_string(&draft.pattern_groups)?),
|
||||
card_assets_json: Some(json_string(&draft.card_assets)?),
|
||||
generation_status: Some("generating".to_string()),
|
||||
compiled_at_micros: now_micros,
|
||||
})
|
||||
}
|
||||
|
||||
fn build_failed_compile_input(
|
||||
current: &PuzzleClearSessionSnapshotResponse,
|
||||
owner_user_id: &str,
|
||||
|
||||
@@ -119,6 +119,53 @@ impl SpacetimeClient {
|
||||
action_type: payload.action_type,
|
||||
session,
|
||||
work,
|
||||
queue_state: None,
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn mark_wooden_fish_generation_queued(
|
||||
&self,
|
||||
session_id: String,
|
||||
owner_user_id: String,
|
||||
author_display_name: String,
|
||||
payload: WoodenFishActionRequest,
|
||||
) -> Result<WoodenFishActionResponse, SpacetimeClientError> {
|
||||
let current = self
|
||||
.get_wooden_fish_session(session_id.clone(), owner_user_id.clone())
|
||||
.await?;
|
||||
let action_type = payload.action_type.clone();
|
||||
let scope = match action_type {
|
||||
WoodenFishActionType::CompileDraft => WoodenFishDraftMergeScope::CompileDraft,
|
||||
WoodenFishActionType::RegenerateHitObject => {
|
||||
WoodenFishDraftMergeScope::RegenerateHitObject
|
||||
}
|
||||
_ => {
|
||||
return Err(SpacetimeClientError::validation_failed(
|
||||
"wooden-fish queued generation 只支持 compile-draft/regenerate-hit-object",
|
||||
));
|
||||
}
|
||||
};
|
||||
let mut draft = merge_action_into_draft(current.draft.clone(), &payload, scope)?;
|
||||
let profile_id =
|
||||
resolve_wooden_fish_profile_id(&draft, &action_type, payload.profile_id.as_deref())?;
|
||||
draft.profile_id = Some(profile_id.clone());
|
||||
draft.generation_status = WoodenFishGenerationStatus::Generating;
|
||||
let session = self
|
||||
.compile_wooden_fish_draft(build_generating_compile_input(
|
||||
¤t,
|
||||
&owner_user_id,
|
||||
&author_display_name,
|
||||
&profile_id,
|
||||
&draft,
|
||||
current_unix_micros(),
|
||||
)?)
|
||||
.await?;
|
||||
|
||||
Ok(WoodenFishActionResponse {
|
||||
action_type,
|
||||
session,
|
||||
work: None,
|
||||
queue_state: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -689,6 +736,52 @@ fn build_compile_input(
|
||||
})
|
||||
}
|
||||
|
||||
fn build_generating_compile_input(
|
||||
current: &WoodenFishSessionSnapshotResponse,
|
||||
owner_user_id: &str,
|
||||
author_display_name: &str,
|
||||
profile_id: &str,
|
||||
draft: &WoodenFishDraftResponse,
|
||||
now_micros: i64,
|
||||
) -> Result<WoodenFishDraftCompileInput, SpacetimeClientError> {
|
||||
Ok(WoodenFishDraftCompileInput {
|
||||
session_id: current.session_id.clone(),
|
||||
owner_user_id: owner_user_id.to_string(),
|
||||
profile_id: profile_id.to_string(),
|
||||
author_display_name: author_display_name.trim().to_string(),
|
||||
work_title: draft.work_title.clone(),
|
||||
work_description: draft.work_description.clone(),
|
||||
theme_tags_json: Some(json_string(&draft.theme_tags)?),
|
||||
hit_object_prompt: draft.hit_object_prompt.clone(),
|
||||
hit_object_reference_image_src: draft.hit_object_reference_image_src.clone(),
|
||||
hit_sound_prompt: draft.hit_sound_prompt.clone(),
|
||||
hit_object_asset_json: draft
|
||||
.hit_object_asset
|
||||
.as_ref()
|
||||
.map(json_string)
|
||||
.transpose()?,
|
||||
background_asset_json: draft
|
||||
.background_asset
|
||||
.as_ref()
|
||||
.map(json_string)
|
||||
.transpose()?,
|
||||
hit_sound_asset_json: draft
|
||||
.hit_sound_asset
|
||||
.as_ref()
|
||||
.map(json_string)
|
||||
.transpose()?,
|
||||
back_button_asset_json: draft
|
||||
.back_button_asset
|
||||
.as_ref()
|
||||
.map(json_string)
|
||||
.transpose()?,
|
||||
floating_words_json: Some(json_string(&draft.floating_words)?),
|
||||
cover_image_src: draft.cover_image_src.clone(),
|
||||
generation_status: Some("generating".to_string()),
|
||||
compiled_at_micros: now_micros,
|
||||
})
|
||||
}
|
||||
|
||||
fn build_failed_compile_input(
|
||||
current: &WoodenFishSessionSnapshotResponse,
|
||||
owner_user_id: &str,
|
||||
|
||||
Reference in New Issue
Block a user