fix: align code with spec
This commit is contained in:
@@ -10,20 +10,44 @@ pub struct GeneratedFileHash {
|
||||
pub updated_at: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum NotificationEntity {
|
||||
Post,
|
||||
Media,
|
||||
Script,
|
||||
Template,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum NotificationAction {
|
||||
Created,
|
||||
Updated,
|
||||
Deleted,
|
||||
}
|
||||
|
||||
/// Notification for CLI-to-app synchronization.
|
||||
/// Matches the `db_notifications` table.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct DbNotification {
|
||||
pub id: i64,
|
||||
pub entity: String,
|
||||
pub entity_type: NotificationEntity,
|
||||
pub entity_id: String,
|
||||
pub action: String,
|
||||
pub action: NotificationAction,
|
||||
pub from_cli: bool,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub seen_at: Option<i64>,
|
||||
pub created_at: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum SshMode {
|
||||
Scp,
|
||||
Rsync,
|
||||
}
|
||||
|
||||
/// Publishing preferences stored in meta/publishing.json.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct PublishingPreferences {
|
||||
@@ -33,6 +57,5 @@ pub struct PublishingPreferences {
|
||||
pub ssh_user: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub ssh_remote_path: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub ssh_mode: Option<String>,
|
||||
pub ssh_mode: SshMode,
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ pub struct Media {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub checksum: Option<String>,
|
||||
/// JSON-serialized string array in DB.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub tags: Option<String>,
|
||||
#[serde(default)]
|
||||
pub tags: Vec<String>,
|
||||
pub created_at: i64,
|
||||
pub updated_at: i64,
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ pub use post::{Post, PostLink, PostMedia, PostStatus, PostTranslation};
|
||||
pub use media::{Media, MediaTranslation};
|
||||
pub use tag::Tag;
|
||||
pub use project::{Project, Setting};
|
||||
pub use template::Template;
|
||||
pub use script::Script;
|
||||
pub use generation::{DbNotification, GeneratedFileHash, PublishingPreferences};
|
||||
pub use template::{Template, TemplateKind, TemplateStatus};
|
||||
pub use script::{Script, ScriptKind, ScriptStatus};
|
||||
pub use generation::{
|
||||
DbNotification, GeneratedFileHash, NotificationAction, NotificationEntity,
|
||||
PublishingPreferences, SshMode,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum ScriptKind {
|
||||
Macro,
|
||||
Utility,
|
||||
Transform,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum ScriptStatus {
|
||||
Draft,
|
||||
Published,
|
||||
}
|
||||
|
||||
/// A user-authored script. Matches the `scripts` table.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Script {
|
||||
@@ -7,13 +22,12 @@ pub struct Script {
|
||||
pub project_id: String,
|
||||
pub slug: String,
|
||||
pub title: String,
|
||||
/// "macro", "transform", or "utility"
|
||||
pub kind: String,
|
||||
pub kind: ScriptKind,
|
||||
pub entrypoint: String,
|
||||
pub enabled: bool,
|
||||
pub version: i32,
|
||||
pub file_path: String,
|
||||
pub status: String,
|
||||
pub status: ScriptStatus,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub content: Option<String>,
|
||||
pub created_at: i64,
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum TemplateKind {
|
||||
Post,
|
||||
List,
|
||||
NotFound,
|
||||
Partial,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum TemplateStatus {
|
||||
Draft,
|
||||
Published,
|
||||
}
|
||||
|
||||
/// A Liquid template. Matches the `templates` table.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Template {
|
||||
@@ -7,11 +23,11 @@ pub struct Template {
|
||||
pub project_id: String,
|
||||
pub slug: String,
|
||||
pub title: String,
|
||||
pub kind: String,
|
||||
pub kind: TemplateKind,
|
||||
pub enabled: bool,
|
||||
pub version: i32,
|
||||
pub file_path: String,
|
||||
pub status: String,
|
||||
pub status: TemplateStatus,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub content: Option<String>,
|
||||
pub created_at: i64,
|
||||
|
||||
Reference in New Issue
Block a user