1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(PartialEq, Eq, Serialize, Deserialize, Clone, Debug, Default)]
5pub struct EntityConnector {
6 pub field: String,
8
9 pub value: String,
11
12 pub version: Option<String>,
14
15 pub entity: String,
17}
18
19#[derive(
23 PartialEq,
24 Eq,
25 Serialize,
26 Deserialize,
27 Clone,
28 Debug,
29 strum_macros::AsRefStr,
30 strum_macros::EnumString,
31 strum_macros::IntoStaticStr,
32)]
33pub enum JobProcessStatus {
34 Running,
35 Pending,
36 Queued,
37 Completed,
38 Cancelled,
39 Failed,
40 Skipped,
41}
42
43impl Default for JobProcessStatus {
45 fn default() -> Self {
46 JobProcessStatus::Queued
47 }
48}
49
50#[derive(PartialEq, Eq, Serialize, Deserialize, Clone, Debug, Default)]
51pub struct JobMetadata {
52 pub last_run: Option<chrono::DateTime<chrono::Utc>>,
54}
55
56#[derive(PartialEq, Eq, Serialize, Deserialize, Clone, Debug, Default)]
57pub struct OwnerMetadata {
58 pub created_by: Option<String>,
60}
61
62pub type Value = serde_json::Value;
64
65#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Default)]
66pub struct RunOutput {
67 pub output: HashMap<String, serde_json::Value>,
68 pub errors: Vec<SystemActivityLog>,
69}
70
71pub type TaskResult = anyhow::Result<RunOutput>;
72
73pub type PluginResult = anyhow::Result<serde_json::Value>;
74
75pub fn plugin_json_response<T>(output: RunOutput) -> PluginResult
76where
77 T: serde::de::DeserializeOwned + serde::Serialize,
78{
79 let res = serde_json::to_value(output).expect("");
80 Ok(res)
81}
82
83pub fn task_json_response(output: RunOutput) -> TaskResult {
84 Ok(output)
85}
86
87#[derive(Serialize, PartialEq, Eq, Deserialize, Clone, Debug, Default)]
88pub struct SystemActivityLog {
89 pub scope: String,
90 pub message: String,
91 pub level: String,
92 pub timestamp: i64,
93}