Skip to main content

distri_types/configuration/
registry.rs

1use serde::{Deserialize, Serialize};
2use uuid::Uuid;
3
4/// Registry package download response
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct RegistryPackageResponse {
7    pub package: String,
8    pub version: String,
9    pub artifact: serde_json::Value,
10    pub tarball: String, // base64-encoded tarball
11    pub checksum: String,
12    pub download_url: String,
13    pub metadata: RegistryPackageMetadata,
14}
15
16/// Registry package metadata
17#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct RegistryPackageMetadata {
19    pub created_at: chrono::DateTime<chrono::Utc>,
20    pub is_yanked: bool,
21}
22
23/// Registry package version information
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct RegistryPackageVersion {
26    pub id: Uuid,
27    pub package_id: Uuid,
28    pub version: String,
29    pub artifact: serde_json::Value,
30    pub tarball: String, // base64-encoded
31    pub checksum: String,
32    pub is_yanked: bool,
33    pub created_at: chrono::DateTime<chrono::Utc>,
34    pub updated_at: chrono::DateTime<chrono::Utc>,
35}
36
37/// Registry package information
38#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct RegistryPackage {
40    pub id: Uuid,
41    pub name: String,
42    pub description: Option<String>,
43    pub owner_id: Uuid,
44    pub created_at: chrono::DateTime<chrono::Utc>,
45    pub updated_at: chrono::DateTime<chrono::Utc>,
46}
47
48/// Registry package detail with versions
49#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct RegistryPackageDetail {
51    pub id: Uuid,
52    pub name: String,
53    pub description: Option<String>,
54    pub owner_id: Uuid,
55    pub created_at: chrono::DateTime<chrono::Utc>,
56    pub updated_at: chrono::DateTime<chrono::Utc>,
57    pub versions: Vec<RegistryPackageVersion>,
58    pub latest_version: Option<String>,
59}
60
61/// Registry search query parameters
62#[derive(Debug, Clone, Serialize, Deserialize)]
63pub struct RegistrySearchQuery {
64    pub q: Option<String>,
65    pub page: Option<i64>,
66    pub limit: Option<i64>,
67    pub sort: Option<String>,
68}
69
70/// Registry search results
71#[derive(Debug, Clone, Serialize, Deserialize)]
72pub struct RegistrySearchResults {
73    pub packages: Vec<RegistryPackage>,
74    pub total: i64,
75    pub page: i64,
76    pub limit: i64,
77    pub total_pages: i64,
78}
79
80/// Registry publish request
81#[derive(Debug, Clone, Serialize, Deserialize)]
82pub struct RegistryPublishRequest {
83    pub name: String,
84    pub version: String,
85    pub artifact: serde_json::Value,
86    pub tarball: String, // base64-encoded
87}
88
89/// Registry publish response
90#[derive(Debug, Clone, Serialize, Deserialize)]
91pub struct RegistryPublishResponse {
92    pub message: String,
93    pub package_id: Uuid,
94    pub version_id: Uuid,
95}
96
97/// Registry yank request
98#[derive(Debug, Clone, Serialize, Deserialize)]
99pub struct RegistryYankRequest {
100    pub yanked: bool,
101}
102
103/// Registry yank response
104#[derive(Debug, Clone, Serialize, Deserialize)]
105pub struct RegistryYankResponse {
106    pub message: String,
107    pub version: String,
108    pub yanked: bool,
109}
110
111/// Registry API error response
112#[derive(Debug, Clone, Serialize, Deserialize)]
113pub struct RegistryApiError {
114    pub error: String,
115    pub message: String,
116}
117
118/// Registry user information
119#[derive(Debug, Clone, Serialize, Deserialize)]
120pub struct RegistryUserInfo {
121    pub id: Uuid,
122    pub email: String,
123    pub name: Option<String>,
124    pub email_verified: bool,
125}
126
127/// Registry login request
128#[derive(Debug, Clone, Serialize, Deserialize)]
129pub struct RegistryLoginRequest {
130    pub email: String,
131    pub password: String,
132}
133
134/// Registry login response
135#[derive(Debug, Clone, Serialize, Deserialize)]
136pub struct RegistryLoginResponse {
137    pub message: String,
138    pub token: String,
139    pub user: RegistryUserInfo,
140}
141
142/// Registry register request
143#[derive(Debug, Clone, Serialize, Deserialize)]
144pub struct RegistryRegisterRequest {
145    pub email: String,
146    pub password: String,
147    pub name: Option<String>,
148}