1use std::collections::BTreeMap;
4
5use serde::{Deserialize, Serialize};
6
7pub use crate::doctor::Check;
8pub use crate::graph::{ContractRole, ContractView, FlowStep, Node, Zoom};
9pub use crate::view::View;
10
11use super::Entry;
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct Overview {
16 pub repos: Vec<RepoSymbols>,
17 pub symbols: usize,
18 pub edges: usize,
19 pub cross_repo_edges: usize,
20 pub contracts: usize,
21 pub linked_contracts: usize,
22 pub ledger: BTreeMap<String, usize>,
24 pub skew: Vec<Skew>,
25 pub writable: bool,
27 pub root: Option<String>,
28 pub problem: Option<String>,
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
32pub struct RepoSymbols {
33 pub repo: String,
34 pub symbols: usize,
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct Skew {
40 pub package: String,
41 pub publisher: String,
42 pub published: Option<String>,
43 pub consumer: String,
44 pub locked: Option<String>,
45}
46
47#[derive(Debug, Clone, Default, Serialize, Deserialize)]
49pub struct AtQuery {
50 pub at: Option<usize>,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct OrgMap {
56 pub nodes: Vec<OrgNode>,
57 pub edges: Vec<OrgEdge>,
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct OrgNode {
62 pub id: String,
63 pub name: String,
64 pub repo: String,
65 pub location: String,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70pub struct OrgEdge {
71 pub src: String,
72 pub dst: String,
73 pub kind: String,
75 pub weight: usize,
76 pub via: Vec<String>,
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
81pub struct FindQuery {
82 pub q: String,
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87pub struct FocusQuery {
88 pub focus: String,
89 #[serde(default, skip_serializing_if = "Option::is_none")]
90 pub budget: Option<usize>,
91}
92
93#[derive(Debug, Clone, Serialize, Deserialize)]
95pub struct NodeDetail {
96 pub zoom: Zoom,
97 pub graph: Neighbourhood,
98 pub ripple: Ripple,
99 pub ledger: Vec<Entry>,
100 pub summary: Option<String>,
101 pub flow: Option<Narration>,
102}
103
104#[derive(Debug, Clone, Default, Serialize, Deserialize)]
106pub struct Neighbourhood {
107 pub nodes: Vec<Node>,
108 pub edges: Vec<GraphEdge>,
109 #[serde(default, skip_serializing_if = "Option::is_none")]
110 pub focus: Option<String>,
111}
112
113#[derive(Debug, Clone, Serialize, Deserialize)]
114pub struct GraphEdge {
115 pub src: String,
116 pub dst: String,
117 pub kind: String,
118}
119
120#[derive(Debug, Clone, Serialize, Deserialize)]
122pub struct Ripple {
123 pub total: usize,
124 pub repos: BTreeMap<String, usize>,
125}
126
127#[derive(Debug, Clone, Serialize, Deserialize)]
129pub struct Narration {
130 pub narration: String,
131 pub questions: Vec<String>,
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
136pub struct SearchQuery {
137 pub q: String,
138 #[serde(default, skip_serializing_if = "Option::is_none")]
139 pub repo: Option<String>,
140}
141
142#[derive(Debug, Clone, Serialize, Deserialize)]
144pub struct SearchHit {
145 pub id: String,
146 pub name: String,
147 pub kind: String,
148 pub repo: String,
149 pub location: String,
150 pub signature: Option<String>,
151 pub summary: Option<String>,
152 pub dependents: usize,
153}
154
155#[derive(Debug, Clone, Serialize, Deserialize)]
157pub struct Package {
158 pub ecosystem: String,
159 pub name: String,
160 pub publisher: String,
161 pub published: Option<String>,
162 pub consumer: String,
163 pub requirement: Option<String>,
164 pub locked: Option<String>,
165 pub skewed: bool,
166}
167
168#[derive(Debug, Clone, Serialize, Deserialize)]
170pub struct AgentQuery {
171 pub tool: String,
172 #[serde(default)]
174 pub args: Option<String>,
175}
176
177#[derive(Debug, Clone, Serialize, Deserialize)]
179pub struct Setup {
180 pub index: String,
181 pub remote: bool,
182 pub version: String,
183 pub checks: Vec<Check>,
184 pub tools: Vec<Tool>,
185 pub agents: Vec<String>,
186 pub agents_md: String,
188 pub skill: String,
189}
190
191#[derive(Debug, Clone, Serialize, Deserialize)]
193pub struct Tool {
194 pub name: String,
195 pub description: String,
196}
197
198#[derive(Debug, Clone, Serialize, Deserialize)]
200pub struct FlowRow {
201 pub entry: Node,
202 pub steps: usize,
203 pub repos: Vec<String>,
205 pub contracts: Vec<String>,
206 pub summary: Option<String>,
207 pub narrated: bool,
208}
209
210#[derive(Debug, Clone, Serialize, Deserialize)]
212pub struct FlowQuery {
213 pub id: String,
214}
215
216#[derive(Debug, Clone, Serialize, Deserialize)]
218pub struct FlowDetail {
219 pub entry: Node,
220 pub narration: Option<String>,
221 pub questions: Option<Vec<String>>,
222 pub steps: Vec<FlowStep>,
223}
224
225fn around() -> usize {
226 6
227}
228
229#[derive(Debug, Clone, Serialize, Deserialize)]
231pub struct SourceQuery {
232 pub repo: String,
233 pub at: String,
235 #[serde(default = "around")]
236 pub around: usize,
237}
238
239#[derive(Debug, Clone, Serialize, Deserialize)]
241pub struct SourceLines {
242 pub path: String,
243 pub line: usize,
244 pub lines: Vec<SourceLine>,
245 pub commit: Option<String>,
247 pub link: Option<String>,
249}
250
251#[derive(Debug, Clone, Serialize, Deserialize)]
252pub struct SourceLine {
253 pub n: usize,
254 pub text: String,
255}