mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 01:18:34 +00:00
map types
This commit is contained in:
1 parent
5322cd7ba2
commit
a99a1665bb
4 files changed
+34
-18
No files matched your search
@@ -51,6 +51,10 @@ then the story, then the fine print.
|
||||
- Group imports: std, external crates, internal workspace crates, `crate::` imports
|
||||
- Use fully qualified paths for one-off references; `use` for repeated references
|
||||
- Prefer specific imports over wildcards, except in `api_doc.rs` and test modules
|
||||
- When two crates export a type with the same name, alias with a suffix describing the source crate:
|
||||
`use enums::...::CommonResolution as CommonResolutionEnum;`
|
||||
`use artcraft_router::...::CommonResolution as CommonResolutionRouter;`
|
||||
This avoids long fully-qualified paths in function signatures and bodies.
|
||||
|
||||
## TypeScript / Frontend
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ artcraft/
|
||||
- SQLx for MySQL and SQLite
|
||||
- A mix of wreq and reqwest for Rust HTTP clients
|
||||
- Never use `println!` or `eprintln!` outside of tests; use `log` crate macros instead
|
||||
- When two crates export the same type name, alias imports with a suffix: `use foo::Bar as BarFoo;`
|
||||
- TypeScript with Nx, React, Vite, Zustand, and Three.js
|
||||
- Use two spaces for indentation
|
||||
|
||||
|
||||
+14
-8
@@ -1,14 +1,20 @@
|
||||
use artcraft_api_defs::omni_gen::cost_and_generate_requests::omni_gen_image_cost_and_generate_request::OmniGenImageCostAndGenerateRequest;
|
||||
use artcraft_router::api::common_aspect_ratio::CommonAspectRatio as CommonAspectRatioRouter;
|
||||
use artcraft_router::api::common_image_model::CommonImageModel as CommonImageModelRouter;
|
||||
use artcraft_router::api::common_resolution::CommonResolution as CommonResolutionRouter;
|
||||
use artcraft_router::api::image_list_ref::ImageListRef;
|
||||
use artcraft_router::api::provider::Provider;
|
||||
use artcraft_router::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use artcraft_router::generate::generate_image::generate_image_request::GenerateImageRequest;
|
||||
use enums::common::generation::common_aspect_ratio::CommonAspectRatio as CommonAspectRatioEnum;
|
||||
use enums::common::generation::common_image_model::CommonImageModel as CommonImageModelEnum;
|
||||
use enums::common::generation::common_resolution::CommonResolution as CommonResolutionEnum;
|
||||
|
||||
use crate::http_server::common_responses::advanced_common_web_error::AdvancedCommonWebError;
|
||||
|
||||
fn convert_model(
|
||||
model: &enums::common::generation::common_image_model::CommonImageModel,
|
||||
) -> Result<artcraft_router::api::common_image_model::CommonImageModel, AdvancedCommonWebError> {
|
||||
model: &CommonImageModelEnum,
|
||||
) -> Result<CommonImageModelRouter, AdvancedCommonWebError> {
|
||||
let json = serde_json::to_string(model)?;
|
||||
serde_json::from_str(&json).map_err(|e| {
|
||||
AdvancedCommonWebError::BadInputWithSimpleMessage(
|
||||
@@ -18,8 +24,8 @@ fn convert_model(
|
||||
}
|
||||
|
||||
fn convert_aspect_ratio(
|
||||
ar: &enums::common::generation::common_aspect_ratio::CommonAspectRatio,
|
||||
) -> Result<artcraft_router::api::common_aspect_ratio::CommonAspectRatio, AdvancedCommonWebError> {
|
||||
ar: &CommonAspectRatioEnum,
|
||||
) -> Result<CommonAspectRatioRouter, AdvancedCommonWebError> {
|
||||
let json = serde_json::to_string(ar)?;
|
||||
serde_json::from_str(&json).map_err(|e| {
|
||||
AdvancedCommonWebError::BadInputWithSimpleMessage(
|
||||
@@ -29,8 +35,8 @@ fn convert_aspect_ratio(
|
||||
}
|
||||
|
||||
fn convert_resolution(
|
||||
res: &enums::common::generation::common_resolution::CommonResolution,
|
||||
) -> Result<artcraft_router::api::common_resolution::CommonResolution, AdvancedCommonWebError> {
|
||||
res: &CommonResolutionEnum,
|
||||
) -> Result<CommonResolutionRouter, AdvancedCommonWebError> {
|
||||
let json = serde_json::to_string(res)?;
|
||||
serde_json::from_str(&json).map_err(|e| {
|
||||
AdvancedCommonWebError::BadInputWithSimpleMessage(
|
||||
@@ -63,8 +69,8 @@ pub fn transform_request(
|
||||
prompt: request.prompt.as_deref(),
|
||||
image_inputs: request.image_media_tokens.as_ref()
|
||||
.map(ImageListRef::MediaFileTokens),
|
||||
resolution: resolution,
|
||||
aspect_ratio: aspect_ratio,
|
||||
resolution,
|
||||
aspect_ratio,
|
||||
image_batch_count: request.image_batch_count,
|
||||
horizontal_angle: request.horizontal_angle,
|
||||
vertical_angle: request.vertical_angle,
|
||||
|
||||
+15
-10
@@ -1,17 +1,22 @@
|
||||
use crate::http_server::common_responses::advanced_common_web_error::AdvancedCommonWebError;
|
||||
use artcraft_api_defs::omni_gen::cost_and_generate_requests::omni_gen_video_cost_and_generate_request::OmniGenVideoCostAndGenerateRequest;
|
||||
use artcraft_router::api::audio_list_ref::AudioListRef;
|
||||
use artcraft_router::api::common_aspect_ratio::CommonAspectRatio as CommonAspectRatioRouter;
|
||||
use artcraft_router::api::common_resolution::CommonResolution as CommonResolutionRouter;
|
||||
use artcraft_router::api::common_video_model::CommonVideoModel as CommonVideoModelRouter;
|
||||
use artcraft_router::api::image_list_ref::ImageListRef;
|
||||
use artcraft_router::api::image_ref::ImageRef;
|
||||
use artcraft_router::api::provider::Provider;
|
||||
use artcraft_router::api::video_list_ref::VideoListRef;
|
||||
use artcraft_router::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy;
|
||||
use artcraft_router::generate::generate_video::generate_video_request::GenerateVideoRequest;
|
||||
|
||||
use crate::http_server::common_responses::advanced_common_web_error::AdvancedCommonWebError;
|
||||
use enums::common::generation::common_aspect_ratio::CommonAspectRatio as CommonAspectRatioEnum;
|
||||
use enums::common::generation::common_resolution::CommonResolution as CommonResolutionEnum;
|
||||
use enums::common::generation::common_video_model::CommonVideoModel as CommonVideoModelEnum;
|
||||
|
||||
fn convert_model(
|
||||
model: &enums::common::generation::common_video_model::CommonVideoModel,
|
||||
) -> Result<artcraft_router::api::common_video_model::CommonVideoModel, AdvancedCommonWebError> {
|
||||
model: &CommonVideoModelEnum,
|
||||
) -> Result<CommonVideoModelRouter, AdvancedCommonWebError> {
|
||||
let json = serde_json::to_string(model)?;
|
||||
serde_json::from_str(&json).map_err(|e| {
|
||||
AdvancedCommonWebError::BadInputWithSimpleMessage(
|
||||
@@ -21,8 +26,8 @@ fn convert_model(
|
||||
}
|
||||
|
||||
fn convert_aspect_ratio(
|
||||
ar: &enums::common::generation::common_aspect_ratio::CommonAspectRatio,
|
||||
) -> Result<artcraft_router::api::common_aspect_ratio::CommonAspectRatio, AdvancedCommonWebError> {
|
||||
ar: &CommonAspectRatioEnum,
|
||||
) -> Result<CommonAspectRatioRouter, AdvancedCommonWebError> {
|
||||
let json = serde_json::to_string(ar)?;
|
||||
serde_json::from_str(&json).map_err(|e| {
|
||||
AdvancedCommonWebError::BadInputWithSimpleMessage(
|
||||
@@ -32,8 +37,8 @@ fn convert_aspect_ratio(
|
||||
}
|
||||
|
||||
fn convert_resolution(
|
||||
res: &enums::common::generation::common_resolution::CommonResolution,
|
||||
) -> Result<artcraft_router::api::common_resolution::CommonResolution, AdvancedCommonWebError> {
|
||||
res: &CommonResolutionEnum,
|
||||
) -> Result<CommonResolutionRouter, AdvancedCommonWebError> {
|
||||
let json = serde_json::to_string(res)?;
|
||||
serde_json::from_str(&json).map_err(|e| {
|
||||
AdvancedCommonWebError::BadInputWithSimpleMessage(
|
||||
@@ -76,8 +81,8 @@ pub fn transform_request(
|
||||
reference_audio: request.reference_audio_media_tokens.as_ref()
|
||||
.map(AudioListRef::MediaFileTokens),
|
||||
reference_character_tokens: None,
|
||||
resolution: resolution,
|
||||
aspect_ratio: aspect_ratio,
|
||||
resolution,
|
||||
aspect_ratio,
|
||||
duration_seconds: request.duration_seconds,
|
||||
video_batch_count: request.video_batch_count,
|
||||
generate_audio: request.generate_audio,
|
||||
|
||||
Reference in new issue
Block a user