Skip to content

Commit 4cd489f

Browse files
committed
feedback changes
1 parent d5e1326 commit 4cd489f

File tree

5 files changed

+282
-858
lines changed

5 files changed

+282
-858
lines changed

Cargo.lock

Lines changed: 50 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/merino/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ edition = "2021"
77
uniffi = { version = "0.28.2" }
88
serde = { version = "1", features=["derive"] }
99
serde_json = "1"
10-
uuid = {version = "1.12.1", features=["serde"]}
11-
url = {version = "2.5.4", features=["serde"]}
1210

1311
[build-dependencies]
1412
uniffi = { version = "0.28.2", features = ["build"] }

components/merino/src/curation.rs

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
*/
5+
use serde::{Deserialize, Serialize};
6+
7+
// Locales supported by Merino Curated Reccomendations
8+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Enum)]
9+
pub enum Locale {
10+
#[serde(rename = "fr")]
11+
Fr,
12+
#[serde(rename = "fr-FR")]
13+
FrFr,
14+
#[serde(rename = "es")]
15+
Es,
16+
#[serde(rename = "es-ES")]
17+
EsEs,
18+
#[serde(rename = "it")]
19+
It,
20+
#[serde(rename = "it-IT")]
21+
ItIt,
22+
#[serde(rename = "en")]
23+
En,
24+
#[serde(rename = "en-CA")]
25+
EnCa,
26+
#[serde(rename = "en-GB")]
27+
EnGb,
28+
#[serde(rename = "en-US")]
29+
EnUs,
30+
#[serde(rename = "de")]
31+
De,
32+
#[serde(rename = "de-DE")]
33+
DeDe,
34+
#[serde(rename = "de-AT")]
35+
DeAt,
36+
#[serde(rename = "de-CH")]
37+
DeCh,
38+
}
39+
// Configuration settings for a Section
40+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Record)]
41+
pub struct SectionSettings {
42+
#[serde(rename = "sectionId")]
43+
section_id: String,
44+
#[serde(rename = "isFollowed")]
45+
is_followed: bool,
46+
#[serde(rename = "isBlocked")]
47+
is_blocked: bool,
48+
}
49+
50+
// Information required to request curated recommendations
51+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Record)]
52+
pub struct CuratedRecommendationsRequest {
53+
pub locale: Locale,
54+
#[uniffi(default = None)]
55+
pub region: Option<String>,
56+
#[uniffi(default = None)]
57+
pub count: Option<i32>,
58+
#[uniffi(default = None)]
59+
pub topics: Option<Vec<String>>,
60+
#[uniffi(default = None)]
61+
pub feeds: Option<Vec<String>>,
62+
#[uniffi(default = None)]
63+
pub sections: Option<Vec<SectionSettings>>,
64+
#[serde(rename = "experimentName")]
65+
#[uniffi(default = None)]
66+
pub experiment_name: Option<String>,
67+
#[serde(rename = "experimentBranch")]
68+
#[uniffi(default = None)]
69+
pub experiment_branch: Option<String>,
70+
}
71+
72+
// Response schema for a list of curated recommendations
73+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Record)]
74+
pub struct CuratedRecommendationsResponse {
75+
#[serde(rename = "recommendedAt")]
76+
pub recommended_at: i32,
77+
pub data: Vec<ReccomendationDataItem>,
78+
#[uniffi(default = None)]
79+
pub feeds: Option<Feeds>,
80+
}
81+
82+
// Multiple list of curated recoummendations
83+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Record)]
84+
pub struct Feeds {
85+
#[uniffi(default = None)]
86+
pub need_to_know: Option<CuratedRecommendationsBucket>,
87+
#[uniffi(default = None)]
88+
pub fakespot: Option<FakespotFeed>,
89+
#[uniffi(default = None)]
90+
pub top_stories_section: Option<FeedSection>,
91+
#[uniffi(default = None)]
92+
pub business: Option<FeedSection>,
93+
#[uniffi(default = None)]
94+
pub career: Option<FeedSection>,
95+
#[uniffi(default = None)]
96+
pub arts: Option<FeedSection>,
97+
#[uniffi(default = None)]
98+
pub food: Option<FeedSection>,
99+
#[uniffi(default = None)]
100+
pub health: Option<FeedSection>,
101+
#[uniffi(default = None)]
102+
pub home: Option<FeedSection>,
103+
#[uniffi(default = None)]
104+
pub finance: Option<FeedSection>,
105+
#[uniffi(default = None)]
106+
pub government: Option<FeedSection>,
107+
#[uniffi(default = None)]
108+
pub sports: Option<FeedSection>,
109+
#[uniffi(default = None)]
110+
pub tech: Option<FeedSection>,
111+
#[uniffi(default = None)]
112+
pub travel: Option<FeedSection>,
113+
#[uniffi(default = None)]
114+
pub education: Option<FeedSection>,
115+
#[uniffi(default = None)]
116+
pub hobbies: Option<FeedSection>,
117+
#[serde(rename = "society-parenting")]
118+
#[uniffi(default = None)]
119+
pub society_parenting: Option<FeedSection>,
120+
#[serde(rename = "education-science")]
121+
#[uniffi(default = None)]
122+
pub education_science: Option<FeedSection>,
123+
#[uniffi(default = None)]
124+
pub society: Option<FeedSection>,
125+
}
126+
127+
// Curated Recommendation Information
128+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Record)]
129+
pub struct ReccomendationDataItem {
130+
#[serde(rename = "corpusItemId")]
131+
pub corpus_item_id: String,
132+
#[serde(rename = "scheduledCorpusItemId")]
133+
pub schdeuled_corpus_item_id: String,
134+
pub url: String,
135+
pub title: String,
136+
pub excerpt: String,
137+
#[uniffi(default = None)]
138+
pub topic: Option<String>,
139+
pub publisher: String,
140+
#[serde(rename = "isTimeSensitive")]
141+
pub is_time_sensitive: bool,
142+
#[serde(rename = "imageUrl")]
143+
pub image_url: String,
144+
#[serde(rename = "tileId")]
145+
pub tile_id: i32,
146+
#[serde(rename = "receivedRank")]
147+
pub received_rank: i32,
148+
}
149+
150+
// Ranked list of curated recommendations
151+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Record)]
152+
pub struct CuratedRecommendationsBucket {
153+
pub recommendations: Vec<ReccomendationDataItem>,
154+
#[uniffi(default = None)]
155+
pub title: Option<String>,
156+
}
157+
158+
// Fakespot product reccomendations
159+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Record)]
160+
pub struct FakespotFeed {
161+
pub products: Vec<FakespotProduct>,
162+
#[serde(rename = "defaultCategoryName")]
163+
pub default_category_name: String,
164+
#[serde(rename = "headerCopy")]
165+
pub header_copy: String,
166+
#[serde(rename = "footerCopy")]
167+
pub footer_copy: String,
168+
pub cta: FakespotCta,
169+
}
170+
171+
// Fakespot product details
172+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Record)]
173+
pub struct FakespotProduct {
174+
id: String,
175+
title: String,
176+
category: String,
177+
#[serde(rename = "imageUrl")]
178+
image_url: String,
179+
url: String,
180+
}
181+
182+
// Fakespot CTA
183+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Record)]
184+
pub struct FakespotCta {
185+
#[serde(rename = "ctaCopy")]
186+
pub cta_copy: String,
187+
pub url: String,
188+
}
189+
190+
// Ranked list of curated recommendations with responsive layout configs
191+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Record)]
192+
pub struct FeedSection {
193+
#[serde(rename = "receivedFeedRank")]
194+
pub received_feed_rank: i32,
195+
pub recommendations: Vec<ReccomendationDataItem>,
196+
pub title: String,
197+
#[uniffi(default = None)]
198+
pub subtitle: Option<String>,
199+
pub layout: Layout,
200+
#[serde(rename = "isFollowed")]
201+
pub is_followed: bool,
202+
#[serde(rename = "isBlocked")]
203+
pub is_blocked: bool,
204+
}
205+
206+
// Representation of a responsive layout configuration with multiple column layouts
207+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Record)]
208+
pub struct Layout {
209+
pub name: String,
210+
#[serde(rename = "responsiveLayouts")]
211+
pub responsive_layouts: Vec<ResponsiveLayout>,
212+
}
213+
214+
// Layout configurations within a column
215+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Record)]
216+
pub struct ResponsiveLayout {
217+
#[serde(rename = "columnCount")]
218+
pub column_count: i32,
219+
pub tiles: Vec<Tile>,
220+
}
221+
// Properties for a single tile in a responsive layout
222+
#[derive(Debug, Serialize, Deserialize, PartialEq, uniffi::Record)]
223+
pub struct Tile {
224+
pub size: String,
225+
pub position: i32,
226+
#[serde(rename = "hasAd")]
227+
pub has_ad: bool,
228+
#[serde(rename = "hasExcerpt")]
229+
pub has_excerpt: bool,
230+
}

components/merino/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
pub mod merino;
1+
pub mod curation;
2+
uniffi::setup_scaffolding!();

0 commit comments

Comments
 (0)