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    /// This block belongs to the front matter the document opens with: a cover, a title
159    /// page. Only the **leading** run of such blocks is front matter; a flagged block after
160    /// the first body block is body like any other. The paginated writers that carry a
161    /// running header (DOCX, ODT) give the front matter's pages neither that header nor a
162    /// page number, and start the body on a page of its own numbered 1. The flowing formats
163    /// have no page furniture to withhold and ignore it. `None` means body.
164    #[serde(default)]
165    pub fmt_front_matter: Option<bool>,
166    pub fmt_direction: Option<TextDirection>,
167    pub fmt_background_color: Option<String>,
168    pub fmt_is_code_block: Option<bool>,
169    pub fmt_code_language: Option<String>,
170    /// Enable automatic + soft-hyphen hyphenation for this block.
171    #[serde(default)]
172    pub fmt_hyphenate: Option<bool>,
173    /// Natural language of this block as an ISO 639-1 code (e.g. "en",
174    /// "fr"); drives hyphenation dictionary selection.
175    #[serde(default)]
176    pub fmt_language: Option<String>,
177}
178
179impl HasId for Block {
180    fn id(&self) -> EntityId {
181        self.id
182    }
183}
184#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
185pub enum Alignment {
186    #[default]
187    Left,
188    Right,
189    Center,
190    Justify,
191}
192#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
193pub enum MarkerType {
194    #[default]
195    NoMarker,
196    Unchecked,
197    Checked,
198}
199
200#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
201pub enum UnderlineStyle {
202    #[default]
203    NoUnderline,
204    SingleUnderline,
205    DashUnderline,
206    DotLine,
207    DashDotLine,
208    DashDotDotLine,
209    WaveUnderline,
210    SpellCheckUnderline,
211}
212#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
213pub enum CharVerticalAlignment {
214    #[default]
215    Normal,
216    SuperScript,
217    SubScript,
218    Middle,
219    Bottom,
220    Top,
221    Baseline,
222}
223
224#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
225pub struct List {
226    pub id: EntityId,
227    #[serde(with = "chrono::serde::ts_milliseconds")]
228    pub created_at: chrono::DateTime<chrono::Utc>,
229    #[serde(with = "chrono::serde::ts_milliseconds")]
230    pub updated_at: chrono::DateTime<chrono::Utc>,
231    pub style: ListStyle,
232    pub indent: i64,
233    pub prefix: String,
234    pub suffix: String,
235    /// The number an ordered list's first item wears, when it is not 1: `3` for a list
236    /// written `3.`, `c.` or `iii.`. `None` for a list numbered from 1, and for every
237    /// unordered list. A Djot, Markdown or HTML list starting past 1 came back numbered
238    /// from 1 after a save and a reload, as the model had nowhere to keep its start.
239    pub start: Option<i64>,
240}
241
242impl HasId for List {
243    fn id(&self) -> EntityId {
244        self.id
245    }
246}
247#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
248pub enum ListStyle {
249    #[default]
250    Disc,
251    Circle,
252    Square,
253    Decimal,
254    LowerAlpha,
255    UpperAlpha,
256    LowerRoman,
257    UpperRoman,
258}
259
260#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
261pub struct Resource {
262    pub id: EntityId,
263    #[serde(with = "chrono::serde::ts_milliseconds")]
264    pub created_at: chrono::DateTime<chrono::Utc>,
265    #[serde(with = "chrono::serde::ts_milliseconds")]
266    pub updated_at: chrono::DateTime<chrono::Utc>,
267    pub resource_type: ResourceType,
268    pub name: String,
269    pub url: String,
270    pub mime_type: String,
271    pub data_base64: String,
272}
273
274impl HasId for Resource {
275    fn id(&self) -> EntityId {
276        self.id
277    }
278}
279#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
280pub enum ResourceType {
281    #[default]
282    Image,
283    StyleSheet,
284    Other,
285}
286
287#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
288pub struct Table {
289    pub id: EntityId,
290    #[serde(with = "chrono::serde::ts_milliseconds")]
291    pub created_at: chrono::DateTime<chrono::Utc>,
292    #[serde(with = "chrono::serde::ts_milliseconds")]
293    pub updated_at: chrono::DateTime<chrono::Utc>,
294    pub cells: Vec<EntityId>,
295    pub rows: i64,
296    pub columns: i64,
297    pub column_widths: Vec<i64>,
298    pub fmt_border: Option<i64>,
299    pub fmt_cell_spacing: Option<i64>,
300    pub fmt_cell_padding: Option<i64>,
301    pub fmt_width: Option<i64>,
302    pub fmt_alignment: Option<Alignment>,
303}
304
305impl HasId for Table {
306    fn id(&self) -> EntityId {
307        self.id
308    }
309}
310
311#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
312pub struct TableCell {
313    pub id: EntityId,
314    #[serde(with = "chrono::serde::ts_milliseconds")]
315    pub created_at: chrono::DateTime<chrono::Utc>,
316    #[serde(with = "chrono::serde::ts_milliseconds")]
317    pub updated_at: chrono::DateTime<chrono::Utc>,
318    pub row: i64,
319    pub column: i64,
320    pub row_span: i64,
321    pub column_span: i64,
322    pub cell_frame: Option<EntityId>,
323    pub fmt_padding: Option<i64>,
324    pub fmt_border: Option<i64>,
325    pub fmt_vertical_alignment: Option<CellVerticalAlignment>,
326    pub fmt_background_color: Option<String>,
327}
328
329impl HasId for TableCell {
330    fn id(&self) -> EntityId {
331        self.id
332    }
333}
334#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq)]
335pub enum CellVerticalAlignment {
336    #[default]
337    Top,
338    Middle,
339    Bottom,
340}