Skip to main content

relay_knowledge/api/operations/
repository.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{
4    api::{ApiMetadata, CodeRepositoryFreshnessDiagnostics, CodeRepositoryScopeMetadata},
5    domain::{
6        BusinessDomain, BusinessKnowledgeQueryRequest, BusinessKnowledgeResolution,
7        BusinessKnowledgeStatus, BusinessTerm, CodeFeatureFlagGraph, CodeFeatureFlagRequest,
8        CodeImpactPathGroups, CodeImpactRequest, CodeIndexCheckpoint, CodeIndexSummary,
9        CodeIndexTaskRecord, CodeRepositoryRegistration, CodeRepositoryRemovalSummary,
10        CodeRepositoryReport, CodeRepositoryScopePreview, CodeRepositoryStatus, CodeRetrievalHit,
11        CodeRetrievalRequest, CodeScopeRetentionSummary, FrameworkGraph, FrameworkGraphRequest,
12        RepositoryGraphEdge, RepositoryGraphNeighborhoodRequest, RepositoryGraphNode,
13        SoftwareBuildTarget, SoftwareComponent, SoftwareDependencyUsage, SoftwareDesignElement,
14        SoftwareFile, SoftwareGlobalRequest, SoftwareGlobalStatus, SoftwareIacResource,
15        SoftwareRelationship, SoftwareSdkUsage, SoftwareTopic,
16    },
17};
18
19/// Code repository registration request.
20#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
21pub struct CodeRepositoryRegisterRequest {
22    pub root_path: String,
23    #[serde(default)]
24    pub alias: String,
25    #[serde(default)]
26    pub path_filters: Vec<String>,
27    #[serde(default)]
28    pub language_filters: Vec<String>,
29}
30
31/// Requests an incremental update from the last published Git snapshot.
32///
33/// The service resolves both optional refs to immutable commit identities
34/// before durable work is queued. Omitting `base_ref` selects the last
35/// successfully published clean commit; omitting `head_ref` selects `HEAD`.
36#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
37pub struct CodeRepositoryUpdateRequest {
38    #[serde(default)]
39    pub repository: String,
40    #[serde(default, skip_serializing_if = "Option::is_none")]
41    pub base_ref: Option<String>,
42    #[serde(default, skip_serializing_if = "Option::is_none")]
43    pub head_ref: Option<String>,
44}
45
46/// Code repository registration response.
47#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
48pub struct CodeRepositoryRegisterResponse {
49    pub metadata: ApiMetadata,
50    pub registration: CodeRepositoryRegistration,
51    pub status: CodeRepositoryStatus,
52}
53
54/// Indexed code repository list response.
55#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
56pub struct CodeRepositoryListResponse {
57    pub metadata: ApiMetadata,
58    pub repositories: Vec<CodeRepositoryStatus>,
59}
60
61/// Code repository removal response.
62#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
63pub struct CodeRepositoryRemoveResponse {
64    pub metadata: ApiMetadata,
65    pub removed_status: CodeRepositoryStatus,
66    pub summary: CodeRepositoryRemovalSummary,
67}
68
69/// Code repository index response.
70#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
71pub struct CodeRepositoryIndexResponse {
72    pub metadata: ApiMetadata,
73    pub scope: CodeRepositoryScopeMetadata,
74    pub summary: CodeIndexSummary,
75    pub status: CodeRepositoryStatus,
76}
77
78/// Code repository index start response for queued or no-op index requests.
79#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
80pub struct CodeRepositoryIndexStartResponse {
81    pub metadata: ApiMetadata,
82    pub scope: CodeRepositoryScopeMetadata,
83    #[serde(skip_serializing_if = "Option::is_none")]
84    pub summary: Option<CodeIndexSummary>,
85    pub status: CodeRepositoryStatus,
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub task: Option<CodeIndexTaskRecord>,
88    #[serde(skip_serializing_if = "Option::is_none")]
89    pub checkpoint: Option<CodeIndexCheckpoint>,
90}
91
92/// Code repository index task reset response.
93#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
94pub struct CodeRepositoryIndexResetResponse {
95    pub metadata: ApiMetadata,
96    pub status: CodeRepositoryStatus,
97    pub reset_task_count: usize,
98    pub reset_tasks: Vec<CodeIndexTaskRecord>,
99    #[serde(skip_serializing_if = "Option::is_none")]
100    pub active_task: Option<CodeIndexTaskRecord>,
101    #[serde(skip_serializing_if = "Option::is_none")]
102    pub checkpoint: Option<CodeIndexCheckpoint>,
103    pub retention: CodeScopeRetentionSummary,
104}
105
106/// Code repository scope preview response.
107#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
108pub struct CodeRepositoryScopePreviewResponse {
109    pub metadata: ApiMetadata,
110    pub scope: CodeRepositoryScopeMetadata,
111    pub preview: CodeRepositoryScopePreview,
112}
113
114/// Code repository retrieval response.
115#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
116pub struct CodeRepositoryQueryResponse {
117    pub metadata: ApiMetadata,
118    pub scope: CodeRepositoryScopeMetadata,
119    #[serde(default = "CodeRepositoryFreshnessDiagnostics::legacy_unknown")]
120    pub freshness: CodeRepositoryFreshnessDiagnostics,
121    pub request: CodeRetrievalRequest,
122    pub results: Vec<CodeRetrievalHit>,
123    #[serde(skip_serializing_if = "Option::is_none")]
124    pub degraded_reason: Option<String>,
125}
126
127/// Versioned, snapshot-bound repository graph neighborhood.
128#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
129pub struct RepositoryGraphNeighborhoodResponseV1 {
130    pub schema_version: u8,
131    pub metadata: ApiMetadata,
132    pub scope: CodeRepositoryScopeMetadata,
133    pub request: RepositoryGraphNeighborhoodRequest,
134    pub nodes: Vec<RepositoryGraphNode>,
135    pub edges: Vec<RepositoryGraphEdge>,
136    pub truncated: bool,
137}
138
139/// Code repository feature-flag graph response.
140#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
141pub struct CodeRepositoryFeatureFlagsResponse {
142    pub metadata: ApiMetadata,
143    pub scope: CodeRepositoryScopeMetadata,
144    #[serde(default = "CodeRepositoryFreshnessDiagnostics::legacy_unknown")]
145    pub freshness: CodeRepositoryFreshnessDiagnostics,
146    pub request: CodeFeatureFlagRequest,
147    pub flags: Vec<CodeFeatureFlagGraph>,
148    #[serde(skip_serializing_if = "Option::is_none")]
149    pub degraded_reason: Option<String>,
150}
151
152/// Framework-aware component and template graph response.
153#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
154pub struct CodeRepositoryFrameworkGraphResponse {
155    pub metadata: ApiMetadata,
156    pub scope: CodeRepositoryScopeMetadata,
157    #[serde(default = "CodeRepositoryFreshnessDiagnostics::legacy_unknown")]
158    pub freshness: CodeRepositoryFreshnessDiagnostics,
159    pub request: FrameworkGraphRequest,
160    pub graph: FrameworkGraph,
161    #[serde(skip_serializing_if = "Option::is_none")]
162    pub degraded_reason: Option<String>,
163}
164
165/// Code repository impact response.
166#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
167pub struct CodeRepositoryImpactResponse {
168    pub metadata: ApiMetadata,
169    pub scope: CodeRepositoryScopeMetadata,
170    pub request: CodeImpactRequest,
171    pub path_groups: CodeImpactPathGroups,
172    pub results: Vec<CodeRetrievalHit>,
173}
174
175/// Code repository status response.
176#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
177pub struct CodeRepositoryStatusResponse {
178    pub metadata: ApiMetadata,
179    pub status: CodeRepositoryStatus,
180    #[serde(skip_serializing_if = "Option::is_none")]
181    pub active_task: Option<CodeIndexTaskRecord>,
182    #[serde(skip_serializing_if = "Option::is_none")]
183    pub checkpoint: Option<CodeIndexCheckpoint>,
184    pub retention: CodeScopeRetentionSummary,
185}
186
187/// Code repository operations report response.
188#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
189pub struct CodeRepositoryReportResponse {
190    pub metadata: ApiMetadata,
191    pub scope: CodeRepositoryScopeMetadata,
192    pub report: CodeRepositoryReport,
193}
194
195/// Repository-scoped software global model projection response.
196#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
197pub struct SoftwareGlobalResponse {
198    pub metadata: ApiMetadata,
199    pub scope: CodeRepositoryScopeMetadata,
200    pub request: SoftwareGlobalRequest,
201    pub status: SoftwareGlobalStatus,
202    pub components: Vec<SoftwareComponent>,
203    pub dependency_usages: Vec<SoftwareDependencyUsage>,
204    pub sdk_usages: Vec<SoftwareSdkUsage>,
205    pub files: Vec<SoftwareFile>,
206    pub topics: Vec<SoftwareTopic>,
207    pub relationships: Vec<SoftwareRelationship>,
208    pub build_targets: Vec<SoftwareBuildTarget>,
209    pub iac_resources: Vec<SoftwareIacResource>,
210    pub design_elements: Vec<SoftwareDesignElement>,
211}
212
213/// Repository-scoped authored business knowledge projection response.
214#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
215pub struct BusinessKnowledgeQueryResponse {
216    pub metadata: ApiMetadata,
217    pub scope: CodeRepositoryScopeMetadata,
218    pub request: BusinessKnowledgeQueryRequest,
219    pub status: BusinessKnowledgeStatus,
220    pub resolution: BusinessKnowledgeResolution,
221    pub domains: Vec<BusinessDomain>,
222    pub terms: Vec<BusinessTerm>,
223}