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
use crate::labels::Label;
use crate::names::Name;
use crate::sorting::{NotebookSortFields, PaginatedSearch, SortDirection, ViewSortFields};
use base64uuid::Base64Uuid;
#[cfg(feature = "fp-bindgen")]
use fp_bindgen::prelude::Serializable;
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use typed_builder::TypedBuilder;
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, TypedBuilder)]
#[cfg_attr(
feature = "fp-bindgen",
derive(Serializable),
fp(rust_module = "fiberplane_models::views")
)]
#[non_exhaustive]
#[serde(rename_all = "camelCase")]
pub struct View {
pub id: Base64Uuid,
pub name: Name,
pub display_name: String,
pub description: String,
pub color: i16,
pub labels: Vec<Label>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub relative_time: Option<RelativeTime>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub sort_by: Option<NotebookSortFields>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub sort_direction: Option<SortDirection>,
#[serde(with = "time::serde::rfc3339")]
pub created_at: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
pub updated_at: OffsetDateTime,
}
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, TypedBuilder)]
#[non_exhaustive]
#[serde(rename_all = "camelCase")]
pub struct ViewQuery {
#[serde(flatten)]
pub search: PaginatedSearch<ViewSortFields>,
}
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, TypedBuilder)]
#[cfg_attr(
feature = "fp-bindgen",
derive(Serializable),
fp(rust_module = "fiberplane_models::views")
)]
#[non_exhaustive]
#[serde(rename_all = "camelCase")]
pub struct NewView {
pub name: Name,
#[builder(default, setter(into))]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[builder(setter(into))]
pub description: String,
#[builder(default)]
pub color: i16,
#[builder(default)]
pub labels: Vec<Label>,
#[builder(default)]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub relative_time: Option<RelativeTime>,
#[builder(default)]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub sort_by: Option<NotebookSortFields>,
#[builder(default)]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub sort_direction: Option<SortDirection>,
}
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, TypedBuilder)]
#[cfg_attr(
feature = "fp-bindgen",
derive(Serializable),
fp(rust_module = "fiberplane_models::views")
)]
#[non_exhaustive]
#[serde(rename_all = "camelCase")]
pub struct UpdateView {
#[builder(default, setter(into))]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[builder(default, setter(into))]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[builder(default)]
pub color: i16,
#[builder(default)]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub labels: Option<Vec<Label>>,
#[builder(default)]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub sort_by: Option<NotebookSortFields>,
#[builder(default)]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub sort_direction: Option<SortDirection>,
}
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, TypedBuilder)]
#[cfg_attr(
feature = "fp-bindgen",
derive(Serializable),
fp(rust_module = "fiberplane_models::views")
)]
#[non_exhaustive]
#[serde(rename_all = "camelCase")]
pub struct PinnedView {
pub name: Name,
}
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize, Copy, Clone)]
#[cfg_attr(
feature = "fp-bindgen",
derive(Serializable),
fp(rust_module = "fiberplane_models::views")
)]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type), sqlx(type_name = "time_unit"))]
#[non_exhaustive]
#[serde(rename_all = "camelCase")]
pub enum TimeUnit {
Seconds,
Minutes,
Hours,
Days,
}
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize, Copy, Clone)]
#[cfg_attr(
feature = "fp-bindgen",
derive(Serializable),
fp(rust_module = "fiberplane_models::views")
)]
#[cfg_attr(
feature = "sqlx",
derive(sqlx::Type),
sqlx(type_name = "relative_time")
)]
#[non_exhaustive]
#[serde(rename_all = "camelCase")]
pub struct RelativeTime {
pub unit: TimeUnit,
pub value: i64,
}