mirror of
https://github.com/storytold/artcraft.git
synced 2026-10-20 17:02:53 -04:00
remove enums crates (#1195)
I tried. I'll have to make a better attempt in the future to divorce DB schema definitions from API definitions (and worse - API clients).
This commit is contained in:
Generated
-56
@@ -3793,49 +3793,6 @@ dependencies = [
|
||||
"workspace-build-acceleration",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enums_api"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"enums_shared",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"toml 1.0.7+spec-1.1.0",
|
||||
"utoipa",
|
||||
"workspace-build-acceleration",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enums_convert"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"enums_api",
|
||||
"enums_db",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"workspace-build-acceleration",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enums_db"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"enums_shared",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"sqlx",
|
||||
"sqlx-core",
|
||||
"sqlx-mysql",
|
||||
"strum",
|
||||
"toml 1.0.7+spec-1.1.0",
|
||||
"workspace-build-acceleration",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enums_public"
|
||||
version = "0.0.1"
|
||||
@@ -3850,19 +3807,6 @@ dependencies = [
|
||||
"workspace-build-acceleration",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enums_shared"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"log",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"toml 1.0.7+spec-1.1.0",
|
||||
"workspace-build-acceleration",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env"
|
||||
version = "1.0.1"
|
||||
|
||||
@@ -111,11 +111,7 @@ members = [
|
||||
# Schema (public): common strongly-typed tokens, ids, payloads, etc.
|
||||
"crates/schema/public/composite_identifiers",
|
||||
"crates/schema/public/enums",
|
||||
"crates/schema/public/enums_api",
|
||||
"crates/schema/public/enums_convert",
|
||||
"crates/schema/public/enums_db",
|
||||
"crates/schema/public/enums_public",
|
||||
"crates/schema/public/enums_shared",
|
||||
"crates/schema/public/reusable_types", # TODO(bt, 2022-12-21): Deprecate
|
||||
"crates/schema/public/tokens",
|
||||
|
||||
@@ -237,10 +233,6 @@ crockford = { path = "crates/lib/data/crockford" }
|
||||
easyenv = { path = "crates/lib/easyenv" }
|
||||
enums = { path = "crates/schema/public/enums" }
|
||||
enums_public = { path = "crates/schema/public/enums_public" }
|
||||
enums_db = { path = "crates/schema/public/enums_db" }
|
||||
enums_api = { path = "crates/schema/public/enums_api" }
|
||||
enums_shared = { path = "crates/schema/public/enums_shared" }
|
||||
enums_convert = { path = "crates/schema/public/enums_convert" }
|
||||
errors = { path = "crates/lib/errors" }
|
||||
fal_client = { path = "crates/api_clients/fal_client" }
|
||||
ffmpeg_utils = { path = "crates/lib/ffmpeg_utils" }
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
[package]
|
||||
name = "enums_api"
|
||||
edition = "2021"
|
||||
version = "0.0.1"
|
||||
authors = [
|
||||
"Brandon Thomas <bt@brand.io>",
|
||||
"Brandon Thomas <echelon@gmail.com>",
|
||||
]
|
||||
publish = false
|
||||
|
||||
[package.metadata.cargo-udeps.ignore]
|
||||
normal = ["workspace-build-acceleration"]
|
||||
|
||||
[lib]
|
||||
name = "enums_api"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
# Workspace hack (faster compile times)
|
||||
workspace-build-acceleration.workspace = true
|
||||
|
||||
# Internal
|
||||
enums_shared.workspace = true
|
||||
|
||||
# External
|
||||
log.workspace = true
|
||||
serde.workspace = true
|
||||
serde_derive.workspace = true
|
||||
strum.workspace = true
|
||||
utoipa.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json.workspace = true
|
||||
toml.workspace = true
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// A forward-compatible version of `FrontendFailureCategory` for API clients.
|
||||
///
|
||||
/// Contains all known variants plus an `Unknown(String)` catch-all so that
|
||||
/// newer server-side values never cause deserialization failures on the client.
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize, ToSchema, EnumIter)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum FrontendFailureCategoryForApiClients {
|
||||
FaceNotDetected,
|
||||
KeepAliveElapsed,
|
||||
NotYetImplemented,
|
||||
RetryableWorkerError,
|
||||
ModelRulesViolation,
|
||||
RuleBansUserImage,
|
||||
RuleBansUserImageWithFaces,
|
||||
RuleBansUserTextPrompt,
|
||||
RuleBansUserContent,
|
||||
RuleBansGeneratedVideo,
|
||||
RuleBansGeneratedAudio,
|
||||
RuleBansGeneratedContent,
|
||||
GenerationFailed,
|
||||
|
||||
/// Catch-all for values the client doesn't yet know about.
|
||||
/// The contained string is the raw serialized value from the server.
|
||||
#[serde(untagged)]
|
||||
Unknown(String),
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::FrontendFailureCategoryForApiClients;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(FrontendFailureCategoryForApiClients::FaceNotDetected, "face_not_detected");
|
||||
assert_serialization(FrontendFailureCategoryForApiClients::KeepAliveElapsed, "keep_alive_elapsed");
|
||||
assert_serialization(FrontendFailureCategoryForApiClients::NotYetImplemented, "not_yet_implemented");
|
||||
assert_serialization(FrontendFailureCategoryForApiClients::RetryableWorkerError, "retryable_worker_error");
|
||||
assert_serialization(FrontendFailureCategoryForApiClients::ModelRulesViolation, "model_rules_violation");
|
||||
assert_serialization(FrontendFailureCategoryForApiClients::RuleBansUserImage, "rule_bans_user_image");
|
||||
assert_serialization(FrontendFailureCategoryForApiClients::RuleBansUserImageWithFaces, "rule_bans_user_image_with_faces");
|
||||
assert_serialization(FrontendFailureCategoryForApiClients::RuleBansUserTextPrompt, "rule_bans_user_text_prompt");
|
||||
assert_serialization(FrontendFailureCategoryForApiClients::RuleBansUserContent, "rule_bans_user_content");
|
||||
assert_serialization(FrontendFailureCategoryForApiClients::RuleBansGeneratedVideo, "rule_bans_generated_video");
|
||||
assert_serialization(FrontendFailureCategoryForApiClients::RuleBansGeneratedAudio, "rule_bans_generated_audio");
|
||||
assert_serialization(FrontendFailureCategoryForApiClients::RuleBansGeneratedContent, "rule_bans_generated_content");
|
||||
assert_serialization(FrontendFailureCategoryForApiClients::GenerationFailed, "generation_failed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("face_not_detected", FrontendFailureCategoryForApiClients::FaceNotDetected);
|
||||
assert_deserialization("keep_alive_elapsed", FrontendFailureCategoryForApiClients::KeepAliveElapsed);
|
||||
assert_deserialization("not_yet_implemented", FrontendFailureCategoryForApiClients::NotYetImplemented);
|
||||
assert_deserialization("retryable_worker_error", FrontendFailureCategoryForApiClients::RetryableWorkerError);
|
||||
assert_deserialization("model_rules_violation", FrontendFailureCategoryForApiClients::ModelRulesViolation);
|
||||
assert_deserialization("rule_bans_user_image", FrontendFailureCategoryForApiClients::RuleBansUserImage);
|
||||
assert_deserialization("rule_bans_user_image_with_faces", FrontendFailureCategoryForApiClients::RuleBansUserImageWithFaces);
|
||||
assert_deserialization("rule_bans_user_text_prompt", FrontendFailureCategoryForApiClients::RuleBansUserTextPrompt);
|
||||
assert_deserialization("rule_bans_user_content", FrontendFailureCategoryForApiClients::RuleBansUserContent);
|
||||
assert_deserialization("rule_bans_generated_video", FrontendFailureCategoryForApiClients::RuleBansGeneratedVideo);
|
||||
assert_deserialization("rule_bans_generated_audio", FrontendFailureCategoryForApiClients::RuleBansGeneratedAudio);
|
||||
assert_deserialization("rule_bans_generated_content", FrontendFailureCategoryForApiClients::RuleBansGeneratedContent);
|
||||
assert_deserialization("generation_failed", FrontendFailureCategoryForApiClients::GenerationFailed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_variant_deserializes() {
|
||||
let json = "\"some_future_category\"";
|
||||
let value: FrontendFailureCategoryForApiClients = serde_json::from_str(json).unwrap();
|
||||
assert_eq!(value, FrontendFailureCategoryForApiClients::Unknown("some_future_category".to_string()));
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
let known_variants = vec![
|
||||
FrontendFailureCategoryForApiClients::FaceNotDetected,
|
||||
FrontendFailureCategoryForApiClients::KeepAliveElapsed,
|
||||
FrontendFailureCategoryForApiClients::NotYetImplemented,
|
||||
FrontendFailureCategoryForApiClients::RetryableWorkerError,
|
||||
FrontendFailureCategoryForApiClients::ModelRulesViolation,
|
||||
FrontendFailureCategoryForApiClients::RuleBansUserImage,
|
||||
FrontendFailureCategoryForApiClients::RuleBansUserImageWithFaces,
|
||||
FrontendFailureCategoryForApiClients::RuleBansUserTextPrompt,
|
||||
FrontendFailureCategoryForApiClients::RuleBansUserContent,
|
||||
FrontendFailureCategoryForApiClients::RuleBansGeneratedVideo,
|
||||
FrontendFailureCategoryForApiClients::RuleBansGeneratedAudio,
|
||||
FrontendFailureCategoryForApiClients::RuleBansGeneratedContent,
|
||||
FrontendFailureCategoryForApiClients::GenerationFailed,
|
||||
];
|
||||
assert_eq!(known_variants.len(), 13);
|
||||
for variant in known_variants {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: FrontendFailureCategoryForApiClients = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// A restricted subset of `FrontendFailureCategory` that only includes values
|
||||
/// known to old deployed clients. New failure categories are omitted so that
|
||||
/// old clients never receive an enum value they cannot deserialize.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Deserialize, Serialize, ToSchema, EnumIter)]
|
||||
pub enum FrontendFailureCategoryForOldClients {
|
||||
#[serde(rename = "face_not_detected")]
|
||||
FaceNotDetected,
|
||||
|
||||
#[serde(rename = "keep_alive_elapsed")]
|
||||
KeepAliveElapsed,
|
||||
|
||||
#[serde(rename = "not_yet_implemented")]
|
||||
NotYetImplemented,
|
||||
|
||||
#[serde(rename = "retryable_worker_error")]
|
||||
RetryableWorkerError,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::FrontendFailureCategoryForOldClients;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(FrontendFailureCategoryForOldClients::FaceNotDetected, "face_not_detected");
|
||||
assert_serialization(FrontendFailureCategoryForOldClients::KeepAliveElapsed, "keep_alive_elapsed");
|
||||
assert_serialization(FrontendFailureCategoryForOldClients::NotYetImplemented, "not_yet_implemented");
|
||||
assert_serialization(FrontendFailureCategoryForOldClients::RetryableWorkerError, "retryable_worker_error");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("face_not_detected", FrontendFailureCategoryForOldClients::FaceNotDetected);
|
||||
assert_deserialization("keep_alive_elapsed", FrontendFailureCategoryForOldClients::KeepAliveElapsed);
|
||||
assert_deserialization("not_yet_implemented", FrontendFailureCategoryForOldClients::NotYetImplemented);
|
||||
assert_deserialization("retryable_worker_error", FrontendFailureCategoryForOldClients::RetryableWorkerError);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(FrontendFailureCategoryForOldClients::iter().count(), 4);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in FrontendFailureCategoryForOldClients::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: FrontendFailureCategoryForOldClients = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
pub mod frontend_failure_category_for_api_clients;
|
||||
pub mod frontend_failure_category_for_old_clients;
|
||||
@@ -1 +0,0 @@
|
||||
pub mod generic_inference_jobs;
|
||||
@@ -1 +0,0 @@
|
||||
pub mod by_table;
|
||||
@@ -1,80 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `audit_logs` table in a `VARCHAR(32)` field named `entity_action`.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum AuditLogEntityAction {
|
||||
/// Create action
|
||||
#[serde(rename = "create")]
|
||||
Create,
|
||||
|
||||
/// Edit action
|
||||
#[serde(rename = "edit")]
|
||||
Edit,
|
||||
|
||||
/// Edit features (eg. user feature flags)
|
||||
#[serde(rename = "edit_features")]
|
||||
EditFeatures,
|
||||
|
||||
/// Delete action
|
||||
#[serde(rename = "delete")]
|
||||
Delete,
|
||||
|
||||
/// Create featured item
|
||||
#[serde(rename = "featured_item_create")]
|
||||
FeaturedItemCreate,
|
||||
|
||||
/// Delete featured item
|
||||
#[serde(rename = "featured_item_delete")]
|
||||
FeaturedItemDelete,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::AuditLogEntityAction;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(AuditLogEntityAction::Create, "create");
|
||||
assert_serialization(AuditLogEntityAction::Edit, "edit");
|
||||
assert_serialization(AuditLogEntityAction::EditFeatures, "edit_features");
|
||||
assert_serialization(AuditLogEntityAction::Delete, "delete");
|
||||
assert_serialization(AuditLogEntityAction::FeaturedItemCreate, "featured_item_create");
|
||||
assert_serialization(AuditLogEntityAction::FeaturedItemDelete, "featured_item_delete");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("create", AuditLogEntityAction::Create);
|
||||
assert_deserialization("edit", AuditLogEntityAction::Edit);
|
||||
assert_deserialization("edit_features", AuditLogEntityAction::EditFeatures);
|
||||
assert_deserialization("delete", AuditLogEntityAction::Delete);
|
||||
assert_deserialization("featured_item_create", AuditLogEntityAction::FeaturedItemCreate);
|
||||
assert_deserialization("featured_item_delete", AuditLogEntityAction::FeaturedItemDelete);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(AuditLogEntityAction::iter().count(), 6);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in AuditLogEntityAction::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: AuditLogEntityAction = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `audit_logs` table in a `VARCHAR(32)` field named `entity_type`.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum AuditLogEntityType {
|
||||
/// Comment system
|
||||
#[serde(rename = "comment")]
|
||||
Comment,
|
||||
|
||||
/// Media file
|
||||
#[serde(rename = "media_file")]
|
||||
MediaFile,
|
||||
|
||||
/// Model weight
|
||||
#[serde(rename = "model_weight")]
|
||||
ModelWeight,
|
||||
|
||||
/// User
|
||||
#[serde(rename = "user")]
|
||||
User,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::AuditLogEntityType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(AuditLogEntityType::Comment, "comment");
|
||||
assert_serialization(AuditLogEntityType::MediaFile, "media_file");
|
||||
assert_serialization(AuditLogEntityType::ModelWeight, "model_weight");
|
||||
assert_serialization(AuditLogEntityType::User, "user");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("comment", AuditLogEntityType::Comment);
|
||||
assert_deserialization("media_file", AuditLogEntityType::MediaFile);
|
||||
assert_deserialization("model_weight", AuditLogEntityType::ModelWeight);
|
||||
assert_deserialization("user", AuditLogEntityType::User);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(AuditLogEntityType::iter().count(), 4);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in AuditLogEntityType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: AuditLogEntityType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
pub mod audit_log_entity_action;
|
||||
pub mod audit_log_entity_type;
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `batch_generations` table in a `VARCHAR(32)` field named `entity_type`.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, Ord, PartialOrd, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum BatchGenerationEntityType {
|
||||
/// Media files
|
||||
/// This will probably be the only type supported, but we'll leave the possibility of future types.
|
||||
#[serde(rename = "media_file")]
|
||||
MediaFile,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::BatchGenerationEntityType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(BatchGenerationEntityType::MediaFile, "media_file");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("media_file", BatchGenerationEntityType::MediaFile);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(BatchGenerationEntityType::iter().count(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in BatchGenerationEntityType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: BatchGenerationEntityType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod batch_generation_entity_type;
|
||||
@@ -1,51 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `batch_generations` table in a `VARCHAR(32)` field named `entity_type`.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, Ord, PartialOrd, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum BetaKeyProduct {
|
||||
/// Media files
|
||||
/// This will probably be the only type supported, but we'll leave the possibility of future types.
|
||||
#[serde(rename = "studio")]
|
||||
Studio,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::BetaKeyProduct;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(BetaKeyProduct::Studio, "studio");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("studio", BetaKeyProduct::Studio);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(BetaKeyProduct::iter().count(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in BetaKeyProduct::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: BetaKeyProduct = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod beta_key_product;
|
||||
@@ -1,86 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `comments` table in a `VARCHAR(32)` field named `entity_type`.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum CommentEntityType {
|
||||
/// User
|
||||
#[serde(rename = "user")]
|
||||
User,
|
||||
|
||||
/// Media files
|
||||
#[serde(rename = "media_file")]
|
||||
MediaFile,
|
||||
|
||||
/// Model weights
|
||||
#[serde(rename = "model_weight")]
|
||||
ModelWeight,
|
||||
|
||||
/// TTS model (architecture does not matter)
|
||||
#[serde(rename = "tts_model")]
|
||||
TtsModel,
|
||||
|
||||
/// TTS result (architecture does not matter)
|
||||
#[serde(rename = "tts_result")]
|
||||
TtsResult,
|
||||
|
||||
/// W2L template
|
||||
#[serde(rename = "w2l_template")]
|
||||
W2lTemplate,
|
||||
|
||||
/// W2L result
|
||||
#[serde(rename = "w2l_result")]
|
||||
W2lResult,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::CommentEntityType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(CommentEntityType::User, "user");
|
||||
assert_serialization(CommentEntityType::MediaFile, "media_file");
|
||||
assert_serialization(CommentEntityType::ModelWeight, "model_weight");
|
||||
assert_serialization(CommentEntityType::TtsModel, "tts_model");
|
||||
assert_serialization(CommentEntityType::TtsResult, "tts_result");
|
||||
assert_serialization(CommentEntityType::W2lTemplate, "w2l_template");
|
||||
assert_serialization(CommentEntityType::W2lResult, "w2l_result");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("user", CommentEntityType::User);
|
||||
assert_deserialization("media_file", CommentEntityType::MediaFile);
|
||||
assert_deserialization("model_weight", CommentEntityType::ModelWeight);
|
||||
assert_deserialization("tts_model", CommentEntityType::TtsModel);
|
||||
assert_deserialization("tts_result", CommentEntityType::TtsResult);
|
||||
assert_deserialization("w2l_template", CommentEntityType::W2lTemplate);
|
||||
assert_deserialization("w2l_result", CommentEntityType::W2lResult);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(CommentEntityType::iter().count(), 7);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in CommentEntityType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: CommentEntityType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod comment_entity_type;
|
||||
@@ -1,60 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `email_sender_jobs` table in `VARCHAR(32)` field `id_category`.
|
||||
///
|
||||
/// This denotes the type of email being sent.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum EmailCategory {
|
||||
/// User is recently registered
|
||||
#[serde(rename = "welcome")]
|
||||
Welcome,
|
||||
|
||||
/// User is resetting their password
|
||||
#[serde(rename = "password_reset")]
|
||||
PasswordReset,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::EmailCategory;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(EmailCategory::Welcome, "welcome");
|
||||
assert_serialization(EmailCategory::PasswordReset, "password_reset");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("welcome", EmailCategory::Welcome);
|
||||
assert_deserialization("password_reset", EmailCategory::PasswordReset);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(EmailCategory::iter().count(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in EmailCategory::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: EmailCategory = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod email_category;
|
||||
@@ -1 +0,0 @@
|
||||
pub mod stats_entity_type;
|
||||
@@ -1,62 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `user_stats` table in a `VARCHAR(32)` field named `entity_type`.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, ToSchema, Ord, PartialOrd, EnumIter, Debug)]
|
||||
|
||||
pub enum StatsEntityType {
|
||||
/// Comment
|
||||
#[serde(rename = "comment")]
|
||||
Comment,
|
||||
|
||||
/// MediaFile
|
||||
#[serde(rename = "media_file")]
|
||||
MediaFile,
|
||||
|
||||
/// ModelWeight (the new way to store models)
|
||||
#[serde(rename = "model_weight")]
|
||||
ModelWeight,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::StatsEntityType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(StatsEntityType::Comment, "comment");
|
||||
assert_serialization(StatsEntityType::MediaFile, "media_file");
|
||||
assert_serialization(StatsEntityType::ModelWeight, "model_weight");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("comment", StatsEntityType::Comment);
|
||||
assert_deserialization("media_file", StatsEntityType::MediaFile);
|
||||
assert_deserialization("model_weight", StatsEntityType::ModelWeight);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(StatsEntityType::iter().count(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in StatsEntityType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: StatsEntityType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `user_bookmarks` table in a `VARCHAR(32)` field named `entity_type`.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum FeaturedItemEntityType {
|
||||
/// MediaFile
|
||||
#[serde(rename = "media_file")]
|
||||
MediaFile,
|
||||
|
||||
/// ModelWeight (the new way to store models)
|
||||
#[serde(rename = "model_weight")]
|
||||
ModelWeight,
|
||||
|
||||
/// User
|
||||
#[serde(rename = "user")]
|
||||
User,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::FeaturedItemEntityType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(FeaturedItemEntityType::MediaFile, "media_file");
|
||||
assert_serialization(FeaturedItemEntityType::ModelWeight, "model_weight");
|
||||
assert_serialization(FeaturedItemEntityType::User, "user");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("media_file", FeaturedItemEntityType::MediaFile);
|
||||
assert_deserialization("model_weight", FeaturedItemEntityType::ModelWeight);
|
||||
assert_deserialization("user", FeaturedItemEntityType::User);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(FeaturedItemEntityType::iter().count(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in FeaturedItemEntityType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: FeaturedItemEntityType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod featured_item_entity_type;
|
||||
-107
@@ -1,107 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
// TODO: Use macro-derived impls
|
||||
|
||||
/// Our "generic downloads" pipeline supports a wide variety of ML models and other media.
|
||||
/// They are serialized in the database table `generic_download_jobs` as a VARCHAR(32).
|
||||
///
|
||||
/// Each type of download is identified by the following enum variants.
|
||||
/// These types are present in the HTTP API and database columns as serialized here.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Debug, Deserialize, Serialize, ToSchema, EnumIter, Hash, Ord, PartialOrd)]
|
||||
pub enum GenericDownloadType {
|
||||
/// NB: Note - this is hifigan for Tacotron2.
|
||||
/// Some work will be needed to unify this with other hifigan types.
|
||||
#[serde(rename = "hifigan")]
|
||||
HifiGan,
|
||||
|
||||
/// NB: Note - this is hifigan for SoftVC (our internal codename is "rocketvc").
|
||||
/// Some work will need to be done to unify this with other hifigan types.
|
||||
#[serde(rename = "hifigan_rocket_vc")]
|
||||
HifiGanRocketVc,
|
||||
|
||||
/// NB: Note - this is hifigan for SoVitsSvc
|
||||
/// Some work will need to be done to unify this with other hifigan types.
|
||||
#[serde(rename = "hifigan_so_vits_svc")]
|
||||
HifiGanSoVitsSvc,
|
||||
|
||||
//#[serde(rename = "melgan_vocodes")]
|
||||
//#[sqlx(rename = "melgan_vocodes")]
|
||||
//MelGanVocodes,
|
||||
|
||||
/// NB: Our external-facing name for "softvc" is rocketvc.
|
||||
/// I wish we could stop being stupid about this.
|
||||
#[serde(rename = "rocket_vc")]
|
||||
RocketVc,
|
||||
|
||||
/// RVC (v2) voice conversion models
|
||||
#[serde(rename = "rvc_v2")]
|
||||
RvcV2,
|
||||
|
||||
/// so-vits-svc voice conversion models
|
||||
#[serde(rename = "so_vits_svc")]
|
||||
SoVitsSvc,
|
||||
|
||||
/// Tacotron TTS models.
|
||||
#[serde(rename = "tacotron2")]
|
||||
Tacotron2,
|
||||
|
||||
/// VITS TTS models.
|
||||
#[serde(rename = "vits")]
|
||||
Vits,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::GenericDownloadType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(GenericDownloadType::HifiGan, "hifigan");
|
||||
assert_serialization(GenericDownloadType::HifiGanRocketVc, "hifigan_rocket_vc");
|
||||
assert_serialization(GenericDownloadType::HifiGanSoVitsSvc, "hifigan_so_vits_svc");
|
||||
assert_serialization(GenericDownloadType::RocketVc, "rocket_vc");
|
||||
assert_serialization(GenericDownloadType::RvcV2, "rvc_v2");
|
||||
assert_serialization(GenericDownloadType::SoVitsSvc, "so_vits_svc");
|
||||
assert_serialization(GenericDownloadType::Tacotron2, "tacotron2");
|
||||
assert_serialization(GenericDownloadType::Vits, "vits");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("hifigan", GenericDownloadType::HifiGan);
|
||||
assert_deserialization("hifigan_rocket_vc", GenericDownloadType::HifiGanRocketVc);
|
||||
assert_deserialization("hifigan_so_vits_svc", GenericDownloadType::HifiGanSoVitsSvc);
|
||||
assert_deserialization("rocket_vc", GenericDownloadType::RocketVc);
|
||||
assert_deserialization("rvc_v2", GenericDownloadType::RvcV2);
|
||||
assert_deserialization("so_vits_svc", GenericDownloadType::SoVitsSvc);
|
||||
assert_deserialization("tacotron2", GenericDownloadType::Tacotron2);
|
||||
assert_deserialization("vits", GenericDownloadType::Vits);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(GenericDownloadType::iter().count(), 8);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in GenericDownloadType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: GenericDownloadType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod generic_download_type;
|
||||
-159
@@ -1,159 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `generic_inference_jobs` table in `VARCHAR(32)` field `inference_category`.
|
||||
///
|
||||
/// Our "generic inference" pipeline supports a wide variety of ML models and other media.
|
||||
/// Each "category" of inference is identified by the following enum variants.
|
||||
/// These types are present in the HTTP API and database columns as serialized here.
|
||||
///
|
||||
/// YOU CAN ADD NEW VALUES, BUT DO NOT CHANGE EXISTING VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, Default, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum InferenceCategory {
|
||||
/// Deprecate this field !!!
|
||||
/// We should drain all jobs from using this database field, then remove it.
|
||||
#[deprecated(note = "NB(bt,2024-09-05): The frontend still needs this")]
|
||||
#[serde(rename = "deprecated_field")]
|
||||
DeprecatedField,
|
||||
|
||||
/// Facial lipsync animation (eg. SadTalker, Wav2Lip, FaceFusion)
|
||||
#[serde(rename = "lipsync_animation")]
|
||||
#[default]
|
||||
LipsyncAnimation,
|
||||
|
||||
/// FakeYou's text to speech (eg. Tacotron2)
|
||||
#[serde(rename = "text_to_speech")]
|
||||
TextToSpeech,
|
||||
|
||||
/// FakeYou's voice conversion (eg. svc, rvc)
|
||||
#[serde(rename = "voice_conversion")]
|
||||
VoiceConversion,
|
||||
|
||||
/// Image generation (eg. Stable Diffusion 1.5), FAL-powered image generation, etc.
|
||||
#[serde(rename = "image_generation")]
|
||||
ImageGeneration,
|
||||
|
||||
/// FAL-powered video generation
|
||||
/// (Also Seedance2-Pro.com)
|
||||
#[serde(rename = "video_generation")]
|
||||
VideoGeneration,
|
||||
|
||||
/// FAL-powered 3D object generation
|
||||
#[serde(rename = "object_generation")]
|
||||
ObjectGeneration,
|
||||
|
||||
/// Gaussian Splat generation (eg. World Labs Marble)
|
||||
#[serde(rename = "splat_generation")]
|
||||
SplatGeneration,
|
||||
|
||||
/// FAL-powered image background removal
|
||||
#[serde(rename = "background_removal")]
|
||||
BackgroundRemoval,
|
||||
|
||||
/// Turn video into animation data with mocap processing (eg. Mocapnet).
|
||||
#[serde(rename = "mocap")]
|
||||
Mocap,
|
||||
|
||||
/// ComfyUI workflows
|
||||
/// This is what powers Storyteller Studio!
|
||||
#[serde(rename = "workflow")]
|
||||
Workflow,
|
||||
|
||||
/// FBX to GLTF/GLB.
|
||||
/// Still supported, but few people will use it.
|
||||
#[serde(rename = "format_conversion")]
|
||||
FormatConversion,
|
||||
|
||||
/// Live portrait
|
||||
#[serde(rename = "live_portrait")]
|
||||
LivePortrait,
|
||||
|
||||
#[serde(rename="seed_vc")]
|
||||
SeedVc,
|
||||
|
||||
/// DEPRECATED. Do not use.
|
||||
/// This was for ReRenderAVideo, which we never productionized.
|
||||
#[deprecated(note = "This was for ReRenderAVideo, which we never productionized.")]
|
||||
#[serde(rename = "video_filter")]
|
||||
VideoFilter,
|
||||
|
||||
/// DEPRECATED. Bevy engine serverside rendering.
|
||||
#[deprecated(note = "This was for Bevy engine's server side rendering.")]
|
||||
#[serde(rename = "convert_bvh_to_workflow")]
|
||||
ConvertBvhToWorkflow,
|
||||
|
||||
#[serde(rename = "f5_tts")]
|
||||
F5TTS,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::InferenceCategory;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(InferenceCategory::DeprecatedField, "deprecated_field");
|
||||
assert_serialization(InferenceCategory::LipsyncAnimation, "lipsync_animation");
|
||||
assert_serialization(InferenceCategory::TextToSpeech, "text_to_speech");
|
||||
assert_serialization(InferenceCategory::VoiceConversion, "voice_conversion");
|
||||
assert_serialization(InferenceCategory::ImageGeneration, "image_generation");
|
||||
assert_serialization(InferenceCategory::VideoGeneration, "video_generation");
|
||||
assert_serialization(InferenceCategory::ObjectGeneration, "object_generation");
|
||||
assert_serialization(InferenceCategory::SplatGeneration, "splat_generation");
|
||||
assert_serialization(InferenceCategory::BackgroundRemoval, "background_removal");
|
||||
assert_serialization(InferenceCategory::Mocap, "mocap");
|
||||
assert_serialization(InferenceCategory::Workflow, "workflow");
|
||||
assert_serialization(InferenceCategory::FormatConversion, "format_conversion");
|
||||
assert_serialization(InferenceCategory::LivePortrait, "live_portrait");
|
||||
assert_serialization(InferenceCategory::SeedVc, "seed_vc");
|
||||
assert_serialization(InferenceCategory::VideoFilter, "video_filter");
|
||||
assert_serialization(InferenceCategory::ConvertBvhToWorkflow, "convert_bvh_to_workflow");
|
||||
assert_serialization(InferenceCategory::F5TTS, "f5_tts");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("deprecated_field", InferenceCategory::DeprecatedField);
|
||||
assert_deserialization("lipsync_animation", InferenceCategory::LipsyncAnimation);
|
||||
assert_deserialization("text_to_speech", InferenceCategory::TextToSpeech);
|
||||
assert_deserialization("voice_conversion", InferenceCategory::VoiceConversion);
|
||||
assert_deserialization("image_generation", InferenceCategory::ImageGeneration);
|
||||
assert_deserialization("video_generation", InferenceCategory::VideoGeneration);
|
||||
assert_deserialization("object_generation", InferenceCategory::ObjectGeneration);
|
||||
assert_deserialization("splat_generation", InferenceCategory::SplatGeneration);
|
||||
assert_deserialization("background_removal", InferenceCategory::BackgroundRemoval);
|
||||
assert_deserialization("mocap", InferenceCategory::Mocap);
|
||||
assert_deserialization("workflow", InferenceCategory::Workflow);
|
||||
assert_deserialization("format_conversion", InferenceCategory::FormatConversion);
|
||||
assert_deserialization("live_portrait", InferenceCategory::LivePortrait);
|
||||
assert_deserialization("seed_vc", InferenceCategory::SeedVc);
|
||||
assert_deserialization("video_filter", InferenceCategory::VideoFilter);
|
||||
assert_deserialization("convert_bvh_to_workflow", InferenceCategory::ConvertBvhToWorkflow);
|
||||
assert_deserialization("f5_tts", InferenceCategory::F5TTS);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(InferenceCategory::iter().count(), 17);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in InferenceCategory::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: InferenceCategory = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `generic_inference_jobs` table in `VARCHAR(32)` field `maybe_input_source_token`.
|
||||
///
|
||||
/// YOU CAN ADD NEW VALUES, BUT DO NOT CHANGE EXISTING VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum InferenceInputSourceTokenType {
|
||||
#[serde(rename = "media_file")]
|
||||
MediaFile,
|
||||
#[serde(rename = "media_upload")]
|
||||
MediaUpload,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::InferenceInputSourceTokenType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(InferenceInputSourceTokenType::MediaFile, "media_file");
|
||||
assert_serialization(InferenceInputSourceTokenType::MediaUpload, "media_upload");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("media_file", InferenceInputSourceTokenType::MediaFile);
|
||||
assert_deserialization("media_upload", InferenceInputSourceTokenType::MediaUpload);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(InferenceInputSourceTokenType::iter().count(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in InferenceInputSourceTokenType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: InferenceInputSourceTokenType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `generic_inference_jobs` table in `VARCHAR(16)` field `maybe_external_third_party`.
|
||||
///
|
||||
/// YOU CAN ADD NEW VALUES, BUT DO NOT CHANGE EXISTING VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, Default, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum InferenceJobExternalThirdParty {
|
||||
/// Fal jobs
|
||||
#[serde(rename = "fal")]
|
||||
#[default]
|
||||
Fal,
|
||||
|
||||
/// Seedance 2 Pro jobs
|
||||
#[serde(rename = "seedance2pro")]
|
||||
Seedance2Pro,
|
||||
|
||||
/// World Labs jobs
|
||||
#[serde(rename = "worldlabs")]
|
||||
Worldlabs,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::InferenceJobExternalThirdParty;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(InferenceJobExternalThirdParty::Fal, "fal");
|
||||
assert_serialization(InferenceJobExternalThirdParty::Seedance2Pro, "seedance2pro");
|
||||
assert_serialization(InferenceJobExternalThirdParty::Worldlabs, "worldlabs");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("fal", InferenceJobExternalThirdParty::Fal);
|
||||
assert_deserialization("seedance2pro", InferenceJobExternalThirdParty::Seedance2Pro);
|
||||
assert_deserialization("worldlabs", InferenceJobExternalThirdParty::Worldlabs);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(InferenceJobExternalThirdParty::iter().count(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in InferenceJobExternalThirdParty::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: InferenceJobExternalThirdParty = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-215
@@ -1,215 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `generic_inference_jobs` table in `VARCHAR(32)` field `product_category`.
|
||||
///
|
||||
/// This is a user-facing and analytics-facing column that describes what product area the job
|
||||
/// is attributed to. For example, this will help us separate "video style transfer" from
|
||||
/// "storyteller studio" and also separate "live portrait" from "webcam live portrait".
|
||||
///
|
||||
/// YOU CAN ADD NEW VALUES, BUT DO NOT CHANGE EXISTING VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, Default, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum InferenceJobProductCategory {
|
||||
// =============== DOWNLOAD ===============
|
||||
|
||||
/// Download: GptSoVits
|
||||
#[default]
|
||||
DownloadGptSoVits,
|
||||
|
||||
// =============== FAL ===============
|
||||
|
||||
FalImage,
|
||||
FalVideo,
|
||||
/// Fal: 3D Object Generation
|
||||
FalObject,
|
||||
FalBgRemoval,
|
||||
|
||||
// =============== SEEDANCE 2 PRO ===============
|
||||
|
||||
#[serde(rename = "seedance2pro_video")]
|
||||
Seedance2ProVideo,
|
||||
|
||||
// =============== WORLD LABS ===============
|
||||
|
||||
/// World Labs: Gaussian Splat Generation
|
||||
#[serde(rename = "worldlabs_splat")]
|
||||
WorldlabsSplat,
|
||||
|
||||
// =============== TEXT TO SPEECH ===============
|
||||
|
||||
/// TTS: GptSoVits
|
||||
TtsGptSoVits,
|
||||
|
||||
/// TTS: F5Tts (Zero Shot)
|
||||
TtsF5,
|
||||
|
||||
/// TTS: StyleTts2 (Zero Shot)
|
||||
TtsStyleTts2,
|
||||
|
||||
/// TTS: Tacotron2
|
||||
TtsTacotron2,
|
||||
|
||||
// =============== VOICE CONVERSION ===============
|
||||
|
||||
/// Voice Conversion: RVC v2
|
||||
VcRvc2,
|
||||
|
||||
/// Voice Conversion: SoVitsSvc
|
||||
VcSvc,
|
||||
|
||||
VcSeedVc, // Ugh
|
||||
|
||||
// =============== VIDEO ===============
|
||||
|
||||
/// Video: Face Fusion (Lipsync)
|
||||
VidLipsyncFaceFusion,
|
||||
|
||||
/// Video: Sad Talker (Lipsync)
|
||||
VidLipsyncSadTalker,
|
||||
|
||||
/// Live Portrait (normal interface)
|
||||
VidLivePortrait,
|
||||
|
||||
/// Live Portrait (webcam interface)
|
||||
VidLivePortraitWebcam,
|
||||
|
||||
/// Video: Studio
|
||||
VidStudio,
|
||||
|
||||
/// Video: Studio Gen 2
|
||||
VidStudioGen2,
|
||||
|
||||
/// Video: Style Transfer
|
||||
VidStyleTransfer,
|
||||
|
||||
// =============== DEPRECATED ===============
|
||||
|
||||
/// Lipsync: Face Fusion
|
||||
#[deprecated(note = "Use `VidLipsyncFaceFusion` instead")]
|
||||
LipsyncFaceFusion,
|
||||
|
||||
/// Lipsync: SadTalker
|
||||
#[deprecated(note = "Use `VidLipsyncSadTalker` instead")]
|
||||
LipsyncSadTalker,
|
||||
|
||||
/// Live Portrait (normal interface)
|
||||
#[deprecated(note = "Use `VidLivePortrait` instead")]
|
||||
LivePortrait,
|
||||
|
||||
/// Live Portrait (webcam interface)
|
||||
#[deprecated(note = "Use `VidLivePortraitWebcam` instead")]
|
||||
LivePortraitWebcam,
|
||||
|
||||
/// Stable Diffusion (deprecated)
|
||||
#[deprecated(note = "unused")]
|
||||
StableDiffusion,
|
||||
|
||||
/// Storyteller Studio
|
||||
#[deprecated(note = "Use `VidStudio` instead")]
|
||||
Studio,
|
||||
|
||||
/// Lipsync: Face Fusion
|
||||
#[deprecated(note = "Use `VidLipsyncFaceFusion` instead")]
|
||||
VidFaceFusion,
|
||||
|
||||
/// Video Style Transfer
|
||||
#[deprecated(note = "Use `VidStyleTransfer` instead")]
|
||||
Vst,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::InferenceJobProductCategory;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(InferenceJobProductCategory::DownloadGptSoVits, "download_gpt_so_vits");
|
||||
assert_serialization(InferenceJobProductCategory::FalImage, "fal_image");
|
||||
assert_serialization(InferenceJobProductCategory::FalVideo, "fal_video");
|
||||
assert_serialization(InferenceJobProductCategory::FalObject, "fal_object");
|
||||
assert_serialization(InferenceJobProductCategory::FalBgRemoval, "fal_bg_removal");
|
||||
assert_serialization(InferenceJobProductCategory::Seedance2ProVideo, "seedance2pro_video");
|
||||
assert_serialization(InferenceJobProductCategory::WorldlabsSplat, "worldlabs_splat");
|
||||
assert_serialization(InferenceJobProductCategory::TtsGptSoVits, "tts_gpt_so_vits");
|
||||
assert_serialization(InferenceJobProductCategory::TtsF5, "tts_f5");
|
||||
assert_serialization(InferenceJobProductCategory::TtsStyleTts2, "tts_style_tts2");
|
||||
assert_serialization(InferenceJobProductCategory::TtsTacotron2, "tts_tacotron2");
|
||||
assert_serialization(InferenceJobProductCategory::VcRvc2, "vc_rvc2");
|
||||
assert_serialization(InferenceJobProductCategory::VcSvc, "vc_svc");
|
||||
assert_serialization(InferenceJobProductCategory::VcSeedVc, "vc_seed_vc");
|
||||
assert_serialization(InferenceJobProductCategory::VidLipsyncFaceFusion, "vid_lipsync_face_fusion");
|
||||
assert_serialization(InferenceJobProductCategory::VidLipsyncSadTalker, "vid_lipsync_sad_talker");
|
||||
assert_serialization(InferenceJobProductCategory::VidLivePortrait, "vid_live_portrait");
|
||||
assert_serialization(InferenceJobProductCategory::VidLivePortraitWebcam, "vid_live_portrait_webcam");
|
||||
assert_serialization(InferenceJobProductCategory::VidStudio, "vid_studio");
|
||||
assert_serialization(InferenceJobProductCategory::VidStudioGen2, "vid_studio_gen2");
|
||||
assert_serialization(InferenceJobProductCategory::VidStyleTransfer, "vid_style_transfer");
|
||||
assert_serialization(InferenceJobProductCategory::LipsyncFaceFusion, "lipsync_face_fusion");
|
||||
assert_serialization(InferenceJobProductCategory::LipsyncSadTalker, "lipsync_sad_talker");
|
||||
assert_serialization(InferenceJobProductCategory::LivePortrait, "live_portrait");
|
||||
assert_serialization(InferenceJobProductCategory::LivePortraitWebcam, "live_portrait_webcam");
|
||||
assert_serialization(InferenceJobProductCategory::StableDiffusion, "stable_diffusion");
|
||||
assert_serialization(InferenceJobProductCategory::Studio, "studio");
|
||||
assert_serialization(InferenceJobProductCategory::VidFaceFusion, "vid_face_fusion");
|
||||
assert_serialization(InferenceJobProductCategory::Vst, "vst");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("download_gpt_so_vits", InferenceJobProductCategory::DownloadGptSoVits);
|
||||
assert_deserialization("fal_image", InferenceJobProductCategory::FalImage);
|
||||
assert_deserialization("fal_video", InferenceJobProductCategory::FalVideo);
|
||||
assert_deserialization("fal_object", InferenceJobProductCategory::FalObject);
|
||||
assert_deserialization("fal_bg_removal", InferenceJobProductCategory::FalBgRemoval);
|
||||
assert_deserialization("seedance2pro_video", InferenceJobProductCategory::Seedance2ProVideo);
|
||||
assert_deserialization("worldlabs_splat", InferenceJobProductCategory::WorldlabsSplat);
|
||||
assert_deserialization("tts_gpt_so_vits", InferenceJobProductCategory::TtsGptSoVits);
|
||||
assert_deserialization("tts_f5", InferenceJobProductCategory::TtsF5);
|
||||
assert_deserialization("tts_style_tts2", InferenceJobProductCategory::TtsStyleTts2);
|
||||
assert_deserialization("tts_tacotron2", InferenceJobProductCategory::TtsTacotron2);
|
||||
assert_deserialization("vc_rvc2", InferenceJobProductCategory::VcRvc2);
|
||||
assert_deserialization("vc_svc", InferenceJobProductCategory::VcSvc);
|
||||
assert_deserialization("vc_seed_vc", InferenceJobProductCategory::VcSeedVc);
|
||||
assert_deserialization("vid_lipsync_face_fusion", InferenceJobProductCategory::VidLipsyncFaceFusion);
|
||||
assert_deserialization("vid_lipsync_sad_talker", InferenceJobProductCategory::VidLipsyncSadTalker);
|
||||
assert_deserialization("vid_live_portrait", InferenceJobProductCategory::VidLivePortrait);
|
||||
assert_deserialization("vid_live_portrait_webcam", InferenceJobProductCategory::VidLivePortraitWebcam);
|
||||
assert_deserialization("vid_studio", InferenceJobProductCategory::VidStudio);
|
||||
assert_deserialization("vid_studio_gen2", InferenceJobProductCategory::VidStudioGen2);
|
||||
assert_deserialization("vid_style_transfer", InferenceJobProductCategory::VidStyleTransfer);
|
||||
assert_deserialization("lipsync_face_fusion", InferenceJobProductCategory::LipsyncFaceFusion);
|
||||
assert_deserialization("lipsync_sad_talker", InferenceJobProductCategory::LipsyncSadTalker);
|
||||
assert_deserialization("live_portrait", InferenceJobProductCategory::LivePortrait);
|
||||
assert_deserialization("live_portrait_webcam", InferenceJobProductCategory::LivePortraitWebcam);
|
||||
assert_deserialization("stable_diffusion", InferenceJobProductCategory::StableDiffusion);
|
||||
assert_deserialization("studio", InferenceJobProductCategory::Studio);
|
||||
assert_deserialization("vid_face_fusion", InferenceJobProductCategory::VidFaceFusion);
|
||||
assert_deserialization("vst", InferenceJobProductCategory::Vst);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(InferenceJobProductCategory::iter().count(), 29);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in InferenceJobProductCategory::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: InferenceJobProductCategory = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-162
@@ -1,162 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Report certain jobs publicly as different from what we actually run.
|
||||
/// This is so we have an edge against the competition that might try to run
|
||||
/// the same models or workflows.
|
||||
///
|
||||
/// Previously named `PublicInferenceJobType` in the `enums_public` crate.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, Default, ToSchema, Debug, EnumIter)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum InferenceJobType {
|
||||
// ======= Renamed enum variants ======
|
||||
|
||||
/// Instead of DB `InferenceJobType::LivePortrait` ("live_portrait")
|
||||
ActingFace,
|
||||
|
||||
/// Instead of DB `InferenceJobType::FaceFusion` ("face_fusion")
|
||||
Lipsync,
|
||||
|
||||
/// Storyteller Studio and Video Style Transfer Jobs.
|
||||
VideoRender,
|
||||
|
||||
GptSovits,
|
||||
|
||||
#[serde(rename = "f5_tts")]
|
||||
F5TTS,
|
||||
|
||||
// ======= Everything else is the same =======
|
||||
|
||||
#[serde(rename = "fal_queue")]
|
||||
FalQueue,
|
||||
|
||||
#[deprecated(note = "Use VideoRender instead.")]
|
||||
ComfyUi,
|
||||
|
||||
#[serde(rename = "studio_gen2")]
|
||||
StudioGen2,
|
||||
|
||||
#[serde(rename = "convert_fbx_gltf")]
|
||||
ConvertFbxToGltf,
|
||||
|
||||
MocapNet,
|
||||
|
||||
#[serde(rename = "rvc_v2")]
|
||||
RvcV2,
|
||||
|
||||
SadTalker,
|
||||
|
||||
#[serde(rename = "seed_vc")]
|
||||
SeedVc,
|
||||
|
||||
SoVitsSvc,
|
||||
|
||||
StableDiffusion,
|
||||
|
||||
#[serde(rename = "styletts2")]
|
||||
StyleTTS2,
|
||||
|
||||
Tacotron2,
|
||||
|
||||
#[default]
|
||||
Unknown,
|
||||
|
||||
#[deprecated(note = "This was for Bevy engine's server side rendering.")]
|
||||
#[serde(rename = "bevy_to_workflow")]
|
||||
BevyToWorkflow,
|
||||
|
||||
#[deprecated(note = "This was for ReRenderAVideo, which we never productionized.")]
|
||||
RerenderAVideo,
|
||||
|
||||
#[serde(rename = "image_gen_api")]
|
||||
ImageGenApi,
|
||||
|
||||
#[serde(rename = "seedance2pro_queue")]
|
||||
Seedance2ProQueue,
|
||||
|
||||
#[serde(rename = "worldlabs_queue")]
|
||||
WorldlabsQueue,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::InferenceJobType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(InferenceJobType::ActingFace, "acting_face");
|
||||
assert_serialization(InferenceJobType::Lipsync, "lipsync");
|
||||
assert_serialization(InferenceJobType::VideoRender, "video_render");
|
||||
assert_serialization(InferenceJobType::GptSovits, "gpt_sovits");
|
||||
assert_serialization(InferenceJobType::F5TTS, "f5_tts");
|
||||
assert_serialization(InferenceJobType::FalQueue, "fal_queue");
|
||||
assert_serialization(InferenceJobType::ComfyUi, "comfy_ui");
|
||||
assert_serialization(InferenceJobType::StudioGen2, "studio_gen2");
|
||||
assert_serialization(InferenceJobType::ConvertFbxToGltf, "convert_fbx_gltf");
|
||||
assert_serialization(InferenceJobType::MocapNet, "mocap_net");
|
||||
assert_serialization(InferenceJobType::RvcV2, "rvc_v2");
|
||||
assert_serialization(InferenceJobType::SadTalker, "sad_talker");
|
||||
assert_serialization(InferenceJobType::SeedVc, "seed_vc");
|
||||
assert_serialization(InferenceJobType::SoVitsSvc, "so_vits_svc");
|
||||
assert_serialization(InferenceJobType::StableDiffusion, "stable_diffusion");
|
||||
assert_serialization(InferenceJobType::StyleTTS2, "styletts2");
|
||||
assert_serialization(InferenceJobType::Tacotron2, "tacotron2");
|
||||
assert_serialization(InferenceJobType::Unknown, "unknown");
|
||||
assert_serialization(InferenceJobType::BevyToWorkflow, "bevy_to_workflow");
|
||||
assert_serialization(InferenceJobType::RerenderAVideo, "rerender_a_video");
|
||||
assert_serialization(InferenceJobType::ImageGenApi, "image_gen_api");
|
||||
assert_serialization(InferenceJobType::Seedance2ProQueue, "seedance2pro_queue");
|
||||
assert_serialization(InferenceJobType::WorldlabsQueue, "worldlabs_queue");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("acting_face", InferenceJobType::ActingFace);
|
||||
assert_deserialization("lipsync", InferenceJobType::Lipsync);
|
||||
assert_deserialization("video_render", InferenceJobType::VideoRender);
|
||||
assert_deserialization("gpt_sovits", InferenceJobType::GptSovits);
|
||||
assert_deserialization("f5_tts", InferenceJobType::F5TTS);
|
||||
assert_deserialization("fal_queue", InferenceJobType::FalQueue);
|
||||
assert_deserialization("comfy_ui", InferenceJobType::ComfyUi);
|
||||
assert_deserialization("studio_gen2", InferenceJobType::StudioGen2);
|
||||
assert_deserialization("convert_fbx_gltf", InferenceJobType::ConvertFbxToGltf);
|
||||
assert_deserialization("mocap_net", InferenceJobType::MocapNet);
|
||||
assert_deserialization("rvc_v2", InferenceJobType::RvcV2);
|
||||
assert_deserialization("sad_talker", InferenceJobType::SadTalker);
|
||||
assert_deserialization("seed_vc", InferenceJobType::SeedVc);
|
||||
assert_deserialization("so_vits_svc", InferenceJobType::SoVitsSvc);
|
||||
assert_deserialization("stable_diffusion", InferenceJobType::StableDiffusion);
|
||||
assert_deserialization("styletts2", InferenceJobType::StyleTTS2);
|
||||
assert_deserialization("tacotron2", InferenceJobType::Tacotron2);
|
||||
assert_deserialization("unknown", InferenceJobType::Unknown);
|
||||
assert_deserialization("bevy_to_workflow", InferenceJobType::BevyToWorkflow);
|
||||
assert_deserialization("rerender_a_video", InferenceJobType::RerenderAVideo);
|
||||
assert_deserialization("image_gen_api", InferenceJobType::ImageGenApi);
|
||||
assert_deserialization("seedance2pro_queue", InferenceJobType::Seedance2ProQueue);
|
||||
assert_deserialization("worldlabs_queue", InferenceJobType::WorldlabsQueue);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(InferenceJobType::iter().count(), 23);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in InferenceJobType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: InferenceJobType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-122
@@ -1,122 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `generic_inference_jobs` table in `VARCHAR(32)` field `maybe_model_type`.
|
||||
///
|
||||
/// Our "generic inference" pipeline supports a wide variety of ML models and other media.
|
||||
/// Each inference "model type" identified by the following enum variants, though some pipelines
|
||||
/// may use multiple models or no model (and may report NULL).
|
||||
///
|
||||
/// These types are present in the HTTP API and database columns as serialized here.
|
||||
///
|
||||
/// YOU CAN ADD NEW VALUES, BUT DO NOT CHANGE EXISTING VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum InferenceModelType {
|
||||
// TODO(bt,2024-07-15): This is too generic. We probably need "StorytellerStudio", "LivePortrait", etc.
|
||||
#[serde(rename = "comfy_ui")]
|
||||
ComfyUi,
|
||||
|
||||
#[serde(rename = "rvc_v2")]
|
||||
RvcV2,
|
||||
// NB: sad_talker does use user-supplied models, so there is no "model token"
|
||||
#[serde(rename = "sad_talker")]
|
||||
SadTalker,
|
||||
#[serde(rename = "so_vits_svc")]
|
||||
SoVitsSvc,
|
||||
// TODO: Does this need to be "legacy_tacotron2" ?
|
||||
|
||||
#[serde(rename = "seed_vc")]
|
||||
SeedVc,
|
||||
|
||||
/// NB: This is for Sora GPT 4o image gen
|
||||
#[serde(rename = "image_gen_api")]
|
||||
ImageGenApi,
|
||||
|
||||
#[serde(rename = "tacotron2")]
|
||||
Tacotron2,
|
||||
#[serde(rename = "vits")]
|
||||
Vits,
|
||||
#[serde(rename = "vall_e_x")]
|
||||
VallEX,
|
||||
#[serde(rename = "rerender_a_video")]
|
||||
RerenderAVideo,
|
||||
#[serde(rename = "stable_diffusion")]
|
||||
StableDiffusion,
|
||||
#[serde(rename = "mocap_net")]
|
||||
MocapNet,
|
||||
#[serde(rename = "styletts2")]
|
||||
StyleTTS2,
|
||||
/// A job that turns "FBX" game engine files into "GLTF" files (Bevy-compatible).
|
||||
#[serde(rename = "convert_fbx_gltf")]
|
||||
ConvertFbxToGltf,
|
||||
#[serde(rename = "bvh_to_workflow")]
|
||||
BvhToWorkflow
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::InferenceModelType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(InferenceModelType::ComfyUi, "comfy_ui");
|
||||
assert_serialization(InferenceModelType::RvcV2, "rvc_v2");
|
||||
assert_serialization(InferenceModelType::SadTalker, "sad_talker");
|
||||
assert_serialization(InferenceModelType::SoVitsSvc, "so_vits_svc");
|
||||
assert_serialization(InferenceModelType::SeedVc, "seed_vc");
|
||||
assert_serialization(InferenceModelType::ImageGenApi, "image_gen_api");
|
||||
assert_serialization(InferenceModelType::Tacotron2, "tacotron2");
|
||||
assert_serialization(InferenceModelType::Vits, "vits");
|
||||
assert_serialization(InferenceModelType::VallEX, "vall_e_x");
|
||||
assert_serialization(InferenceModelType::RerenderAVideo, "rerender_a_video");
|
||||
assert_serialization(InferenceModelType::StableDiffusion, "stable_diffusion");
|
||||
assert_serialization(InferenceModelType::MocapNet, "mocap_net");
|
||||
assert_serialization(InferenceModelType::StyleTTS2, "styletts2");
|
||||
assert_serialization(InferenceModelType::ConvertFbxToGltf, "convert_fbx_gltf");
|
||||
assert_serialization(InferenceModelType::BvhToWorkflow, "bvh_to_workflow");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("comfy_ui", InferenceModelType::ComfyUi);
|
||||
assert_deserialization("rvc_v2", InferenceModelType::RvcV2);
|
||||
assert_deserialization("sad_talker", InferenceModelType::SadTalker);
|
||||
assert_deserialization("so_vits_svc", InferenceModelType::SoVitsSvc);
|
||||
assert_deserialization("seed_vc", InferenceModelType::SeedVc);
|
||||
assert_deserialization("image_gen_api", InferenceModelType::ImageGenApi);
|
||||
assert_deserialization("tacotron2", InferenceModelType::Tacotron2);
|
||||
assert_deserialization("vits", InferenceModelType::Vits);
|
||||
assert_deserialization("vall_e_x", InferenceModelType::VallEX);
|
||||
assert_deserialization("rerender_a_video", InferenceModelType::RerenderAVideo);
|
||||
assert_deserialization("stable_diffusion", InferenceModelType::StableDiffusion);
|
||||
assert_deserialization("mocap_net", InferenceModelType::MocapNet);
|
||||
assert_deserialization("styletts2", InferenceModelType::StyleTTS2);
|
||||
assert_deserialization("convert_fbx_gltf", InferenceModelType::ConvertFbxToGltf);
|
||||
assert_deserialization("bvh_to_workflow", InferenceModelType::BvhToWorkflow);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(InferenceModelType::iter().count(), 15);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in InferenceModelType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: InferenceModelType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `generic_inference_jobs` table in `VARCHAR(32)` field `on_success_result_entity_type`.
|
||||
///
|
||||
/// Our "generic inference" pipeline supports a wide variety of output types.
|
||||
/// Each "result type" is identified by the following enum variants.
|
||||
///
|
||||
/// These types are present in the HTTP API and database columns as serialized here.
|
||||
///
|
||||
/// YOU CAN ADD NEW VALUES, BUT DO NOT CHANGE EXISTING VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum InferenceResultType {
|
||||
/// Result is stored in the "media_files" table.
|
||||
/// (The upstream model could have produced any type of media - image, video, audio. That is irrelevant.)
|
||||
#[serde(rename = "media_file")]
|
||||
MediaFile,
|
||||
|
||||
#[serde(rename = "text_to_speech")]
|
||||
TextToSpeech,
|
||||
|
||||
#[serde(rename = "voice_conversion")]
|
||||
VoiceConversion,
|
||||
|
||||
#[serde(rename = "zs_voice_embedding")]
|
||||
ZeroShotVoiceEmbedding,
|
||||
|
||||
#[serde(rename = "upload_model")]
|
||||
UploadModel
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::InferenceResultType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(InferenceResultType::MediaFile, "media_file");
|
||||
assert_serialization(InferenceResultType::TextToSpeech, "text_to_speech");
|
||||
assert_serialization(InferenceResultType::VoiceConversion, "voice_conversion");
|
||||
assert_serialization(InferenceResultType::ZeroShotVoiceEmbedding, "zs_voice_embedding");
|
||||
assert_serialization(InferenceResultType::UploadModel, "upload_model");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("media_file", InferenceResultType::MediaFile);
|
||||
assert_deserialization("text_to_speech", InferenceResultType::TextToSpeech);
|
||||
assert_deserialization("voice_conversion", InferenceResultType::VoiceConversion);
|
||||
assert_deserialization("zs_voice_embedding", InferenceResultType::ZeroShotVoiceEmbedding);
|
||||
assert_deserialization("upload_model", InferenceResultType::UploadModel);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(InferenceResultType::iter().count(), 5);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in InferenceResultType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: InferenceResultType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
pub mod inference_category;
|
||||
pub mod inference_input_source_token_type;
|
||||
pub mod inference_job_external_third_party;
|
||||
pub mod inference_job_product_category;
|
||||
pub mod inference_job_type;
|
||||
pub mod inference_model_type;
|
||||
pub mod inference_result_type;
|
||||
@@ -1,139 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `generic_synthetic_ids` table in `VARCHAR(32)` field `id_category`.
|
||||
///
|
||||
/// This lets us create synthetic increment IDs on a per-user, per-category basis.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum IdCategory {
|
||||
/// media_files table
|
||||
#[serde(rename = "media_file")]
|
||||
MediaFile,
|
||||
|
||||
/// Results from lipsync animations (which may live in the media_files table)
|
||||
#[serde(rename = "lipsync_animation")]
|
||||
LipsyncAnimationResult,
|
||||
|
||||
/// Results from face fusion
|
||||
#[serde(rename = "face_fusion")]
|
||||
FaceFusionResult,
|
||||
|
||||
/// Results from video filters
|
||||
#[serde(rename = "video_filter")]
|
||||
VideoFilterResult,
|
||||
|
||||
/// Results from Live Portrait
|
||||
#[serde(rename = "live_portrait")]
|
||||
LivePortraitResult,
|
||||
|
||||
/// Studio Renders
|
||||
#[serde(rename = "studio_render")]
|
||||
StudioRender,
|
||||
|
||||
/// Results from mocap
|
||||
#[serde(rename = "mocap")]
|
||||
MocapResult,
|
||||
|
||||
/// Results from workflows
|
||||
#[serde(rename = "workflow")]
|
||||
WorkflowResult,
|
||||
|
||||
/// Results from tacotron2
|
||||
/// Applies for RVC and SVC
|
||||
#[serde(rename = "tts_result")]
|
||||
TtsResult,
|
||||
|
||||
/// Results from voice conversion (which may live in the media_files table)
|
||||
/// Applies for RVC and SVC
|
||||
#[serde(rename = "voice_conversion")]
|
||||
VoiceConversionResult,
|
||||
|
||||
/// Results from the zero shot tts (which may live in the media_files table)
|
||||
#[serde(rename = "zs_tts_result")]
|
||||
ZeroShotTtsResult,
|
||||
|
||||
/// Zs dataset which lives in the zs_voice_datasets table
|
||||
#[serde(rename = "zs_dataset")]
|
||||
ZeroShotVoiceDataset,
|
||||
|
||||
/// Zs voice which lives in the zs_voices table
|
||||
#[serde(rename = "zs_voice")]
|
||||
ZeroShotVoiceEmbedding,
|
||||
|
||||
#[serde(rename = "model_weights")]
|
||||
ModelWeights,
|
||||
|
||||
/// Files that are uploaded with no general product area they belong to. (Eg. local dev testing)
|
||||
#[serde(rename = "file_upload")]
|
||||
FileUpload,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::IdCategory;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(IdCategory::MediaFile, "media_file");
|
||||
assert_serialization(IdCategory::LipsyncAnimationResult, "lipsync_animation");
|
||||
assert_serialization(IdCategory::FaceFusionResult, "face_fusion");
|
||||
assert_serialization(IdCategory::VideoFilterResult, "video_filter");
|
||||
assert_serialization(IdCategory::LivePortraitResult, "live_portrait");
|
||||
assert_serialization(IdCategory::StudioRender, "studio_render");
|
||||
assert_serialization(IdCategory::MocapResult, "mocap");
|
||||
assert_serialization(IdCategory::WorkflowResult, "workflow");
|
||||
assert_serialization(IdCategory::TtsResult, "tts_result");
|
||||
assert_serialization(IdCategory::VoiceConversionResult, "voice_conversion");
|
||||
assert_serialization(IdCategory::ZeroShotTtsResult, "zs_tts_result");
|
||||
assert_serialization(IdCategory::ZeroShotVoiceDataset, "zs_dataset");
|
||||
assert_serialization(IdCategory::ZeroShotVoiceEmbedding, "zs_voice");
|
||||
assert_serialization(IdCategory::ModelWeights, "model_weights");
|
||||
assert_serialization(IdCategory::FileUpload, "file_upload");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("media_file", IdCategory::MediaFile);
|
||||
assert_deserialization("lipsync_animation", IdCategory::LipsyncAnimationResult);
|
||||
assert_deserialization("face_fusion", IdCategory::FaceFusionResult);
|
||||
assert_deserialization("video_filter", IdCategory::VideoFilterResult);
|
||||
assert_deserialization("live_portrait", IdCategory::LivePortraitResult);
|
||||
assert_deserialization("studio_render", IdCategory::StudioRender);
|
||||
assert_deserialization("mocap", IdCategory::MocapResult);
|
||||
assert_deserialization("workflow", IdCategory::WorkflowResult);
|
||||
assert_deserialization("tts_result", IdCategory::TtsResult);
|
||||
assert_deserialization("voice_conversion", IdCategory::VoiceConversionResult);
|
||||
assert_deserialization("zs_tts_result", IdCategory::ZeroShotTtsResult);
|
||||
assert_deserialization("zs_dataset", IdCategory::ZeroShotVoiceDataset);
|
||||
assert_deserialization("zs_voice", IdCategory::ZeroShotVoiceEmbedding);
|
||||
assert_deserialization("model_weights", IdCategory::ModelWeights);
|
||||
assert_deserialization("file_upload", IdCategory::FileUpload);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(IdCategory::iter().count(), 15);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in IdCategory::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: IdCategory = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod id_category;
|
||||
@@ -1,125 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `media_files` table in a `VARCHAR` field.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum MediaFileAnimationType {
|
||||
/// Body: No body animation or rig.
|
||||
/// Face: Rig supporting ARKit face blendshapes, or ARKit data
|
||||
ArKit,
|
||||
|
||||
/// Body: Animation or rig for MikuMikuDance (MMD).
|
||||
/// Face: No face animation.
|
||||
MikuMikuDance,
|
||||
|
||||
/// Body: Animation or rig for MikuMikuDance (MMD).
|
||||
/// Face: Animation blendshapes for ARKit.
|
||||
MikuMikuDanceArKit,
|
||||
|
||||
/// Body: Animation or rig for Mixamo
|
||||
/// Face: No face animation.
|
||||
Mixamo,
|
||||
|
||||
/// Body: Animation or rig for Mixamo
|
||||
/// Face: Animation blendshapes for ARKit.
|
||||
MixamoArKit,
|
||||
|
||||
/// Body: Animation or rig by MocapNet
|
||||
/// Face: No face animation.
|
||||
MocapNet,
|
||||
|
||||
/// Body: Animation or rig for MocapNet
|
||||
/// Face: Animation blendshapes for ARKit.
|
||||
MocapNetArKit,
|
||||
|
||||
/// Body: Animation or rig by Move.ai
|
||||
/// Face: No face animation.
|
||||
MoveAi,
|
||||
|
||||
/// Body: Animation or rig for Move.ai
|
||||
/// Face: Animation blendshapes for ARKit.
|
||||
MoveAiArKit,
|
||||
|
||||
/// Body: Animation or rig for Rigify.
|
||||
/// Face: No face animation.
|
||||
Rigify,
|
||||
|
||||
/// Body: Animation or rig for Rigify.
|
||||
/// Face: Animation blendshapes for ARKit.
|
||||
RigifyArKit,
|
||||
|
||||
/// Body: Animation or rig for Rokoko.
|
||||
/// Face: No face animation.
|
||||
Rokoko,
|
||||
|
||||
/// Body: Animation or rig for Rokoko.
|
||||
/// Face: Animation blendshapes for ARKit.
|
||||
RokokoArKit,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::MediaFileAnimationType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(MediaFileAnimationType::ArKit, "ar_kit");
|
||||
assert_serialization(MediaFileAnimationType::MikuMikuDance, "miku_miku_dance");
|
||||
assert_serialization(MediaFileAnimationType::MikuMikuDanceArKit, "miku_miku_dance_ar_kit");
|
||||
assert_serialization(MediaFileAnimationType::Mixamo, "mixamo");
|
||||
assert_serialization(MediaFileAnimationType::MixamoArKit, "mixamo_ar_kit");
|
||||
assert_serialization(MediaFileAnimationType::MocapNet, "mocap_net");
|
||||
assert_serialization(MediaFileAnimationType::MocapNetArKit, "mocap_net_ar_kit");
|
||||
assert_serialization(MediaFileAnimationType::MoveAi, "move_ai");
|
||||
assert_serialization(MediaFileAnimationType::MoveAiArKit, "move_ai_ar_kit");
|
||||
assert_serialization(MediaFileAnimationType::Rigify, "rigify");
|
||||
assert_serialization(MediaFileAnimationType::RigifyArKit, "rigify_ar_kit");
|
||||
assert_serialization(MediaFileAnimationType::Rokoko, "rokoko");
|
||||
assert_serialization(MediaFileAnimationType::RokokoArKit, "rokoko_ar_kit");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("ar_kit", MediaFileAnimationType::ArKit);
|
||||
assert_deserialization("miku_miku_dance", MediaFileAnimationType::MikuMikuDance);
|
||||
assert_deserialization("miku_miku_dance_ar_kit", MediaFileAnimationType::MikuMikuDanceArKit);
|
||||
assert_deserialization("mixamo", MediaFileAnimationType::Mixamo);
|
||||
assert_deserialization("mixamo_ar_kit", MediaFileAnimationType::MixamoArKit);
|
||||
assert_deserialization("mocap_net", MediaFileAnimationType::MocapNet);
|
||||
assert_deserialization("mocap_net_ar_kit", MediaFileAnimationType::MocapNetArKit);
|
||||
assert_deserialization("move_ai", MediaFileAnimationType::MoveAi);
|
||||
assert_deserialization("move_ai_ar_kit", MediaFileAnimationType::MoveAiArKit);
|
||||
assert_deserialization("rigify", MediaFileAnimationType::Rigify);
|
||||
assert_deserialization("rigify_ar_kit", MediaFileAnimationType::RigifyArKit);
|
||||
assert_deserialization("rokoko", MediaFileAnimationType::Rokoko);
|
||||
assert_deserialization("rokoko_ar_kit", MediaFileAnimationType::RokokoArKit);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(MediaFileAnimationType::iter().count(), 13);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in MediaFileAnimationType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: MediaFileAnimationType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `media_files` table in a `VARCHAR(16)` field.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum MediaFileClass {
|
||||
/// Unknown (default value)
|
||||
/// This will be present until we migrate all old files.
|
||||
Unknown,
|
||||
|
||||
/// Audio files: wav, mp3, etc.
|
||||
Audio,
|
||||
|
||||
/// Image files: png, jpeg, etc.
|
||||
Image,
|
||||
|
||||
/// Video files: mp4, etc.
|
||||
Video,
|
||||
|
||||
/// 3D engine data: glb, gltf, etc.
|
||||
Dimensional,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::MediaFileClass;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(MediaFileClass::Unknown, "unknown");
|
||||
assert_serialization(MediaFileClass::Audio, "audio");
|
||||
assert_serialization(MediaFileClass::Image, "image");
|
||||
assert_serialization(MediaFileClass::Video, "video");
|
||||
assert_serialization(MediaFileClass::Dimensional, "dimensional");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("unknown", MediaFileClass::Unknown);
|
||||
assert_deserialization("audio", MediaFileClass::Audio);
|
||||
assert_deserialization("image", MediaFileClass::Image);
|
||||
assert_deserialization("video", MediaFileClass::Video);
|
||||
assert_deserialization("dimensional", MediaFileClass::Dimensional);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(MediaFileClass::iter().count(), 5);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in MediaFileClass::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: MediaFileClass = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `media_files` table in a `VARCHAR` field.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum MediaFileEngineCategory {
|
||||
/// A 3D scene full of objects, characters, animations, etc.
|
||||
Scene,
|
||||
|
||||
/// A 3D character model.
|
||||
Character,
|
||||
|
||||
/// A 3D non-humanoid model, e.g. dragon, wolf, slime creature, etc.
|
||||
/// These may or may not have a skeleton that can be animated with IK/FK.
|
||||
Creature,
|
||||
|
||||
/// A 3D skeletal animation sequence that can be applied to a character,
|
||||
/// creature, etc. Typically, these use Mixamo or Move.ai.
|
||||
Animation,
|
||||
|
||||
/// A facial blend shape / shape key animation. Currently, these
|
||||
/// are 100% ARKit.
|
||||
Expression,
|
||||
|
||||
/// A large 3D object that can be used as a backdrop for a scene,
|
||||
/// a.k.a. "set", "stage", etc. These are typically self-contained
|
||||
/// locations, buildings, or environments.
|
||||
Location,
|
||||
|
||||
/// All items used to add atmosphere to a scene, e.g. furniture, plants,
|
||||
/// vehicles, radios, and certain props. (We'll reserve the word props for
|
||||
/// "hand props" later.)
|
||||
SetDressing,
|
||||
|
||||
/// A 3D object that doesn't fit with the other types.
|
||||
Object,
|
||||
|
||||
/// A 3D skybox.
|
||||
Skybox,
|
||||
|
||||
/// An Image Plane (texture that spawns as an object)
|
||||
ImagePlane,
|
||||
|
||||
/// A Video Plane (texture that spawns as an object)
|
||||
VideoPlane,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::MediaFileEngineCategory;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(MediaFileEngineCategory::Scene, "scene");
|
||||
assert_serialization(MediaFileEngineCategory::Character, "character");
|
||||
assert_serialization(MediaFileEngineCategory::Creature, "creature");
|
||||
assert_serialization(MediaFileEngineCategory::Animation, "animation");
|
||||
assert_serialization(MediaFileEngineCategory::Expression, "expression");
|
||||
assert_serialization(MediaFileEngineCategory::Location, "location");
|
||||
assert_serialization(MediaFileEngineCategory::SetDressing, "set_dressing");
|
||||
assert_serialization(MediaFileEngineCategory::Object, "object");
|
||||
assert_serialization(MediaFileEngineCategory::Skybox, "skybox");
|
||||
assert_serialization(MediaFileEngineCategory::ImagePlane, "image_plane");
|
||||
assert_serialization(MediaFileEngineCategory::VideoPlane, "video_plane");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("scene", MediaFileEngineCategory::Scene);
|
||||
assert_deserialization("character", MediaFileEngineCategory::Character);
|
||||
assert_deserialization("creature", MediaFileEngineCategory::Creature);
|
||||
assert_deserialization("animation", MediaFileEngineCategory::Animation);
|
||||
assert_deserialization("expression", MediaFileEngineCategory::Expression);
|
||||
assert_deserialization("location", MediaFileEngineCategory::Location);
|
||||
assert_deserialization("set_dressing", MediaFileEngineCategory::SetDressing);
|
||||
assert_deserialization("object", MediaFileEngineCategory::Object);
|
||||
assert_deserialization("skybox", MediaFileEngineCategory::Skybox);
|
||||
assert_deserialization("image_plane", MediaFileEngineCategory::ImagePlane);
|
||||
assert_deserialization("video_plane", MediaFileEngineCategory::VideoPlane);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(MediaFileEngineCategory::iter().count(), 11);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in MediaFileEngineCategory::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: MediaFileEngineCategory = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `media_files` table in a `VARCHAR` field.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum MediaFileOriginCategory {
|
||||
/// ML model inference output - uploaded models or zero shot.
|
||||
Inference,
|
||||
|
||||
/// Processed results - (we don't have these systems yet, but eg. trim, transcode, etc).
|
||||
Processed,
|
||||
|
||||
/// User uploaded files (from their filesystem)
|
||||
Upload,
|
||||
|
||||
/// User uploaded files recorded directly from their device (browser, mobile), typically using device APIs.
|
||||
DeviceApi,
|
||||
|
||||
/// From Storyteller Studio Engine
|
||||
#[deprecated(note="This db field should only denote file provenance, not the product.")]
|
||||
#[serde(rename = "studio")]
|
||||
StorytellerStudio,
|
||||
|
||||
/// From Storyteller Studio Engine
|
||||
#[deprecated(note = "DO NOT USE. Originally deprecated in favor of `StorytellerStudio`.")]
|
||||
StoryEngine,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::MediaFileOriginCategory;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(MediaFileOriginCategory::Inference, "inference");
|
||||
assert_serialization(MediaFileOriginCategory::Processed, "processed");
|
||||
assert_serialization(MediaFileOriginCategory::Upload, "upload");
|
||||
assert_serialization(MediaFileOriginCategory::DeviceApi, "device_api");
|
||||
assert_serialization(MediaFileOriginCategory::StorytellerStudio, "studio");
|
||||
assert_serialization(MediaFileOriginCategory::StoryEngine, "story_engine");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("inference", MediaFileOriginCategory::Inference);
|
||||
assert_deserialization("processed", MediaFileOriginCategory::Processed);
|
||||
assert_deserialization("upload", MediaFileOriginCategory::Upload);
|
||||
assert_deserialization("device_api", MediaFileOriginCategory::DeviceApi);
|
||||
assert_deserialization("studio", MediaFileOriginCategory::StorytellerStudio);
|
||||
assert_deserialization("story_engine", MediaFileOriginCategory::StoryEngine);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(MediaFileOriginCategory::iter().count(), 6);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in MediaFileOriginCategory::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: MediaFileOriginCategory = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-154
@@ -1,154 +0,0 @@
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Report certain models publicly as different from what we actually use.
|
||||
/// This is so we have an edge against the competition that might try to run
|
||||
/// the same models. This won't always make sense, but in some cases it will.
|
||||
///
|
||||
/// This was previously named `PublicMediaFileModelType` in the `enums_public` crate.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, Debug, EnumIter)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum MediaFileOriginModelType {
|
||||
// Renamed enum variants
|
||||
|
||||
/// Instead of DB `MediaFileOriginModelType::LivePortrait` ("live_portrait")
|
||||
#[serde(rename = "face_mirror")]
|
||||
FaceMirror,
|
||||
|
||||
/// Instead of DB `MediaFileOriginModelType::SadTalker` ("sad_talker")
|
||||
#[serde(rename = "face_animator")]
|
||||
FaceAnimator,
|
||||
|
||||
/// Instead of DB `MediaFileOriginModelType::FaceFusion` ("face_fusion")
|
||||
#[serde(rename = "lipsync")]
|
||||
Lipsync,
|
||||
|
||||
/// Instead of DB `MediaFileOriginModelType::StyleTTS2` ("styletts2")
|
||||
#[serde(rename = "voice_designer")]
|
||||
VoiceDesigner,
|
||||
|
||||
// Everything else is the same
|
||||
|
||||
/// RVC (v2) voice conversion models
|
||||
#[serde(rename = "rvc_v2")]
|
||||
RvcV2,
|
||||
|
||||
/// so-vits-svc voice conversion models
|
||||
#[serde(rename = "so_vits_svc")]
|
||||
SoVitsSvc,
|
||||
|
||||
#[serde(rename = "tacotron2")]
|
||||
Tacotron2,
|
||||
|
||||
#[serde(rename = "mocap_net")]
|
||||
MocapNet,
|
||||
|
||||
#[serde(rename = "stable_diffusion_1_5")]
|
||||
StableDiffusion15,
|
||||
|
||||
#[serde(rename = "gpt_sovits")]
|
||||
GptSovits,
|
||||
|
||||
#[serde(rename = "f5_tts")]
|
||||
F5TTS,
|
||||
|
||||
#[serde(rename = "seed_vc")]
|
||||
SeedVc,
|
||||
|
||||
#[serde(rename = "studio")]
|
||||
StorytellerStudio,
|
||||
|
||||
/// NB: This is GPT4o image generation
|
||||
#[serde(rename = "studio_ig")]
|
||||
StorytellerStudioImageGen,
|
||||
|
||||
#[serde(rename = "vst")]
|
||||
VideoStyleTransfer,
|
||||
|
||||
#[deprecated(note = "This is not a model type!")]
|
||||
#[serde(rename = "comfy_ui")]
|
||||
ComfyUi,
|
||||
|
||||
#[deprecated(note = "We don't use this anymore")]
|
||||
#[serde(rename = "vall_e_x")]
|
||||
VallEX,
|
||||
|
||||
#[deprecated(note = "We don't use this anymore")]
|
||||
#[serde(rename = "rerender")]
|
||||
Rerender,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::MediaFileOriginModelType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(MediaFileOriginModelType::FaceMirror, "face_mirror");
|
||||
assert_serialization(MediaFileOriginModelType::FaceAnimator, "face_animator");
|
||||
assert_serialization(MediaFileOriginModelType::Lipsync, "lipsync");
|
||||
assert_serialization(MediaFileOriginModelType::VoiceDesigner, "voice_designer");
|
||||
assert_serialization(MediaFileOriginModelType::RvcV2, "rvc_v2");
|
||||
assert_serialization(MediaFileOriginModelType::SoVitsSvc, "so_vits_svc");
|
||||
assert_serialization(MediaFileOriginModelType::Tacotron2, "tacotron2");
|
||||
assert_serialization(MediaFileOriginModelType::MocapNet, "mocap_net");
|
||||
assert_serialization(MediaFileOriginModelType::StableDiffusion15, "stable_diffusion_1_5");
|
||||
assert_serialization(MediaFileOriginModelType::GptSovits, "gpt_sovits");
|
||||
assert_serialization(MediaFileOriginModelType::F5TTS, "f5_tts");
|
||||
assert_serialization(MediaFileOriginModelType::SeedVc, "seed_vc");
|
||||
assert_serialization(MediaFileOriginModelType::StorytellerStudio, "studio");
|
||||
assert_serialization(MediaFileOriginModelType::StorytellerStudioImageGen, "studio_ig");
|
||||
assert_serialization(MediaFileOriginModelType::VideoStyleTransfer, "vst");
|
||||
assert_serialization(MediaFileOriginModelType::ComfyUi, "comfy_ui");
|
||||
assert_serialization(MediaFileOriginModelType::VallEX, "vall_e_x");
|
||||
assert_serialization(MediaFileOriginModelType::Rerender, "rerender");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("face_mirror", MediaFileOriginModelType::FaceMirror);
|
||||
assert_deserialization("face_animator", MediaFileOriginModelType::FaceAnimator);
|
||||
assert_deserialization("lipsync", MediaFileOriginModelType::Lipsync);
|
||||
assert_deserialization("voice_designer", MediaFileOriginModelType::VoiceDesigner);
|
||||
assert_deserialization("rvc_v2", MediaFileOriginModelType::RvcV2);
|
||||
assert_deserialization("so_vits_svc", MediaFileOriginModelType::SoVitsSvc);
|
||||
assert_deserialization("tacotron2", MediaFileOriginModelType::Tacotron2);
|
||||
assert_deserialization("mocap_net", MediaFileOriginModelType::MocapNet);
|
||||
assert_deserialization("stable_diffusion_1_5", MediaFileOriginModelType::StableDiffusion15);
|
||||
assert_deserialization("gpt_sovits", MediaFileOriginModelType::GptSovits);
|
||||
assert_deserialization("f5_tts", MediaFileOriginModelType::F5TTS);
|
||||
assert_deserialization("seed_vc", MediaFileOriginModelType::SeedVc);
|
||||
assert_deserialization("studio", MediaFileOriginModelType::StorytellerStudio);
|
||||
assert_deserialization("studio_ig", MediaFileOriginModelType::StorytellerStudioImageGen);
|
||||
assert_deserialization("vst", MediaFileOriginModelType::VideoStyleTransfer);
|
||||
assert_deserialization("comfy_ui", MediaFileOriginModelType::ComfyUi);
|
||||
assert_deserialization("vall_e_x", MediaFileOriginModelType::VallEX);
|
||||
assert_deserialization("rerender", MediaFileOriginModelType::Rerender);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(MediaFileOriginModelType::iter().count(), 18);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in MediaFileOriginModelType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: MediaFileOriginModelType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-148
@@ -1,148 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `media_files` table in `VARCHAR(16)` field `origin_product_category`.
|
||||
///
|
||||
/// This value indicates what product originally created the media file. (Not the ML model or
|
||||
/// user upload process.) This will let us scope media files to the product that generated them
|
||||
/// and filter them out of unrelated products if necessary (eg. a user probably doesn't want
|
||||
/// "Voice Designer" dataset samples in a video generation flow.)
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum MediaFileOriginProductCategory {
|
||||
/// Unknown which product is attached to the file (generated the file, the file was
|
||||
/// uploaded on behalf of, etc.)
|
||||
#[serde(rename = "unknown")]
|
||||
Unknown,
|
||||
|
||||
/// Media files created by (or uploaded for) the Face Animator product.
|
||||
/// The underlying model could be SadTalker, Wav2Lip, or some future model
|
||||
#[serde(rename = "face_animator")]
|
||||
FaceAnimator,
|
||||
|
||||
/// Media files created by Face Fusion (lipsync)
|
||||
#[serde(rename = "face_fusion")]
|
||||
FaceFusion,
|
||||
|
||||
/// Media files created by Face Mirror (currently powered by Live Portrait)
|
||||
#[serde(rename = "face_mirror")]
|
||||
FaceMirror,
|
||||
|
||||
/// Video style transfer
|
||||
#[serde(rename = "vst")]
|
||||
VideoStyleTransfer,
|
||||
|
||||
/// Image Studio
|
||||
#[serde(rename = "image_studio")]
|
||||
ImageStudio,
|
||||
|
||||
/// Storyteller Studio
|
||||
#[serde(rename = "studio")]
|
||||
StorytellerStudio,
|
||||
|
||||
/// Text to speech (Tacotron2, not voice designer / VallE-X)
|
||||
#[serde(rename = "tts")]
|
||||
TextToSpeech,
|
||||
|
||||
/// Voice conversion (either RVC or SVC)
|
||||
#[serde(rename = "voice_conversion")]
|
||||
VoiceConversion,
|
||||
|
||||
/// Media files created by (or uploaded for) the Zero Shot voice product.
|
||||
#[serde(rename = "zs_voice")]
|
||||
ZeroShotVoice,
|
||||
|
||||
// Mocap
|
||||
#[serde(rename = "mocap")]
|
||||
Mocap,
|
||||
|
||||
#[serde(rename = "image_gen")]
|
||||
ImageGeneration,
|
||||
|
||||
#[serde(rename = "video_gen")]
|
||||
VideoGeneration,
|
||||
|
||||
#[serde(rename = "world_gen")]
|
||||
WorldGeneration,
|
||||
|
||||
// Media files for video filters
|
||||
#[deprecated(note = "This isn't relevant product surface area anymore")]
|
||||
#[serde(rename = "video_filter")]
|
||||
VideoFilter,
|
||||
|
||||
// Workflow
|
||||
#[deprecated(note = "Use studio and VST instead.")]
|
||||
#[serde(rename = "workflow")]
|
||||
Workflow,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::MediaFileOriginProductCategory;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(MediaFileOriginProductCategory::Unknown, "unknown");
|
||||
assert_serialization(MediaFileOriginProductCategory::FaceAnimator, "face_animator");
|
||||
assert_serialization(MediaFileOriginProductCategory::FaceFusion, "face_fusion");
|
||||
assert_serialization(MediaFileOriginProductCategory::FaceMirror, "face_mirror");
|
||||
assert_serialization(MediaFileOriginProductCategory::VideoStyleTransfer, "vst");
|
||||
assert_serialization(MediaFileOriginProductCategory::ImageStudio, "image_studio");
|
||||
assert_serialization(MediaFileOriginProductCategory::StorytellerStudio, "studio");
|
||||
assert_serialization(MediaFileOriginProductCategory::TextToSpeech, "tts");
|
||||
assert_serialization(MediaFileOriginProductCategory::VoiceConversion, "voice_conversion");
|
||||
assert_serialization(MediaFileOriginProductCategory::ZeroShotVoice, "zs_voice");
|
||||
assert_serialization(MediaFileOriginProductCategory::Mocap, "mocap");
|
||||
assert_serialization(MediaFileOriginProductCategory::ImageGeneration, "image_gen");
|
||||
assert_serialization(MediaFileOriginProductCategory::VideoGeneration, "video_gen");
|
||||
assert_serialization(MediaFileOriginProductCategory::WorldGeneration, "world_gen");
|
||||
assert_serialization(MediaFileOriginProductCategory::VideoFilter, "video_filter");
|
||||
assert_serialization(MediaFileOriginProductCategory::Workflow, "workflow");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("unknown", MediaFileOriginProductCategory::Unknown);
|
||||
assert_deserialization("face_animator", MediaFileOriginProductCategory::FaceAnimator);
|
||||
assert_deserialization("face_fusion", MediaFileOriginProductCategory::FaceFusion);
|
||||
assert_deserialization("face_mirror", MediaFileOriginProductCategory::FaceMirror);
|
||||
assert_deserialization("vst", MediaFileOriginProductCategory::VideoStyleTransfer);
|
||||
assert_deserialization("image_studio", MediaFileOriginProductCategory::ImageStudio);
|
||||
assert_deserialization("studio", MediaFileOriginProductCategory::StorytellerStudio);
|
||||
assert_deserialization("tts", MediaFileOriginProductCategory::TextToSpeech);
|
||||
assert_deserialization("voice_conversion", MediaFileOriginProductCategory::VoiceConversion);
|
||||
assert_deserialization("zs_voice", MediaFileOriginProductCategory::ZeroShotVoice);
|
||||
assert_deserialization("mocap", MediaFileOriginProductCategory::Mocap);
|
||||
assert_deserialization("image_gen", MediaFileOriginProductCategory::ImageGeneration);
|
||||
assert_deserialization("video_gen", MediaFileOriginProductCategory::VideoGeneration);
|
||||
assert_deserialization("world_gen", MediaFileOriginProductCategory::WorldGeneration);
|
||||
assert_deserialization("video_filter", MediaFileOriginProductCategory::VideoFilter);
|
||||
assert_deserialization("workflow", MediaFileOriginProductCategory::Workflow);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(MediaFileOriginProductCategory::iter().count(), 16);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in MediaFileOriginProductCategory::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: MediaFileOriginProductCategory = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `media_files` table in a `VARCHAR` field.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[deprecated(note = "This was primarily for Bevy")]
|
||||
|
||||
pub enum MediaFileSubtype {
|
||||
/// NB: MediaFileSubtype is deprecated.
|
||||
/// This should signal that the field / enum is fully deprecated.
|
||||
Deprecated,
|
||||
|
||||
// TODO(bt,2024-04-22): Deprecated (migrate)
|
||||
/// Animation file from Mixamo
|
||||
/// Primarily used for FBX and GLB.
|
||||
Mixamo,
|
||||
|
||||
// TODO(bt,2024-04-22): Deprecated (migrate)
|
||||
/// Animation file from MocapNet
|
||||
/// Primarily used for BVH.
|
||||
MocapNet,
|
||||
|
||||
// TODO(bt,2024-04-22): Deprecated
|
||||
/// Generic animation case
|
||||
/// Used for BVH files, but can also pertain to animation-only files of other types.
|
||||
AnimationOnly,
|
||||
|
||||
// TODO(bt,2024-04-22): Deprecated
|
||||
/// Generic 3D scene file.
|
||||
/// Can pertain to glTF, glB, FBX, etc.
|
||||
SceneImport,
|
||||
|
||||
// TODO(bt,2024-04-22): Deprecated
|
||||
/// Native Storyteller scene format.
|
||||
/// Typically stored in a `.scn.ron` file.
|
||||
StorytellerScene,
|
||||
|
||||
/// A 3D scene full of objects, characters, animations, etc.
|
||||
Scene,
|
||||
|
||||
/// A 3D character model.
|
||||
Character,
|
||||
|
||||
/// A 3D animation.
|
||||
Animation,
|
||||
|
||||
/// A 3D object that doesn't fit with the other types.
|
||||
Object,
|
||||
|
||||
/// A 3D skybox.
|
||||
Skybox,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::MediaFileSubtype;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(MediaFileSubtype::Deprecated, "deprecated");
|
||||
assert_serialization(MediaFileSubtype::Mixamo, "mixamo");
|
||||
assert_serialization(MediaFileSubtype::MocapNet, "mocap_net");
|
||||
assert_serialization(MediaFileSubtype::AnimationOnly, "animation_only");
|
||||
assert_serialization(MediaFileSubtype::SceneImport, "scene_import");
|
||||
assert_serialization(MediaFileSubtype::StorytellerScene, "storyteller_scene");
|
||||
assert_serialization(MediaFileSubtype::Scene, "scene");
|
||||
assert_serialization(MediaFileSubtype::Character, "character");
|
||||
assert_serialization(MediaFileSubtype::Animation, "animation");
|
||||
assert_serialization(MediaFileSubtype::Object, "object");
|
||||
assert_serialization(MediaFileSubtype::Skybox, "skybox");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("deprecated", MediaFileSubtype::Deprecated);
|
||||
assert_deserialization("mixamo", MediaFileSubtype::Mixamo);
|
||||
assert_deserialization("mocap_net", MediaFileSubtype::MocapNet);
|
||||
assert_deserialization("animation_only", MediaFileSubtype::AnimationOnly);
|
||||
assert_deserialization("scene_import", MediaFileSubtype::SceneImport);
|
||||
assert_deserialization("storyteller_scene", MediaFileSubtype::StorytellerScene);
|
||||
assert_deserialization("scene", MediaFileSubtype::Scene);
|
||||
assert_deserialization("character", MediaFileSubtype::Character);
|
||||
assert_deserialization("animation", MediaFileSubtype::Animation);
|
||||
assert_deserialization("object", MediaFileSubtype::Object);
|
||||
assert_deserialization("skybox", MediaFileSubtype::Skybox);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(MediaFileSubtype::iter().count(), 11);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in MediaFileSubtype::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: MediaFileSubtype = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,248 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `media_files` table in a `VARCHAR(16)` field.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum MediaFileType {
|
||||
// TODO(bt): Deprecate and split into audio mime types; use media_class to represent broadly
|
||||
/// Audio files: wav, mp3, etc.
|
||||
#[deprecated]
|
||||
Audio,
|
||||
|
||||
// TODO(bt): Deprecate and split into image mime types; use media_class to represent broadly
|
||||
/// Image files: png, jpeg, etc.
|
||||
#[deprecated]
|
||||
Image,
|
||||
|
||||
// TODO(bt): Deprecate and split into video mime types; use media_class to represent broadly
|
||||
/// Video files: mp4, etc.
|
||||
#[deprecated]
|
||||
Video,
|
||||
|
||||
/// BVH files (for Bevy)
|
||||
/// NB: This is the new type to migrate to.
|
||||
Bvh,
|
||||
|
||||
/// FBX files (for Bevy)
|
||||
Fbx,
|
||||
|
||||
/// glTF binary files (for Bevy)
|
||||
Glb,
|
||||
|
||||
/// glTF files (for Bevy)
|
||||
Gltf,
|
||||
|
||||
/// Spz Gaussian splats
|
||||
/// This is a standard file format for Gaussian Splats, used by World Labs.
|
||||
/// The mime type is application/gzip.
|
||||
Spz,
|
||||
|
||||
/// Bevy's scene files (in RON; Rusty Object Notation)
|
||||
/// This will be replaced with another format in future versions of Bevy
|
||||
SceneRon,
|
||||
|
||||
/// Alternate scene files.
|
||||
SceneJson,
|
||||
|
||||
/// "Polygon Model Data", character data for MikuMikuDance
|
||||
/// See: https://mikumikudance.fandom.com/wiki/MMD:Polygon_Model_Data
|
||||
Pmd,
|
||||
|
||||
/// "Vocaloid Motion Data", animation data for MikuMikuDance
|
||||
/// See: https://mikumikudance.fandom.com/wiki/VMD_file_format
|
||||
Vmd,
|
||||
|
||||
/// "Polygon Model eXtend", character data from MikuMikuDance
|
||||
/// NB: this is often associated with external files for textures, which
|
||||
/// we'll store in the same bucket path.
|
||||
/// See: https://mikumikudance.fandom.com/wiki/MMD:Polygon_Model_eXtend
|
||||
Pmx,
|
||||
|
||||
/// CSV format. (We use these for ArKit)
|
||||
Csv,
|
||||
|
||||
/// Jpeg images
|
||||
Jpg,
|
||||
|
||||
/// Png images
|
||||
Png,
|
||||
|
||||
/// Gif images
|
||||
Gif,
|
||||
|
||||
/// Mp4 videos
|
||||
Mp4,
|
||||
|
||||
/// Wav audio
|
||||
Wav,
|
||||
|
||||
/// Mp3 audio
|
||||
Mp3,
|
||||
}
|
||||
|
||||
impl MediaFileType {
|
||||
/// Jpeg and Png are the most widely supported static image formats for AI inference.
|
||||
/// Webp, Webm, and Gif aren't as widely supported, so we don't include them here.
|
||||
pub fn is_jpg_or_png(&self) -> bool {
|
||||
matches!(self, Self::Jpg | Self::Png)
|
||||
}
|
||||
|
||||
/// A little bit less strict than `is_jpg_or_png`, this includes the legacy `Image` type.
|
||||
pub fn is_jpg_or_png_or_legacy_image(&self) -> bool {
|
||||
matches!(self, Self::Jpg | Self::Png | Self::Image)
|
||||
}
|
||||
|
||||
/// Returns the `MediaFileType` if the mime type matches one of the known types.
|
||||
/// This is not exhaustive.
|
||||
pub fn try_from_mime_type(mime_type: &str) -> Option<Self> {
|
||||
match mime_type {
|
||||
"image/jpeg" => Some(Self::Jpg),
|
||||
"image/png" => Some(Self::Png),
|
||||
"video/mp4" => Some(Self::Mp4),
|
||||
"model/gltf-binary" => Some(Self::Glb),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::MediaFileType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(MediaFileType::Audio, "audio");
|
||||
assert_serialization(MediaFileType::Image, "image");
|
||||
assert_serialization(MediaFileType::Video, "video");
|
||||
assert_serialization(MediaFileType::Bvh, "bvh");
|
||||
assert_serialization(MediaFileType::Fbx, "fbx");
|
||||
assert_serialization(MediaFileType::Glb, "glb");
|
||||
assert_serialization(MediaFileType::Gltf, "gltf");
|
||||
assert_serialization(MediaFileType::Spz, "spz");
|
||||
assert_serialization(MediaFileType::SceneRon, "scene_ron");
|
||||
assert_serialization(MediaFileType::SceneJson, "scene_json");
|
||||
assert_serialization(MediaFileType::Pmd, "pmd");
|
||||
assert_serialization(MediaFileType::Vmd, "vmd");
|
||||
assert_serialization(MediaFileType::Pmx, "pmx");
|
||||
assert_serialization(MediaFileType::Csv, "csv");
|
||||
assert_serialization(MediaFileType::Jpg, "jpg");
|
||||
assert_serialization(MediaFileType::Png, "png");
|
||||
assert_serialization(MediaFileType::Gif, "gif");
|
||||
assert_serialization(MediaFileType::Mp4, "mp4");
|
||||
assert_serialization(MediaFileType::Wav, "wav");
|
||||
assert_serialization(MediaFileType::Mp3, "mp3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("audio", MediaFileType::Audio);
|
||||
assert_deserialization("image", MediaFileType::Image);
|
||||
assert_deserialization("video", MediaFileType::Video);
|
||||
assert_deserialization("bvh", MediaFileType::Bvh);
|
||||
assert_deserialization("fbx", MediaFileType::Fbx);
|
||||
assert_deserialization("glb", MediaFileType::Glb);
|
||||
assert_deserialization("gltf", MediaFileType::Gltf);
|
||||
assert_deserialization("spz", MediaFileType::Spz);
|
||||
assert_deserialization("scene_ron", MediaFileType::SceneRon);
|
||||
assert_deserialization("scene_json", MediaFileType::SceneJson);
|
||||
assert_deserialization("pmd", MediaFileType::Pmd);
|
||||
assert_deserialization("vmd", MediaFileType::Vmd);
|
||||
assert_deserialization("pmx", MediaFileType::Pmx);
|
||||
assert_deserialization("csv", MediaFileType::Csv);
|
||||
assert_deserialization("jpg", MediaFileType::Jpg);
|
||||
assert_deserialization("png", MediaFileType::Png);
|
||||
assert_deserialization("gif", MediaFileType::Gif);
|
||||
assert_deserialization("mp4", MediaFileType::Mp4);
|
||||
assert_deserialization("wav", MediaFileType::Wav);
|
||||
assert_deserialization("mp3", MediaFileType::Mp3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(MediaFileType::iter().count(), 20);
|
||||
}
|
||||
}
|
||||
|
||||
mod test_is_jpg_or_png {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn true_for_jpg_and_png() {
|
||||
assert!(MediaFileType::Jpg.is_jpg_or_png());
|
||||
assert!(MediaFileType::Png.is_jpg_or_png());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn false_for_everything_else() {
|
||||
for variant in MediaFileType::iter() {
|
||||
if matches!(variant, MediaFileType::Jpg | MediaFileType::Png) {
|
||||
continue;
|
||||
}
|
||||
assert!(!variant.is_jpg_or_png(), "Expected {:?} to be false", variant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod test_is_jpg_or_png_or_legacy_image {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn true_for_jpg_png_image() {
|
||||
assert!(MediaFileType::Jpg.is_jpg_or_png_or_legacy_image());
|
||||
assert!(MediaFileType::Png.is_jpg_or_png_or_legacy_image());
|
||||
assert!(MediaFileType::Image.is_jpg_or_png_or_legacy_image());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn false_for_everything_else() {
|
||||
for variant in MediaFileType::iter() {
|
||||
if matches!(variant, MediaFileType::Jpg | MediaFileType::Png | MediaFileType::Image) {
|
||||
continue;
|
||||
}
|
||||
assert!(!variant.is_jpg_or_png_or_legacy_image(), "Expected {:?} to be false", variant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod test_try_from_mime_type {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn known_mime_types() {
|
||||
assert_eq!(MediaFileType::try_from_mime_type("image/jpeg"), Some(MediaFileType::Jpg));
|
||||
assert_eq!(MediaFileType::try_from_mime_type("image/png"), Some(MediaFileType::Png));
|
||||
assert_eq!(MediaFileType::try_from_mime_type("video/mp4"), Some(MediaFileType::Mp4));
|
||||
assert_eq!(MediaFileType::try_from_mime_type("model/gltf-binary"), Some(MediaFileType::Glb));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_mime_types_return_none() {
|
||||
assert_eq!(MediaFileType::try_from_mime_type("audio/wav"), None);
|
||||
assert_eq!(MediaFileType::try_from_mime_type("image/gif"), None);
|
||||
assert_eq!(MediaFileType::try_from_mime_type("text/plain"), None);
|
||||
assert_eq!(MediaFileType::try_from_mime_type(""), None);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in MediaFileType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: MediaFileType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
pub mod media_file_animation_type;
|
||||
pub mod media_file_class;
|
||||
pub mod media_file_engine_category;
|
||||
pub mod media_file_origin_category;
|
||||
pub mod media_file_origin_model_type;
|
||||
pub mod media_file_origin_product_category;
|
||||
pub mod media_file_subtype;
|
||||
pub mod media_file_type;
|
||||
@@ -1,64 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `media_uploads` table in a `VARCHAR` field `media_source`.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum MediaUploadSource {
|
||||
/// Eg. browser javascript APIs to access the microphone, webcam, etc.
|
||||
#[serde(rename = "device_api")]
|
||||
DeviceApi,
|
||||
|
||||
/// Uploaded files from the filesystem
|
||||
#[serde(rename = "file")]
|
||||
File,
|
||||
|
||||
/// Unknown sources
|
||||
#[serde(rename = "unknown")]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::MediaUploadSource;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(MediaUploadSource::DeviceApi, "device_api");
|
||||
assert_serialization(MediaUploadSource::File, "file");
|
||||
assert_serialization(MediaUploadSource::Unknown, "unknown");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("device_api", MediaUploadSource::DeviceApi);
|
||||
assert_deserialization("file", MediaUploadSource::File);
|
||||
assert_deserialization("unknown", MediaUploadSource::Unknown);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(MediaUploadSource::iter().count(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in MediaUploadSource::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: MediaUploadSource = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `media_uploads` table in a `VARCHAR` field.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
|
||||
pub enum MediaUploadType {
|
||||
/// Audio files: wav, mp3, etc.
|
||||
Audio,
|
||||
|
||||
/// Image files: png, jpeg, etc.
|
||||
Image,
|
||||
|
||||
/// Video files: mp4, etc.
|
||||
Video,
|
||||
|
||||
// Binary files: safetensors ... weights, etc.
|
||||
Binary,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::MediaUploadType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(MediaUploadType::Audio, "audio");
|
||||
assert_serialization(MediaUploadType::Image, "image");
|
||||
assert_serialization(MediaUploadType::Video, "video");
|
||||
assert_serialization(MediaUploadType::Binary, "binary");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("audio", MediaUploadType::Audio);
|
||||
assert_deserialization("image", MediaUploadType::Image);
|
||||
assert_deserialization("video", MediaUploadType::Video);
|
||||
assert_deserialization("binary", MediaUploadType::Binary);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(MediaUploadType::iter().count(), 4);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in MediaUploadType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: MediaUploadType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
pub mod media_upload_source;
|
||||
pub mod media_upload_type;
|
||||
@@ -1,30 +0,0 @@
|
||||
pub mod audit_logs;
|
||||
pub mod batch_generations;
|
||||
pub mod beta_keys;
|
||||
pub mod comments;
|
||||
pub mod email_sender_jobs;
|
||||
pub mod entity_stats;
|
||||
pub mod featured_items;
|
||||
pub mod generic_download_jobs;
|
||||
pub mod generic_inference_jobs;
|
||||
pub mod generic_synthetic_ids;
|
||||
pub mod media_files;
|
||||
pub mod media_uploads;
|
||||
pub mod model_categories;
|
||||
pub mod model_weights;
|
||||
pub mod prompt_context_items;
|
||||
pub mod prompts;
|
||||
pub mod tag_uses;
|
||||
pub mod trending_model_analytics;
|
||||
pub mod tts_models;
|
||||
pub mod tts_render_tasks;
|
||||
pub mod usages;
|
||||
pub mod user_bookmarks;
|
||||
pub mod user_ratings;
|
||||
pub mod users;
|
||||
pub mod voice_conversion_models;
|
||||
pub mod voice_conversion_results;
|
||||
pub mod wallet_ledger_entries;
|
||||
pub mod web_rendition_targets;
|
||||
pub mod web_scraping_targets;
|
||||
pub mod zs_voices;
|
||||
@@ -1 +0,0 @@
|
||||
pub mod model_type;
|
||||
@@ -1,55 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `model_categories` table in an `ENUM` field.
|
||||
/// (*WE WANT TO STOP USING ENUM FIELDS DUE TO MIGRATION ISSUES*)
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
|
||||
pub enum ModelType {
|
||||
Tts,
|
||||
W2l,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ModelType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(ModelType::Tts, "tts");
|
||||
assert_serialization(ModelType::W2l, "w2l");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("tts", ModelType::Tts);
|
||||
assert_deserialization("w2l", ModelType::W2l);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(ModelType::iter().count(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in ModelType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: ModelType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
pub mod weights_category;
|
||||
pub mod weights_file_type;
|
||||
pub mod weights_types;
|
||||
@@ -1,64 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum WeightsCategory {
|
||||
#[serde(rename = "image_generation")]
|
||||
ImageGeneration,
|
||||
#[serde(rename = "text_to_speech")]
|
||||
TextToSpeech,
|
||||
#[serde(rename = "vocoder")]
|
||||
Vocoder,
|
||||
#[serde(rename = "voice_conversion")]
|
||||
VoiceConversion,
|
||||
#[serde(rename = "workflow_config")]
|
||||
WorkflowConfig,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::WeightsCategory;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(WeightsCategory::ImageGeneration, "image_generation");
|
||||
assert_serialization(WeightsCategory::TextToSpeech, "text_to_speech");
|
||||
assert_serialization(WeightsCategory::Vocoder, "vocoder");
|
||||
assert_serialization(WeightsCategory::VoiceConversion, "voice_conversion");
|
||||
assert_serialization(WeightsCategory::WorkflowConfig, "workflow_config");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("image_generation", WeightsCategory::ImageGeneration);
|
||||
assert_deserialization("text_to_speech", WeightsCategory::TextToSpeech);
|
||||
assert_deserialization("vocoder", WeightsCategory::Vocoder);
|
||||
assert_deserialization("voice_conversion", WeightsCategory::VoiceConversion);
|
||||
assert_deserialization("workflow_config", WeightsCategory::WorkflowConfig);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(WeightsCategory::iter().count(), 5);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in WeightsCategory::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: WeightsCategory = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
// TODO we will need to scan the checkpoints for malicious code. We can't just trust the file extension.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum WeightsFileType {
|
||||
#[serde(rename = "checkpoint")]
|
||||
Checkpoint,
|
||||
#[serde(rename = "safetensors")]
|
||||
SafeTensors,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::WeightsFileType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(WeightsFileType::Checkpoint, "checkpoint");
|
||||
assert_serialization(WeightsFileType::SafeTensors, "safetensors");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("checkpoint", WeightsFileType::Checkpoint);
|
||||
assert_deserialization("safetensors", WeightsFileType::SafeTensors);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(WeightsFileType::iter().count(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in WeightsFileType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: WeightsFileType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Report certain models publicly as different from what we actually use.
|
||||
///
|
||||
/// Previously named `PublicWeightsType` in the `enums_public` crate.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, Debug, EnumIter)]
|
||||
|
||||
pub enum WeightsType {
|
||||
// Renamed enum variants
|
||||
|
||||
/// Instead of DB `WeightsType::GptSoVits` ("gpt_so_vits")
|
||||
#[serde(rename = "tacotron2.5")]
|
||||
Tacotron2_5,
|
||||
|
||||
// Everything else is the same
|
||||
|
||||
#[serde(rename = "hifigan_tt2")]
|
||||
HifiganTacotron2,
|
||||
#[serde(rename = "rvc_v2")]
|
||||
RvcV2,
|
||||
#[serde(rename = "sd_1.5")]
|
||||
StableDiffusion15,
|
||||
#[serde(rename = "sdxl")]
|
||||
StableDiffusionXL,
|
||||
#[serde(rename = "so_vits_svc")]
|
||||
SoVitsSvc,
|
||||
#[serde(rename = "tt2")]
|
||||
Tacotron2,
|
||||
#[serde(rename = "loRA")]
|
||||
LoRA,
|
||||
#[serde(rename = "vall_e")]
|
||||
VallE,
|
||||
#[serde(rename = "comfy_ui")]
|
||||
ComfyUi,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::WeightsType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(WeightsType::Tacotron2_5, "tacotron2.5");
|
||||
assert_serialization(WeightsType::HifiganTacotron2, "hifigan_tt2");
|
||||
assert_serialization(WeightsType::RvcV2, "rvc_v2");
|
||||
assert_serialization(WeightsType::StableDiffusion15, "sd_1.5");
|
||||
assert_serialization(WeightsType::StableDiffusionXL, "sdxl");
|
||||
assert_serialization(WeightsType::SoVitsSvc, "so_vits_svc");
|
||||
assert_serialization(WeightsType::Tacotron2, "tt2");
|
||||
assert_serialization(WeightsType::LoRA, "loRA");
|
||||
assert_serialization(WeightsType::VallE, "vall_e");
|
||||
assert_serialization(WeightsType::ComfyUi, "comfy_ui");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("tacotron2.5", WeightsType::Tacotron2_5);
|
||||
assert_deserialization("hifigan_tt2", WeightsType::HifiganTacotron2);
|
||||
assert_deserialization("rvc_v2", WeightsType::RvcV2);
|
||||
assert_deserialization("sd_1.5", WeightsType::StableDiffusion15);
|
||||
assert_deserialization("sdxl", WeightsType::StableDiffusionXL);
|
||||
assert_deserialization("so_vits_svc", WeightsType::SoVitsSvc);
|
||||
assert_deserialization("tt2", WeightsType::Tacotron2);
|
||||
assert_deserialization("loRA", WeightsType::LoRA);
|
||||
assert_deserialization("vall_e", WeightsType::VallE);
|
||||
assert_deserialization("comfy_ui", WeightsType::ComfyUi);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(WeightsType::iter().count(), 10);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in WeightsType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: WeightsType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod prompt_context_semantic_type;
|
||||
-102
@@ -1,102 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/*
|
||||
Current DB values - this is in conflict with API serializations. Need to fix!
|
||||
imgref
|
||||
imgsrc
|
||||
imgmask
|
||||
vid_start_frame
|
||||
vid_end_frame
|
||||
vidref
|
||||
*/
|
||||
|
||||
/// Used in the `prompt_context_items` table in a `VARCHAR(16)` field.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum PromptContextSemanticType {
|
||||
/// Image-to-Video starting frame
|
||||
VidStartFrame,
|
||||
|
||||
/// Image-to-Video ending frame
|
||||
VidEndFrame,
|
||||
|
||||
/// Reference image for video generation (e.g. Seedance "vidref" mode)
|
||||
VidRef,
|
||||
|
||||
/// Source image, eg. for inpainting.
|
||||
Imgsrc,
|
||||
|
||||
/// Image mask, eg. for inpainting.
|
||||
Imgmask,
|
||||
|
||||
/// Standard image reference without a semantic type (e.g. Sora/ChatGPT 4o/gpt-image-1)
|
||||
Imgref,
|
||||
|
||||
ImgrefCharacter,
|
||||
ImgrefStyle,
|
||||
ImgrefBg,
|
||||
|
||||
/// Audio reference (e.g. for audio-to-video generation)
|
||||
Audioref,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::PromptContextSemanticType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(PromptContextSemanticType::VidStartFrame, "vid_start_frame");
|
||||
assert_serialization(PromptContextSemanticType::VidEndFrame, "vid_end_frame");
|
||||
assert_serialization(PromptContextSemanticType::VidRef, "vid_ref");
|
||||
assert_serialization(PromptContextSemanticType::Imgsrc, "imgsrc");
|
||||
assert_serialization(PromptContextSemanticType::Imgmask, "imgmask");
|
||||
assert_serialization(PromptContextSemanticType::Imgref, "imgref");
|
||||
assert_serialization(PromptContextSemanticType::ImgrefCharacter, "imgref_character");
|
||||
assert_serialization(PromptContextSemanticType::ImgrefStyle, "imgref_style");
|
||||
assert_serialization(PromptContextSemanticType::ImgrefBg, "imgref_bg");
|
||||
assert_serialization(PromptContextSemanticType::Audioref, "audioref");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("vid_start_frame", PromptContextSemanticType::VidStartFrame);
|
||||
assert_deserialization("vid_end_frame", PromptContextSemanticType::VidEndFrame);
|
||||
assert_deserialization("vid_ref", PromptContextSemanticType::VidRef);
|
||||
assert_deserialization("imgsrc", PromptContextSemanticType::Imgsrc);
|
||||
assert_deserialization("imgmask", PromptContextSemanticType::Imgmask);
|
||||
assert_deserialization("imgref", PromptContextSemanticType::Imgref);
|
||||
assert_deserialization("imgref_character", PromptContextSemanticType::ImgrefCharacter);
|
||||
assert_deserialization("imgref_style", PromptContextSemanticType::ImgrefStyle);
|
||||
assert_deserialization("imgref_bg", PromptContextSemanticType::ImgrefBg);
|
||||
assert_deserialization("audioref", PromptContextSemanticType::Audioref);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(PromptContextSemanticType::iter().count(), 10);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in PromptContextSemanticType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: PromptContextSemanticType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod prompt_type;
|
||||
@@ -1,64 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `prompts` table in a `VARCHAR(16)` field.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum PromptType {
|
||||
/// Artcraft (App)
|
||||
ArtcraftApp,
|
||||
|
||||
/// Stable diffusion
|
||||
#[deprecated]
|
||||
StableDiffusion,
|
||||
|
||||
/// Comfy UI
|
||||
#[deprecated]
|
||||
ComfyUi,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::PromptType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(PromptType::ArtcraftApp, "artcraft_app");
|
||||
assert_serialization(PromptType::StableDiffusion, "stable_diffusion");
|
||||
assert_serialization(PromptType::ComfyUi, "comfy_ui");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("artcraft_app", PromptType::ArtcraftApp);
|
||||
assert_deserialization("stable_diffusion", PromptType::StableDiffusion);
|
||||
assert_deserialization("comfy_ui", PromptType::ComfyUi);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(PromptType::iter().count(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in PromptType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: PromptType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod tag_use_entity_type;
|
||||
@@ -1,56 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `tag_uses` table in a `VARCHAR(32)` field named `entity_type`.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum TagUseEntityType {
|
||||
/// Media files
|
||||
#[serde(rename = "media_file")]
|
||||
MediaFile,
|
||||
|
||||
/// Model weights
|
||||
#[serde(rename = "model_weight")]
|
||||
ModelWeight,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::TagUseEntityType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(TagUseEntityType::MediaFile, "media_file");
|
||||
assert_serialization(TagUseEntityType::ModelWeight, "model_weight");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("media_file", TagUseEntityType::MediaFile);
|
||||
assert_deserialization("model_weight", TagUseEntityType::ModelWeight);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(TagUseEntityType::iter().count(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in TagUseEntityType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: TagUseEntityType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
pub mod model_type;
|
||||
pub mod window_name;
|
||||
@@ -1,55 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `trending_model_analytics` table in a `VARCHAR` field.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
|
||||
pub enum ModelType {
|
||||
/// TTS models
|
||||
Tts,
|
||||
|
||||
// NB: It's assumed we'll use this same system to track
|
||||
// trending VC models too, so the next type would be "VC".
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ModelType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(ModelType::Tts, "tts");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("tts", ModelType::Tts);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(ModelType::iter().count(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in ModelType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: ModelType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `window_name` table in a `VARCHAR` field.
|
||||
///
|
||||
/// Contrary to most of this crate and unlike most "enum"-types
|
||||
/// that are inflexible, new window names can be added/removed
|
||||
/// without breaking too much.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum WindowName {
|
||||
/// Analytics over the last three hours
|
||||
#[serde(rename = "last_3_hours")]
|
||||
Last3Hours,
|
||||
|
||||
/// Analytics over the last three hours
|
||||
#[serde(rename = "last_3_days")]
|
||||
Last3Days,
|
||||
|
||||
/// Analytics over all historical records
|
||||
#[serde(rename = "all_time")]
|
||||
AllTime,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::WindowName;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(WindowName::Last3Hours, "last_3_hours");
|
||||
assert_serialization(WindowName::Last3Days, "last_3_days");
|
||||
assert_serialization(WindowName::AllTime, "all_time");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("last_3_hours", WindowName::Last3Hours);
|
||||
assert_deserialization("last_3_days", WindowName::Last3Days);
|
||||
assert_deserialization("all_time", WindowName::AllTime);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(WindowName::iter().count(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in WindowName::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: WindowName = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod tts_model_type;
|
||||
@@ -1,57 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `tts_models` table in an `ENUM` field.
|
||||
/// -- Furthermore -- not all enum values are represented !!
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum TtsModelType {
|
||||
#[serde(rename = "tacotron2")]
|
||||
Tacotron2,
|
||||
|
||||
#[serde(rename = "vits")]
|
||||
Vits,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::TtsModelType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(TtsModelType::Tacotron2, "tacotron2");
|
||||
assert_serialization(TtsModelType::Vits, "vits");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("tacotron2", TtsModelType::Tacotron2);
|
||||
assert_deserialization("vits", TtsModelType::Vits);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(TtsModelType::iter().count(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in TtsModelType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: TtsModelType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod tts_render_status;
|
||||
@@ -1,75 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the SqLite `tts_render_tasks` table in a `TEXT` field named `tts_render_status`.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum TtsRenderStatus {
|
||||
#[serde(rename = "new")]
|
||||
New,
|
||||
|
||||
// TODO: Added to fix a big. This whole enum should die.
|
||||
#[serde(rename = "processing")]
|
||||
Processing,
|
||||
|
||||
#[serde(rename = "skipped")]
|
||||
Skipped,
|
||||
|
||||
#[serde(rename = "failed")]
|
||||
Failed,
|
||||
|
||||
#[serde(rename = "permanently_failed")]
|
||||
PermanentlyFailed,
|
||||
|
||||
#[serde(rename = "success")]
|
||||
Success,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::TtsRenderStatus;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(TtsRenderStatus::New, "new");
|
||||
assert_serialization(TtsRenderStatus::Processing, "processing");
|
||||
assert_serialization(TtsRenderStatus::Skipped, "skipped");
|
||||
assert_serialization(TtsRenderStatus::Failed, "failed");
|
||||
assert_serialization(TtsRenderStatus::PermanentlyFailed, "permanently_failed");
|
||||
assert_serialization(TtsRenderStatus::Success, "success");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("new", TtsRenderStatus::New);
|
||||
assert_deserialization("processing", TtsRenderStatus::Processing);
|
||||
assert_deserialization("skipped", TtsRenderStatus::Skipped);
|
||||
assert_deserialization("failed", TtsRenderStatus::Failed);
|
||||
assert_deserialization("permanently_failed", TtsRenderStatus::PermanentlyFailed);
|
||||
assert_deserialization("success", TtsRenderStatus::Success);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(TtsRenderStatus::iter().count(), 6);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in TtsRenderStatus::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: TtsRenderStatus = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod usages_type;
|
||||
@@ -1,57 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `usages` table in a `VARCHAR(16)` field. (Two fields!)
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum UsagesType {
|
||||
/// Represents a foreign key link against a model_weights record
|
||||
ModelWeight,
|
||||
|
||||
/// Represents a foreign key link against a media_files record
|
||||
MediaFile,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::UsagesType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(UsagesType::ModelWeight, "model_weight");
|
||||
assert_serialization(UsagesType::MediaFile, "media_file");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("model_weight", UsagesType::ModelWeight);
|
||||
assert_deserialization("media_file", UsagesType::MediaFile);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(UsagesType::iter().count(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in UsagesType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: UsagesType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod user_bookmark_entity_type;
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `user_bookmarks` table in a `VARCHAR(32)` field named `entity_type`.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum UserBookmarkEntityType {
|
||||
/// User
|
||||
#[serde(rename = "user")]
|
||||
User,
|
||||
|
||||
/// TTS model (architecture does not matter)
|
||||
#[serde(rename = "tts_model")]
|
||||
TtsModel,
|
||||
|
||||
/// TTS result (architecture does not matter)
|
||||
#[serde(rename = "tts_result")]
|
||||
TtsResult,
|
||||
|
||||
/// W2L template
|
||||
#[serde(rename = "w2l_template")]
|
||||
W2lTemplate,
|
||||
|
||||
/// W2L result
|
||||
#[serde(rename = "w2l_result")]
|
||||
W2lResult,
|
||||
|
||||
/// MediaFile
|
||||
#[serde(rename = "media_file")]
|
||||
MediaFile,
|
||||
|
||||
/// ModelWeight (the new way to store models)
|
||||
#[serde(rename = "model_weight")]
|
||||
ModelWeight,
|
||||
|
||||
/// VoiceConversionModel
|
||||
#[serde(rename = "voice_conversion_model")]
|
||||
VoiceConversionModel,
|
||||
|
||||
/// ZsVoice
|
||||
#[serde(rename = "zs_voice")]
|
||||
ZsVoice,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::UserBookmarkEntityType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(UserBookmarkEntityType::User, "user");
|
||||
assert_serialization(UserBookmarkEntityType::TtsModel, "tts_model");
|
||||
assert_serialization(UserBookmarkEntityType::TtsResult, "tts_result");
|
||||
assert_serialization(UserBookmarkEntityType::W2lTemplate, "w2l_template");
|
||||
assert_serialization(UserBookmarkEntityType::W2lResult, "w2l_result");
|
||||
assert_serialization(UserBookmarkEntityType::MediaFile, "media_file");
|
||||
assert_serialization(UserBookmarkEntityType::ModelWeight, "model_weight");
|
||||
assert_serialization(UserBookmarkEntityType::VoiceConversionModel, "voice_conversion_model");
|
||||
assert_serialization(UserBookmarkEntityType::ZsVoice, "zs_voice");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("user", UserBookmarkEntityType::User);
|
||||
assert_deserialization("tts_model", UserBookmarkEntityType::TtsModel);
|
||||
assert_deserialization("tts_result", UserBookmarkEntityType::TtsResult);
|
||||
assert_deserialization("w2l_template", UserBookmarkEntityType::W2lTemplate);
|
||||
assert_deserialization("w2l_result", UserBookmarkEntityType::W2lResult);
|
||||
assert_deserialization("media_file", UserBookmarkEntityType::MediaFile);
|
||||
assert_deserialization("model_weight", UserBookmarkEntityType::ModelWeight);
|
||||
assert_deserialization("voice_conversion_model", UserBookmarkEntityType::VoiceConversionModel);
|
||||
assert_deserialization("zs_voice", UserBookmarkEntityType::ZsVoice);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(UserBookmarkEntityType::iter().count(), 9);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in UserBookmarkEntityType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: UserBookmarkEntityType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `user_ratings` table in a `VARCHAR(32)` field named `entity_type`.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum UserRatingEntityType {
|
||||
/// Media files (inference results, uploads, etc.)
|
||||
#[serde(rename = "media_file")]
|
||||
MediaFile,
|
||||
|
||||
/// Model weights (modern, polymorphic, type agnostic)
|
||||
#[serde(rename = "model_weight")]
|
||||
ModelWeight,
|
||||
|
||||
/// TTS model (architecture does not matter)
|
||||
#[serde(rename = "tts_model")]
|
||||
TtsModel,
|
||||
|
||||
/// TTS result (architecture does not matter)
|
||||
#[serde(rename = "tts_result")]
|
||||
TtsResult,
|
||||
|
||||
/// W2L template
|
||||
#[serde(rename = "w2l_template")]
|
||||
W2lTemplate,
|
||||
|
||||
/// W2L result
|
||||
#[serde(rename = "w2l_result")]
|
||||
W2lResult,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::UserRatingEntityType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(UserRatingEntityType::MediaFile, "media_file");
|
||||
assert_serialization(UserRatingEntityType::ModelWeight, "model_weight");
|
||||
assert_serialization(UserRatingEntityType::TtsModel, "tts_model");
|
||||
assert_serialization(UserRatingEntityType::TtsResult, "tts_result");
|
||||
assert_serialization(UserRatingEntityType::W2lTemplate, "w2l_template");
|
||||
assert_serialization(UserRatingEntityType::W2lResult, "w2l_result");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("media_file", UserRatingEntityType::MediaFile);
|
||||
assert_deserialization("model_weight", UserRatingEntityType::ModelWeight);
|
||||
assert_deserialization("tts_model", UserRatingEntityType::TtsModel);
|
||||
assert_deserialization("tts_result", UserRatingEntityType::TtsResult);
|
||||
assert_deserialization("w2l_template", UserRatingEntityType::W2lTemplate);
|
||||
assert_deserialization("w2l_result", UserRatingEntityType::W2lResult);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(UserRatingEntityType::iter().count(), 6);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in UserRatingEntityType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: UserRatingEntityType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
pub mod entity_type;
|
||||
pub mod rating_value;
|
||||
@@ -1,72 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// UserRatingValue
|
||||
///
|
||||
/// - Used in the `user_ratings` table as an `ENUM` field named `rating_type`.
|
||||
/// - Used in the HTTP API.
|
||||
///
|
||||
/// To use this in a query, the query must have type annotations.
|
||||
/// See: https://www.gitmemory.com/issue/launchbadge/sqlx/1241/847154375
|
||||
/// eg. preferred_tts_result_visibility as `rating_type: enums::by_table::user_ratings::rating_type::UserRatingValue`
|
||||
///
|
||||
/// See also: https://docs.rs/sqlx/0.4.0-beta.1/sqlx/trait.Type.html
|
||||
///
|
||||
/// *DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY!*
|
||||
///
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
|
||||
pub enum UserRatingValue {
|
||||
/// This is considered a ratings "soft deletion" and does not count towards a total score.
|
||||
/// This is the default rating.
|
||||
Neutral,
|
||||
/// This is a positive vote / upvote / like.
|
||||
/// They are available to non-logged-in users as long as they have the URL.
|
||||
Positive,
|
||||
/// This is a negative vote / downvote / dislike.
|
||||
Negative,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::UserRatingValue;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(UserRatingValue::Neutral, "neutral");
|
||||
assert_serialization(UserRatingValue::Positive, "positive");
|
||||
assert_serialization(UserRatingValue::Negative, "negative");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("neutral", UserRatingValue::Neutral);
|
||||
assert_deserialization("positive", UserRatingValue::Positive);
|
||||
assert_deserialization("negative", UserRatingValue::Negative);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(UserRatingValue::iter().count(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in UserRatingValue::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: UserRatingValue = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
pub mod user_feature_flag;
|
||||
pub mod user_signup_method;
|
||||
pub mod user_signup_source;
|
||||
@@ -1,69 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `users` table in a `VARCHAR` field (stored as comma separated set).
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum UserFeatureFlag {
|
||||
/// Grants a user the ability to list media
|
||||
/// (For now, it's hidden until we get an NSFW filter.)
|
||||
ExploreMedia,
|
||||
|
||||
/// Access to studio features
|
||||
Studio,
|
||||
|
||||
/// Whether users are allowed to upload 3D models
|
||||
#[serde(rename = "upload_3d")]
|
||||
Upload3d,
|
||||
|
||||
/// Access to video style transfer
|
||||
VideoStyleTransfer,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::UserFeatureFlag;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(UserFeatureFlag::ExploreMedia, "explore_media");
|
||||
assert_serialization(UserFeatureFlag::Studio, "studio");
|
||||
assert_serialization(UserFeatureFlag::Upload3d, "upload_3d");
|
||||
assert_serialization(UserFeatureFlag::VideoStyleTransfer, "video_style_transfer");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("explore_media", UserFeatureFlag::ExploreMedia);
|
||||
assert_deserialization("studio", UserFeatureFlag::Studio);
|
||||
assert_deserialization("upload_3d", UserFeatureFlag::Upload3d);
|
||||
assert_deserialization("video_style_transfer", UserFeatureFlag::VideoStyleTransfer);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(UserFeatureFlag::iter().count(), 4);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in UserFeatureFlag::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: UserFeatureFlag = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `users` table in a `VARCHAR(16)` field.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum UserSignupMethod {
|
||||
/// Email + Password
|
||||
EmailPassword,
|
||||
|
||||
/// "Sign in With Google" SSO
|
||||
GoogleSignIn,
|
||||
|
||||
/// Stripe Checkout flow, where we provision user accounts for users with a
|
||||
/// synthetic/fake email address and no password. After checkout completes,
|
||||
/// the user gets a real email and password - or the user can set them.
|
||||
StripeCheckout,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::UserSignupMethod;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(UserSignupMethod::EmailPassword, "email_password");
|
||||
assert_serialization(UserSignupMethod::GoogleSignIn, "google_sign_in");
|
||||
assert_serialization(UserSignupMethod::StripeCheckout, "stripe_checkout");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("email_password", UserSignupMethod::EmailPassword);
|
||||
assert_deserialization("google_sign_in", UserSignupMethod::GoogleSignIn);
|
||||
assert_deserialization("stripe_checkout", UserSignupMethod::StripeCheckout);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(UserSignupMethod::iter().count(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in UserSignupMethod::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: UserSignupMethod = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `users` table in a `VARCHAR(255)` (which should be a `VARCHAR(16)`) field, `maybe_source`.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum UserSignupSource {
|
||||
#[deprecated(since = "2026-01-30", note = "Use other Artcraft* enum variants instead")]
|
||||
#[serde(rename = "artcraft")]
|
||||
ArtCraft,
|
||||
|
||||
/// ArtCraft Tauri App Onboard Flow
|
||||
#[serde(rename = "artcraft_app")]
|
||||
ArtCraftApp,
|
||||
|
||||
/// artcraft.ai normal onboard flow
|
||||
#[serde(rename = "artcraft_ai_web")]
|
||||
ArtCraftAiWeb,
|
||||
|
||||
/// artcraft.ai stripe checkout flow
|
||||
#[serde(rename = "artcraft_ai_s")]
|
||||
ArtCraftAiStripe,
|
||||
|
||||
/// getartcraft.com normal onboard flow
|
||||
#[serde(rename = "artcraft_get_web")]
|
||||
ArtCraftGetWeb,
|
||||
|
||||
/// getartcraft.com stripe checkout flow
|
||||
#[serde(rename = "artcraft_get_s")]
|
||||
ArtCraftGetStripe,
|
||||
|
||||
#[serde(rename = "fakeyou")]
|
||||
FakeYou,
|
||||
|
||||
#[serde(rename = "storyteller")]
|
||||
Storyteller,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::UserSignupSource;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(UserSignupSource::ArtCraft, "artcraft");
|
||||
assert_serialization(UserSignupSource::ArtCraftApp, "artcraft_app");
|
||||
assert_serialization(UserSignupSource::ArtCraftAiWeb, "artcraft_ai_web");
|
||||
assert_serialization(UserSignupSource::ArtCraftAiStripe, "artcraft_ai_s");
|
||||
assert_serialization(UserSignupSource::ArtCraftGetWeb, "artcraft_get_web");
|
||||
assert_serialization(UserSignupSource::ArtCraftGetStripe, "artcraft_get_s");
|
||||
assert_serialization(UserSignupSource::FakeYou, "fakeyou");
|
||||
assert_serialization(UserSignupSource::Storyteller, "storyteller");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("artcraft", UserSignupSource::ArtCraft);
|
||||
assert_deserialization("artcraft_app", UserSignupSource::ArtCraftApp);
|
||||
assert_deserialization("artcraft_ai_web", UserSignupSource::ArtCraftAiWeb);
|
||||
assert_deserialization("artcraft_ai_s", UserSignupSource::ArtCraftAiStripe);
|
||||
assert_deserialization("artcraft_get_web", UserSignupSource::ArtCraftGetWeb);
|
||||
assert_deserialization("artcraft_get_s", UserSignupSource::ArtCraftGetStripe);
|
||||
assert_deserialization("fakeyou", UserSignupSource::FakeYou);
|
||||
assert_deserialization("storyteller", UserSignupSource::Storyteller);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(UserSignupSource::iter().count(), 8);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in UserSignupSource::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: UserSignupSource = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod voice_conversion_model_type;
|
||||
-63
@@ -1,63 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `voice_conversion_models` table in `VARCHAR(32)` field `model_type`.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum VoiceConversionModelType {
|
||||
// We're skipping RVC "v1" models as "v2" are much higher quality.
|
||||
// Future incompatible upgrades may deserve a different enum variant.
|
||||
#[serde(rename = "rvc_v2")]
|
||||
RvcV2,
|
||||
|
||||
#[serde(rename = "soft_vc")]
|
||||
SoftVc,
|
||||
|
||||
#[serde(rename = "so_vits_svc")]
|
||||
SoVitsSvc,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::VoiceConversionModelType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(VoiceConversionModelType::RvcV2, "rvc_v2");
|
||||
assert_serialization(VoiceConversionModelType::SoftVc, "soft_vc");
|
||||
assert_serialization(VoiceConversionModelType::SoVitsSvc, "so_vits_svc");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("rvc_v2", VoiceConversionModelType::RvcV2);
|
||||
assert_deserialization("soft_vc", VoiceConversionModelType::SoftVc);
|
||||
assert_deserialization("so_vits_svc", VoiceConversionModelType::SoVitsSvc);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(VoiceConversionModelType::iter().count(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in VoiceConversionModelType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: VoiceConversionModelType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod voice_conversion_media_token_type;
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `voice_conversion_results` table in a `VARCHAR` field.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum VoiceConversionMediaTokenType {
|
||||
/// Media token refers to record in `media_uploads` table.
|
||||
MediaUpload,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::VoiceConversionMediaTokenType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(VoiceConversionMediaTokenType::MediaUpload, "media_upload");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("media_upload", VoiceConversionMediaTokenType::MediaUpload);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(VoiceConversionMediaTokenType::iter().count(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in VoiceConversionMediaTokenType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: VoiceConversionMediaTokenType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod wallet_ledger_entry_type;
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `wallet_ledger_entries` table in a `VARCHAR(16)` field.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum WalletLedgerEntryType {
|
||||
/// Wallet created
|
||||
#[serde(rename = "create")]
|
||||
Create,
|
||||
|
||||
/// Credit durable banked balance
|
||||
#[serde(rename = "credit_banked")]
|
||||
CreditBanked,
|
||||
|
||||
/// Credit monthly refill
|
||||
#[serde(rename = "credit_monthly")]
|
||||
CreditMonthly,
|
||||
|
||||
/// Deduct credits (mixed durable and monthly deduction)
|
||||
#[serde(rename = "deduct_mixed")]
|
||||
DeductMixed,
|
||||
|
||||
/// Deduct durable banked credits
|
||||
#[serde(rename = "deduct_banked")]
|
||||
DeductBanked,
|
||||
|
||||
/// Deduct monthly credits
|
||||
#[serde(rename = "deduct_monthly")]
|
||||
DeductMonthly,
|
||||
|
||||
/// Refund banked credits
|
||||
#[serde(rename = "refund_banked")]
|
||||
RefundBanked,
|
||||
|
||||
/// Support staff manually credit account
|
||||
#[serde(rename = "staff_add_banked")]
|
||||
StaffAddBanked,
|
||||
|
||||
// TODO: No clean way to do "mixed" refunds yet, and if we
|
||||
// refund close to the cutoff it might be unfair. Let's
|
||||
// just not do monthly refunds yet and instead credit our
|
||||
// users with banked credits.
|
||||
// /// Refund monthly credits
|
||||
// #[serde(rename = "refund_monthly")]
|
||||
// RefundMonthly,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::WalletLedgerEntryType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(WalletLedgerEntryType::Create, "create");
|
||||
assert_serialization(WalletLedgerEntryType::CreditBanked, "credit_banked");
|
||||
assert_serialization(WalletLedgerEntryType::CreditMonthly, "credit_monthly");
|
||||
assert_serialization(WalletLedgerEntryType::DeductMixed, "deduct_mixed");
|
||||
assert_serialization(WalletLedgerEntryType::DeductBanked, "deduct_banked");
|
||||
assert_serialization(WalletLedgerEntryType::DeductMonthly, "deduct_monthly");
|
||||
assert_serialization(WalletLedgerEntryType::RefundBanked, "refund_banked");
|
||||
assert_serialization(WalletLedgerEntryType::StaffAddBanked, "staff_add_banked");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("create", WalletLedgerEntryType::Create);
|
||||
assert_deserialization("credit_banked", WalletLedgerEntryType::CreditBanked);
|
||||
assert_deserialization("credit_monthly", WalletLedgerEntryType::CreditMonthly);
|
||||
assert_deserialization("deduct_mixed", WalletLedgerEntryType::DeductMixed);
|
||||
assert_deserialization("deduct_banked", WalletLedgerEntryType::DeductBanked);
|
||||
assert_deserialization("deduct_monthly", WalletLedgerEntryType::DeductMonthly);
|
||||
assert_deserialization("refund_banked", WalletLedgerEntryType::RefundBanked);
|
||||
assert_deserialization("staff_add_banked", WalletLedgerEntryType::StaffAddBanked);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(WalletLedgerEntryType::iter().count(), 8);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in WalletLedgerEntryType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: WalletLedgerEntryType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod rendition_status;
|
||||
@@ -1,69 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the SqLite `web_scraping_targets` table in a `TEXT` field named `scraping_status`.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum RenditionStatus {
|
||||
#[serde(rename = "new")]
|
||||
New,
|
||||
|
||||
#[serde(rename = "skipped")]
|
||||
Skipped,
|
||||
|
||||
#[serde(rename = "failed")]
|
||||
Failed,
|
||||
|
||||
#[serde(rename = "permanently_failed")]
|
||||
PermanentlyFailed,
|
||||
|
||||
#[serde(rename = "success")]
|
||||
Success,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::RenditionStatus;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(RenditionStatus::New, "new");
|
||||
assert_serialization(RenditionStatus::Skipped, "skipped");
|
||||
assert_serialization(RenditionStatus::Failed, "failed");
|
||||
assert_serialization(RenditionStatus::PermanentlyFailed, "permanently_failed");
|
||||
assert_serialization(RenditionStatus::Success, "success");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("new", RenditionStatus::New);
|
||||
assert_deserialization("skipped", RenditionStatus::Skipped);
|
||||
assert_deserialization("failed", RenditionStatus::Failed);
|
||||
assert_deserialization("permanently_failed", RenditionStatus::PermanentlyFailed);
|
||||
assert_deserialization("success", RenditionStatus::Success);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(RenditionStatus::iter().count(), 5);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in RenditionStatus::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: RenditionStatus = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod scraping_status;
|
||||
@@ -1,69 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the SqLite `web_scraping_targets` table in a `TEXT` field named `scraping_status`.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum ScrapingStatus {
|
||||
#[serde(rename = "new")]
|
||||
New,
|
||||
|
||||
#[serde(rename = "skipped")]
|
||||
Skipped,
|
||||
|
||||
#[serde(rename = "failed")]
|
||||
Failed,
|
||||
|
||||
#[serde(rename = "permanently_failed")]
|
||||
PermanentlyFailed,
|
||||
|
||||
#[serde(rename = "success")]
|
||||
Success,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ScrapingStatus;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(ScrapingStatus::New, "new");
|
||||
assert_serialization(ScrapingStatus::Skipped, "skipped");
|
||||
assert_serialization(ScrapingStatus::Failed, "failed");
|
||||
assert_serialization(ScrapingStatus::PermanentlyFailed, "permanently_failed");
|
||||
assert_serialization(ScrapingStatus::Success, "success");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("new", ScrapingStatus::New);
|
||||
assert_deserialization("skipped", ScrapingStatus::Skipped);
|
||||
assert_deserialization("failed", ScrapingStatus::Failed);
|
||||
assert_deserialization("permanently_failed", ScrapingStatus::PermanentlyFailed);
|
||||
assert_deserialization("success", ScrapingStatus::Success);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(ScrapingStatus::iter().count(), 5);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in ScrapingStatus::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: ScrapingStatus = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `zs_voices` table in a `VARCHAR(16)` field named `encoding_type`.
|
||||
///
|
||||
/// This indicates what type of features are used in the embeddings.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum ZsVoiceEncodingType {
|
||||
/// Encodec features
|
||||
#[serde(rename = "encodec")]
|
||||
Encodec,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ZsVoiceEncodingType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(ZsVoiceEncodingType::Encodec, "encodec");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("encodec", ZsVoiceEncodingType::Encodec);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(ZsVoiceEncodingType::iter().count(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in ZsVoiceEncodingType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: ZsVoiceEncodingType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
pub mod encoding_type;
|
||||
pub mod model_category;
|
||||
pub mod model_type;
|
||||
@@ -1,54 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `zs_voices` table in a `VARCHAR(16)` field named `model_category`.
|
||||
///
|
||||
/// This indicates what type of features are used in the embeddings.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum ZsVoiceModelCategory {
|
||||
/// TTS-type zero shot models
|
||||
#[serde(rename = "tts")]
|
||||
Tts,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ZsVoiceModelCategory;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(ZsVoiceModelCategory::Tts, "tts");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("tts", ZsVoiceModelCategory::Tts);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(ZsVoiceModelCategory::iter().count(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in ZsVoiceModelCategory::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: ZsVoiceModelCategory = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Used in the `zs_voices` table in a `VARCHAR(16)` field named `model_type`.
|
||||
///
|
||||
/// This indicates what type of features are used in the embeddings.
|
||||
///
|
||||
/// DO NOT CHANGE VALUES WITHOUT A MIGRATION STRATEGY.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Deserialize, Serialize, ToSchema, EnumIter, Debug)]
|
||||
|
||||
pub enum ZsVoiceModelType {
|
||||
/// TTS-type zero shot models
|
||||
#[serde(rename = "vall-e-x")]
|
||||
VallEX,
|
||||
#[serde(rename = "styletts2")]
|
||||
StyleTTS2,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ZsVoiceModelType;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(ZsVoiceModelType::VallEX, "vall-e-x");
|
||||
assert_serialization(ZsVoiceModelType::StyleTTS2, "styletts2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("vall-e-x", ZsVoiceModelType::VallEX);
|
||||
assert_deserialization("styletts2", ZsVoiceModelType::StyleTTS2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(ZsVoiceModelType::iter().count(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in ZsVoiceModelType::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: ZsVoiceModelType = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// NB: This will be used by a variety of tables (MySQL and sqlite)!
|
||||
/// Keep the max length to 16 characters.
|
||||
#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, EnumIter, Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum ArtcraftCreditsPackSlug {
|
||||
#[serde(rename= "artcraft_1000")]
|
||||
Artcraft1000,
|
||||
#[serde(rename= "artcraft_2500")]
|
||||
Artcraft2500,
|
||||
#[serde(rename= "artcraft_5000")]
|
||||
Artcraft5000,
|
||||
#[serde(rename= "artcraft_10000")]
|
||||
Artcraft10000,
|
||||
#[serde(rename= "artcraft_25000")]
|
||||
Artcraft25000,
|
||||
#[serde(rename= "artcraft_50000")]
|
||||
Artcraft50000,
|
||||
}
|
||||
|
||||
impl ArtcraftCreditsPackSlug {
|
||||
pub const fn to_str(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Artcraft1000 => "artcraft_1000",
|
||||
Self::Artcraft2500 => "artcraft_2500",
|
||||
Self::Artcraft5000 => "artcraft_5000",
|
||||
Self::Artcraft10000 => "artcraft_10000",
|
||||
Self::Artcraft25000 => "artcraft_25000",
|
||||
Self::Artcraft50000 => "artcraft_50000",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ArtcraftCreditsPackSlug;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(ArtcraftCreditsPackSlug::Artcraft1000, "artcraft_1000");
|
||||
assert_serialization(ArtcraftCreditsPackSlug::Artcraft2500, "artcraft_2500");
|
||||
assert_serialization(ArtcraftCreditsPackSlug::Artcraft5000, "artcraft_5000");
|
||||
assert_serialization(ArtcraftCreditsPackSlug::Artcraft10000, "artcraft_10000");
|
||||
assert_serialization(ArtcraftCreditsPackSlug::Artcraft25000, "artcraft_25000");
|
||||
assert_serialization(ArtcraftCreditsPackSlug::Artcraft50000, "artcraft_50000");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("artcraft_1000", ArtcraftCreditsPackSlug::Artcraft1000);
|
||||
assert_deserialization("artcraft_2500", ArtcraftCreditsPackSlug::Artcraft2500);
|
||||
assert_deserialization("artcraft_5000", ArtcraftCreditsPackSlug::Artcraft5000);
|
||||
assert_deserialization("artcraft_10000", ArtcraftCreditsPackSlug::Artcraft10000);
|
||||
assert_deserialization("artcraft_25000", ArtcraftCreditsPackSlug::Artcraft25000);
|
||||
assert_deserialization("artcraft_50000", ArtcraftCreditsPackSlug::Artcraft50000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(ArtcraftCreditsPackSlug::iter().count(), 6);
|
||||
}
|
||||
}
|
||||
|
||||
mod to_str_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn to_str() {
|
||||
assert_eq!(ArtcraftCreditsPackSlug::Artcraft1000.to_str(), "artcraft_1000");
|
||||
assert_eq!(ArtcraftCreditsPackSlug::Artcraft2500.to_str(), "artcraft_2500");
|
||||
assert_eq!(ArtcraftCreditsPackSlug::Artcraft5000.to_str(), "artcraft_5000");
|
||||
assert_eq!(ArtcraftCreditsPackSlug::Artcraft10000.to_str(), "artcraft_10000");
|
||||
assert_eq!(ArtcraftCreditsPackSlug::Artcraft25000.to_str(), "artcraft_25000");
|
||||
assert_eq!(ArtcraftCreditsPackSlug::Artcraft50000.to_str(), "artcraft_50000");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_str_matches_serde() {
|
||||
for variant in ArtcraftCreditsPackSlug::iter() {
|
||||
let serde_str = serde_json::to_string(&variant).unwrap().replace('"', "");
|
||||
assert_eq!(variant.to_str(), serde_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in ArtcraftCreditsPackSlug::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: ArtcraftCreditsPackSlug = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// NB: This will be used by a variety of tables (MySQL and sqlite)!
|
||||
/// Keep the max length to 16 characters.
|
||||
#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, EnumIter, Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
pub enum ArtcraftSubscriptionSlug {
|
||||
ArtcraftBasic,
|
||||
ArtcraftPro,
|
||||
ArtcraftMax,
|
||||
}
|
||||
|
||||
impl ArtcraftSubscriptionSlug {
|
||||
pub const fn to_str(&self) -> &'static str {
|
||||
match self {
|
||||
Self::ArtcraftBasic => "artcraft_basic",
|
||||
Self::ArtcraftPro => "artcraft_pro",
|
||||
Self::ArtcraftMax => "artcraft_max",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ArtcraftSubscriptionSlug;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(ArtcraftSubscriptionSlug::ArtcraftBasic, "artcraft_basic");
|
||||
assert_serialization(ArtcraftSubscriptionSlug::ArtcraftPro, "artcraft_pro");
|
||||
assert_serialization(ArtcraftSubscriptionSlug::ArtcraftMax, "artcraft_max");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("artcraft_basic", ArtcraftSubscriptionSlug::ArtcraftBasic);
|
||||
assert_deserialization("artcraft_pro", ArtcraftSubscriptionSlug::ArtcraftPro);
|
||||
assert_deserialization("artcraft_max", ArtcraftSubscriptionSlug::ArtcraftMax);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(ArtcraftSubscriptionSlug::iter().count(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
mod to_str_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn to_str() {
|
||||
assert_eq!(ArtcraftSubscriptionSlug::ArtcraftBasic.to_str(), "artcraft_basic");
|
||||
assert_eq!(ArtcraftSubscriptionSlug::ArtcraftPro.to_str(), "artcraft_pro");
|
||||
assert_eq!(ArtcraftSubscriptionSlug::ArtcraftMax.to_str(), "artcraft_max");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_str_matches_serde() {
|
||||
for variant in ArtcraftSubscriptionSlug::iter() {
|
||||
let serde_str = serde_json::to_string(&variant).unwrap().replace('"', "");
|
||||
assert_eq!(variant.to_str(), serde_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in ArtcraftSubscriptionSlug::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: ArtcraftSubscriptionSlug = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Common aspect ratios for video generation.
|
||||
/// Mirrors artcraft_router::api::common_aspect_ratio::CommonAspectRatio.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, ToSchema, EnumIter)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommonAspectRatio {
|
||||
Auto,
|
||||
Square,
|
||||
WideThreeByTwo,
|
||||
WideFourByThree,
|
||||
WideFiveByFour,
|
||||
WideSixteenByNine,
|
||||
WideTwentyOneByNine,
|
||||
TallTwoByThree,
|
||||
TallThreeByFour,
|
||||
TallFourByFive,
|
||||
TallNineBySixteen,
|
||||
TallNineByTwentyOne,
|
||||
Wide,
|
||||
Tall,
|
||||
Auto2k,
|
||||
Auto4k,
|
||||
SquareHd,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::CommonAspectRatio;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(CommonAspectRatio::Auto, "auto");
|
||||
assert_serialization(CommonAspectRatio::Square, "square");
|
||||
assert_serialization(CommonAspectRatio::WideThreeByTwo, "wide_three_by_two");
|
||||
assert_serialization(CommonAspectRatio::WideFourByThree, "wide_four_by_three");
|
||||
assert_serialization(CommonAspectRatio::WideFiveByFour, "wide_five_by_four");
|
||||
assert_serialization(CommonAspectRatio::WideSixteenByNine, "wide_sixteen_by_nine");
|
||||
assert_serialization(CommonAspectRatio::WideTwentyOneByNine, "wide_twenty_one_by_nine");
|
||||
assert_serialization(CommonAspectRatio::TallTwoByThree, "tall_two_by_three");
|
||||
assert_serialization(CommonAspectRatio::TallThreeByFour, "tall_three_by_four");
|
||||
assert_serialization(CommonAspectRatio::TallFourByFive, "tall_four_by_five");
|
||||
assert_serialization(CommonAspectRatio::TallNineBySixteen, "tall_nine_by_sixteen");
|
||||
assert_serialization(CommonAspectRatio::TallNineByTwentyOne, "tall_nine_by_twenty_one");
|
||||
assert_serialization(CommonAspectRatio::Wide, "wide");
|
||||
assert_serialization(CommonAspectRatio::Tall, "tall");
|
||||
assert_serialization(CommonAspectRatio::Auto2k, "auto2k");
|
||||
assert_serialization(CommonAspectRatio::Auto4k, "auto4k");
|
||||
assert_serialization(CommonAspectRatio::SquareHd, "square_hd");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("auto", CommonAspectRatio::Auto);
|
||||
assert_deserialization("square", CommonAspectRatio::Square);
|
||||
assert_deserialization("wide_three_by_two", CommonAspectRatio::WideThreeByTwo);
|
||||
assert_deserialization("wide_four_by_three", CommonAspectRatio::WideFourByThree);
|
||||
assert_deserialization("wide_five_by_four", CommonAspectRatio::WideFiveByFour);
|
||||
assert_deserialization("wide_sixteen_by_nine", CommonAspectRatio::WideSixteenByNine);
|
||||
assert_deserialization("wide_twenty_one_by_nine", CommonAspectRatio::WideTwentyOneByNine);
|
||||
assert_deserialization("tall_two_by_three", CommonAspectRatio::TallTwoByThree);
|
||||
assert_deserialization("tall_three_by_four", CommonAspectRatio::TallThreeByFour);
|
||||
assert_deserialization("tall_four_by_five", CommonAspectRatio::TallFourByFive);
|
||||
assert_deserialization("tall_nine_by_sixteen", CommonAspectRatio::TallNineBySixteen);
|
||||
assert_deserialization("tall_nine_by_twenty_one", CommonAspectRatio::TallNineByTwentyOne);
|
||||
assert_deserialization("wide", CommonAspectRatio::Wide);
|
||||
assert_deserialization("tall", CommonAspectRatio::Tall);
|
||||
assert_deserialization("auto2k", CommonAspectRatio::Auto2k);
|
||||
assert_deserialization("auto4k", CommonAspectRatio::Auto4k);
|
||||
assert_deserialization("square_hd", CommonAspectRatio::SquareHd);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(CommonAspectRatio::iter().count(), 17);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in CommonAspectRatio::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: CommonAspectRatio = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Image models available for generation.
|
||||
/// Mirrors artcraft_router::api::common_image_model::CommonImageModel.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, ToSchema, EnumIter)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommonImageModel {
|
||||
#[serde(rename = "flux_1_dev")]
|
||||
Flux1Dev,
|
||||
#[serde(rename = "flux_1_schnell")]
|
||||
Flux1Schnell,
|
||||
#[serde(rename = "flux_pro_1p1")]
|
||||
FluxPro11,
|
||||
#[serde(rename = "flux_pro_1p1_ultra")]
|
||||
FluxPro11Ultra,
|
||||
#[serde(rename = "gpt_image_1p5")]
|
||||
GptImage1p5,
|
||||
#[serde(rename = "nano_banana")]
|
||||
NanaBanana,
|
||||
#[serde(rename = "nano_banana_2")]
|
||||
NanaBanana2,
|
||||
#[serde(rename = "nano_banana_pro")]
|
||||
NanaBananaPro,
|
||||
#[serde(rename = "seedream_4")]
|
||||
Seedream4,
|
||||
#[serde(rename = "seedream_4p5")]
|
||||
Seedream4p5,
|
||||
#[serde(rename = "seedream_5_lite")]
|
||||
Seedream5Lite,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::CommonImageModel;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(CommonImageModel::Flux1Dev, "flux_1_dev");
|
||||
assert_serialization(CommonImageModel::Flux1Schnell, "flux_1_schnell");
|
||||
assert_serialization(CommonImageModel::FluxPro11, "flux_pro_1p1");
|
||||
assert_serialization(CommonImageModel::FluxPro11Ultra, "flux_pro_1p1_ultra");
|
||||
assert_serialization(CommonImageModel::GptImage1p5, "gpt_image_1p5");
|
||||
assert_serialization(CommonImageModel::NanaBanana, "nano_banana");
|
||||
assert_serialization(CommonImageModel::NanaBanana2, "nano_banana_2");
|
||||
assert_serialization(CommonImageModel::NanaBananaPro, "nano_banana_pro");
|
||||
assert_serialization(CommonImageModel::Seedream4, "seedream_4");
|
||||
assert_serialization(CommonImageModel::Seedream4p5, "seedream_4p5");
|
||||
assert_serialization(CommonImageModel::Seedream5Lite, "seedream_5_lite");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("flux_1_dev", CommonImageModel::Flux1Dev);
|
||||
assert_deserialization("flux_1_schnell", CommonImageModel::Flux1Schnell);
|
||||
assert_deserialization("flux_pro_1p1", CommonImageModel::FluxPro11);
|
||||
assert_deserialization("flux_pro_1p1_ultra", CommonImageModel::FluxPro11Ultra);
|
||||
assert_deserialization("gpt_image_1p5", CommonImageModel::GptImage1p5);
|
||||
assert_deserialization("nano_banana", CommonImageModel::NanaBanana);
|
||||
assert_deserialization("nano_banana_2", CommonImageModel::NanaBanana2);
|
||||
assert_deserialization("nano_banana_pro", CommonImageModel::NanaBananaPro);
|
||||
assert_deserialization("seedream_4", CommonImageModel::Seedream4);
|
||||
assert_deserialization("seedream_4p5", CommonImageModel::Seedream4p5);
|
||||
assert_deserialization("seedream_5_lite", CommonImageModel::Seedream5Lite);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(CommonImageModel::iter().count(), 11);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in CommonImageModel::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: CommonImageModel = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Splat models available for generation.
|
||||
/// Mirrors artcraft_router::api::common_splat_model::CommonSplatModel.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, ToSchema, EnumIter)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommonSplatModel {
|
||||
#[serde(rename = "marble_0p1_mini")]
|
||||
Marble0p1Mini,
|
||||
|
||||
#[serde(rename = "marble_0p1_plus")]
|
||||
Marble0p1Plus,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::CommonSplatModel;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(CommonSplatModel::Marble0p1Mini, "marble_0p1_mini");
|
||||
assert_serialization(CommonSplatModel::Marble0p1Plus, "marble_0p1_plus");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("marble_0p1_mini", CommonSplatModel::Marble0p1Mini);
|
||||
assert_deserialization("marble_0p1_plus", CommonSplatModel::Marble0p1Plus);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(CommonSplatModel::iter().count(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in CommonSplatModel::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: CommonSplatModel = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Video models available for generation.
|
||||
/// Mirrors artcraft_router::api::common_video_model::CommonVideoModel.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, ToSchema, EnumIter)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommonVideoModel {
|
||||
#[serde(rename = "grok_video")]
|
||||
GrokVideo,
|
||||
|
||||
#[serde(rename = "kling_1p6_pro")]
|
||||
Kling16Pro,
|
||||
|
||||
#[serde(rename = "kling_2p1_pro")]
|
||||
Kling21Pro,
|
||||
|
||||
#[serde(rename = "kling_2p1_master")]
|
||||
Kling21Master,
|
||||
|
||||
#[serde(rename = "kling_2p5_turbo_pro")]
|
||||
Kling2p5TurboPro,
|
||||
|
||||
#[serde(rename = "kling_2p6_pro")]
|
||||
Kling2p6Pro,
|
||||
|
||||
#[serde(rename = "kling_3p0_standard")]
|
||||
Kling3p0Standard,
|
||||
|
||||
#[serde(rename = "kling_3p0_pro")]
|
||||
Kling3p0Pro,
|
||||
|
||||
#[serde(rename = "seedance_1p0_lite")]
|
||||
Seedance10Lite,
|
||||
|
||||
#[serde(rename = "seedance_1p5_pro")]
|
||||
Seedance1p5Pro,
|
||||
|
||||
#[serde(rename = "seedance_2p0")]
|
||||
Seedance2p0,
|
||||
|
||||
#[serde(rename = "sora_2")]
|
||||
Sora2,
|
||||
|
||||
#[serde(rename = "sora_2_pro")]
|
||||
Sora2Pro,
|
||||
|
||||
#[serde(rename = "veo_2")]
|
||||
Veo2,
|
||||
|
||||
#[serde(rename = "veo_3")]
|
||||
Veo3,
|
||||
|
||||
#[serde(rename = "veo_3_fast")]
|
||||
Veo3Fast,
|
||||
|
||||
#[serde(rename = "veo_3p1")]
|
||||
Veo3p1,
|
||||
|
||||
#[serde(rename = "veo_3p1_fast")]
|
||||
Veo3p1Fast,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::CommonVideoModel;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(CommonVideoModel::GrokVideo, "grok_video");
|
||||
assert_serialization(CommonVideoModel::Kling16Pro, "kling_1p6_pro");
|
||||
assert_serialization(CommonVideoModel::Kling21Pro, "kling_2p1_pro");
|
||||
assert_serialization(CommonVideoModel::Kling21Master, "kling_2p1_master");
|
||||
assert_serialization(CommonVideoModel::Kling2p5TurboPro, "kling_2p5_turbo_pro");
|
||||
assert_serialization(CommonVideoModel::Kling2p6Pro, "kling_2p6_pro");
|
||||
assert_serialization(CommonVideoModel::Kling3p0Standard, "kling_3p0_standard");
|
||||
assert_serialization(CommonVideoModel::Kling3p0Pro, "kling_3p0_pro");
|
||||
assert_serialization(CommonVideoModel::Seedance10Lite, "seedance_1p0_lite");
|
||||
assert_serialization(CommonVideoModel::Seedance1p5Pro, "seedance_1p5_pro");
|
||||
assert_serialization(CommonVideoModel::Seedance2p0, "seedance_2p0");
|
||||
assert_serialization(CommonVideoModel::Sora2, "sora_2");
|
||||
assert_serialization(CommonVideoModel::Sora2Pro, "sora_2_pro");
|
||||
assert_serialization(CommonVideoModel::Veo2, "veo_2");
|
||||
assert_serialization(CommonVideoModel::Veo3, "veo_3");
|
||||
assert_serialization(CommonVideoModel::Veo3Fast, "veo_3_fast");
|
||||
assert_serialization(CommonVideoModel::Veo3p1, "veo_3p1");
|
||||
assert_serialization(CommonVideoModel::Veo3p1Fast, "veo_3p1_fast");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("grok_video", CommonVideoModel::GrokVideo);
|
||||
assert_deserialization("kling_1p6_pro", CommonVideoModel::Kling16Pro);
|
||||
assert_deserialization("kling_2p1_pro", CommonVideoModel::Kling21Pro);
|
||||
assert_deserialization("kling_2p1_master", CommonVideoModel::Kling21Master);
|
||||
assert_deserialization("kling_2p5_turbo_pro", CommonVideoModel::Kling2p5TurboPro);
|
||||
assert_deserialization("kling_2p6_pro", CommonVideoModel::Kling2p6Pro);
|
||||
assert_deserialization("kling_3p0_standard", CommonVideoModel::Kling3p0Standard);
|
||||
assert_deserialization("kling_3p0_pro", CommonVideoModel::Kling3p0Pro);
|
||||
assert_deserialization("seedance_1p0_lite", CommonVideoModel::Seedance10Lite);
|
||||
assert_deserialization("seedance_1p5_pro", CommonVideoModel::Seedance1p5Pro);
|
||||
assert_deserialization("seedance_2p0", CommonVideoModel::Seedance2p0);
|
||||
assert_deserialization("sora_2", CommonVideoModel::Sora2);
|
||||
assert_deserialization("sora_2_pro", CommonVideoModel::Sora2Pro);
|
||||
assert_deserialization("veo_2", CommonVideoModel::Veo2);
|
||||
assert_deserialization("veo_3", CommonVideoModel::Veo3);
|
||||
assert_deserialization("veo_3_fast", CommonVideoModel::Veo3Fast);
|
||||
assert_deserialization("veo_3p1", CommonVideoModel::Veo3p1);
|
||||
assert_deserialization("veo_3p1_fast", CommonVideoModel::Veo3p1Fast);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(CommonVideoModel::iter().count(), 18);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in CommonVideoModel::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: CommonVideoModel = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// Common video resolutions.
|
||||
/// Mirrors artcraft_router::api::common_resolution::CommonResolution.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, ToSchema, EnumIter)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommonVideoResolution {
|
||||
OneK,
|
||||
TwoK,
|
||||
ThreeK,
|
||||
FourK,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::CommonVideoResolution;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(CommonVideoResolution::OneK, "one_k");
|
||||
assert_serialization(CommonVideoResolution::TwoK, "two_k");
|
||||
assert_serialization(CommonVideoResolution::ThreeK, "three_k");
|
||||
assert_serialization(CommonVideoResolution::FourK, "four_k");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("one_k", CommonVideoResolution::OneK);
|
||||
assert_deserialization("two_k", CommonVideoResolution::TwoK);
|
||||
assert_deserialization("three_k", CommonVideoResolution::ThreeK);
|
||||
assert_deserialization("four_k", CommonVideoResolution::FourK);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(CommonVideoResolution::iter().count(), 4);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in CommonVideoResolution::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: CommonVideoResolution = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
//! This is an important enum.
|
||||
//!
|
||||
//! It's used in storyteller-web inference generation, the cost estimate handler,
|
||||
//! the ArtCraft Tauri app, and more.
|
||||
//!
|
||||
//! Do not change the values here without cause or care.
|
||||
|
||||
use strum::EnumCount;
|
||||
use strum::EnumIter;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
/// NB: Keep the max length to 16 characters.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize, ToSchema, EnumIter, EnumCount)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum GenerationProvider {
|
||||
Artcraft,
|
||||
Fal,
|
||||
Grok,
|
||||
Midjourney,
|
||||
Sora,
|
||||
WorldLabs,
|
||||
|
||||
// /// Catch-all for values the client doesn't yet know about.
|
||||
// ///
|
||||
// /// We need this to help prevent old versions of deployed-in-the-field
|
||||
// /// apps from breaking, eg. Tauri Desktop, when new enum variants are added.
|
||||
// /// This will stop deserialization from failing, but the client still has
|
||||
// /// to behave intelligently.
|
||||
// ///
|
||||
// /// The contained string is the raw serialized value from the server.
|
||||
// #[serde(untagged)]
|
||||
// Unknown(String),
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::GenerationProvider;
|
||||
use enums_shared::test_helpers::{assert_deserialization, assert_serialization};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
mod manual_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(GenerationProvider::Artcraft, "artcraft");
|
||||
assert_serialization(GenerationProvider::Fal, "fal");
|
||||
assert_serialization(GenerationProvider::Grok, "grok");
|
||||
assert_serialization(GenerationProvider::Midjourney, "midjourney");
|
||||
assert_serialization(GenerationProvider::Sora, "sora");
|
||||
assert_serialization(GenerationProvider::WorldLabs, "world_labs");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
assert_deserialization("artcraft", GenerationProvider::Artcraft);
|
||||
assert_deserialization("fal", GenerationProvider::Fal);
|
||||
assert_deserialization("grok", GenerationProvider::Grok);
|
||||
assert_deserialization("midjourney", GenerationProvider::Midjourney);
|
||||
assert_deserialization("sora", GenerationProvider::Sora);
|
||||
assert_deserialization("world_labs", GenerationProvider::WorldLabs);
|
||||
}
|
||||
#[test]
|
||||
fn variants_count_check() {
|
||||
assert_eq!(GenerationProvider::iter().count(), 6);
|
||||
}
|
||||
}
|
||||
|
||||
mod mechanical_checks {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn round_trip_json() {
|
||||
for variant in GenerationProvider::iter() {
|
||||
let json = serde_json::to_string(&variant).unwrap();
|
||||
let back: GenerationProvider = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(variant, back);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user