mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-19 08:05:20 +00:00
list meshes and splats (#1774)
This commit is contained in:
1 parent
bc0174ac7a
commit
7dffc5fb5c
37 files changed
+1467
-281
No files matched your search
-12
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "\n INSERT INTO media_files\n SET\n token = ?,\n\n media_class = ?,\n media_type = ?,\n\n is_user_upload = ?,\n is_intermediate_system_file = ?,\n\n origin_category = ?, \n origin_product_category = ?, \n maybe_origin_model_type = ?, \n maybe_origin_model_token = ?, \n maybe_origin_filename = ?,\n\n maybe_batch_token = ?,\n\n maybe_mime_type = ?,\n file_size_bytes = ?,\n maybe_duration_millis = ?,\n maybe_audio_encoding = ?, \n maybe_video_encoding = ?, \n maybe_frame_width = ?, \n maybe_frame_height = ?,\n maybe_prompt_token = ?,\n checksum_sha2 = ?,\n \n maybe_engine_category = ?,\n\n maybe_title = ?,\n maybe_text_transcript = ?,\n\n maybe_scene_source_media_file_token = ?,\n\n public_bucket_directory_hash = ?, \n maybe_public_bucket_prefix = ?, \n maybe_public_bucket_extension = ?, \n\n maybe_creator_user_token = ?, \n maybe_creator_anonymous_visitor_token = ?, \n\n creator_ip_address = ?, \n creator_set_visibility = ?, \n\n maybe_creator_file_synthetic_id = ?, \n maybe_creator_category_synthetic_id = ?,\n\n extra_file_modification_info = ?,\n\n maybe_generation_provider = ?,\n\n platform_type = ?,\n\n maybe_cover_image_media_file_token = ?,\n\n maybe_mod_user_token = ?,\n is_generated_on_prem = ?,\n generated_by_worker = ?,\n generated_by_cluster = ?\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 41
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "1c74e9c2dcc9205e2c9fe60a6de0828208e497e68560246e588092bafd03eb59"
|
||||
}
|
||||
+223
@@ -0,0 +1,223 @@
|
||||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "\nSELECT\n m.id as `id: u64`,\n m.token as `token: tokens::tokens::media_files::MediaFileToken`,\n\n m.media_class as `media_class: enums::by_table::media_files::media_file_class::MediaFileClass`,\n m.media_type as `media_type: enums::by_table::media_files::media_file_type::MediaFileType`,\n\n m.public_bucket_directory_hash,\n m.maybe_public_bucket_prefix,\n m.maybe_public_bucket_extension,\n\n users.token as `maybe_creator_user_token: tokens::tokens::users::UserToken`,\n users.username as maybe_creator_username,\n users.display_name as maybe_creator_display_name,\n users.email_gravatar_hash as maybe_creator_gravatar_hash,\n\n media_file_cover_image.public_bucket_directory_hash as maybe_file_cover_image_public_bucket_hash,\n media_file_cover_image.maybe_public_bucket_prefix as maybe_file_cover_image_public_bucket_prefix,\n media_file_cover_image.maybe_public_bucket_extension as maybe_file_cover_image_public_bucket_extension,\n\n m.creator_set_visibility as `creator_set_visibility: enums::common::visibility::Visibility`,\n\n m.maybe_prompt_token as `maybe_prompt_token: tokens::tokens::prompts::PromptToken`,\n m.maybe_title,\n\n m.created_at,\n m.updated_at\n\nFROM media_files AS m FORCE INDEX (fk_maybe_creator_user_token)\nLEFT OUTER JOIN users\n ON m.maybe_creator_user_token = users.token\nLEFT OUTER JOIN media_files as media_file_cover_image\n ON media_file_cover_image.token = m.maybe_cover_image_media_file_token\nWHERE\n m.maybe_creator_user_token = ?\n AND m.media_class = ?\n AND m.user_deleted_at IS NULL\n AND m.mod_deleted_at IS NULL\n AND NOT m.is_intermediate_system_file\n AND m.id < ?\nORDER BY m.id DESC\nLIMIT ?\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id: u64",
|
||||
"type_info": {
|
||||
"type": "LongLong",
|
||||
"flags": "NOT_NULL | PRIMARY_KEY | AUTO_INCREMENT",
|
||||
"char_set": 63,
|
||||
"max_size": 20
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "token: tokens::tokens::media_files::MediaFileToken",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "media_class: enums::by_table::media_files::media_file_class::MediaFileClass",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | MULTIPLE_KEY | BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "media_type: enums::by_table::media_files::media_file_type::MediaFileType",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | MULTIPLE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "public_bucket_directory_hash",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "maybe_public_bucket_prefix",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "maybe_public_bucket_extension",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"name": "maybe_creator_user_token: tokens::tokens::users::UserToken",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "UNIQUE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"name": "maybe_creator_username",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "UNIQUE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 80
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 9,
|
||||
"name": "maybe_creator_display_name",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 80
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 10,
|
||||
"name": "maybe_creator_gravatar_hash",
|
||||
"type_info": {
|
||||
"type": "String",
|
||||
"flags": "BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 11,
|
||||
"name": "maybe_file_cover_image_public_bucket_hash",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 12,
|
||||
"name": "maybe_file_cover_image_public_bucket_prefix",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 13,
|
||||
"name": "maybe_file_cover_image_public_bucket_extension",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 14,
|
||||
"name": "creator_set_visibility: enums::common::visibility::Visibility",
|
||||
"type_info": {
|
||||
"type": "String",
|
||||
"flags": "NOT_NULL | BINARY | ENUM",
|
||||
"char_set": 224,
|
||||
"max_size": 28
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 15,
|
||||
"name": "maybe_prompt_token: tokens::tokens::prompts::PromptToken",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "MULTIPLE_KEY | BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 16,
|
||||
"name": "maybe_title",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 1020
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 17,
|
||||
"name": "created_at",
|
||||
"type_info": {
|
||||
"type": "Timestamp",
|
||||
"flags": "NOT_NULL | MULTIPLE_KEY | BINARY | TIMESTAMP",
|
||||
"char_set": 63,
|
||||
"max_size": 19
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 18,
|
||||
"name": "updated_at",
|
||||
"type_info": {
|
||||
"type": "Timestamp",
|
||||
"flags": "NOT_NULL | MULTIPLE_KEY | BINARY | TIMESTAMP | ON_UPDATE_NOW",
|
||||
"char_set": 63,
|
||||
"max_size": 19
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 4
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "73540435892b7b4dbc11c6c63712abdb18fd8b3db2bcd56b8518c968b8169de7"
|
||||
}
|
||||
+223
@@ -0,0 +1,223 @@
|
||||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "\nSELECT\n m.id as `id: u64`,\n m.token as `token: tokens::tokens::media_files::MediaFileToken`,\n\n m.media_class as `media_class: enums::by_table::media_files::media_file_class::MediaFileClass`,\n m.media_type as `media_type: enums::by_table::media_files::media_file_type::MediaFileType`,\n\n m.public_bucket_directory_hash,\n m.maybe_public_bucket_prefix,\n m.maybe_public_bucket_extension,\n\n users.token as `maybe_creator_user_token: tokens::tokens::users::UserToken`,\n users.username as maybe_creator_username,\n users.display_name as maybe_creator_display_name,\n users.email_gravatar_hash as maybe_creator_gravatar_hash,\n\n media_file_cover_image.public_bucket_directory_hash as maybe_file_cover_image_public_bucket_hash,\n media_file_cover_image.maybe_public_bucket_prefix as maybe_file_cover_image_public_bucket_prefix,\n media_file_cover_image.maybe_public_bucket_extension as maybe_file_cover_image_public_bucket_extension,\n\n m.creator_set_visibility as `creator_set_visibility: enums::common::visibility::Visibility`,\n\n m.maybe_prompt_token as `maybe_prompt_token: tokens::tokens::prompts::PromptToken`,\n m.maybe_title,\n\n m.created_at,\n m.updated_at\n\nFROM media_files AS m FORCE INDEX (fk_maybe_creator_user_token)\nLEFT OUTER JOIN users\n ON m.maybe_creator_user_token = users.token\nLEFT OUTER JOIN media_files as media_file_cover_image\n ON media_file_cover_image.token = m.maybe_cover_image_media_file_token\nWHERE\n m.maybe_creator_user_token = ?\n AND m.media_class = ?\n AND m.user_deleted_at IS NULL\n AND m.mod_deleted_at IS NULL\n AND NOT m.is_intermediate_system_file\n AND m.id > ?\nORDER BY m.id ASC\nLIMIT ?\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id: u64",
|
||||
"type_info": {
|
||||
"type": "LongLong",
|
||||
"flags": "NOT_NULL | PRIMARY_KEY | AUTO_INCREMENT",
|
||||
"char_set": 63,
|
||||
"max_size": 20
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "token: tokens::tokens::media_files::MediaFileToken",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "media_class: enums::by_table::media_files::media_file_class::MediaFileClass",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | MULTIPLE_KEY | BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "media_type: enums::by_table::media_files::media_file_type::MediaFileType",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | MULTIPLE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "public_bucket_directory_hash",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "maybe_public_bucket_prefix",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "maybe_public_bucket_extension",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"name": "maybe_creator_user_token: tokens::tokens::users::UserToken",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "UNIQUE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"name": "maybe_creator_username",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "UNIQUE_KEY | BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 80
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 9,
|
||||
"name": "maybe_creator_display_name",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 80
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 10,
|
||||
"name": "maybe_creator_gravatar_hash",
|
||||
"type_info": {
|
||||
"type": "String",
|
||||
"flags": "BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 11,
|
||||
"name": "maybe_file_cover_image_public_bucket_hash",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 12,
|
||||
"name": "maybe_file_cover_image_public_bucket_prefix",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 13,
|
||||
"name": "maybe_file_cover_image_public_bucket_extension",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 14,
|
||||
"name": "creator_set_visibility: enums::common::visibility::Visibility",
|
||||
"type_info": {
|
||||
"type": "String",
|
||||
"flags": "NOT_NULL | BINARY | ENUM",
|
||||
"char_set": 224,
|
||||
"max_size": 28
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 15,
|
||||
"name": "maybe_prompt_token: tokens::tokens::prompts::PromptToken",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "MULTIPLE_KEY | BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 128
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 16,
|
||||
"name": "maybe_title",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "BINARY",
|
||||
"char_set": 224,
|
||||
"max_size": 1020
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 17,
|
||||
"name": "created_at",
|
||||
"type_info": {
|
||||
"type": "Timestamp",
|
||||
"flags": "NOT_NULL | MULTIPLE_KEY | BINARY | TIMESTAMP",
|
||||
"char_set": 63,
|
||||
"max_size": 19
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 18,
|
||||
"name": "updated_at",
|
||||
"type_info": {
|
||||
"type": "Timestamp",
|
||||
"flags": "NOT_NULL | MULTIPLE_KEY | BINARY | TIMESTAMP | ON_UPDATE_NOW",
|
||||
"char_set": 63,
|
||||
"max_size": 19
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 4
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "a52cc2d6e86607c430173553230b3794a4c1ada07274a975c04128e47d3b7f83"
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
//! Shared types for the by-class session media file list endpoints
|
||||
//! (`/v1/media_files/mesh/list`, `/v1/media_files/splat/list`).
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use utoipa::{IntoParams, ToSchema};
|
||||
|
||||
use enums::by_table::media_files::media_file_class::MediaFileClass;
|
||||
use enums::by_table::media_files::media_file_type::MediaFileType;
|
||||
use enums::common::visibility::Visibility;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
use tokens::tokens::prompts::PromptToken;
|
||||
|
||||
use crate::common::responses::media_file_cover_image_details::MediaFileCoverImageDetails;
|
||||
use crate::common::responses::media_links::MediaLinks;
|
||||
use crate::common::responses::user_details_light::UserDetailsLight;
|
||||
|
||||
/// Query string parameters for the by-class session media file lists.
|
||||
/// Pagination only — the media class is fixed by the endpoint.
|
||||
#[derive(Deserialize, IntoParams)]
|
||||
pub struct ListSessionMediaFilesByTypeQueryParams {
|
||||
pub sort_ascending: Option<bool>,
|
||||
pub page_size: Option<usize>,
|
||||
pub cursor: Option<String>,
|
||||
pub cursor_is_reversed: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, ToSchema)]
|
||||
pub struct SessionMediaFileInfo {
|
||||
/// Primary key identifier
|
||||
pub token: MediaFileToken,
|
||||
|
||||
/// The coarse-grained class of media file.
|
||||
/// Fixed per endpoint (`mesh` or `splat`).
|
||||
pub media_class: MediaFileClass,
|
||||
|
||||
/// Type of media will dictate which fields are populated and what
|
||||
/// the frontend should display (eg. video player vs audio player).
|
||||
/// This is closer in meaning to a "mime type".
|
||||
pub media_type: MediaFileType,
|
||||
|
||||
/// Rich CDN links to the media, including thumbnails, previews, and more.
|
||||
pub media_links: MediaLinks,
|
||||
|
||||
/// Information about the cover image. Many media files do not require a cover image,
|
||||
/// e.g. image files, video files with thumbnails, audio files, etc.
|
||||
/// 3D files require them.
|
||||
pub cover_image: MediaFileCoverImageDetails,
|
||||
|
||||
/// User info
|
||||
pub maybe_creator_user: Option<UserDetailsLight>,
|
||||
|
||||
pub creator_set_visibility: Visibility,
|
||||
|
||||
/// The generation's prompt record, when there is one. Clients resolve it
|
||||
/// to display the original prompt and model.
|
||||
pub maybe_prompt_token: Option<PromptToken>,
|
||||
|
||||
/// The name or title of the media file (optional)
|
||||
pub maybe_title: Option<String>,
|
||||
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use utoipa::ToSchema;
|
||||
|
||||
use crate::common::responses::pagination_cursors::PaginationCursors;
|
||||
use crate::media_file::list::by_type::list_session_common::SessionMediaFileInfo;
|
||||
|
||||
pub const LIST_SESSION_MESH_MEDIA_FILES_URL_PATH: &str = "/v1/media_files/mesh/list";
|
||||
|
||||
#[derive(Serialize, Deserialize, ToSchema)]
|
||||
pub struct ListSessionMeshMediaFilesSuccessResponse {
|
||||
pub success: bool,
|
||||
pub results: Vec<SessionMediaFileInfo>,
|
||||
pub pagination: PaginationCursors,
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use utoipa::ToSchema;
|
||||
|
||||
use crate::common::responses::pagination_cursors::PaginationCursors;
|
||||
use crate::media_file::list::by_type::list_session_common::SessionMediaFileInfo;
|
||||
|
||||
pub const LIST_SESSION_SPLAT_MEDIA_FILES_URL_PATH: &str = "/v1/media_files/splat/list";
|
||||
|
||||
#[derive(Serialize, Deserialize, ToSchema)]
|
||||
pub struct ListSessionSplatMediaFilesSuccessResponse {
|
||||
pub success: bool,
|
||||
pub results: Vec<SessionMediaFileInfo>,
|
||||
pub pagination: PaginationCursors,
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod list_session_common;
|
||||
pub mod list_session_mesh_media_files;
|
||||
pub mod list_session_splat_media_files;
|
||||
@@ -0,0 +1 @@
|
||||
pub mod by_type;
|
||||
@@ -1,4 +1,5 @@
|
||||
pub mod delete_media_file;
|
||||
pub mod list;
|
||||
pub mod list_batch_generated_media_files;
|
||||
pub mod list_session_project_media_files;
|
||||
pub mod project;
|
||||
pub mod project;
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use sqlx::{Executor, MySql};
|
||||
|
||||
use enums::by_table::media_files::media_file_class::MediaFileClass;
|
||||
use enums::by_table::media_files::media_file_type::MediaFileType;
|
||||
use enums::common::visibility::Visibility;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
use tokens::tokens::prompts::PromptToken;
|
||||
use tokens::tokens::users::UserToken;
|
||||
|
||||
pub struct SessionMediaFileListPage {
|
||||
pub records: Vec<SessionMediaFileListItem>,
|
||||
|
||||
/// ID of the first record (for building the "previous" cursor).
|
||||
pub first_id: Option<u64>,
|
||||
|
||||
/// ID of the last record (for building the "next" cursor).
|
||||
pub last_id: Option<u64>,
|
||||
}
|
||||
|
||||
pub struct SessionMediaFileListItem {
|
||||
pub id: u64,
|
||||
pub token: MediaFileToken,
|
||||
|
||||
pub media_class: MediaFileClass,
|
||||
pub media_type: MediaFileType,
|
||||
|
||||
pub public_bucket_directory_hash: String,
|
||||
pub maybe_public_bucket_prefix: Option<String>,
|
||||
pub maybe_public_bucket_extension: Option<String>,
|
||||
|
||||
pub maybe_creator_user_token: Option<UserToken>,
|
||||
pub maybe_creator_username: Option<String>,
|
||||
pub maybe_creator_display_name: Option<String>,
|
||||
pub maybe_creator_gravatar_hash: Option<String>,
|
||||
|
||||
pub maybe_file_cover_image_public_bucket_hash: Option<String>,
|
||||
pub maybe_file_cover_image_public_bucket_prefix: Option<String>,
|
||||
pub maybe_file_cover_image_public_bucket_extension: Option<String>,
|
||||
|
||||
pub creator_set_visibility: Visibility,
|
||||
|
||||
pub maybe_prompt_token: Option<PromptToken>,
|
||||
pub maybe_title: Option<String>,
|
||||
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
pub struct ListSessionMediaFilesByClassArgs<'a, 'c, E>
|
||||
where
|
||||
E: 'a + Executor<'c, Database = MySql>,
|
||||
{
|
||||
pub user_token: &'a UserToken,
|
||||
|
||||
/// The media class to list (e.g. `mesh` or `splat`).
|
||||
pub media_class: MediaFileClass,
|
||||
|
||||
pub limit: usize,
|
||||
|
||||
/// Keyset cursor: a `media_files.id` from a previous page.
|
||||
pub maybe_cursor_id: Option<u64>,
|
||||
pub cursor_is_reversed: bool,
|
||||
pub sort_ascending: bool,
|
||||
|
||||
pub mysql_executor: E,
|
||||
pub phantom: PhantomData<&'c E>,
|
||||
}
|
||||
|
||||
/// List the session user's media files of a single class (e.g. `mesh` or
|
||||
/// `splat`), newest first by default, with keyset pagination on `id`.
|
||||
pub async fn list_session_media_files_by_class<'a, 'c: 'a, E>(
|
||||
args: ListSessionMediaFilesByClassArgs<'a, 'c, E>,
|
||||
) -> Result<SessionMediaFileListPage, sqlx::Error>
|
||||
where
|
||||
E: 'a + Executor<'c, Database = MySql>,
|
||||
{
|
||||
// A reversed cursor walks the opposite direction of the sort, so the effective
|
||||
// scan direction is the XOR of the two flags (same scheme as `list_media_files`).
|
||||
let ascending = args.sort_ascending != args.cursor_is_reversed;
|
||||
|
||||
let limit = args.limit as u64;
|
||||
|
||||
let records = if ascending {
|
||||
// NB: IDs start at 1, so a zero sentinel means "no cursor".
|
||||
let cursor_id = args.maybe_cursor_id.unwrap_or(0);
|
||||
select_page_ascending(
|
||||
args.user_token,
|
||||
args.media_class,
|
||||
cursor_id,
|
||||
limit,
|
||||
args.mysql_executor,
|
||||
).await?
|
||||
} else {
|
||||
let cursor_id = args.maybe_cursor_id.unwrap_or(u64::MAX);
|
||||
select_page_descending(
|
||||
args.user_token,
|
||||
args.media_class,
|
||||
cursor_id,
|
||||
limit,
|
||||
args.mysql_executor,
|
||||
).await?
|
||||
};
|
||||
|
||||
let first_id = records.first().map(|record| record.id);
|
||||
let last_id = records.last().map(|record| record.id);
|
||||
|
||||
Ok(SessionMediaFileListPage {
|
||||
records,
|
||||
first_id,
|
||||
last_id,
|
||||
})
|
||||
}
|
||||
|
||||
// NB: The two queries below are intentionally duplicated so that sqlx can check
|
||||
// them at compile time (no QueryBuilder). Keep the SELECT lists and predicates
|
||||
// in sync; they differ only in the cursor comparison direction and sort order.
|
||||
|
||||
async fn select_page_ascending<'a, 'c: 'a, E>(
|
||||
user_token: &'a UserToken,
|
||||
media_class: MediaFileClass,
|
||||
cursor_id: u64,
|
||||
limit: u64,
|
||||
mysql_executor: E,
|
||||
) -> Result<Vec<SessionMediaFileListItem>, sqlx::Error>
|
||||
where
|
||||
E: 'a + Executor<'c, Database = MySql>,
|
||||
{
|
||||
sqlx::query_as!(
|
||||
SessionMediaFileListItem,
|
||||
r#"
|
||||
SELECT
|
||||
m.id as `id: u64`,
|
||||
m.token as `token: tokens::tokens::media_files::MediaFileToken`,
|
||||
|
||||
m.media_class as `media_class: enums::by_table::media_files::media_file_class::MediaFileClass`,
|
||||
m.media_type as `media_type: enums::by_table::media_files::media_file_type::MediaFileType`,
|
||||
|
||||
m.public_bucket_directory_hash,
|
||||
m.maybe_public_bucket_prefix,
|
||||
m.maybe_public_bucket_extension,
|
||||
|
||||
users.token as `maybe_creator_user_token: tokens::tokens::users::UserToken`,
|
||||
users.username as maybe_creator_username,
|
||||
users.display_name as maybe_creator_display_name,
|
||||
users.email_gravatar_hash as maybe_creator_gravatar_hash,
|
||||
|
||||
media_file_cover_image.public_bucket_directory_hash as maybe_file_cover_image_public_bucket_hash,
|
||||
media_file_cover_image.maybe_public_bucket_prefix as maybe_file_cover_image_public_bucket_prefix,
|
||||
media_file_cover_image.maybe_public_bucket_extension as maybe_file_cover_image_public_bucket_extension,
|
||||
|
||||
m.creator_set_visibility as `creator_set_visibility: enums::common::visibility::Visibility`,
|
||||
|
||||
m.maybe_prompt_token as `maybe_prompt_token: tokens::tokens::prompts::PromptToken`,
|
||||
m.maybe_title,
|
||||
|
||||
m.created_at,
|
||||
m.updated_at
|
||||
|
||||
FROM media_files AS m FORCE INDEX (fk_maybe_creator_user_token)
|
||||
LEFT OUTER JOIN users
|
||||
ON m.maybe_creator_user_token = users.token
|
||||
LEFT OUTER JOIN media_files as media_file_cover_image
|
||||
ON media_file_cover_image.token = m.maybe_cover_image_media_file_token
|
||||
WHERE
|
||||
m.maybe_creator_user_token = ?
|
||||
AND m.media_class = ?
|
||||
AND m.user_deleted_at IS NULL
|
||||
AND m.mod_deleted_at IS NULL
|
||||
AND NOT m.is_intermediate_system_file
|
||||
AND m.id > ?
|
||||
ORDER BY m.id ASC
|
||||
LIMIT ?
|
||||
"#,
|
||||
user_token,
|
||||
media_class.to_str(),
|
||||
cursor_id,
|
||||
limit,
|
||||
)
|
||||
.fetch_all(mysql_executor)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn select_page_descending<'a, 'c: 'a, E>(
|
||||
user_token: &'a UserToken,
|
||||
media_class: MediaFileClass,
|
||||
cursor_id: u64,
|
||||
limit: u64,
|
||||
mysql_executor: E,
|
||||
) -> Result<Vec<SessionMediaFileListItem>, sqlx::Error>
|
||||
where
|
||||
E: 'a + Executor<'c, Database = MySql>,
|
||||
{
|
||||
sqlx::query_as!(
|
||||
SessionMediaFileListItem,
|
||||
r#"
|
||||
SELECT
|
||||
m.id as `id: u64`,
|
||||
m.token as `token: tokens::tokens::media_files::MediaFileToken`,
|
||||
|
||||
m.media_class as `media_class: enums::by_table::media_files::media_file_class::MediaFileClass`,
|
||||
m.media_type as `media_type: enums::by_table::media_files::media_file_type::MediaFileType`,
|
||||
|
||||
m.public_bucket_directory_hash,
|
||||
m.maybe_public_bucket_prefix,
|
||||
m.maybe_public_bucket_extension,
|
||||
|
||||
users.token as `maybe_creator_user_token: tokens::tokens::users::UserToken`,
|
||||
users.username as maybe_creator_username,
|
||||
users.display_name as maybe_creator_display_name,
|
||||
users.email_gravatar_hash as maybe_creator_gravatar_hash,
|
||||
|
||||
media_file_cover_image.public_bucket_directory_hash as maybe_file_cover_image_public_bucket_hash,
|
||||
media_file_cover_image.maybe_public_bucket_prefix as maybe_file_cover_image_public_bucket_prefix,
|
||||
media_file_cover_image.maybe_public_bucket_extension as maybe_file_cover_image_public_bucket_extension,
|
||||
|
||||
m.creator_set_visibility as `creator_set_visibility: enums::common::visibility::Visibility`,
|
||||
|
||||
m.maybe_prompt_token as `maybe_prompt_token: tokens::tokens::prompts::PromptToken`,
|
||||
m.maybe_title,
|
||||
|
||||
m.created_at,
|
||||
m.updated_at
|
||||
|
||||
FROM media_files AS m FORCE INDEX (fk_maybe_creator_user_token)
|
||||
LEFT OUTER JOIN users
|
||||
ON m.maybe_creator_user_token = users.token
|
||||
LEFT OUTER JOIN media_files as media_file_cover_image
|
||||
ON media_file_cover_image.token = m.maybe_cover_image_media_file_token
|
||||
WHERE
|
||||
m.maybe_creator_user_token = ?
|
||||
AND m.media_class = ?
|
||||
AND m.user_deleted_at IS NULL
|
||||
AND m.mod_deleted_at IS NULL
|
||||
AND NOT m.is_intermediate_system_file
|
||||
AND m.id < ?
|
||||
ORDER BY m.id DESC
|
||||
LIMIT ?
|
||||
"#,
|
||||
user_token,
|
||||
media_class.to_str(),
|
||||
cursor_id,
|
||||
limit,
|
||||
)
|
||||
.fetch_all(mysql_executor)
|
||||
.await
|
||||
}
|
||||
@@ -4,5 +4,6 @@ pub mod list_media_files;
|
||||
pub mod list_media_files_by_batch_token;
|
||||
pub mod list_media_files_for_elastic_search_backfill_using_cursor;
|
||||
pub mod list_media_files_for_user;
|
||||
pub mod list_session_media_files_by_class;
|
||||
pub mod list_session_project_media_files;
|
||||
pub mod media_file_list_row;
|
||||
@@ -353,6 +353,9 @@ use artcraft_api_defs::analytics::log_active_user::*;
|
||||
use artcraft_api_defs::credits::get_session_credits::*;
|
||||
use artcraft_api_defs::subscriptions::get_session_subscription::*;
|
||||
use artcraft_api_defs::media_file::list_batch_generated_media_files::*;
|
||||
use artcraft_api_defs::media_file::list::by_type::list_session_common::*;
|
||||
use artcraft_api_defs::media_file::list::by_type::list_session_mesh_media_files::*;
|
||||
use artcraft_api_defs::media_file::list::by_type::list_session_splat_media_files::*;
|
||||
use artcraft_api_defs::media_file::list_session_project_media_files::*;
|
||||
use artcraft_api_defs::media_file::project::upload_updated_mood_board_project::*;
|
||||
use artcraft_api_defs::media_file::project::upload_new_mood_board_project::*;
|
||||
@@ -495,6 +498,8 @@ use crate::http_server::endpoints::media_files::list::list_batch_generated_redux
|
||||
crate::http_server::endpoints::media_files::list::list_media_files_for_user_handler::list_media_files_for_user_handler,
|
||||
crate::http_server::endpoints::media_files::list::list_media_files_handler::list_media_files_handler,
|
||||
crate::http_server::endpoints::media_files::list::list_pinned_media_files_handler::list_pinned_media_files_handler,
|
||||
crate::http_server::endpoints::media_files::list::by_type::list_session_mesh_media_files_handler::list_session_mesh_media_files_handler,
|
||||
crate::http_server::endpoints::media_files::list::by_type::list_session_splat_media_files_handler::list_session_splat_media_files_handler,
|
||||
crate::http_server::endpoints::media_files::list::list_session_project_media_files_handler::list_session_project_media_files_handler,
|
||||
crate::http_server::endpoints::media_files::search::search_featured_media_files_handler::search_featured_media_files_handler,
|
||||
crate::http_server::endpoints::media_files::search::search_session_media_files_handler::search_session_media_files_handler,
|
||||
@@ -1124,7 +1129,9 @@ use crate::http_server::endpoints::media_files::list::list_batch_generated_redux
|
||||
ListPinnedWeightsSuccessResponse,
|
||||
ListSessionJobsItem,
|
||||
ListSessionJobsQueryParams,
|
||||
ListSessionMeshMediaFilesSuccessResponse,
|
||||
ListSessionProjectMediaFilesSuccessResponse,
|
||||
ListSessionSplatMediaFilesSuccessResponse,
|
||||
ListSessionJobsSuccessResponse,
|
||||
ListSessionRequestDetailsResponse,
|
||||
ListSessionResultDetailsResponse,
|
||||
@@ -1168,6 +1175,7 @@ use crate::http_server::endpoints::media_files::list::list_batch_generated_redux
|
||||
PinnedMediaFile,
|
||||
PinnedModelWeightForList,
|
||||
ProjectMediaFileInfo,
|
||||
SessionMediaFileInfo,
|
||||
PromptInfo,
|
||||
RatingRow,
|
||||
RedeemBetaKeyRequest,
|
||||
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
//! Shared logic for the by-class session media file list endpoints
|
||||
//! (`/v1/media_files/mesh/list`, `/v1/media_files/splat/list`).
|
||||
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
|
||||
use actix_web::HttpRequest;
|
||||
use log::{error, warn};
|
||||
|
||||
use artcraft_api_defs::common::responses::pagination_cursors::PaginationCursors;
|
||||
use artcraft_api_defs::media_file::list::by_type::list_session_common::{ListSessionMediaFilesByTypeQueryParams, SessionMediaFileInfo};
|
||||
use bucket_paths::legacy::typified_paths::public::media_files::bucket_file_path::MediaFileBucketPath;
|
||||
use enums::by_table::media_files::media_file_class::MediaFileClass;
|
||||
use mysql_queries::queries::media_files::list::list_session_media_files_by_class::{list_session_media_files_by_class, ListSessionMediaFilesByClassArgs};
|
||||
|
||||
use crate::http_server::common_responses::common_web_error::CommonWebError;
|
||||
use crate::http_server::common_responses::media::media_file_cover_image_details_builder::MediaFileCoverImageDetailsBuilder;
|
||||
use crate::http_server::common_responses::media::media_links_builder::MediaLinksBuilder;
|
||||
use crate::http_server::common_responses::user_details_lite_builder::UserDetailsLightBuilder;
|
||||
use crate::http_server::endpoints::media_files::helpers::get_media_domain::get_media_domain;
|
||||
use crate::http_server::user_lookup::user_session::require_user_session::require_user_session;
|
||||
use crate::state::server_state::ServerState;
|
||||
|
||||
const DEFAULT_PAGE_SIZE: usize = 100;
|
||||
const MAX_PAGE_SIZE: usize = 1000;
|
||||
|
||||
/// List the session user's media files of a single class (paginated).
|
||||
/// The shared core of the mesh and splat list handlers.
|
||||
pub async fn list_session_media_files_of_class(
|
||||
http_request: &HttpRequest,
|
||||
query: &ListSessionMediaFilesByTypeQueryParams,
|
||||
server_state: &Arc<ServerState>,
|
||||
media_class: MediaFileClass,
|
||||
) -> Result<(Vec<SessionMediaFileInfo>, PaginationCursors), CommonWebError> {
|
||||
|
||||
let mut mysql_connection = server_state.mysql_pool
|
||||
.acquire()
|
||||
.await
|
||||
.map_err(|err| {
|
||||
error!("MySql pool error: {:?}", err);
|
||||
CommonWebError::from_error(err)
|
||||
})?;
|
||||
|
||||
let user_session = require_user_session(
|
||||
http_request,
|
||||
&server_state.session_checker,
|
||||
&mut *mysql_connection,
|
||||
).await?;
|
||||
|
||||
let limit = query.page_size
|
||||
.unwrap_or(DEFAULT_PAGE_SIZE)
|
||||
.min(MAX_PAGE_SIZE);
|
||||
|
||||
let sort_ascending = query.sort_ascending.unwrap_or(false);
|
||||
let cursor_is_reversed = query.cursor_is_reversed.unwrap_or(false);
|
||||
|
||||
let maybe_cursor_id = if let Some(cursor) = query.cursor.as_deref() {
|
||||
Some(server_state.sort_key_crypto.decrypt_id(cursor)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let results_page = list_session_media_files_by_class(ListSessionMediaFilesByClassArgs {
|
||||
user_token: user_session.get_user_token(),
|
||||
media_class,
|
||||
limit,
|
||||
maybe_cursor_id,
|
||||
cursor_is_reversed,
|
||||
sort_ascending,
|
||||
mysql_executor: &mut *mysql_connection,
|
||||
phantom: PhantomData,
|
||||
})
|
||||
.await
|
||||
.map_err(|err| {
|
||||
warn!("List session {:?} media files query error: {:?}", media_class, err);
|
||||
CommonWebError::from_error(err)
|
||||
})?;
|
||||
|
||||
let maybe_next = if let Some(id) = results_page.last_id {
|
||||
Some(server_state.sort_key_crypto.encrypt_id(id)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let maybe_previous = if let Some(id) = results_page.first_id {
|
||||
Some(server_state.sort_key_crypto.encrypt_id(id)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let media_domain = get_media_domain(http_request);
|
||||
|
||||
let results = results_page.records.into_iter()
|
||||
.map(|record| {
|
||||
let public_bucket_path = MediaFileBucketPath::from_object_hash(
|
||||
&record.public_bucket_directory_hash,
|
||||
record.maybe_public_bucket_prefix.as_deref(),
|
||||
record.maybe_public_bucket_extension.as_deref(),
|
||||
);
|
||||
SessionMediaFileInfo {
|
||||
media_links: MediaLinksBuilder::from_media_path_and_env(
|
||||
media_domain,
|
||||
server_state.server_environment,
|
||||
&public_bucket_path,
|
||||
),
|
||||
cover_image: MediaFileCoverImageDetailsBuilder::from_optional_db_fields(
|
||||
&record.token,
|
||||
media_domain,
|
||||
server_state.server_environment,
|
||||
record.maybe_file_cover_image_public_bucket_hash.as_deref(),
|
||||
record.maybe_file_cover_image_public_bucket_prefix.as_deref(),
|
||||
record.maybe_file_cover_image_public_bucket_extension.as_deref(),
|
||||
),
|
||||
maybe_creator_user: UserDetailsLightBuilder::from_optional_db_fields_owned(
|
||||
record.maybe_creator_user_token,
|
||||
record.maybe_creator_username,
|
||||
record.maybe_creator_display_name,
|
||||
record.maybe_creator_gravatar_hash,
|
||||
),
|
||||
token: record.token,
|
||||
media_class: record.media_class,
|
||||
media_type: record.media_type,
|
||||
creator_set_visibility: record.creator_set_visibility,
|
||||
maybe_prompt_token: record.maybe_prompt_token,
|
||||
maybe_title: record.maybe_title,
|
||||
created_at: record.created_at,
|
||||
updated_at: record.updated_at,
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let pagination = PaginationCursors {
|
||||
maybe_next,
|
||||
maybe_previous,
|
||||
cursor_is_reversed,
|
||||
};
|
||||
|
||||
Ok((results, pagination))
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
pub mod list_session_common;
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use actix_web::web::{Json, Query};
|
||||
use actix_web::{web, HttpRequest};
|
||||
|
||||
use artcraft_api_defs::media_file::list::by_type::list_session_common::ListSessionMediaFilesByTypeQueryParams;
|
||||
use artcraft_api_defs::media_file::list::by_type::list_session_mesh_media_files::ListSessionMeshMediaFilesSuccessResponse;
|
||||
use enums::by_table::media_files::media_file_class::MediaFileClass;
|
||||
|
||||
use crate::http_server::common_responses::common_web_error::CommonWebError;
|
||||
use crate::http_server::endpoints::media_files::list::by_type::common::list_session_common::list_session_media_files_of_class;
|
||||
use crate::state::server_state::ServerState;
|
||||
|
||||
/// List the session user's mesh files (`media_class = 'mesh'`), paginated.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
tag = "Media Files",
|
||||
path = "/v1/media_files/mesh/list",
|
||||
params(ListSessionMediaFilesByTypeQueryParams),
|
||||
responses(
|
||||
(status = 200, description = "List the session user's mesh files", body = ListSessionMeshMediaFilesSuccessResponse),
|
||||
(status = 401, description = "Not authorized"),
|
||||
(status = 500, description = "Server error"),
|
||||
),
|
||||
)]
|
||||
pub async fn list_session_mesh_media_files_handler(
|
||||
http_request: HttpRequest,
|
||||
query: Query<ListSessionMediaFilesByTypeQueryParams>,
|
||||
server_state: web::Data<Arc<ServerState>>,
|
||||
) -> Result<Json<ListSessionMeshMediaFilesSuccessResponse>, CommonWebError> {
|
||||
|
||||
let (results, pagination) = list_session_media_files_of_class(
|
||||
&http_request,
|
||||
&query,
|
||||
&server_state,
|
||||
MediaFileClass::Mesh,
|
||||
).await?;
|
||||
|
||||
Ok(Json(ListSessionMeshMediaFilesSuccessResponse {
|
||||
success: true,
|
||||
results,
|
||||
pagination,
|
||||
}))
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use actix_web::web::{Json, Query};
|
||||
use actix_web::{web, HttpRequest};
|
||||
|
||||
use artcraft_api_defs::media_file::list::by_type::list_session_common::ListSessionMediaFilesByTypeQueryParams;
|
||||
use artcraft_api_defs::media_file::list::by_type::list_session_splat_media_files::ListSessionSplatMediaFilesSuccessResponse;
|
||||
use enums::by_table::media_files::media_file_class::MediaFileClass;
|
||||
|
||||
use crate::http_server::common_responses::common_web_error::CommonWebError;
|
||||
use crate::http_server::endpoints::media_files::list::by_type::common::list_session_common::list_session_media_files_of_class;
|
||||
use crate::state::server_state::ServerState;
|
||||
|
||||
/// List the session user's gaussian splat files (`media_class = 'splat'`), paginated.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
tag = "Media Files",
|
||||
path = "/v1/media_files/splat/list",
|
||||
params(ListSessionMediaFilesByTypeQueryParams),
|
||||
responses(
|
||||
(status = 200, description = "List the session user's splat files", body = ListSessionSplatMediaFilesSuccessResponse),
|
||||
(status = 401, description = "Not authorized"),
|
||||
(status = 500, description = "Server error"),
|
||||
),
|
||||
)]
|
||||
pub async fn list_session_splat_media_files_handler(
|
||||
http_request: HttpRequest,
|
||||
query: Query<ListSessionMediaFilesByTypeQueryParams>,
|
||||
server_state: web::Data<Arc<ServerState>>,
|
||||
) -> Result<Json<ListSessionSplatMediaFilesSuccessResponse>, CommonWebError> {
|
||||
|
||||
let (results, pagination) = list_session_media_files_of_class(
|
||||
&http_request,
|
||||
&query,
|
||||
&server_state,
|
||||
MediaFileClass::Splat,
|
||||
).await?;
|
||||
|
||||
Ok(Json(ListSessionSplatMediaFilesSuccessResponse {
|
||||
success: true,
|
||||
results,
|
||||
pagination,
|
||||
}))
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
pub mod common;
|
||||
pub mod list_session_mesh_media_files_handler;
|
||||
pub mod list_session_splat_media_files_handler;
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod by_type;
|
||||
pub mod list_batch_generated_redux_media_files_handler;
|
||||
pub mod list_featured_media_files_handler;
|
||||
pub mod list_media_files_by_batch_token_handler;
|
||||
|
||||
+10
@@ -18,6 +18,8 @@ use crate::http_server::endpoints::media_files::list::list_media_files_by_batch_
|
||||
use crate::http_server::endpoints::media_files::list::list_media_files_for_user_handler::list_media_files_for_user_handler;
|
||||
use crate::http_server::endpoints::media_files::list::list_media_files_handler::list_media_files_handler;
|
||||
use crate::http_server::endpoints::media_files::list::list_pinned_media_files_handler::list_pinned_media_files_handler;
|
||||
use crate::http_server::endpoints::media_files::list::by_type::list_session_mesh_media_files_handler::list_session_mesh_media_files_handler;
|
||||
use crate::http_server::endpoints::media_files::list::by_type::list_session_splat_media_files_handler::list_session_splat_media_files_handler;
|
||||
use crate::http_server::endpoints::media_files::list::list_session_project_media_files_handler::list_session_project_media_files_handler;
|
||||
use crate::http_server::endpoints::media_files::search::search_featured_media_files_handler::search_featured_media_files_handler;
|
||||
use crate::http_server::endpoints::media_files::search::search_session_media_files_handler::search_session_media_files_handler;
|
||||
@@ -108,10 +110,18 @@ pub fn add_media_file_routes<T, B> (app: App<T>) -> App<T>
|
||||
.route(web::get().to(list_media_files_for_user_handler))
|
||||
.route(web::head().to(|| HttpResponse::Ok()))
|
||||
)
|
||||
.service(web::resource("/mesh/list")
|
||||
.route(web::get().to(list_session_mesh_media_files_handler))
|
||||
.route(web::head().to(|| HttpResponse::Ok()))
|
||||
)
|
||||
.service(web::resource("/project/list")
|
||||
.route(web::get().to(list_session_project_media_files_handler))
|
||||
.route(web::head().to(|| HttpResponse::Ok()))
|
||||
)
|
||||
.service(web::resource("/splat/list")
|
||||
.route(web::get().to(list_session_splat_media_files_handler))
|
||||
.route(web::head().to(|| HttpResponse::Ok()))
|
||||
)
|
||||
.service(web::resource("/search_featured")
|
||||
.route(web::get().to(search_featured_media_files_handler))
|
||||
.route(web::head().to(|| HttpResponse::Ok()))
|
||||
|
||||
+3
-2
@@ -11,6 +11,7 @@ import { Tooltip } from "@storyteller/ui-tooltip";
|
||||
import {
|
||||
GenerationGridView,
|
||||
type GalleryItem,
|
||||
is3DMediaClass,
|
||||
type RecreateSlotContext,
|
||||
} from "@storyteller/ui-generation-list";
|
||||
import { useRecreateFromPromptToken } from "../../lib/recreate";
|
||||
@@ -69,10 +70,10 @@ function CardRecreateButton({
|
||||
// recreate flow, so map to a valid class for the hook and render nothing.
|
||||
const { isRecreating, handleRecreate } = useRecreateFromPromptToken(
|
||||
promptToken,
|
||||
mediaClass === "dimensional" ? "image" : mediaClass,
|
||||
is3DMediaClass(mediaClass) ? "image" : mediaClass,
|
||||
);
|
||||
|
||||
if (mediaClass === "dimensional") return null;
|
||||
if (is3DMediaClass(mediaClass)) return null;
|
||||
|
||||
if (kind === "failed") {
|
||||
return (
|
||||
|
||||
+3
-2
@@ -11,6 +11,7 @@ import { Tooltip } from "@storyteller/ui-tooltip";
|
||||
import {
|
||||
GenerationListView,
|
||||
type GalleryItem,
|
||||
is3DMediaClass,
|
||||
type RecreateSlotContext,
|
||||
} from "@storyteller/ui-generation-list";
|
||||
import { toast } from "../toast/toast";
|
||||
@@ -85,10 +86,10 @@ function RowRecreateButton({
|
||||
// recreate flow, so map to a valid class for the hook and render nothing.
|
||||
const { isRecreating, handleRecreate } = useRecreateFromPromptToken(
|
||||
promptToken,
|
||||
mediaClass === "dimensional" ? "image" : mediaClass,
|
||||
is3DMediaClass(mediaClass) ? "image" : mediaClass,
|
||||
);
|
||||
|
||||
if (mediaClass === "dimensional") return null;
|
||||
if (is3DMediaClass(mediaClass)) return null;
|
||||
return (
|
||||
<Tooltip content="Recreate" position="top">
|
||||
<button
|
||||
|
||||
@@ -3,6 +3,7 @@ export { GenerationGalleryGrid } from "./GenerationGalleryGrid";
|
||||
export { GenerationGalleryList } from "./GenerationGalleryList";
|
||||
export { GalleryViewToggle } from "./GalleryViewToggle";
|
||||
export { useGalleryData, type GalleryItem } from "./useGalleryData";
|
||||
export { useSessionMediaByClass } from "@storyteller/ui-generation-list";
|
||||
export {
|
||||
useGenerationJobs,
|
||||
type InProgressJob,
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
import { useCallback, useState } from "react";
|
||||
import { is3DMediaClass } from "@storyteller/ui-generation-list";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import type { IconDefinition } from "@fortawesome/fontawesome-svg-core";
|
||||
import {
|
||||
@@ -62,7 +63,7 @@ export function useGalleryItemActions(
|
||||
const [isDownloading, setIsDownloading] = useState(false);
|
||||
|
||||
const isVideo = item.mediaClass === "video";
|
||||
const is3D = item.mediaClass === "dimensional";
|
||||
const is3D = is3DMediaClass(item.mediaClass);
|
||||
const isAudio = item.mediaClass === "audio";
|
||||
// Audio v1: no recreate / make-video — download + share only.
|
||||
const recreateMediaClass: RecreateMediaClass | null = isVideo
|
||||
|
||||
@@ -4,6 +4,7 @@ import { toast } from "../toast/toast";
|
||||
import { useEffect, useState, useMemo, useCallback } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { MediaFilesApi, PromptsApi, type UserInfo } from "@storyteller/api";
|
||||
import { is3DMediaClass } from "@storyteller/ui-generation-list";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import {
|
||||
faChevronLeft,
|
||||
@@ -277,7 +278,7 @@ export function Lightbox({
|
||||
: propMediaClass === "video";
|
||||
const is3D = selectedImageUrl
|
||||
? is3DModelUrl(selectedImageUrl)
|
||||
: propMediaClass === "dimensional";
|
||||
: is3DMediaClass(propMediaClass);
|
||||
const isAudio = selectedImageUrl
|
||||
? isAudioUrl(selectedImageUrl) || propMediaClass === "audio"
|
||||
: propMediaClass === "audio";
|
||||
|
||||
@@ -11,7 +11,7 @@ export const SHARE_URL_BASE = "https://getartcraft.com/media/";
|
||||
export const COPY_FEEDBACK_DURATION = 1500;
|
||||
|
||||
const VIDEO_EXTENSIONS = [".mp4", ".webm", ".mov", ".avi", ".mkv", ".m4v"];
|
||||
const MODEL_3D_EXTENSIONS = [".glb", ".gltf", ".fbx", ".spz"];
|
||||
const MODEL_3D_EXTENSIONS = [".glb", ".gltf", ".fbx", ".spz", ".obj", ".ply"];
|
||||
const AUDIO_EXTENSIONS = [".mp3", ".wav", ".ogg", ".m4a", ".flac", ".aac"];
|
||||
|
||||
export const isVideoUrl = (url: string): boolean =>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { FilterMediaClasses } from "@storyteller/api";
|
||||
import type { OmniGenMeshModelInfo } from "@storyteller/api";
|
||||
import { PopoverMenu, type PopoverItem } from "@storyteller/ui-popover";
|
||||
import { Tooltip } from "@storyteller/ui-tooltip";
|
||||
@@ -19,7 +18,7 @@ import {
|
||||
} from "../../components/prompt-box";
|
||||
import {
|
||||
GenerationGallery,
|
||||
useGalleryData,
|
||||
useSessionMediaByClass,
|
||||
useGenerationJobs,
|
||||
useAuthCheck,
|
||||
usePromptHeight,
|
||||
@@ -27,7 +26,6 @@ import {
|
||||
CreateMediaPageShell,
|
||||
} from "../../components/generation-gallery";
|
||||
import { Lightbox } from "../../components/lightbox/lightbox";
|
||||
import { is3DModelUrl } from "../../components/lightbox/shared";
|
||||
import { useCreateObjectStore } from "./create-object-store";
|
||||
import { enqueueMeshGeneration, startPolling } from "./generate-object-api";
|
||||
import {
|
||||
@@ -57,7 +55,6 @@ import { useInsufficientCredits } from "../../components/insufficient-credits-mo
|
||||
// ── Constants ────────────────────────────────────────────────────────────
|
||||
|
||||
const DEFAULT_MODEL_ID = "hunyuan_3d_3";
|
||||
const DIMENSIONAL_FILTER = [FilterMediaClasses.DIMENSIONAL];
|
||||
|
||||
let _modelLookup = new Map<string, OmniGenMeshModelInfo>();
|
||||
|
||||
@@ -167,27 +164,16 @@ export default function CreateObject() {
|
||||
const dismissBatch = useCreateObjectStore((s) => s.dismissBatch);
|
||||
const pollingCleanupsRef = useRef<Map<string, () => void>>(new Map());
|
||||
|
||||
// Jobs + gallery (only this page's own — mesh objects, not splats)
|
||||
const meshModelIds = useMemo(
|
||||
() => apiModels.map((m) => m.model),
|
||||
[apiModels],
|
||||
);
|
||||
// Jobs + gallery (only this page's own — mesh objects, not splats). The
|
||||
// mesh list endpoint is scoped server-side (`media_class = 'mesh'`), so no
|
||||
// client-side model or screenshot filtering is needed.
|
||||
const jobs = useGenerationJobs({ mediaType: "object", enabled: !!user });
|
||||
const gallery = useGalleryData({
|
||||
username: user?.username ?? null,
|
||||
filterMediaClasses: DIMENSIONAL_FILTER,
|
||||
filterModelIds: meshModelIds,
|
||||
excludeUploads: true,
|
||||
const gallery = useSessionMediaByClass({
|
||||
mediaClass: "mesh",
|
||||
enabled: !!user,
|
||||
});
|
||||
|
||||
// The library's dimensional feed can include a 3D model's cover screenshot as
|
||||
// its own entry (the backend surfaces it as a "dimensional" media file even
|
||||
// though its asset is a .png). Keep only real 3D-model files so that stray
|
||||
// screenshot doesn't show up as a separate card.
|
||||
const modelGalleryItems = useMemo(
|
||||
() => gallery.items.filter((i) => !!i.fullImage && is3DModelUrl(i.fullImage)),
|
||||
[gallery.items],
|
||||
);
|
||||
const modelGalleryItems = gallery.items;
|
||||
|
||||
// A freshly-completed 3D job has no cover screenshot in its payload (the
|
||||
// backend renders it a moment later), so its card would be blank. Once the
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { FilterMediaClasses } from "@storyteller/api";
|
||||
import type { OmniGenSplatModelInfo } from "@storyteller/api";
|
||||
import { PopoverMenu, type PopoverItem } from "@storyteller/ui-popover";
|
||||
import { Tooltip } from "@storyteller/ui-tooltip";
|
||||
@@ -19,7 +18,7 @@ import {
|
||||
} from "../../components/prompt-box";
|
||||
import {
|
||||
GenerationGallery,
|
||||
useGalleryData,
|
||||
useSessionMediaByClass,
|
||||
useGenerationJobs,
|
||||
useAuthCheck,
|
||||
usePromptHeight,
|
||||
@@ -27,7 +26,6 @@ import {
|
||||
CreateMediaPageShell,
|
||||
} from "../../components/generation-gallery";
|
||||
import { Lightbox } from "../../components/lightbox/lightbox";
|
||||
import { is3DModelUrl } from "../../components/lightbox/shared";
|
||||
import { useCreateWorldStore } from "./create-world-store";
|
||||
import { enqueueSplatGeneration, startPolling } from "./generate-world-api";
|
||||
import { ReferenceVideoSlot } from "./components/ReferenceVideoSlot";
|
||||
@@ -48,7 +46,6 @@ import { useInsufficientCredits } from "../../components/insufficient-credits-mo
|
||||
// ── Constants ────────────────────────────────────────────────────────────
|
||||
|
||||
const DEFAULT_MODEL_ID = "marble_1p1";
|
||||
const DIMENSIONAL_FILTER = [FilterMediaClasses.DIMENSIONAL];
|
||||
|
||||
let _modelLookup = new Map<string, OmniGenSplatModelInfo>();
|
||||
|
||||
@@ -147,31 +144,16 @@ export default function CreateWorld() {
|
||||
const dismissBatch = useCreateWorldStore((s) => s.dismissBatch);
|
||||
const pollingCleanupsRef = useRef<Map<string, () => void>>(new Map());
|
||||
|
||||
// Jobs + gallery (only splats, not mesh objects)
|
||||
const splatModelIds = useMemo(
|
||||
() => apiModels.map((m) => m.model),
|
||||
[apiModels],
|
||||
);
|
||||
// Jobs + gallery (only splats, not mesh objects). The splat list endpoint
|
||||
// is scoped server-side (`media_class = 'splat'`), so no client-side model
|
||||
// or screenshot filtering is needed.
|
||||
const jobs = useGenerationJobs({ mediaType: "splat", enabled: !!user });
|
||||
const gallery = useGalleryData({
|
||||
username: user?.username ?? null,
|
||||
filterMediaClasses: DIMENSIONAL_FILTER,
|
||||
filterModelIds: splatModelIds,
|
||||
excludeUploads: true,
|
||||
const gallery = useSessionMediaByClass({
|
||||
mediaClass: "splat",
|
||||
enabled: !!user,
|
||||
});
|
||||
|
||||
// A freshly-completed splat job has no cover screenshot in its payload (the
|
||||
// backend renders it a moment later), so its card would be blank. Once the
|
||||
// library re-fetch returns the same world with its cover, adopt that
|
||||
// thumbnail so the card stops showing the placeholder.
|
||||
// The library's dimensional feed can include a world's cover screenshot as
|
||||
// its own entry (surfaced as a "dimensional" media file even though its asset
|
||||
// is a .png). Keep only real 3D/splat files so that stray screenshot doesn't
|
||||
// show up as a separate card.
|
||||
const modelGalleryItems = useMemo(
|
||||
() => gallery.items.filter((i) => !!i.fullImage && is3DModelUrl(i.fullImage)),
|
||||
[gallery.items],
|
||||
);
|
||||
const modelGalleryItems = gallery.items;
|
||||
|
||||
const galleryById = useMemo(
|
||||
() => new Map(modelGalleryItems.map((i) => [i.id, i])),
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
mergeCollageUrls,
|
||||
} from "@storyteller/ui-gallery-modal";
|
||||
import { getMediaThumbnail, THUMBNAIL_SIZES } from "@storyteller/common";
|
||||
import { is3DMediaClass } from "@storyteller/ui-generation-list";
|
||||
import { toast } from "../../components/toast/toast";
|
||||
|
||||
// ── Bulk selection store ────────────────────────────────────────────────────
|
||||
@@ -141,7 +142,10 @@ const getLabel = (item: any): string => {
|
||||
case "video":
|
||||
return "Video Generation";
|
||||
case "dimensional":
|
||||
case "mesh":
|
||||
return "3D Mesh";
|
||||
case "splat":
|
||||
return "3D World";
|
||||
default:
|
||||
return "Generation";
|
||||
}
|
||||
@@ -149,12 +153,11 @@ const getLabel = (item: any): string => {
|
||||
|
||||
/** Map a raw user-media list row (origin_category shape) → GalleryItem (root library). */
|
||||
export function mapRawToGalleryItem(item: any): GalleryItem {
|
||||
const thumbnail =
|
||||
item.media_class === "dimensional"
|
||||
? (item.cover_image?.maybe_cover_image_public_bucket_url ?? null)
|
||||
: getMediaThumbnail(item.media_links, item.media_class, {
|
||||
size: THUMBNAIL_SIZES.LARGE,
|
||||
});
|
||||
const thumbnail = is3DMediaClass(item.media_class)
|
||||
? (item.cover_image?.maybe_cover_image_public_bucket_url ?? null)
|
||||
: getMediaThumbnail(item.media_links, item.media_class, {
|
||||
size: THUMBNAIL_SIZES.LARGE,
|
||||
});
|
||||
return {
|
||||
id: item.token,
|
||||
label: getLabel(item),
|
||||
@@ -172,12 +175,11 @@ export function mapRawToGalleryItem(item: any): GalleryItem {
|
||||
function mapFolderListItemToGalleryItem(
|
||||
item: FolderMediaFileListItem,
|
||||
): GalleryItem {
|
||||
const thumbnail =
|
||||
item.media_class === "dimensional"
|
||||
? (item.cover_image?.maybe_cover_image_public_bucket_url ?? null)
|
||||
: getMediaThumbnail(item.media_links, item.media_class, {
|
||||
size: THUMBNAIL_SIZES.LARGE,
|
||||
});
|
||||
const thumbnail = is3DMediaClass(item.media_class)
|
||||
? (item.cover_image?.maybe_cover_image_public_bucket_url ?? null)
|
||||
: getMediaThumbnail(item.media_links, item.media_class, {
|
||||
size: THUMBNAIL_SIZES.LARGE,
|
||||
});
|
||||
return {
|
||||
id: item.token,
|
||||
label: getLabel(item),
|
||||
|
||||
@@ -8,6 +8,7 @@ import { LoadingSpinner } from "@storyteller/ui-loading-spinner";
|
||||
import {
|
||||
UsersApi,
|
||||
GalleryModalApi,
|
||||
MediaFilesApi,
|
||||
FilterMediaClasses,
|
||||
FilterMediaType,
|
||||
} from "@storyteller/api";
|
||||
@@ -24,6 +25,7 @@ import {
|
||||
type GalleryItem,
|
||||
} from "@storyteller/ui-gallery-modal";
|
||||
import { PLACEHOLDER_IMAGES, is3DModelUrl } from "@storyteller/common";
|
||||
import { is3DMediaClass } from "@storyteller/ui-generation-list";
|
||||
import {
|
||||
showActionReminder,
|
||||
isActionReminderOpen,
|
||||
@@ -41,6 +43,7 @@ import {
|
||||
faFolderPlus,
|
||||
faFolder,
|
||||
faFolderOpen,
|
||||
faGlobe,
|
||||
faPlus,
|
||||
faXmark,
|
||||
faStar,
|
||||
@@ -62,6 +65,7 @@ const FILTERS = [
|
||||
{ id: "video", label: "Videos", icon: faVideo, route: "/library/videos" },
|
||||
{ id: "audio", label: "Audio", icon: faMusic, route: "/library/audio" },
|
||||
{ id: "meshes", label: "Meshes", icon: faCube, route: "/library/meshes" },
|
||||
{ id: "splats", label: "Splats", icon: faGlobe, route: "/library/splats" },
|
||||
];
|
||||
|
||||
const ROUTE_TO_FILTER: Record<string, string> = {
|
||||
@@ -69,8 +73,11 @@ const ROUTE_TO_FILTER: Record<string, string> = {
|
||||
videos: "video",
|
||||
audio: "audio",
|
||||
meshes: "meshes",
|
||||
splats: "splats",
|
||||
};
|
||||
|
||||
// Media classes for the user-list endpoint. The Meshes and Splats tabs don't
|
||||
// use it — they call the session mesh/splat list endpoints instead.
|
||||
const getFilterMediaClass = (
|
||||
filter: string,
|
||||
): FilterMediaClasses[] | undefined => {
|
||||
@@ -81,14 +88,14 @@ const getFilterMediaClass = (
|
||||
return [FilterMediaClasses.VIDEO];
|
||||
case "audio":
|
||||
return [FilterMediaClasses.AUDIO];
|
||||
case "meshes":
|
||||
return [FilterMediaClasses.DIMENSIONAL];
|
||||
default:
|
||||
return [
|
||||
FilterMediaClasses.IMAGE,
|
||||
FilterMediaClasses.VIDEO,
|
||||
FilterMediaClasses.AUDIO,
|
||||
FilterMediaClasses.DIMENSIONAL,
|
||||
FilterMediaClasses.MESH,
|
||||
FilterMediaClasses.SPLAT,
|
||||
];
|
||||
}
|
||||
};
|
||||
@@ -168,6 +175,10 @@ export default function Library() {
|
||||
useEffect(() => () => useLibrarySelectionStore.getState().clear(), []);
|
||||
|
||||
const api = useMemo(() => new GalleryModalApi(), []);
|
||||
const mediaFilesApi = useMemo(() => new MediaFilesApi(), []);
|
||||
// Keyset cursor for the Meshes / Splats tabs (their endpoints paginate by
|
||||
// cursor, not page index).
|
||||
const meshSplatCursorRef = useRef<string | undefined>(undefined);
|
||||
|
||||
// ── Folder store ──────────────────────────────────────────────────────────
|
||||
const folders = useLibraryFoldersStore((s) => s.folders);
|
||||
@@ -275,31 +286,57 @@ export default function Library() {
|
||||
isLoadingRef.current = true;
|
||||
setLoading(true);
|
||||
try {
|
||||
const response = await api.listUserMediaFiles({
|
||||
username,
|
||||
filter_media_classes: getFilterMediaClass(activeFilter),
|
||||
include_user_uploads: true,
|
||||
page_index: reset ? 0 : pageIndex,
|
||||
page_size: PAGE_SIZE,
|
||||
});
|
||||
if (response.success && response.data) {
|
||||
const newItems = response.data
|
||||
.filter(
|
||||
(item: any) =>
|
||||
item.media_type !== FilterMediaType.SCENE_JSON &&
|
||||
// Drop 3D-model cover screenshots the backend surfaces as
|
||||
// "dimensional" items whose asset is actually a .png.
|
||||
!(
|
||||
item.media_class === "dimensional" &&
|
||||
!is3DModelUrl(item.media_links?.cdn_url)
|
||||
),
|
||||
)
|
||||
.map(mapRawToGalleryItem);
|
||||
setAllItems((prev) => (reset ? newItems : [...prev, ...newItems]));
|
||||
const current = response.pagination?.current ?? 0;
|
||||
const total = response.pagination?.total_page_count ?? 1;
|
||||
setPageIndex(current + 1);
|
||||
setHasMore(current + 1 < total);
|
||||
if (activeFilter === "meshes" || activeFilter === "splats") {
|
||||
// The Meshes / Splats tabs use the session by-class list endpoints
|
||||
// (server-scoped, cursor-paginated) instead of the user list.
|
||||
const cursor = reset ? undefined : meshSplatCursorRef.current;
|
||||
const response =
|
||||
activeFilter === "splats"
|
||||
? await mediaFilesApi.ListSessionSplatMediaFiles({
|
||||
cursor,
|
||||
page_size: PAGE_SIZE,
|
||||
})
|
||||
: await mediaFilesApi.ListSessionMeshMediaFiles({
|
||||
cursor,
|
||||
page_size: PAGE_SIZE,
|
||||
});
|
||||
if (response.success && response.data) {
|
||||
const newItems = response.data.map(mapRawToGalleryItem);
|
||||
setAllItems((prev) => (reset ? newItems : [...prev, ...newItems]));
|
||||
meshSplatCursorRef.current =
|
||||
response.pagination?.maybe_next ?? undefined;
|
||||
setHasMore(
|
||||
newItems.length >= PAGE_SIZE &&
|
||||
!!response.pagination?.maybe_next,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
const response = await api.listUserMediaFiles({
|
||||
username,
|
||||
filter_media_classes: getFilterMediaClass(activeFilter),
|
||||
include_user_uploads: true,
|
||||
page_index: reset ? 0 : pageIndex,
|
||||
page_size: PAGE_SIZE,
|
||||
});
|
||||
if (response.success && response.data) {
|
||||
const newItems = response.data
|
||||
.filter(
|
||||
(item: any) =>
|
||||
item.media_type !== FilterMediaType.SCENE_JSON &&
|
||||
// Drop 3D-model cover screenshots the backend surfaces as
|
||||
// "dimensional" items whose asset is actually a .png.
|
||||
!(
|
||||
item.media_class === "dimensional" &&
|
||||
!is3DModelUrl(item.media_links?.cdn_url)
|
||||
),
|
||||
)
|
||||
.map(mapRawToGalleryItem);
|
||||
setAllItems((prev) => (reset ? newItems : [...prev, ...newItems]));
|
||||
const current = response.pagination?.current ?? 0;
|
||||
const total = response.pagination?.total_page_count ?? 1;
|
||||
setPageIndex(current + 1);
|
||||
setHasMore(current + 1 < total);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
@@ -308,7 +345,7 @@ export default function Library() {
|
||||
setInitialLoading(false);
|
||||
isLoadingRef.current = false;
|
||||
},
|
||||
[username, activeFilter, pageIndex, api],
|
||||
[username, activeFilter, pageIndex, api, mediaFilesApi],
|
||||
);
|
||||
|
||||
// Initial load + filter change
|
||||
@@ -316,6 +353,7 @@ export default function Library() {
|
||||
if (!username) return;
|
||||
setAllItems([]);
|
||||
setPageIndex(0);
|
||||
meshSplatCursorRef.current = undefined;
|
||||
setHasMore(true);
|
||||
setInitialLoading(true);
|
||||
isLoadingRef.current = false;
|
||||
@@ -706,6 +744,7 @@ export default function Library() {
|
||||
const refreshRoot = useCallback(() => {
|
||||
setAllItems([]);
|
||||
setPageIndex(0);
|
||||
meshSplatCursorRef.current = undefined;
|
||||
setHasMore(true);
|
||||
setInitialLoading(true);
|
||||
isLoadingRef.current = false;
|
||||
@@ -1558,7 +1597,7 @@ function BulkThumb({ item }: { item: GalleryItem }) {
|
||||
const placeholderIcon =
|
||||
item.mediaClass === "video"
|
||||
? faVideo
|
||||
: item.mediaClass === "dimensional"
|
||||
: is3DMediaClass(item.mediaClass)
|
||||
? faCube
|
||||
: item.mediaClass === "audio"
|
||||
? faMusic
|
||||
|
||||
@@ -38,6 +38,15 @@ interface SearchFeaturedMediaQuery {
|
||||
filter_engine_categories?: FilterEngineCategories[];
|
||||
}
|
||||
|
||||
// Pagination-only query for the by-class session lists (mesh / splat); the
|
||||
// media class is fixed by the endpoint.
|
||||
interface ListSessionMediaByClassQuery {
|
||||
sort_ascending?: boolean;
|
||||
page_size?: number;
|
||||
cursor?: string;
|
||||
cursor_is_reversed?: boolean;
|
||||
}
|
||||
|
||||
export class MediaFilesApi extends ApiManager {
|
||||
public async DeleteMediaFileByToken({
|
||||
mediaFileToken,
|
||||
@@ -216,6 +225,52 @@ export class MediaFilesApi extends ApiManager {
|
||||
});
|
||||
}
|
||||
|
||||
/** List the session user's mesh files (`media_class = 'mesh'`), paginated. */
|
||||
public async ListSessionMeshMediaFiles(
|
||||
query: ListSessionMediaByClassQuery = {}
|
||||
): Promise<ApiResponse<MediaFile[], PaginationInfinite>> {
|
||||
const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/mesh/list`;
|
||||
return await this.get<{
|
||||
success: boolean;
|
||||
results: MediaFile[];
|
||||
pagination?: PaginationInfinite;
|
||||
}>({ endpoint, query })
|
||||
.then((response) => ({
|
||||
success: response.success,
|
||||
data: response.results ?? [],
|
||||
pagination: response.pagination,
|
||||
}))
|
||||
.catch((err) => {
|
||||
return {
|
||||
success: false,
|
||||
errorMessage: err.message,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/** List the session user's gaussian splat files (`media_class = 'splat'`), paginated. */
|
||||
public async ListSessionSplatMediaFiles(
|
||||
query: ListSessionMediaByClassQuery = {}
|
||||
): Promise<ApiResponse<MediaFile[], PaginationInfinite>> {
|
||||
const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/splat/list`;
|
||||
return await this.get<{
|
||||
success: boolean;
|
||||
results: MediaFile[];
|
||||
pagination?: PaginationInfinite;
|
||||
}>({ endpoint, query })
|
||||
.then((response) => ({
|
||||
success: response.success,
|
||||
data: response.results ?? [],
|
||||
pagination: response.pagination,
|
||||
}))
|
||||
.catch((err) => {
|
||||
return {
|
||||
success: false,
|
||||
errorMessage: err.message,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async ListUserMediaFiles(
|
||||
query: ListUserMediaQuery
|
||||
): Promise<ApiResponse<MediaFile[], Pagination>> {
|
||||
|
||||
@@ -2,7 +2,10 @@ export enum FilterMediaClasses {
|
||||
AUDIO = "audio",
|
||||
IMAGE = "image",
|
||||
VIDEO = "video",
|
||||
/** Deprecated coarse 3D class; legacy records only. New 3D media is MESH or SPLAT. */
|
||||
DIMENSIONAL = "dimensional",
|
||||
MESH = "mesh",
|
||||
SPLAT = "splat",
|
||||
}
|
||||
|
||||
export enum FilterMediaType {
|
||||
|
||||
@@ -6,6 +6,7 @@ export * from "./lib/media-prompt-token-cache";
|
||||
export * from "./lib/gallery-view-store";
|
||||
export * from "./lib/GalleryViewToggle";
|
||||
export * from "./lib/useGalleryData";
|
||||
export * from "./lib/useSessionMediaByClass";
|
||||
export * from "./lib/useGalleryEntries";
|
||||
export * from "./lib/useGenerationJobs";
|
||||
export * from "./lib/GalleryThumbnail";
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from "@storyteller/model-list";
|
||||
import { WaveformAudioPlayer } from "@storyteller/ui-audio-player";
|
||||
import { GalleryThumbnail } from "./GalleryThumbnail";
|
||||
import type { GalleryItem } from "./types";
|
||||
import { is3DMediaClass, type GalleryItem } from "./types";
|
||||
|
||||
// ── Persistent aspect ratio cache ─────────────────────────────────────────
|
||||
|
||||
@@ -87,7 +87,7 @@ export const GalleryCard = memo(function GalleryCard({
|
||||
const [ratio, setRatio] = useState<number | undefined>(cached);
|
||||
|
||||
const isVideo = item.mediaClass === "video";
|
||||
const is3D = item.mediaClass === "dimensional";
|
||||
const is3D = is3DMediaClass(item.mediaClass);
|
||||
const isAudio = item.mediaClass === "audio";
|
||||
const mediaIcon = isVideo
|
||||
? faVideo
|
||||
|
||||
@@ -15,7 +15,7 @@ import { WaveformAudioPlayer } from "@storyteller/ui-audio-player";
|
||||
import { GalleryThumbnail } from "./GalleryThumbnail";
|
||||
import { CopyPromptButton } from "./CopyPromptButton";
|
||||
import { formatTimeAgo } from "./format-time-ago";
|
||||
import type { GalleryItem } from "./types";
|
||||
import { is3DMediaClass, type GalleryItem } from "./types";
|
||||
|
||||
export interface GalleryRowProps {
|
||||
item: GalleryItem;
|
||||
@@ -41,7 +41,7 @@ export const GalleryRow = memo(function GalleryRow({
|
||||
onCopyPromptResult,
|
||||
}: GalleryRowProps) {
|
||||
const isVideo = item.mediaClass === "video";
|
||||
const is3D = item.mediaClass === "dimensional";
|
||||
const is3D = is3DMediaClass(item.mediaClass);
|
||||
const isAudio = item.mediaClass === "audio";
|
||||
const mediaIcon = isVideo
|
||||
? faVideo
|
||||
|
||||
@@ -7,6 +7,17 @@ export type GenerationMediaClass =
|
||||
| "audio"
|
||||
| "dimensional";
|
||||
|
||||
// The backend used to file all 3D media under the (now deprecated) coarse
|
||||
// "dimensional" class; new records are written as "mesh" (3D models) or
|
||||
// "splat" (gaussian splats). Treat all three as 3D.
|
||||
export function is3DMediaClass(mediaClass: string | undefined | null): boolean {
|
||||
return (
|
||||
mediaClass === "dimensional" ||
|
||||
mediaClass === "mesh" ||
|
||||
mediaClass === "splat"
|
||||
);
|
||||
}
|
||||
|
||||
/** Plural noun for batch captions, e.g. "Generating 4 images". */
|
||||
export function batchNoun(mediaClass: GenerationMediaClass): string {
|
||||
switch (mediaClass) {
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { MediaFilesApi } from "@storyteller/api";
|
||||
import type { GalleryItem } from "./types";
|
||||
|
||||
const PAGE_SIZE = 40;
|
||||
|
||||
// Pull the cover image / screenshot URL off a 3D library item. The item's own
|
||||
// cdn_url is the .glb/.obj/.ply asset, so 3D cards render the separate cover
|
||||
// image the backend attaches instead. Mirrors the gallery-modal logic.
|
||||
function getCoverThumbnail(item: any): string | null {
|
||||
const cover = item?.cover_image;
|
||||
if (!cover) return null;
|
||||
return (
|
||||
cover.maybe_links?.maybe_thumbnail_template?.replace("{WIDTH}", "512") ??
|
||||
cover.maybe_links?.cdn_url ??
|
||||
cover.maybe_cover_image_public_bucket_url ??
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Session-scoped, cursor-paginated feed of the user's 3D media of one class:
|
||||
* "mesh" (`/v1/media_files/mesh/list`) or "splat" (`/v1/media_files/splat/list`).
|
||||
*
|
||||
* Successor to `useGalleryData` + `filterMediaClasses: ["dimensional"]` for
|
||||
* the 3D create pages: the class scoping happens server-side (the deprecated
|
||||
* "dimensional" class is no longer written), cover screenshots can't leak in
|
||||
* as their own entries, and mesh vs splat feeds can't see each other.
|
||||
* Returns the same surface as `useGalleryData`.
|
||||
*/
|
||||
export function useSessionMediaByClass(options: {
|
||||
mediaClass: "mesh" | "splat";
|
||||
enabled: boolean;
|
||||
}) {
|
||||
const { mediaClass, enabled } = options;
|
||||
|
||||
const [items, setItems] = useState<GalleryItem[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isInitialLoading, setIsInitialLoading] = useState(true);
|
||||
const [hasMore, setHasMore] = useState(true);
|
||||
const cursorRef = useRef<string | undefined>(undefined);
|
||||
const isLoadingRef = useRef(false);
|
||||
|
||||
const api = useMemo(() => new MediaFilesApi(), []);
|
||||
|
||||
const mapApiItem = useCallback(
|
||||
(item: any): GalleryItem => ({
|
||||
id: item.token,
|
||||
label:
|
||||
item.maybe_title ?? (mediaClass === "splat" ? "3D World" : "3D Mesh"),
|
||||
thumbnail: getCoverThumbnail(item),
|
||||
fullImage: item.media_links?.cdn_url || null,
|
||||
createdAt: item.created_at,
|
||||
mediaClass: item.media_class || mediaClass,
|
||||
promptToken: item.maybe_prompt_token || undefined,
|
||||
}),
|
||||
[mediaClass],
|
||||
);
|
||||
|
||||
const loadItems = useCallback(
|
||||
async (reset = false) => {
|
||||
if (!enabled) return;
|
||||
if (isLoadingRef.current) return;
|
||||
isLoadingRef.current = true;
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const cursor = reset ? undefined : cursorRef.current;
|
||||
const response =
|
||||
mediaClass === "splat"
|
||||
? await api.ListSessionSplatMediaFiles({
|
||||
cursor,
|
||||
page_size: PAGE_SIZE,
|
||||
})
|
||||
: await api.ListSessionMeshMediaFiles({
|
||||
cursor,
|
||||
page_size: PAGE_SIZE,
|
||||
});
|
||||
|
||||
if (response.success && response.data) {
|
||||
const newItems = response.data.map(mapApiItem);
|
||||
|
||||
if (reset) {
|
||||
setItems(newItems);
|
||||
} else {
|
||||
setItems((prev) => [...prev, ...newItems]);
|
||||
}
|
||||
|
||||
// Keyset pagination: a full page implies there may be more; the
|
||||
// next cursor continues where this page ended.
|
||||
cursorRef.current = response.pagination?.maybe_next ?? undefined;
|
||||
setHasMore(
|
||||
newItems.length >= PAGE_SIZE && !!response.pagination?.maybe_next,
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
setIsLoading(false);
|
||||
setIsInitialLoading(false);
|
||||
isLoadingRef.current = false;
|
||||
},
|
||||
[enabled, mediaClass, api, mapApiItem],
|
||||
);
|
||||
|
||||
// Initial load + class / login change. When logged out, clear the loading
|
||||
// flag so the shell renders the empty state instead of a spinner.
|
||||
useEffect(() => {
|
||||
setItems([]);
|
||||
cursorRef.current = undefined;
|
||||
isLoadingRef.current = false;
|
||||
if (!enabled) {
|
||||
setHasMore(false);
|
||||
setIsInitialLoading(false);
|
||||
return;
|
||||
}
|
||||
setHasMore(true);
|
||||
setIsInitialLoading(true);
|
||||
loadItems(true);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [enabled, mediaClass]);
|
||||
|
||||
const loadMore = useCallback(() => {
|
||||
if (hasMore && !isLoadingRef.current) {
|
||||
loadItems();
|
||||
}
|
||||
}, [hasMore, loadItems]);
|
||||
|
||||
const refresh = useCallback(() => {
|
||||
setItems([]);
|
||||
cursorRef.current = undefined;
|
||||
setHasMore(true);
|
||||
isLoadingRef.current = false;
|
||||
loadItems(true);
|
||||
}, [loadItems]);
|
||||
|
||||
const removeItem = useCallback((id: string) => {
|
||||
setItems((prev) => prev.filter((item) => item.id !== id));
|
||||
}, []);
|
||||
|
||||
return {
|
||||
items,
|
||||
isLoading,
|
||||
isInitialLoading,
|
||||
hasMore,
|
||||
loadMore,
|
||||
refresh,
|
||||
removeItem,
|
||||
};
|
||||
}
|
||||
Generated
+88
-168
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user