thunderstore_api/models/v2/
submission.rs

1////////////////////////////////////////////////////////////////////////////////
2// This Source Code Form is subject to the terms of the Mozilla Public         /
3// License, v. 2.0. If a copy of the MPL was not distributed with this         /
4// file, You can obtain one at https://mozilla.org/MPL/2.0/.                   /
5////////////////////////////////////////////////////////////////////////////////
6
7use crate::models::v2::available_community::AvailableCommunity;
8use crate::models::v2::package;
9#[cfg(feature = "ts-rs")]
10use ts_rs::TS;
11use uuid::Uuid;
12
13#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
14pub struct PackageSubmissionMetadata {
15    pub author_name: String,
16    pub categories: Vec<String>,
17    pub communities: Vec<String>,
18    pub has_nsfw_content: bool,
19    pub upload_uuid: Uuid,
20}
21
22impl PackageSubmissionMetadata {
23    #[must_use]
24    pub fn new(
25        author_name: String,
26        categories: Vec<String>,
27        communities: Vec<String>,
28        has_nsfw_content: bool,
29        upload_uuid: uuid::Uuid,
30    ) -> PackageSubmissionMetadata {
31        PackageSubmissionMetadata {
32            author_name,
33            categories,
34            communities,
35            has_nsfw_content,
36            upload_uuid,
37        }
38    }
39}
40
41#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
42#[cfg_attr(feature = "ts-rs", derive(TS))]
43#[cfg_attr(feature = "ts-rs", ts(export))]
44pub struct PackageSubmissionResult {
45    pub package_version: package::Version,
46    pub available_communities: Vec<AvailableCommunity>,
47}
48
49impl PackageSubmissionResult {
50    #[must_use]
51    pub fn new(
52        package_version: package::Version,
53        available_communities: Vec<AvailableCommunity>,
54    ) -> PackageSubmissionResult {
55        PackageSubmissionResult {
56            package_version,
57            available_communities,
58        }
59    }
60}
61
62#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
63#[cfg_attr(feature = "ts-rs", derive(TS))]
64#[cfg_attr(feature = "ts-rs", ts(export))]
65pub struct ReadmeValidatorParams {
66    pub readme_data: String,
67}
68
69impl ReadmeValidatorParams {
70    #[must_use]
71    pub fn new(readme_data: String) -> ReadmeValidatorParams {
72        ReadmeValidatorParams { readme_data }
73    }
74}
75
76#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
77#[cfg_attr(feature = "ts-rs", derive(TS))]
78#[cfg_attr(feature = "ts-rs", ts(export))]
79pub struct ValidatorResponse {
80    pub success: bool,
81}
82
83impl ValidatorResponse {
84    #[must_use]
85    pub fn new(success: bool) -> ValidatorResponse {
86        ValidatorResponse { success }
87    }
88}
89
90#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
91#[cfg_attr(feature = "ts-rs", derive(TS))]
92#[cfg_attr(feature = "ts-rs", ts(export))]
93pub struct ManifestV1ValidatorParams {
94    pub namespace: String,
95    pub manifest_data: String,
96}
97
98impl ManifestV1ValidatorParams {
99    #[must_use]
100    pub fn new(namespace: String, manifest_data: String) -> ManifestV1ValidatorParams {
101        ManifestV1ValidatorParams {
102            namespace,
103            manifest_data,
104        }
105    }
106}
107
108#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
109#[cfg_attr(feature = "ts-rs", derive(TS))]
110#[cfg_attr(feature = "ts-rs", ts(export))]
111pub struct IconValidatorParams {
112    #[serde(rename = "icon_data")]
113    pub icon_data: String,
114}
115
116impl IconValidatorParams {
117    #[must_use]
118    pub fn new(icon_data: String) -> IconValidatorParams {
119        IconValidatorParams { icon_data }
120    }
121}