use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(PartialEq, Eq, Serialize, Deserialize, Clone, Debug, Default)]
pub struct EntityConnector {
pub field: String,
pub value: String,
pub version: Option<String>,
pub entity: String,
}
#[derive(
PartialEq,
Eq,
Serialize,
Deserialize,
Clone,
Debug,
strum_macros::AsRefStr,
strum_macros::EnumString,
strum_macros::IntoStaticStr,
)]
pub enum JobProcessStatus {
Running,
Pending,
Queued,
Completed,
Cancelled,
Failed,
Skipped,
}
impl Default for JobProcessStatus {
fn default() -> Self {
JobProcessStatus::Queued
}
}
#[derive(PartialEq, Eq, Serialize, Deserialize, Clone, Debug, Default)]
pub struct JobMetadata {
pub last_run: Option<chrono::DateTime<chrono::Utc>>,
}
#[derive(PartialEq, Eq, Serialize, Deserialize, Clone, Debug, Default)]
pub struct OwnerMetadata {
pub created_by: Option<String>,
}
pub type Value = serde_json::Value;
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Default)]
pub struct RunOutput {
pub output: HashMap<String, serde_json::Value>,
pub errors: Vec<SystemActivityLog>,
}
pub type TaskResult = anyhow::Result<RunOutput>;
pub type PluginResult = anyhow::Result<serde_json::Value>;
pub fn plugin_json_response<T>(output: RunOutput) -> PluginResult
where
T: serde::de::DeserializeOwned + serde::Serialize,
{
let res = serde_json::to_value(output).expect("");
Ok(res)
}
pub fn task_json_response(output: RunOutput) -> TaskResult {
Ok(output)
}
#[derive(Serialize, PartialEq, Eq, Deserialize, Clone, Debug, Default)]
pub struct SystemActivityLog {
pub scope: String,
pub message: String,
pub level: String,
pub timestamp: i64,
}