nylas-types 0.1.1

Type definitions for Nylas API v3
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
//! Notetaker types for meeting recording and transcription.

use crate::common::{NotetakerId, RecordingId};
use serde::{Deserialize, Serialize};

/// Notetaker configuration.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Notetaker {
    /// Unique identifier for the notetaker configuration
    pub id: NotetakerId,

    /// Grant ID this notetaker belongs to
    pub grant_id: String,

    /// Whether the notetaker is active
    pub active: bool,

    /// Provider-specific settings
    pub provider_settings: ProviderSettings,

    /// Transcription settings
    pub transcription_settings: Option<TranscriptionSettings>,

    /// AI summary settings
    pub summary_settings: Option<SummarySettings>,

    /// Webhook URL for notifications
    pub webhook_url: Option<String>,

    /// Created timestamp (Unix seconds)
    pub created_at: i64,

    /// Updated timestamp (Unix seconds)
    pub updated_at: i64,
}

/// Provider-specific settings.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "provider", rename_all = "lowercase")]
pub enum ProviderSettings {
    /// Google Meet settings
    #[serde(rename = "google-meet")]
    GoogleMeet {
        /// Auto-join meetings on calendar
        auto_join: bool,
        /// Recording quality
        quality: RecordingQuality,
    },

    /// Microsoft Teams settings
    #[serde(rename = "microsoft-teams")]
    MicrosoftTeams {
        /// Auto-join meetings on calendar
        auto_join: bool,
        /// Recording quality
        quality: RecordingQuality,
    },

    /// Zoom settings
    Zoom {
        /// Auto-join meetings on calendar
        auto_join: bool,
        /// Recording quality
        quality: RecordingQuality,
        /// Cloud recording (vs local)
        cloud_recording: bool,
    },
}

/// Recording quality levels.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum RecordingQuality {
    /// Standard definition
    Standard,
    /// High definition
    Hd,
}

/// Transcription settings.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TranscriptionSettings {
    /// Enable transcription
    pub enabled: bool,

    /// Language for transcription (e.g., "en-US")
    pub language: Option<String>,

    /// Enable speaker identification
    pub speaker_identification: bool,

    /// Profanity filtering
    pub profanity_filter: Option<bool>,
}

/// AI summary settings.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SummarySettings {
    /// Enable AI summaries
    pub enabled: bool,

    /// Extract action items
    pub extract_action_items: bool,

    /// Extract key topics
    pub extract_topics: bool,

    /// Extract decisions made
    pub extract_decisions: bool,

    /// Summary length preference
    pub summary_length: SummaryLength,
}

/// Summary length preference.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum SummaryLength {
    /// Brief summary
    Brief,
    /// Medium-length summary
    Medium,
    /// Detailed summary
    Detailed,
}

/// Recording from a meeting.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Recording {
    /// Unique identifier for the recording
    pub id: RecordingId,

    /// Notetaker configuration ID
    pub notetaker_id: NotetakerId,

    /// Meeting title
    pub title: String,

    /// Meeting start time (Unix seconds)
    pub start_time: i64,

    /// Meeting end time (Unix seconds)
    pub end_time: Option<i64>,

    /// Recording duration in seconds
    pub duration: Option<i64>,

    /// Recording status
    pub status: RecordingStatus,

    /// Recording file URL (when available)
    pub recording_url: Option<String>,

    /// Transcription (when available)
    pub transcription: Option<Transcription>,

    /// AI-generated summary (when available)
    pub summary: Option<Summary>,

    /// Meeting participants
    pub participants: Vec<MeetingParticipant>,

    /// Created timestamp (Unix seconds)
    pub created_at: i64,

    /// Updated timestamp (Unix seconds)
    pub updated_at: i64,
}

/// Recording status.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum RecordingStatus {
    /// Recording in progress
    Recording,
    /// Processing (transcribing, summarizing)
    Processing,
    /// Completed and available
    Completed,
    /// Failed
    Failed,
}

