Skip to main content

ibridge_server/
calendar_dto.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! Calendar and reminders tool arguments and structured results.
4
5use schemars::JsonSchema;
6use serde::{Deserialize, Serialize};
7
8fn default_page_limit() -> u32 {
9    25
10}
11
12/// Arguments for `calendar_list_events`.
13#[derive(Debug, Default, Deserialize, JsonSchema)]
14pub struct ListEventsParams {
15    /// Calendar ids from `calendar_list_calendars`. Omit for every calendar that holds events.
16    #[serde(default)]
17    pub calendars: Vec<String>,
18    /// Start of the range, as an ISO-8601 date or timestamp. Included.
19    pub start: String,
20    /// End of the range, as an ISO-8601 date or timestamp. Excluded.
21    pub end: String,
22    /// Page size. Omitted means 25. More than 100 is rejected.
23    #[serde(default = "default_page_limit")]
24    pub limit: u32,
25    /// Cursor from the previous page.
26    #[serde(default)]
27    pub cursor: Option<String>,
28}
29
30/// Arguments for `calendar_get_event`.
31#[derive(Debug, Default, Deserialize, JsonSchema)]
32pub struct GetByIdParams {
33    /// Opaque id from a list result.
34    pub id: String,
35}
36
37/// Arguments for `calendar_create_event`.
38#[derive(Debug, Default, Deserialize, JsonSchema)]
39pub struct CreateEventParams {
40    /// Calendar id from `calendar_list_calendars`. It must hold events.
41    pub calendar: String,
42    /// Title of the event.
43    pub summary: String,
44    /// Notes.
45    #[serde(default)]
46    pub description: Option<String>,
47    /// Start: an ISO-8601 date for an all-day event, otherwise a timestamp.
48    pub start: String,
49    /// End. Omit for one hour after the start, or one day for an all-day event.
50    #[serde(default)]
51    pub end: Option<String>,
52    /// IANA time zone name, such as Europe/Berlin. Omit for UTC.
53    #[serde(default)]
54    pub time_zone: Option<String>,
55    /// Guests' email addresses, one plain address each (name@example.com), at most 50.
56    /// iCloud emails each one an invitation. Omit for an event with no guests.
57    #[serde(default)]
58    pub attendees: Option<Vec<String>>,
59}
60
61/// Arguments for `calendar_update_event`.
62#[derive(Debug, Default, Deserialize, JsonSchema)]
63pub struct UpdateEventParams {
64    /// Opaque event id.
65    pub id: String,
66    /// The `etag` from the last read. A different one means the event changed.
67    pub etag: String,
68    /// New title. Omit to keep it.
69    #[serde(default)]
70    pub summary: Option<String>,
71    /// New notes. Omit to keep them.
72    #[serde(default)]
73    pub description: Option<String>,
74    /// New start. Omit to keep it.
75    #[serde(default)]
76    pub start: Option<String>,
77    /// New end. Omit to keep it.
78    #[serde(default)]
79    pub end: Option<String>,
80    /// IANA time zone for the new times. Omit to keep the event's zone.
81    #[serde(default)]
82    pub time_zone: Option<String>,
83    /// For a repeating event: the `recurrence_id` of one occurrence to change on its own.
84    /// Omit to change the whole series. Changing one occurrence needs `start` and `end`.
85    #[serde(default)]
86    pub occurrence: Option<String>,
87    /// The whole new guest list for the series, one plain address each, at most 50. It
88    /// replaces the old list: iCloud emails an invitation to each added guest and a
89    /// cancellation to each removed one. An empty list removes every guest. Omit to
90    /// leave the guests alone. Not allowed with `occurrence`. Leave your own address out.
91    #[serde(default)]
92    pub attendees: Option<Vec<String>>,
93}
94
95/// Arguments for the delete tools.
96#[derive(Debug, Default, Deserialize, JsonSchema)]
97pub struct DeleteParams {
98    /// Opaque id.
99    pub id: String,
100    /// The `etag` from the last read.
101    pub etag: String,
102}
103
104/// Arguments for `reminders_list`.
105#[derive(Debug, Default, Deserialize, JsonSchema)]
106pub struct ListRemindersParams {
107    /// List id from `reminders_list_lists`. Omit for every list.
108    #[serde(default)]
109    pub list: Option<String>,
110    /// Also return completed reminders. Omitted means open reminders only.
111    #[serde(default)]
112    pub include_completed: Option<bool>,
113    /// Page size. Omitted means 25. More than 100 is rejected.
114    #[serde(default = "default_page_limit")]
115    pub limit: u32,
116    /// Cursor from the previous page.
117    #[serde(default)]
118    pub cursor: Option<String>,
119}
120
121/// Arguments for `reminders_create`.
122#[derive(Debug, Default, Deserialize, JsonSchema)]
123pub struct CreateReminderParams {
124    /// List id from `reminders_list_lists`.
125    pub list: String,
126    /// Title.
127    pub title: String,
128    /// Notes.
129    #[serde(default)]
130    pub notes: Option<String>,
131    /// Due date or timestamp, ISO-8601.
132    #[serde(default)]
133    pub due: Option<String>,
134    /// Priority from 1 (highest) to 9.
135    #[serde(default)]
136    pub priority: Option<u8>,
137}
138
139/// Arguments for `reminders_update`.
140#[derive(Debug, Default, Deserialize, JsonSchema)]
141pub struct UpdateReminderParams {
142    /// Opaque reminder id.
143    pub id: String,
144    /// The `etag` from the last read.
145    pub etag: String,
146    /// New title. Omit to keep it.
147    #[serde(default)]
148    pub title: Option<String>,
149    /// New notes. Omit to keep them.
150    #[serde(default)]
151    pub notes: Option<String>,
152    /// New due date. Omit to keep it; an empty string removes it.
153    #[serde(default)]
154    pub due: Option<String>,
155    /// New priority, 1 to 9. Omit to keep it; 0 removes it.
156    #[serde(default)]
157    pub priority: Option<u8>,
158    /// Mark completed or open. Omit to keep it.
159    #[serde(default)]
160    pub completed: Option<bool>,
161}
162
163#[derive(Debug, Serialize, JsonSchema)]
164pub(crate) struct CalendarOut {
165    pub(crate) id: String,
166    /// As the calendar's owner named it.
167    pub(crate) name: String,
168    /// `events`, `tasks` or `both`.
169    pub(crate) kind: &'static str,
170}
171
172#[derive(Debug, Serialize, JsonSchema)]
173pub(crate) struct CalendarListOut {
174    pub(crate) calendars: Vec<CalendarOut>,
175}
176
177#[derive(Debug, Serialize, JsonSchema)]
178pub(crate) struct EventOut {
179    pub(crate) id: String,
180    pub(crate) etag: String,
181    pub(crate) uid: String,
182    /// As the event's author wrote it.
183    pub(crate) summary: String,
184    /// As the event's author wrote it.
185    pub(crate) description: String,
186    pub(crate) start: String,
187    pub(crate) end: String,
188    pub(crate) time_zone: Option<String>,
189    pub(crate) all_day: bool,
190    pub(crate) recurring: bool,
191    /// Pass as `occurrence` to change only this occurrence.
192    pub(crate) recurrence_id: Option<String>,
193    /// As the event's author entered them.
194    pub(crate) attendees: Vec<String>,
195    pub(crate) alarms: Vec<String>,
196}
197
198#[derive(Debug, Serialize, JsonSchema)]
199pub(crate) struct EventListOut {
200    pub(crate) events: Vec<EventOut>,
201    pub(crate) next_cursor: Option<String>,
202    /// Items that could not be read and were skipped.
203    pub(crate) warnings: u32,
204}
205
206#[derive(Debug, Serialize, JsonSchema)]
207pub(crate) struct WriteOut {
208    pub(crate) id: String,
209    /// The new `etag`, when the write returned one.
210    pub(crate) etag: Option<String>,
211}
212
213#[derive(Debug, Serialize, JsonSchema)]
214pub(crate) struct DeleteOut {
215    pub(crate) deleted: bool,
216}
217
218#[derive(Debug, Serialize, JsonSchema)]
219pub(crate) struct ReminderListOut {
220    pub(crate) id: String,
221    /// As the calendar's owner named it.
222    pub(crate) name: String,
223}
224
225#[derive(Debug, Serialize, JsonSchema)]
226pub(crate) struct ReminderListsOut {
227    pub(crate) lists: Vec<ReminderListOut>,
228    /// Says that lists the Reminders app upgraded are not reachable.
229    pub(crate) note: &'static str,
230}
231
232#[derive(Debug, Serialize, JsonSchema)]
233pub(crate) struct ReminderOut {
234    pub(crate) id: String,
235    pub(crate) etag: String,
236    /// As the reminder's author wrote it.
237    pub(crate) title: String,
238    /// As the reminder's author wrote it.
239    pub(crate) notes: String,
240    pub(crate) due: Option<String>,
241    pub(crate) priority: Option<u8>,
242    pub(crate) completed: bool,
243}
244
245#[derive(Debug, Serialize, JsonSchema)]
246pub(crate) struct RemindersOut {
247    pub(crate) reminders: Vec<ReminderOut>,
248    pub(crate) next_cursor: Option<String>,
249    /// Items that could not be read and were skipped.
250    pub(crate) warnings: u32,
251}