Files
jspg/src/database/type.rs

54 lines
1.4 KiB
Rust

use indexmap::{IndexMap, IndexSet};
use crate::database::schema::Schema;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use serde_json::Value;
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Roles {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub read: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub write: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(default)]
pub struct Type {
pub id: String,
pub r#type: String,
pub name: String,
pub module: String,
pub source: String,
#[serde(default)]
pub historical: bool,
#[serde(default)]
pub notify: bool,
#[serde(default)]
pub sensitive: bool,
#[serde(default)]
pub ownable: bool,
pub longevity: Option<i32>,
#[serde(default)]
pub hierarchy: Vec<String>,
#[serde(default)]
pub variations: IndexSet<String>,
#[serde(default)]
pub relationship: bool,
#[serde(default)]
pub fields: Vec<String>,
pub grouped_fields: Option<Value>,
#[serde(default)]
pub lookup_fields: Vec<String>,
#[serde(default)]
pub null_fields: Vec<String>,
#[serde(default)]
pub field_defaults: IndexMap<String, Value>,
pub field_types: Option<Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub roles: Option<Roles>,
#[serde(default)]
pub schemas: IndexMap<String, Arc<Schema>>,
}