diff --git a/crates/_types/tokens/src/prefixes.rs b/crates/_types/tokens/src/prefixes.rs index df74429035..e9a2ceb5fe 100644 --- a/crates/_types/tokens/src/prefixes.rs +++ b/crates/_types/tokens/src/prefixes.rs @@ -13,6 +13,8 @@ use strum::EnumIter; #[derive(Debug, Copy, Clone, Eq, PartialEq)] #[cfg_attr(test, derive(EnumIter, EnumCount))] pub(crate) enum EntityType { + AuditLog, + Comment, DownloadJob, InferenceJob, MediaUpload, @@ -29,6 +31,8 @@ impl EntityType { pub fn prefix(self) -> &'static str { match self { + Self::AuditLog => "audit_", + Self::Comment => "comment_", Self::DownloadJob => "jdown_", // NB: Was "JGUP:" Self::InferenceJob => "jinf_", Self::MediaUpload => "mu_", diff --git a/crates/_types/tokens/src/tokens/audit_logs.rs b/crates/_types/tokens/src/tokens/audit_logs.rs new file mode 100644 index 0000000000..3e1c84ee28 --- /dev/null +++ b/crates/_types/tokens/src/tokens/audit_logs.rs @@ -0,0 +1,12 @@ +use crate::prefixes::EntityType; +use serde::Deserialize; +use serde::Serialize; +use std::fmt::Debug; + +/// The primary key for Audit Logs. +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, sqlx::Type, Debug, Serialize, Deserialize)] +#[sqlx(transparent)] +pub struct AuditLogToken(pub String); + +impl_string_token!(AuditLogToken); +impl_crockford_generator!(AuditLogToken, 32usize, EntityType::AuditLog, CrockfordLower); diff --git a/crates/_types/tokens/src/tokens/comments.rs b/crates/_types/tokens/src/tokens/comments.rs new file mode 100644 index 0000000000..e6b77a082a --- /dev/null +++ b/crates/_types/tokens/src/tokens/comments.rs @@ -0,0 +1,12 @@ +use crate::prefixes::EntityType; +use serde::Deserialize; +use serde::Serialize; +use std::fmt::Debug; + +/// The primary key for Audit Logs. +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, sqlx::Type, Debug, Serialize, Deserialize)] +#[sqlx(transparent)] +pub struct CommentToken(pub String); + +impl_string_token!(CommentToken); +impl_crockford_generator!(CommentToken, 32usize, EntityType::Comment, CrockfordLower); diff --git a/crates/_types/tokens/src/tokens/mod.rs b/crates/_types/tokens/src/tokens/mod.rs index 567f1af03f..9b7b40010d 100644 --- a/crates/_types/tokens/src/tokens/mod.rs +++ b/crates/_types/tokens/src/tokens/mod.rs @@ -1,4 +1,6 @@ // ===== For MySQL ===== +pub mod audit_logs; +pub mod comments; pub mod model_categories; pub mod tts_models; pub mod w2l_templates;