Skip to main content

aeo_graph_explorer/
model.rs

1//! Serde-friendly view of an AEO doc.
2//!
3//! We don't pull in `aeo-sdk-rust` because that would force callers into a
4//! specific spec version. Instead we accept "anything that has `entity.id`
5//! and `claims`" and treat unknown fields as opaque — the JSONL is whatever
6//! the upstream crawler emitted.
7
8use std::collections::HashMap;
9
10use serde::{Deserialize, Serialize};
11use serde_json::Value;
12
13/// One ingested AEO node — the JSONL line stored verbatim, plus a denormalised
14/// `entity` so the query API doesn't have to peek inside `body` every time.
15#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
16pub struct AeoNode {
17    /// Stable entity identifier — typically the canonical entity URL.
18    pub id: String,
19    /// Lightweight summary used by `/nodes` so list responses don't carry the
20    /// whole body.
21    pub entity: AeoEntity,
22    /// Full AEO doc (whatever the crawler captured). Returned by
23    /// `/nodes/{id}`.
24    #[serde(default)]
25    pub body: HashMap<String, Value>,
26}
27
28/// Denormalised view of the most-asked-about fields.
29#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
30pub struct AeoEntity {
31    /// The same identifier as `AeoNode.id`. Kept here for consumers who only
32    /// receive the summary.
33    pub id: String,
34    /// `Organization`, `Person`, `Product`, ...
35    #[serde(default)]
36    pub kind: Option<String>,
37    /// Human-readable name.
38    #[serde(default)]
39    pub name: Option<String>,
40    /// Where the entity says its truth-source lives.
41    #[serde(default)]
42    pub canonical_url: Option<String>,
43}
44
45/// One assertion the entity makes about itself.
46#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
47pub struct AeoClaim {
48    /// Stable identifier for the claim (used for round-tripping).
49    pub id: String,
50    /// The predicate / type — e.g. `description`, `industry`, `headquartered_in`.
51    pub predicate: String,
52    /// The claim's value — a string in the common case, but kept as JSON for
53    /// flexibility.
54    pub value: Value,
55    /// Self-reported confidence (`"high"`, `"medium"`, `"low"`).
56    #[serde(default)]
57    pub confidence: Option<String>,
58}