lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

log_error.rs (3720B)


      1 use radroots_types::types::{IResult, IResultList};
      2 use serde::{Deserialize, Serialize};
      3 use serde_json::Value;
      4 #[derive(Serialize, Deserialize)]
      5 pub struct LogError {
      6     pub id: String,
      7     pub created_at: String,
      8     pub updated_at: String,
      9     pub error: String,
     10     pub message: String,
     11     pub stack_trace: Option<String>,
     12     pub cause: Option<String>,
     13     pub app_system: String,
     14     pub app_version: String,
     15     pub nostr_pubkey: String,
     16     pub data: Option<String>,
     17 }
     18 #[derive(Clone, Deserialize, Serialize)]
     19 pub struct ILogErrorFields {
     20     pub error: String,
     21     pub message: String,
     22     pub stack_trace: Option<String>,
     23     pub cause: Option<String>,
     24     pub app_system: String,
     25     pub app_version: String,
     26     pub nostr_pubkey: String,
     27     pub data: Option<String>,
     28 }
     29 #[derive(Clone, Deserialize, Serialize)]
     30 pub struct ILogErrorFieldsPartial {
     31     pub error: Option<serde_json::Value>,
     32     pub message: Option<serde_json::Value>,
     33     pub stack_trace: Option<serde_json::Value>,
     34     pub cause: Option<serde_json::Value>,
     35     pub app_system: Option<serde_json::Value>,
     36     pub app_version: Option<serde_json::Value>,
     37     pub nostr_pubkey: Option<serde_json::Value>,
     38     pub data: Option<serde_json::Value>,
     39 }
     40 #[derive(Clone, Deserialize, Serialize)]
     41 pub struct ILogErrorFieldsFilter {
     42     pub id: Option<String>,
     43     pub created_at: Option<String>,
     44     pub updated_at: Option<String>,
     45     pub error: Option<String>,
     46     pub message: Option<String>,
     47     pub stack_trace: Option<String>,
     48     pub cause: Option<String>,
     49     pub app_system: Option<String>,
     50     pub app_version: Option<String>,
     51     pub nostr_pubkey: Option<String>,
     52     pub data: Option<String>,
     53 }
     54 #[derive(Clone, Deserialize, Serialize)]
     55 #[serde(untagged)]
     56 pub enum LogErrorQueryBindValues {
     57     Id { id: String },
     58     NostrPubkey { nostr_pubkey: String },
     59 }
     60 impl LogErrorQueryBindValues {
     61     pub fn to_filter_param(&self) -> (&'static str, Value) {
     62         match self {
     63             Self::Id { id } => ("id", Value::from(id.clone())),
     64             Self::NostrPubkey { nostr_pubkey } => {
     65                 ("nostr_pubkey", Value::from(nostr_pubkey.clone()))
     66             }
     67         }
     68     }
     69 
     70     pub fn primary_key(&self) -> Option<String> {
     71         match self {
     72             Self::Id { id } => Some(id.clone()),
     73             _ => None,
     74         }
     75     }
     76 
     77     pub fn lookup_key(&self) -> String {
     78         match self {
     79             Self::Id { id } => id.clone(),
     80             Self::NostrPubkey { nostr_pubkey } => nostr_pubkey.clone(),
     81         }
     82     }
     83 }
     84 pub struct ILogErrorCreateTs;
     85 pub type ILogErrorCreate = ILogErrorFields;
     86 pub struct ILogErrorCreateResolveTs;
     87 pub type ILogErrorCreateResolve = IResult<LogError>;
     88 #[derive(Deserialize, Serialize)]
     89 pub struct ILogErrorFindOneArgs {
     90     pub on: LogErrorQueryBindValues,
     91 }
     92 
     93 #[derive(Deserialize, Serialize)]
     94 #[serde(untagged)]
     95 pub enum ILogErrorFindOne {
     96     On(ILogErrorFindOneArgs),
     97 }
     98 
     99 pub struct ILogErrorFindOneResolveTs;
    100 pub type ILogErrorFindOneResolve = IResult<Option<LogError>>;
    101 #[derive(Deserialize, Serialize)]
    102 pub struct ILogErrorFindManyArgs {
    103     pub filter: Option<ILogErrorFieldsFilter>,
    104 }
    105 pub type ILogErrorFindMany = ILogErrorFindManyArgs;
    106 pub struct ILogErrorFindManyResolveTs;
    107 pub type ILogErrorFindManyResolve = IResultList<LogError>;
    108 pub struct ILogErrorDeleteTs;
    109 pub type ILogErrorDelete = ILogErrorFindOne;
    110 pub struct ILogErrorDeleteResolveTs;
    111 pub type ILogErrorDeleteResolve = IResult<String>;
    112 #[derive(Deserialize, Serialize)]
    113 pub struct ILogErrorUpdateArgs {
    114     pub on: LogErrorQueryBindValues,
    115     pub fields: ILogErrorFieldsPartial,
    116 }
    117 pub type ILogErrorUpdate = ILogErrorUpdateArgs;
    118 pub struct ILogErrorUpdateResolveTs;
    119 pub type ILogErrorUpdateResolve = IResult<LogError>;