/// Meeting transcription.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Transcription {
    /// Full transcript text
    pub text: String,

    /// Transcript segments with timestamps
    pub segments: Vec<TranscriptSegment>,

    /// Detected language
    pub language: String,

    /// Confidence score (0.0 - 1.0)
    pub confidence: f64,
}

/// Transcript segment with speaker and timing.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TranscriptSegment {
    /// Segment text
    pub text: String,

    /// Speaker identifier
    pub speaker: Option<String>,

    /// Start time in seconds from recording start
    pub start_time: f64,

    /// End time in seconds from recording start
    pub end_time: f64,

    /// Confidence score (0.0 - 1.0)
    pub confidence: f64,
}

/// AI-generated meeting summary.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Summary {
    /// Overall meeting summary
    pub summary: String,

    /// Extracted action items
    pub action_items: Vec<ActionItem>,

    /// Key topics discussed
    pub topics: Vec<String>,

    /// Decisions made
    pub decisions: Vec<String>,

    /// Next steps
    pub next_steps: Vec<String>,
}

/// Action item from meeting.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ActionItem {
    /// Description of the action
    pub description: String,

    /// Assigned to (if detected)
    pub assignee: Option<String>,

    /// Due date (if mentioned, Unix seconds)
    pub due_date: Option<i64>,

    /// Priority level (if detected)
    pub priority: Option<Priority>,
}

/// Action item priority.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Priority {
    /// High priority
    High,
    /// Medium priority
    Medium,
    /// Low priority
    Low,
}

/// Meeting participant.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MeetingParticipant {
    /// Participant name
    pub name: String,

    /// Email address (if available)
    pub email: Option<String>,

    /// Join time (Unix seconds)
    pub joined_at: i64,

    /// Leave time (Unix seconds, None if still in meeting)
    pub left_at: Option<i64>,

    /// Speaking time in seconds
    pub speaking_time: Option<i64>,
}

/// Request to create a notetaker configuration.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CreateNotetakerRequest {
    /// Provider-specific settings
    pub provider_settings: ProviderSettings,

    /// Transcription settings
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transcription_settings: Option<TranscriptionSettings>,

    /// AI summary settings
    #[serde(skip_serializing_if = "Option::is_none")]
    pub summary_settings: Option<SummarySettings>,

    /// Webhook URL for notifications
    #[serde(skip_serializing_if = "Option::is_none")]
    pub webhook_url: Option<String>,

    /// Whether the notetaker is active
    #[serde(skip_serializing_if = "Option::is_none")]
    pub active: Option<bool>,
}

impl CreateNotetakerRequest {
    /// Create a builder for CreateNotetakerRequest.
    pub fn builder(provider_settings: ProviderSettings) -> CreateNotetakerRequestBuilder {
        CreateNotetakerRequestBuilder::new(provider_settings)
    }
}

/// Builder for CreateNotetakerRequest.
#[derive(Debug)]
pub struct CreateNotetakerRequestBuilder {
    request: CreateNotetakerRequest,
}

impl CreateNotetakerRequestBuilder {
    /// Create a new builder.
    pub fn new(provider_settings: ProviderSettings) -> Self {
        Self {
            request: CreateNotetakerRequest {
                provider_settings,
                transcription_settings: None,
                summary_settings: None,
                webhook_url: None,
                active: None,
            },
        }
    }

    /// Set transcription settings.
    pub fn transcription_settings(mut self, settings: TranscriptionSettings) -> Self {
        self.request.transcription_settings = Some(settings);
        self
    }

    /// Set summary settings.
    pub fn summary_settings(mut self, settings: SummarySettings) -> Self {
        self.request.summary_settings = Some(settings);
        self
    }

    /// Set webhook URL.
    pub fn webhook_url(mut self, url: impl Into<String>) -> Self {
        self.request.webhook_url = Some(url.into());
        self
    }

    /// Set active status.
    pub fn active(mut self, active: bool) -> Self {
        self.request.active = Some(active);
        self
    }

