Skip to main content

common/
entities.rs

1// Generated by Qleany v1.5.6 from common_entities.tera
2
3use crate::types::EntityId;
4use crate::types::HasId;
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
8pub struct Root {
9    pub id: EntityId,
10    #[serde(with = "chrono::serde::ts_milliseconds")]
11    pub created_at: chrono::DateTime<chrono::Utc>,
12    #[serde(with = "chrono::serde::ts_milliseconds")]
13    pub updated_at: chrono::DateTime<chrono::Utc>,
14    pub document: EntityId,
15}
16
17impl HasId for Root {
18    fn id(&self) -> EntityId {
19        self.id
20    }
21}
22
23#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
24pub struct Document {
25    pub id: EntityId,
26    #[serde(with = "chrono::serde::ts_milliseconds")]
27    pub created_at: chrono::DateTime<chrono::Utc>,
28    #[serde(with = "chrono::serde::ts_milliseconds")]
29    pub updated_at: chrono::DateTime<chrono::Utc>,
30    pub title: String,
31    pub frames: Vec<EntityId>,
32    pub text_direction: TextDirection,
33    pub default_wrap_mode: WrapMode,
34    /// Document-wide default natural language as an ISO 639-1 code (e.g.
35    /// "en", "fr"). Used as the fallback hyphenation language for blocks
36    /// that don't set their own `fmt_language`. `None` is treated as "en".
37    #[serde(default)]
38    pub default_language: Option<String>,
39    pub resources: Vec<EntityId>,
40    pub lists: Vec<EntityId>,
41    pub tables: Vec<EntityId>,
42    pub character_count: i64,
43    pub block_count: i64,
44}
45
46impl HasId for Document {
47    fn id(&self) -> EntityId {
48        self.id
49    }
50}
51#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
52pub enum TextDirection {
53    #[default]
54    LeftToRight,
55    RightToLeft,
56}
57#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
58pub enum WrapMode {
59    #[default]
60    NoWrap,
61    WordWrap,
62    WrapAnywhere,
63    WrapAtWordBoundaryOrAnywhere,
64}
65
66#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
67pub struct Frame {
68    pub id: EntityId,
69    #[serde(with = "chrono::serde::ts_milliseconds")]
70    pub created_at: chrono::DateTime<chrono::Utc>,
71    #[serde(with = "chrono::serde::ts_milliseconds")]
72    pub updated_at: chrono::DateTime<chrono::Utc>,
73    pub parent_frame: Option<EntityId>,
74    pub blocks: Vec<EntityId>,
75    pub child_order: Vec<i64>,
76    pub fmt_height: Option<i64>,
77    pub fmt_width: Option<i64>,
78    pub fmt_top_margin: Option<i64>,
79    pub fmt_bottom_margin: Option<i64>,
80    pub fmt_left_margin: Option<i64>,
81    pub fmt_right_margin: Option<i64>,
82    pub fmt_padding: Option<i64>,
83    pub fmt_border: Option<i64>,
84    pub fmt_position: Option<FramePosition>,
85    pub fmt_is_blockquote: Option<bool>,
86    /// What this frame *is*, when a blockquote stands in for something a format can
87    /// name semantically (an epigraph). `None` for an ordinary quotation.
88    #[serde(default)]
89    pub fmt_semantic_role: Option<SemanticRole>,
90    pub table: Option<EntityId>,
91    /// Rope byte range occupied by this frame's contents. Plan §1.6
92    /// invariant: all blocks in `Frame.blocks` have byte ranges
93    /// contained within this range, and no two frames' ranges
94    /// overlap. Empty/unset = `(0, 0)`. Internal field — not
95    /// surfaced through DTOs.
96    #[serde(default)]
97    pub byte_range: (u32, u32),
98    /// The footnote this frame *is the body of*, identified by the label its
99    /// references name it with. `None` for every ordinary frame.
100    ///
101    /// A definition is arbitrary block content, so it needs a frame of its own
102    /// exactly as a table cell does — but unlike a cell it is not part of the
103    /// flow it was written in: it belongs at the foot of a page, the end of a
104    /// chapter, or wherever the format puts notes. So it is a **detached**
105    /// top-level frame, reachable by label rather than by position.
106    ///
107    /// Hand-maintained beside `byte_range` above, for the same reason.
108    #[serde(default)]
109    pub footnote_label: Option<String>,
110}
111
112impl HasId for Frame {
113    fn id(&self) -> EntityId {
114        self.id
115    }
116}
117#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
118pub enum FramePosition {
119    #[default]
120    InFlow,
121    FloatLeft,
122    FloatRight,
123}
124#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
125pub enum SemanticRole {
126    #[default]
127    Epigraph,
128}
129
130#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
131pub struct Block {
132    pub id: EntityId,
133    #[serde(with = "chrono::serde::ts_milliseconds")]
134    pub created_at: chrono::DateTime<chrono::Utc>,
135    #[serde(with = "chrono::serde::ts_milliseconds")]
136    pub updated_at: chrono::DateTime<chrono::Utc>,
137    pub list: Option<EntityId>,
138    pub document_position: i64,
139    pub fmt_alignment: Option<Alignment>,
140    pub fmt_top_margin: Option<i64>,
141    pub fmt_bottom_margin: Option<i64>,
142    pub fmt_left_margin: Option<i64>,
143    pub fmt_right_margin: Option<i64>,
144    pub fmt_heading_level: Option<i64>,
145    pub fmt_indent: Option<i64>,
146    pub fmt_text_indent: Option<i64>,
147    pub fmt_marker: Option<MarkerType>,
148    pub fmt_tab_positions: Vec<i64>,
149    pub fmt_line_height: Option<i64>,
150    pub fmt_non_breakable_lines: Option<bool>,
151    /// Start this block on a new page. Its neighbour above keeps a block's lines
152    /// together; this one puts a page boundary in front of it. Only the paginated
153    /// formats can honour it literally — DOCX `w:pageBreakBefore`, Typst `#pagebreak`,
154    /// LaTeX `\newpage`, CSS `break-before` — and the flowing ones render it as best
155    /// they can or not at all. `None` means "wherever the text falls".
156    #[serde(default)]
157    pub fmt_page_break_before: Option<bool>,
158    pub fmt_direction: Option<TextDirection>,
159    pub fmt_background_color: Option<String>,
160    pub fmt_is_code_block: Option<bool>,
161    pub fmt_code_language: Option<String>,
162    /// Enable automatic + soft-hyphen hyphenation for this block.
163    #[serde(default)]
164    pub fmt_hyphenate: Option<bool>,
165    /// Natural language of this block as an ISO 639-1 code (e.g. "en",
166    /// "fr"); drives hyphenation dictionary selection.
167    #[serde(default)]
168    pub fmt_language: Option<String>,
169}
170
171impl HasId for Block {
172    fn id(&self) -> EntityId {
173        self.id
174    }
175}
176#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
177pub enum Alignment {
178    #[default]
179    Left,
180    Right,
181    Center,
182    Justify,
183}
184#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
185pub enum MarkerType {
186    #[default]
187    NoMarker,
188    Unchecked,
189    Checked,
190}
191
192#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
193pub enum UnderlineStyle {
194    #[default]
195    NoUnderline,
196    SingleUnderline,
197    DashUnderline,
198    DotLine,
199    DashDotLine,
200    DashDotDotLine,
201    WaveUnderline,
202    SpellCheckUnderline,
203}
204#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
205pub enum CharVerticalAlignment {
206    #[default]
207    Normal,
208    SuperScript,
209    SubScript,
210    Middle,
211    Bottom,
212    Top,
213    Baseline,
214}
215
216#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
217pub struct List {
218    pub id: EntityId,
219    #[serde(with = "chrono::serde::ts_milliseconds")]
220    pub created_at: chrono::DateTime<chrono::Utc>,
221    #[serde(with = "chrono::serde::ts_milliseconds")]
222    pub updated_at: chrono::DateTime<chrono::Utc>,
223    pub style: ListStyle,
224    pub indent: i64,
225    pub prefix: String,
226    pub suffix: String,
227}
228
229impl HasId for List {
230    fn id(&self) -> EntityId {
231        self.id
232    }
233}
234#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
235pub enum ListStyle {
236    #[default]
237    Disc,
238    Circle,
239    Square,
240    Decimal,
241    LowerAlpha,
242    UpperAlpha,
243    LowerRoman,
244    UpperRoman,
245}
246
247#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
248pub struct Resource {
249    pub id: EntityId,
250    #[serde(with = "chrono::serde::ts_milliseconds")]
251    pub created_at: chrono::DateTime<chrono::Utc>,
252    #[serde(with = "chrono::serde::ts_milliseconds")]
253    pub updated_at: chrono::DateTime<chrono::Utc>,
254    pub resource_type: ResourceType,
255    pub name: String,
256    pub url: String,
257    pub mime_type: String,
258    pub data_base64: String,
259}
260
261impl HasId for Resource {
262    fn id(&self) -> EntityId {
263        self.id
264    }
265}
266#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
267pub enum ResourceType {
268    #[default]
269    Image,
270    StyleSheet,
271    Other,
272}
273
274#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
275pub struct Table {
276    pub id: EntityId,
277    #[serde(with = "chrono::serde::ts_milliseconds")]
278    pub created_at: chrono::DateTime<chrono::Utc>,
279    #[serde(with = "chrono::serde::ts_milliseconds")]
280    pub updated_at: chrono::DateTime<chrono::Utc>,
281    pub cells: Vec<EntityId>,
282    pub rows: i64,
283    pub columns: i64,
284    pub column_widths: Vec<i64>,
285    pub fmt_border: Option<i64>,
286    pub fmt_cell_spacing: Option<i64>,
287    pub fmt_cell_padding: Option<i64>,
288    pub fmt_width: Option<i64>,
289    pub fmt_alignment: Option<Alignment>,
290}
291
292impl HasId for Table {
293    fn id(&self) -> EntityId {
294        self.id
295    }
296}
297
298#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
299pub struct TableCell {
300    pub id: EntityId,
301    #[serde(with = "chrono::serde::ts_milliseconds")]
302    pub created_at: chrono::DateTime<chrono::Utc>,
303    #[serde(with = "chrono::serde::ts_milliseconds")]
304    pub updated_at: chrono::DateTime<chrono::Utc>,
305    pub row: i64,
306    pub column: i64,
307    pub row_span: i64,
308    pub column_span: i64,
309    pub cell_frame: Option<EntityId>,
310    pub fmt_padding: Option<i64>,
311    pub fmt_border: Option<i64>,
312    pub fmt_vertical_alignment: Option<CellVerticalAlignment>,
313    pub fmt_background_color: Option<String>,
314}
315
316impl HasId for TableCell {
317    fn id(&self) -> EntityId {
318        self.id
319    }
320}
321#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
322pub enum CellVerticalAlignment {
323    #[default]
324    Top,
325    Middle,
326    Bottom,
327}