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    /// The number an ordered list's first item wears, when it is not 1: `3` for a list
228    /// written `3.`, `c.` or `iii.`. `None` for a list numbered from 1, and for every
229    /// unordered list. A Djot, Markdown or HTML list starting past 1 came back numbered
230    /// from 1 after a save and a reload, as the model had nowhere to keep its start.
231    pub start: Option<i64>,
232}
233
234impl HasId for List {
235    fn id(&self) -> EntityId {
236        self.id
237    }
238}
239#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
240pub enum ListStyle {
241    #[default]
242    Disc,
243    Circle,
244    Square,
245    Decimal,
246    LowerAlpha,
247    UpperAlpha,
248    LowerRoman,
249    UpperRoman,
250}
251
252#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
253pub struct Resource {
254    pub id: EntityId,
255    #[serde(with = "chrono::serde::ts_milliseconds")]
256    pub created_at: chrono::DateTime<chrono::Utc>,
257    #[serde(with = "chrono::serde::ts_milliseconds")]
258    pub updated_at: chrono::DateTime<chrono::Utc>,
259    pub resource_type: ResourceType,
260    pub name: String,
261    pub url: String,
262    pub mime_type: String,
263    pub data_base64: String,
264}
265
266impl HasId for Resource {
267    fn id(&self) -> EntityId {
268        self.id
269    }
270}
271#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
272pub enum ResourceType {
273    #[default]
274    Image,
275    StyleSheet,
276    Other,
277}
278
279#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
280pub struct Table {
281    pub id: EntityId,
282    #[serde(with = "chrono::serde::ts_milliseconds")]
283    pub created_at: chrono::DateTime<chrono::Utc>,
284    #[serde(with = "chrono::serde::ts_milliseconds")]
285    pub updated_at: chrono::DateTime<chrono::Utc>,
286    pub cells: Vec<EntityId>,
287    pub rows: i64,
288    pub columns: i64,
289    pub column_widths: Vec<i64>,
290    pub fmt_border: Option<i64>,
291    pub fmt_cell_spacing: Option<i64>,
292    pub fmt_cell_padding: Option<i64>,
293    pub fmt_width: Option<i64>,
294    pub fmt_alignment: Option<Alignment>,
295}
296
297impl HasId for Table {
298    fn id(&self) -> EntityId {
299        self.id
300    }
301}
302
303#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
304pub struct TableCell {
305    pub id: EntityId,
306    #[serde(with = "chrono::serde::ts_milliseconds")]
307    pub created_at: chrono::DateTime<chrono::Utc>,
308    #[serde(with = "chrono::serde::ts_milliseconds")]
309    pub updated_at: chrono::DateTime<chrono::Utc>,
310    pub row: i64,
311    pub column: i64,
312    pub row_span: i64,
313    pub column_span: i64,
314    pub cell_frame: Option<EntityId>,
315    pub fmt_padding: Option<i64>,
316    pub fmt_border: Option<i64>,
317    pub fmt_vertical_alignment: Option<CellVerticalAlignment>,
318    pub fmt_background_color: Option<String>,
319}
320
321impl HasId for TableCell {
322    fn id(&self) -> EntityId {
323        self.id
324    }
325}
326#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
327pub enum CellVerticalAlignment {
328    #[default]
329    Top,
330    Middle,
331    Bottom,
332}