use serde::Serialize;
#[derive(Debug, Serialize)]
pub struct DiagnosticJson {
pub code: String,
pub severity: String,
pub message: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub subject_id: Option<String>,
}
impl From<&zenith_core::Diagnostic> for DiagnosticJson {
fn from(d: &zenith_core::Diagnostic) -> Self {
Self {
code: d.code.clone(),
severity: severity_str(&d.severity).to_owned(),
message: d.message.clone(),
subject_id: d.subject_id.clone(),
}
}
}
pub(crate) fn severity_str(s: &zenith_core::Severity) -> &'static str {
match s {
zenith_core::Severity::Error => "error",
zenith_core::Severity::Warning => "warning",
zenith_core::Severity::Advisory => "advisory",
}
}
#[derive(Debug, Serialize)]
pub struct ValidateOutput {
pub schema: &'static str,
pub valid: bool,
pub diagnostics: Vec<DiagnosticJson>,
}
#[derive(Debug, Serialize)]
pub struct FmtOutput {
pub schema: &'static str,
pub changed: bool,
pub hash: String,
}
#[derive(Debug, Serialize)]
pub struct TokenEntry {
pub id: String,
pub token_type: String,
pub resolved_value: String,
}
#[derive(Debug, Serialize)]
pub struct TokensOutput {
pub schema: &'static str,
pub tokens: Vec<TokenEntry>,
pub diagnostics: Vec<DiagnosticJson>,
}
#[derive(Debug, Serialize)]
pub struct RenderOutput {
pub schema: &'static str,
pub diagnostics: Vec<DiagnosticJson>,
}
#[derive(Debug, Serialize)]
pub struct TxOutputJson {
pub schema: &'static str,
pub status: String,
pub affected: Vec<String>,
pub diagnostics: Vec<DiagnosticJson>,
pub changed: bool,
}
#[derive(Debug, Serialize)]
pub struct MergeRowResult {
pub row: usize,
#[serde(skip_serializing_if = "Option::is_none")]
pub key: Option<String>,
pub status: &'static str,
pub outputs: Vec<String>,
pub diagnostics: Vec<DiagnosticJson>,
}
#[derive(Debug, Serialize)]
pub struct MergeOutput {
pub schema: &'static str,
pub total_rows: usize,
pub written: usize,
pub failed: usize,
pub rows: Vec<MergeRowResult>,
}
#[derive(Debug, Serialize)]
pub struct ManifestRow {
pub row: usize,
#[serde(skip_serializing_if = "Option::is_none")]
pub key: Option<String>,
pub outputs: Vec<String>,
}
#[derive(Debug, Serialize)]
pub struct MergeManifest {
pub schema: &'static str,
pub generator: &'static str,
pub source_sha256: String,
pub data_sha256: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub name_by: Option<String>,
pub rows: Vec<ManifestRow>,
}
#[derive(Debug, Serialize)]
pub struct VariantResultJson {
pub id: String,
pub source: String,
pub status: &'static str,
#[serde(skip_serializing_if = "Option::is_none")]
pub outputs_zen: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub outputs_png: Option<String>,
pub diagnostics: Vec<DiagnosticJson>,
}
#[derive(Debug, Serialize)]
pub struct VariantOutput {
pub schema: &'static str,
pub total_variants: usize,
pub generated: usize,
pub failed: usize,
pub variants: Vec<VariantResultJson>,
}
#[derive(Debug, Serialize)]
pub struct VariantManifestTarget {
pub id: String,
pub source: String,
pub outputs_zen: String,
pub outputs_png: String,
}
#[derive(Debug, Serialize)]
pub struct VariantManifest {
pub schema: &'static str,
pub generator: &'static str,
pub source_sha256: String,
pub targets: Vec<VariantManifestTarget>,
}
#[derive(Debug, Serialize)]
pub struct SchemaNodeEntry {
pub kind: String,
pub summary: String,
}
#[derive(Debug, Serialize)]
pub struct SchemaAttr {
pub name: String,
pub ty: String,
}
#[derive(Debug, Serialize)]
pub struct SchemaNodeDetail {
pub kind: String,
pub summary: String,
pub attributes: Vec<SchemaAttr>,
#[serde(skip_serializing_if = "Option::is_none")]
pub example: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<SchemaNodeContent>,
}
#[derive(Debug, Serialize)]
pub struct SchemaNodeContent {
pub description: String,
pub example: String,
}
#[derive(Debug, Serialize)]
pub struct SchemaOpEntry {
pub op: String,
pub summary: String,
}
#[derive(Debug, Serialize)]
pub struct SchemaOpFieldEntry {
pub name: String,
pub ty: String,
pub required: bool,
}
#[derive(Debug, Serialize)]
pub struct SchemaOpDetail {
pub op: String,
pub summary: String,
pub fields: Vec<SchemaOpFieldEntry>,
pub example: String,
}
#[derive(Debug, Serialize)]
pub struct SchemaNodesOutput {
pub schema: &'static str,
pub nodes: Vec<SchemaNodeEntry>,
}
#[derive(Debug, Serialize)]
pub struct SchemaNodeOutput {
pub schema: &'static str,
pub node: SchemaNodeDetail,
}
#[derive(Debug, Serialize)]
pub struct SchemaOpsOutput {
pub schema: &'static str,
pub ops: Vec<SchemaOpEntry>,
}
#[derive(Debug, Serialize)]
pub struct SchemaOpOutput {
pub schema: &'static str,
pub op: SchemaOpDetail,
}
#[derive(Debug, Serialize)]
pub struct SchemaOverviewOutput {
pub schema: &'static str,
pub node_kinds: usize,
pub tx_ops: usize,
pub token_types: usize,
}
#[derive(Debug, Serialize)]
pub struct SchemaTokenEntry {
pub ty: String,
pub summary: String,
}
#[derive(Debug, Serialize)]
pub struct SchemaTokenDetail {
pub ty: String,
pub summary: String,
pub value_form: String,
pub child_nodes: String,
pub example: String,
}
#[derive(Debug, Serialize)]
pub struct SchemaTokensOutput {
pub schema: &'static str,
pub token_types: Vec<SchemaTokenEntry>,
}
#[derive(Debug, Serialize)]
pub struct SchemaTokenOutput {
pub schema: &'static str,
pub token: SchemaTokenDetail,
}
#[derive(Debug, Serialize)]
pub struct SchemaSurfaceOutput {
pub schema: &'static str,
pub surface: &'static str,
pub summary: String,
pub attributes: Vec<SchemaAttr>,
}
#[derive(Debug, Serialize)]
pub struct SchemaDiagnosticCode {
pub code: String,
pub severity: String,
pub summary: String,
pub governable: bool,
}
#[derive(Debug, Serialize)]
pub struct SchemaDiagnosticsOutput {
pub schema: &'static str,
pub summary: String,
pub verbs: Vec<String>,
pub syntax: Vec<String>,
pub precedence: &'static str,
pub codes: Vec<SchemaDiagnosticCode>,
}
#[derive(Debug, Serialize)]
pub struct SchemaOverridePropEntry {
pub name: String,
pub ty: String,
pub required: bool,
}
#[derive(Debug, Serialize)]
pub struct SchemaVariantOutput {
pub schema: &'static str,
pub summary: String,
pub block_structure: String,
pub variant_node: String,
pub override_entry: String,
pub override_props: Vec<SchemaOverridePropEntry>,
pub example: String,
}
#[derive(Debug, Serialize)]
pub struct SchemaBrandOutput {
pub schema: &'static str,
pub summary: String,
pub placement: &'static str,
pub child_nodes: Vec<SchemaBrandChildNode>,
pub absent_means: &'static str,
pub diagnostic_codes: Vec<SchemaBrandDiagCode>,
pub example: &'static str,
}
#[derive(Debug, Serialize)]
pub struct SchemaBrandChildNode {
pub node: &'static str,
pub syntax: &'static str,
pub description: &'static str,
}
#[derive(Debug, Serialize)]
pub struct SchemaBrandDiagCode {
pub code: &'static str,
pub severity: &'static str,
pub summary: &'static str,
}
#[derive(Debug, Serialize)]
pub struct FontsOutput {
pub schema: &'static str,
pub bundled: Vec<String>,
pub local: Vec<String>,
}
#[derive(Debug, Serialize)]
pub struct RecipeParamInspectJson {
pub name: String,
pub value: String,
}
#[derive(Debug, Serialize)]
pub struct RecipeInspectJson {
pub id: String,
pub kind: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub seed: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub generator: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bounds: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub detached: Option<bool>,
pub params: Vec<RecipeParamInspectJson>,
pub palette: Vec<String>,
pub expanded: Vec<String>,
}