    /// Build the request.
    pub fn build(self) -> CreateNotetakerRequest {
        self.request
    }
}

/// Request to update a notetaker configuration.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
pub struct UpdateNotetakerRequest {
    /// Provider-specific settings
    #[serde(skip_serializing_if = "Option::is_none")]
    pub provider_settings: Option<ProviderSettings>,

    /// Transcription settings
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transcription_settings: Option<TranscriptionSettings>,

    /// AI summary settings
    #[serde(skip_serializing_if = "Option::is_none")]
    pub summary_settings: Option<SummarySettings>,

    /// Webhook URL for notifications
    #[serde(skip_serializing_if = "Option::is_none")]
    pub webhook_url: Option<String>,

    /// Whether the notetaker is active
    #[serde(skip_serializing_if = "Option::is_none")]
    pub active: Option<bool>,
}

impl UpdateNotetakerRequest {
    /// Create a builder for UpdateNotetakerRequest.
    pub fn builder() -> UpdateNotetakerRequestBuilder {
        UpdateNotetakerRequestBuilder::default()
    }
}

/// Builder for UpdateNotetakerRequest.
#[derive(Debug, Default)]
pub struct UpdateNotetakerRequestBuilder {
    request: UpdateNotetakerRequest,
}

impl UpdateNotetakerRequestBuilder {
    /// Set provider settings.
    pub fn provider_settings(mut self, settings: ProviderSettings) -> Self {
        self.request.provider_settings = Some(settings);
        self
    }

    /// Set transcription settings.
    pub fn transcription_settings(mut self, settings: TranscriptionSettings) -> Self {
        self.request.transcription_settings = Some(settings);
        self
    }

    /// Set summary settings.
    pub fn summary_settings(mut self, settings: SummarySettings) -> Self {
        self.request.summary_settings = Some(settings);
        self
    }

    /// Set webhook URL.
    pub fn webhook_url(mut self, url: impl Into<String>) -> Self {
        self.request.webhook_url = Some(url.into());
        self
    }

    /// Set active status.
    pub fn active(mut self, active: bool) -> Self {
        self.request.active = Some(active);
        self
    }

    /// Build the request.
    pub fn build(self) -> UpdateNotetakerRequest {
        self.request
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_notetaker_id_creation() {
        let id = NotetakerId::new("notetaker_123");
        assert_eq!(id.as_str(), "notetaker_123");
    }

    #[test]
    fn test_recording_id_creation() {
        let id = RecordingId::new("rec_456");
        assert_eq!(id.as_str(), "rec_456");
    }

    #[test]
    fn test_create_notetaker_request_builder() {
        let provider = ProviderSettings::GoogleMeet {
            auto_join: true,
            quality: RecordingQuality::Hd,
        };

        let transcription = TranscriptionSettings {
            enabled: true,
            language: Some("en-US".to_string()),
            speaker_identification: true,
            profanity_filter: Some(false),
        };

        let request = CreateNotetakerRequest::builder(provider)
            .transcription_settings(transcription)
            .active(true)
            .build();

        assert!(request.active.unwrap());
        assert!(request.transcription_settings.is_some());
    }

    #[test]
    fn test_update_notetaker_request_builder() {
        let request = UpdateNotetakerRequest::builder()
            .active(false)
            .webhook_url("https://example.com/webhook")
            .build();

        assert_eq!(request.active, Some(false));
        assert_eq!(
            request.webhook_url,
            Some("https://example.com/webhook".to_string())
        );
    }

    #[test]
    fn test_recording_status_serialization() {
        let status = RecordingStatus::Processing;
        let json = serde_json::to_string(&status).unwrap();
        assert_eq!(json, "\"processing\"");
    }

    #[test]
    fn test_summary_length_serialization() {
        let length = SummaryLength::Brief;
        let json = serde_json::to_string(&length).unwrap();
        assert_eq!(json, "\"brief\"");
    }
}