hammer-plugin-kit 0.6.0

Write plugins for the Hammer editor in Rust: Hammer's imports, typed operations, and the action and text check types.
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
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
//! Hammer's operations, typed. Each function runs one operation, as [`crate::call`] would. A plugin may
//! call only those its manifest's `[permissions]` ask for: each function's documentation names what it needs.
//!
//! Generated from api/operations.json by kotlin/codegen: regenerate rather than edit.
#![allow(clippy::all, unused_imports)]

use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;

/// A value this kit doesn't know, from a later Hammer, reads as [`Access::Unknown`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Access {
    #[default]
    #[serde(rename = "read")]
    Read,
    #[serde(rename = "write")]
    Write,
    #[serde(rename = "destructive")]
    Destructive,
    /// A value this kit doesn't know. Hammer rejects it as an input.
    #[serde(other)]
    Unknown,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct AccountStatus {
    pub server: Option<String>,
    pub ssl: Option<bool>,
    pub email: Option<String>,
    #[serde(rename = "loggedIn")]
    pub logged_in: bool,
    /// Null unless checked.
    #[serde(rename = "tokenValid")]
    pub token_valid: Option<bool>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Activity {
    pub days: Vec<DayWords>,
    /// Lifetime totals, not limited to the range.
    pub devices: Vec<DeviceWords>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Appearance {
    #[serde(rename = "entryId")]
    pub entry_id: i32,
    pub name: String,
    pub r#type: EntryKind,
    #[serde(rename = "sceneCount")]
    pub scene_count: i32,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ArchivedScene {
    pub id: i32,
    pub name: String,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ArchivedScenes {
    pub scenes: Vec<ArchivedScene>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Backup {
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    pub date: String,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Backups {
    pub backups: Vec<Backup>,
}

/// A value this kit doesn't know, from a later Hammer, reads as [`Cadence::Unknown`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Cadence {
    #[default]
    #[serde(rename = "day")]
    Day,
    #[serde(rename = "week")]
    Week,
    /// A value this kit doesn't know. Hammer rejects it as an input.
    #[serde(other)]
    Unknown,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ChapterWords {
    pub id: i32,
    pub name: String,
    pub words: i32,
}

/// A value this kit doesn't know, from a later Hammer, reads as [`ConflictChoice::Unknown`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ConflictChoice {
    #[default]
    #[serde(rename = "abort")]
    Abort,
    #[serde(rename = "local")]
    Local,
    #[serde(rename = "server")]
    Server,
    /// A value this kit doesn't know. Hammer rejects it as an input.
    #[serde(other)]
    Unknown,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct DayWords {
    /// An ISO 8601 date, such as `2026-03-01`.
    pub date: String,
    pub words: i32,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct DeviceWords {
    pub device: String,
    pub words: i32,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct DraftApplied {
    #[serde(rename = "sceneId")]
    pub scene_id: i32,
    /// The draft holding the text it replaced; null when the text was unchanged.
    #[serde(rename = "previousDraftId")]
    pub previous_draft_id: Option<i32>,
    #[serde(rename = "wordCount")]
    pub word_count: i32,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct DraftInfo {
    pub id: i32,
    pub name: String,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    pub created: String,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct DraftText {
    pub id: i32,
    #[serde(rename = "sceneId")]
    pub scene_id: i32,
    pub name: String,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    pub created: String,
    pub markdown: String,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Drafts {
    pub drafts: Vec<DraftInfo>,
}

/// A value this kit doesn't know, from a later Hammer, reads as [`EntityKind::Unknown`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum EntityKind {
    #[default]
    #[serde(rename = "scene")]
    Scene,
    #[serde(rename = "note")]
    Note,
    #[serde(rename = "entry")]
    Entry,
    #[serde(rename = "timeline")]
    Timeline,
    /// A value this kit doesn't know. Hammer rejects it as an input.
    #[serde(other)]
    Unknown,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Entries {
    pub entries: Vec<EntrySummary>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Entry {
    pub id: i32,
    pub name: String,
    pub r#type: EntryKind,
    pub text: String,
    pub tags: Vec<String>,
    pub aliases: Vec<String>,
    #[serde(rename = "hasImage")]
    pub has_image: bool,
    /// Scene ids whose references to this entry have been confirmed.
    #[serde(rename = "referencedBy")]
    pub referenced_by: Vec<i32>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct EntryCount {
    pub r#type: EntryKind,
    pub count: i32,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct EntryImage {
    /// jpg, jpeg, png, or webp.
    pub extension: String,
    #[serde(with = "crate::base64::bytes")]
    pub content: Vec<u8>,
}

/// A value this kit doesn't know, from a later Hammer, reads as [`EntryKind::Unknown`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum EntryKind {
    #[default]
    #[serde(rename = "person")]
    Person,
    #[serde(rename = "place")]
    Place,
    #[serde(rename = "thing")]
    Thing,
    #[serde(rename = "event")]
    Event,
    #[serde(rename = "idea")]
    Idea,
    /// A value this kit doesn't know. Hammer rejects it as an input.
    #[serde(other)]
    Unknown,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct EntrySummary {
    pub id: i32,
    pub name: String,
    pub r#type: EntryKind,
    /// Other names the entry goes by.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub aliases: Option<Vec<String>>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ExportFormat {
    pub id: String,
    #[serde(rename = "fileExtension")]
    pub file_extension: String,
    #[serde(rename = "mimeType")]
    pub mime_type: String,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ExportFormats {
    pub formats: Vec<ExportFormat>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ExportedFile {
    #[serde(rename = "fileName")]
    pub file_name: String,
    #[serde(rename = "mimeType")]
    pub mime_type: String,
    #[serde(with = "crate::base64::bytes")]
    pub content: Vec<u8>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Idea {
    pub id: String,
    pub title: Option<String>,
    pub content: String,
    pub tags: Vec<String>,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    pub created: String,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    pub updated: String,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    pub promoted: Option<String>,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    pub archived: Option<String>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Ideas {
    pub ideas: Vec<Idea>,
}

/// A value this kit doesn't know, from a later Hammer, reads as [`ImportFileFormat::Unknown`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ImportFileFormat {
    #[default]
    #[serde(rename = "markdown")]
    Markdown,
    #[serde(rename = "rtf")]
    Rtf,
    /// A value this kit doesn't know. Hammer rejects it as an input.
    #[serde(other)]
    Unknown,
}

/// A value this kit doesn't know, from a later Hammer, reads as [`MarkdownSplit::Unknown`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum MarkdownSplit {
    #[default]
    #[serde(rename = "auto")]
    Auto,
    #[serde(rename = "h1")]
    H1,
    #[serde(rename = "h2")]
    H2,
    #[serde(rename = "pattern")]
    Pattern,
    /// A value this kit doesn't know. Hammer rejects it as an input.
    #[serde(other)]
    Unknown,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Note {
    pub id: i32,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    pub created: String,
    pub tags: Vec<String>,
    pub content: String,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Notes {
    pub notes: Vec<Note>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct OperationDescriptor {
    pub name: String,
    pub description: String,
    pub access: Access,
    pub scope: OperationScope,
    pub input: BTreeMap<String, serde_json::Value>,
    pub output: BTreeMap<String, serde_json::Value>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct OperationList {
    pub operations: Vec<OperationDescriptor>,
}

/// A value this kit doesn't know, from a later Hammer, reads as [`OperationScope::Unknown`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum OperationScope {
    #[default]
    #[serde(rename = "content")]
    Content,
    #[serde(rename = "account")]
    Account,
    /// A value this kit doesn't know. Hammer rejects it as an input.
    #[serde(other)]
    Unknown,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct PagedScene {
    pub id: i32,
    pub name: String,
    /// Names of the groups containing the scene, outermost first.
    pub path: Vec<String>,
    pub markdown: String,
    #[serde(rename = "wordCount")]
    pub word_count: i32,
    pub meta: SceneMeta,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ProjectImported {
    pub name: String,
    pub scenes: i32,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ProjectInfo {
    pub name: String,
    #[serde(rename = "projectId")]
    pub project_id: String,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    pub created: Option<String>,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    #[serde(rename = "lastAccessed")]
    pub last_accessed: Option<String>,
    #[serde(rename = "authorName")]
    pub author_name: Option<String>,
    pub language: Option<String>,
    pub tags: Vec<String>,
    #[serde(rename = "wordCountGoal")]
    pub word_count_goal: Option<WordGoal>,
    #[serde(rename = "wordCount")]
    pub word_count: Option<i32>,
    #[serde(rename = "sceneCount")]
    pub scene_count: Option<i32>,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    #[serde(rename = "lastEdited")]
    pub last_edited: Option<String>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ProjectList {
    pub projects: Vec<ProjectSummary>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ProjectName {
    pub name: String,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ProjectStats {
    #[serde(rename = "totalWords")]
    pub total_words: i32,
    #[serde(rename = "sceneCount")]
    pub scene_count: i32,
    /// Top-level scenes and groups, in story order.
    pub chapters: Vec<ChapterWords>,
    #[serde(rename = "longestScene")]
    pub longest_scene: Option<SceneWords>,
    #[serde(rename = "shortestSceneWords")]
    pub shortest_scene_words: i32,
    #[serde(rename = "medianSceneWords")]
    pub median_scene_words: i32,
    #[serde(rename = "noteCount")]
    pub note_count: i32,
    #[serde(rename = "timelineEventCount")]
    pub timeline_event_count: i32,
    #[serde(rename = "entryCounts")]
    pub entry_counts: Vec<EntryCount>,
    /// People appearing in the most scenes.
    #[serde(rename = "topAppearances")]
    pub top_appearances: Vec<Appearance>,
    #[serde(rename = "wordCountGoal")]
    pub word_count_goal: Option<WordGoal>,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    #[serde(rename = "lastEdited")]
    pub last_edited: Option<String>,
    #[serde(rename = "lastEditedScene")]
    pub last_edited_scene: Option<SceneRef>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ProjectSummary {
    pub name: String,
    #[serde(rename = "projectId")]
    pub project_id: String,
    /// From the statistics cache; null until statistics are first calculated.
    #[serde(rename = "wordCount")]
    pub word_count: Option<i32>,
    /// Null when the project's metadata can't be read. An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    pub created: Option<String>,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    #[serde(rename = "lastAccessed")]
    pub last_accessed: Option<String>,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    #[serde(rename = "lastEdited")]
    pub last_edited: Option<String>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ProjectSyncResult {
    pub name: String,
    pub outcome: SyncOutcome,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ProjectSyncStatus {
    pub name: String,
    /// True once the project has synced.
    pub linked: bool,
    /// Null when never synced. An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    #[serde(rename = "lastSync")]
    pub last_sync: Option<String>,
    #[serde(rename = "pendingChanges")]
    pub pending_changes: i32,
}

/// A value this kit doesn't know, from a later Hammer, reads as [`RtfSplit::Unknown`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum RtfSplit {
    #[default]
    #[serde(rename = "formatting")]
    Formatting,
    #[serde(rename = "pattern")]
    Pattern,
    #[serde(rename = "single")]
    Single,
    /// A value this kit doesn't know. Hammer rejects it as an input.
    #[serde(other)]
    Unknown,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct SceneItemRef {
    pub id: i32,
    pub name: String,
    pub kind: SceneKind,
}

/// A value this kit doesn't know, from a later Hammer, reads as [`SceneKind::Unknown`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SceneKind {
    #[default]
    #[serde(rename = "scene")]
    Scene,
    #[serde(rename = "group")]
    Group,
    /// A value this kit doesn't know. Hammer rejects it as an input.
    #[serde(other)]
    Unknown,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct SceneMeta {
    pub outline: String,
    pub notes: String,
    pub tags: Vec<String>,
    #[serde(rename = "currentDraft")]
    pub current_draft: String,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    pub created: Option<String>,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    #[serde(rename = "lastEdited")]
    pub last_edited: Option<String>,
    /// Entry ids confirmed as in the scene.
    pub references: Vec<i32>,
    /// Entry ids the writer dismissed, which name matching no longer adds.
    #[serde(rename = "dismissedReferences")]
    pub dismissed_references: Vec<i32>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct SceneNode {
    pub id: i32,
    pub name: String,
    pub kind: SceneKind,
    #[serde(rename = "wordCount")]
    pub word_count: i32,
    pub children: Vec<SceneNode>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ScenePage {
    pub scenes: Vec<PagedScene>,
    /// The last scene's id when more follow, to pass as after; null on the last page.
    pub next: Option<i32>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct SceneRef {
    pub id: i32,
    pub name: String,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct SceneText {
    pub id: i32,
    pub name: String,
    pub archived: bool,
    pub markdown: String,
    #[serde(rename = "wordCount")]
    pub word_count: i32,
    pub meta: SceneMeta,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct SceneTree {
    pub nodes: Vec<SceneNode>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct SceneWordCount {
    #[serde(rename = "wordCount")]
    pub word_count: i32,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct SceneWords {
    pub id: i32,
    pub name: String,
    pub words: i32,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct SceneWriteResult {
    /// The new draft, in draft mode.
    #[serde(rename = "draftId")]
    pub draft_id: Option<i32>,
    /// In live mode, the draft holding the text it replaced; null when the text was unchanged.
    #[serde(rename = "previousDraftId")]
    pub previous_draft_id: Option<i32>,
    #[serde(rename = "wordCount")]
    pub word_count: i32,
}

/// A value this kit doesn't know, from a later Hammer, reads as [`SearchFilter::Unknown`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SearchFilter {
    #[default]
    #[serde(rename = "all")]
    All,
    #[serde(rename = "scenes")]
    Scenes,
    #[serde(rename = "notes")]
    Notes,
    #[serde(rename = "encyclopedia")]
    Encyclopedia,
    #[serde(rename = "timeline")]
    Timeline,
    /// A value this kit doesn't know. Hammer rejects it as an input.
    #[serde(other)]
    Unknown,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct SearchHit {
    pub kind: EntityKind,
    pub id: i32,
    pub title: String,
    pub snippet: String,
    /// The match's range within [snippet].
    #[serde(rename = "matchStart")]
    pub match_start: i32,
    #[serde(rename = "matchEnd")]
    pub match_end: i32,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct SearchResults {
    pub results: Vec<SearchHit>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Session {
    pub device: String,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    #[serde(rename = "startedAt")]
    pub started_at: String,
    /// An ISO 8601 instant, such as `2026-03-01T09:30:00Z`.
    #[serde(rename = "endedAt")]
    pub ended_at: String,
    pub words: i32,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Sessions {
    pub sessions: Vec<Session>,
}

/// A value this kit doesn't know, from a later Hammer, reads as [`SyncOutcome::Unknown`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SyncOutcome {
    #[default]
    #[serde(rename = "success")]
    Success,
    #[serde(rename = "unchanged")]
    Unchanged,
    #[serde(rename = "needs_resolution")]
    NeedsResolution,
    #[serde(rename = "failed")]
    Failed,
    #[serde(rename = "skipped")]
    Skipped,
    /// A value this kit doesn't know. Hammer rejects it as an input.
    #[serde(other)]
    Unknown,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct SyncRunResult {
    #[serde(rename = "accountSynced")]
    pub account_synced: bool,
    #[serde(rename = "ideasSynced")]
    pub ideas_synced: bool,
    pub projects: Vec<ProjectSyncResult>,
    pub log: Vec<String>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct SyncStatus {
    pub projects: Vec<ProjectSyncStatus>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct TagCount {
    pub tag: String,
    pub count: i32,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct TaggedEntities {
    pub entities: Vec<TaggedEntity>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct TaggedEntity {
    pub kind: EntityKind,
    pub id: i32,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Tags {
    pub tags: Vec<TagCount>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Timeline {
    pub events: Vec<TimelineEntry>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct TimelineEntry {
    pub id: i32,
    pub order: i32,
    /// Free text; timelines are not bound to a calendar.
    pub date: Option<String>,
    pub content: String,
    pub tags: Vec<String>,
}

#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct WordGoal {
    pub cadence: Cadence,
    pub count: i32,
}

/// A value this kit doesn't know, from a later Hammer, reads as [`WriteMode::Unknown`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum WriteMode {
    #[default]
    #[serde(rename = "draft")]
    Draft,
    #[serde(rename = "live")]
    Live,
    /// A value this kit doesn't know. Hammer rejects it as an input.
    #[serde(other)]
    Unknown,
}

/// The optional inputs of [`search`]; leave any out with `..Default::default()`.
#[derive(Debug, Clone, Default, PartialEq, Serialize)]
pub struct SearchOptions {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub filter: Option<SearchFilter>,
}

/// Search a project's scenes, notes, encyclopedia, and timeline. #tag in the query filters by tag.
///
/// Needs `search` or `content:read` in the manifest's `[permissions]`.
pub fn search(project: &str, query: &str, options: SearchOptions) -> crate::Result<SearchResults> {
    #[derive(Serialize)]
    struct Input<'a> {
        project: &'a str,
        query: &'a str,
        #[serde(flatten)]
        options: SearchOptions,
    }
    crate::call("search", &Input { project, query, options })
}

/// The `account` operations.
pub mod account {
    use super::*;

    /// Log in to a sync server with an existing account. Accounts are created in the app.
    ///
    /// Needs `account.login` or `account:write` in the manifest's `[permissions]`.
    pub fn login(url: &str, email: &str, password: &str) -> crate::Result<AccountStatus> {
        #[derive(Serialize)]
        struct Input<'a> {
            url: &'a str,
            email: &'a str,
            password: &'a str,
        }
        crate::call("account.login", &Input { url, email, password })
    }

    /// Forget the sync server and every project's sync state for it, as removing the server in Settings does.
    ///
    /// Needs `account.logout` or `account:write` in the manifest's `[permissions]`.
    pub fn logout() -> crate::Result<AccountStatus> {
        #[derive(Serialize)]
        struct Input {
        }
        crate::call("account.logout", &Input {  })
    }

    /// The optional inputs of [`status`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct AccountStatusOptions {
        /// Ask the server whether the stored token is still good; needs the network.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub check: Option<bool>,
    }

    /// The sync server and account this install uses, and optionally whether the server still accepts it.
    ///
    /// Needs `account.status` or `account:read` in the manifest's `[permissions]`.
    pub fn status(options: AccountStatusOptions) -> crate::Result<AccountStatus> {
        #[derive(Serialize)]
        struct Input {
            #[serde(flatten)]
            options: AccountStatusOptions,
        }
        crate::call("account.status", &Input { options })
    }

}

/// The `backup` operations.
pub mod backup {
    use super::*;

    /// Back up a project's saved files.
    ///
    /// Needs `backup.create` or `content:write` in the manifest's `[permissions]`.
    pub fn create(project: &str) -> crate::Result<Backup> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
        }
        crate::call("backup.create", &Input { project })
    }

    /// A project's backups, oldest first.
    ///
    /// Needs `backup.list` or `content:read` in the manifest's `[permissions]`.
    pub fn list(project: &str) -> crate::Result<Backups> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
        }
        crate::call("backup.list", &Input { project })
    }

}

/// The `draft` operations.
pub mod draft {
    use super::*;

    /// Replace a scene's text with one of its drafts, saving the replaced text as a draft first.
    ///
    /// Needs `draft.apply` or `content:write` in the manifest's `[permissions]`.
    pub fn apply(project: &str, id: i32) -> crate::Result<DraftApplied> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
        }
        crate::call("draft.apply", &Input { project, id })
    }

    /// Save a scene's current text as a named draft.
    ///
    /// Needs `draft.create` or `content:write` in the manifest's `[permissions]`.
    pub fn create(project: &str, scene_id: i32, name: &str) -> crate::Result<DraftInfo> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            #[serde(rename = "sceneId")]
            scene_id: i32,
            name: &'a str,
        }
        crate::call("draft.create", &Input { project, scene_id, name })
    }

    /// Delete a draft for good.
    ///
    /// Needs `draft.delete` (by name) in the manifest's `[permissions]`.
    pub fn delete(project: &str, id: i32) -> crate::Result<DraftInfo> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
        }
        crate::call("draft.delete", &Input { project, id })
    }

    /// A scene's saved drafts, oldest first.
    ///
    /// Needs `draft.list` or `content:read` in the manifest's `[permissions]`.
    pub fn list(project: &str, scene_id: i32) -> crate::Result<Drafts> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            #[serde(rename = "sceneId")]
            scene_id: i32,
        }
        crate::call("draft.list", &Input { project, scene_id })
    }

    /// A draft's markdown.
    ///
    /// Needs `draft.read` or `content:read` in the manifest's `[permissions]`.
    pub fn read(project: &str, id: i32) -> crate::Result<DraftText> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
        }
        crate::call("draft.read", &Input { project, id })
    }

}

/// The `entry` operations.
pub mod entry {
    use super::*;

    /// The optional inputs of [`create`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct EntryCreateOptions {
        #[serde(skip_serializing_if = "Option::is_none")]
        pub tags: Option<Vec<String>>,
        /// Other names the entry goes by, matched in scenes like its name.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub aliases: Option<Vec<String>>,
    }

    /// Add an encyclopedia entry to a project.
    ///
    /// Needs `entry.create` or `content:write` in the manifest's `[permissions]`.
    pub fn create(project: &str, name: &str, r#type: EntryKind, text: &str, options: EntryCreateOptions) -> crate::Result<Entry> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            name: &'a str,
            r#type: EntryKind,
            text: &'a str,
            #[serde(flatten)]
            options: EntryCreateOptions,
        }
        crate::call("entry.create", &Input { project, name, r#type, text, options })
    }

    /// Delete an encyclopedia entry, and its image, for good.
    ///
    /// Needs `entry.delete` (by name) in the manifest's `[permissions]`.
    pub fn delete(project: &str, id: i32) -> crate::Result<EntrySummary> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
        }
        crate::call("entry.delete", &Input { project, id })
    }

    /// The optional inputs of [`list`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct EntryListOptions {
        #[serde(skip_serializing_if = "Option::is_none")]
        pub r#type: Option<EntryKind>,
        #[serde(skip_serializing_if = "Option::is_none")]
        pub tag: Option<String>,
    }

    /// A project's encyclopedia entries, with their aliases, optionally only one type or those with a tag.
    ///
    /// Needs `entry.list` or `content:read` in the manifest's `[permissions]`.
    pub fn list(project: &str, options: EntryListOptions) -> crate::Result<Entries> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            #[serde(flatten)]
            options: EntryListOptions,
        }
        crate::call("entry.list", &Input { project, options })
    }

    /// An encyclopedia entry, with the scenes confirmed to reference it.
    ///
    /// Needs `entry.read` or `content:read` in the manifest's `[permissions]`.
    pub fn read(project: &str, id: i32) -> crate::Result<Entry> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
        }
        crate::call("entry.read", &Input { project, id })
    }

    /// The optional inputs of [`update`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct EntryUpdateOptions {
        #[serde(skip_serializing_if = "Option::is_none")]
        pub name: Option<String>,
        #[serde(skip_serializing_if = "Option::is_none")]
        pub tags: Option<Vec<String>>,
        #[serde(skip_serializing_if = "Option::is_none")]
        pub aliases: Option<Vec<String>>,
    }

    /// Replace an encyclopedia entry's text, and its name, tags, or aliases when given.
    ///
    /// Needs `entry.update` or `content:write` in the manifest's `[permissions]`.
    pub fn update(project: &str, id: i32, text: &str, options: EntryUpdateOptions) -> crate::Result<Entry> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
            text: &'a str,
            #[serde(flatten)]
            options: EntryUpdateOptions,
        }
        crate::call("entry.update", &Input { project, id, text, options })
    }

    /// The `entry.image` operations.
    pub mod image {
        use super::*;

        /// An encyclopedia entry's image.
        ///
        /// Needs `entry.image.get` or `content:read` in the manifest's `[permissions]`.
        pub fn get(project: &str, id: i32) -> crate::Result<EntryImage> {
            #[derive(Serialize)]
            struct Input<'a> {
                project: &'a str,
                id: i32,
            }
            crate::call("entry.image.get", &Input { project, id })
        }

        /// Remove an encyclopedia entry's image.
        ///
        /// Needs `entry.image.remove` or `content:write` in the manifest's `[permissions]`.
        pub fn remove(project: &str, id: i32) -> crate::Result<Entry> {
            #[derive(Serialize)]
            struct Input<'a> {
                project: &'a str,
                id: i32,
            }
            crate::call("entry.image.remove", &Input { project, id })
        }

        /// Set an encyclopedia entry's image, replacing any it has. The extension is jpg, jpeg, png, or webp, and must match the image.
        ///
        /// Needs `entry.image.set` or `content:write` in the manifest's `[permissions]`.
        pub fn set(project: &str, id: i32, extension: &str, content: &[u8]) -> crate::Result<Entry> {
            #[derive(Serialize)]
            struct Input<'a> {
                project: &'a str,
                id: i32,
                extension: &'a str,
                #[serde(serialize_with = "crate::base64::serialize")]
                content: &'a [u8],
            }
            crate::call("entry.image.set", &Input { project, id, extension, content })
        }

    }

}

/// The `export` operations.
pub mod export {
    use super::*;

    /// The formats project.export can produce.
    ///
    /// Needs `export.formats` or `content:read` in the manifest's `[permissions]`.
    pub fn formats() -> crate::Result<ExportFormats> {
        #[derive(Serialize)]
        struct Input {
        }
        crate::call("export.formats", &Input {  })
    }

}

/// The `idea` operations.
pub mod idea {
    use super::*;

    /// Archive a story idea.
    ///
    /// Needs `idea.archive` or `content:write` in the manifest's `[permissions]`.
    pub fn archive(id: &str) -> crate::Result<Idea> {
        #[derive(Serialize)]
        struct Input<'a> {
            id: &'a str,
        }
        crate::call("idea.archive", &Input { id })
    }

    /// The optional inputs of [`create`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct IdeaCreateOptions {
        #[serde(skip_serializing_if = "Option::is_none")]
        pub title: Option<String>,
        #[serde(skip_serializing_if = "Option::is_none")]
        pub tags: Option<Vec<String>>,
    }

    /// Add a story idea.
    ///
    /// Needs `idea.create` or `content:write` in the manifest's `[permissions]`.
    pub fn create(content: &str, options: IdeaCreateOptions) -> crate::Result<Idea> {
        #[derive(Serialize)]
        struct Input<'a> {
            content: &'a str,
            #[serde(flatten)]
            options: IdeaCreateOptions,
        }
        crate::call("idea.create", &Input { content, options })
    }

    /// Delete a story idea for good.
    ///
    /// Needs `idea.delete` (by name) in the manifest's `[permissions]`.
    pub fn delete(id: &str) -> crate::Result<Idea> {
        #[derive(Serialize)]
        struct Input<'a> {
            id: &'a str,
        }
        crate::call("idea.delete", &Input { id })
    }

    /// The optional inputs of [`list`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct IdeaListOptions {
        /// True for only archived ideas, false for only active ones; omitted for both.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub archived: Option<bool>,
    }

    /// Story ideas, which belong to the account rather than a project.
    ///
    /// Needs `idea.list` or `content:read` in the manifest's `[permissions]`.
    pub fn list(options: IdeaListOptions) -> crate::Result<Ideas> {
        #[derive(Serialize)]
        struct Input {
            #[serde(flatten)]
            options: IdeaListOptions,
        }
        crate::call("idea.list", &Input { options })
    }

    /// Return an archived story idea to the active ones.
    ///
    /// Needs `idea.unarchive` or `content:write` in the manifest's `[permissions]`.
    pub fn unarchive(id: &str) -> crate::Result<Idea> {
        #[derive(Serialize)]
        struct Input<'a> {
            id: &'a str,
        }
        crate::call("idea.unarchive", &Input { id })
    }

    /// The optional inputs of [`update`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct IdeaUpdateOptions {
        /// Left out, unchanged; empty, cleared.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub title: Option<String>,
        #[serde(skip_serializing_if = "Option::is_none")]
        pub tags: Option<Vec<String>>,
    }

    /// Replace a story idea's text, and its title or tags when given. An empty title clears it.
    ///
    /// Needs `idea.update` or `content:write` in the manifest's `[permissions]`.
    pub fn update(id: &str, content: &str, options: IdeaUpdateOptions) -> crate::Result<Idea> {
        #[derive(Serialize)]
        struct Input<'a> {
            id: &'a str,
            content: &'a str,
            #[serde(flatten)]
            options: IdeaUpdateOptions,
        }
        crate::call("idea.update", &Input { id, content, options })
    }

}

/// The `note` operations.
pub mod note {
    use super::*;

    /// The optional inputs of [`create`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct NoteCreateOptions {
        #[serde(skip_serializing_if = "Option::is_none")]
        pub tags: Option<Vec<String>>,
    }

    /// Add a note to a project.
    ///
    /// Needs `note.create` or `content:write` in the manifest's `[permissions]`.
    pub fn create(project: &str, content: &str, options: NoteCreateOptions) -> crate::Result<Note> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            content: &'a str,
            #[serde(flatten)]
            options: NoteCreateOptions,
        }
        crate::call("note.create", &Input { project, content, options })
    }

    /// Delete a note for good.
    ///
    /// Needs `note.delete` (by name) in the manifest's `[permissions]`.
    pub fn delete(project: &str, id: i32) -> crate::Result<Note> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
        }
        crate::call("note.delete", &Input { project, id })
    }

    /// The optional inputs of [`list`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct NoteListOptions {
        #[serde(skip_serializing_if = "Option::is_none")]
        pub tag: Option<String>,
    }

    /// A project's notes, optionally only those with a tag.
    ///
    /// Needs `note.list` or `content:read` in the manifest's `[permissions]`.
    pub fn list(project: &str, options: NoteListOptions) -> crate::Result<Notes> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            #[serde(flatten)]
            options: NoteListOptions,
        }
        crate::call("note.list", &Input { project, options })
    }

    /// One note.
    ///
    /// Needs `note.read` or `content:read` in the manifest's `[permissions]`.
    pub fn read(project: &str, id: i32) -> crate::Result<Note> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
        }
        crate::call("note.read", &Input { project, id })
    }

    /// The optional inputs of [`update`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct NoteUpdateOptions {
        /// Left out, the tags stay as they are.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub tags: Option<Vec<String>>,
    }

    /// Replace a note's text, and its tags when given.
    ///
    /// Needs `note.update` or `content:write` in the manifest's `[permissions]`.
    pub fn update(project: &str, id: i32, content: &str, options: NoteUpdateOptions) -> crate::Result<Note> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
            content: &'a str,
            #[serde(flatten)]
            options: NoteUpdateOptions,
        }
        crate::call("note.update", &Input { project, id, content, options })
    }

}

/// The `ops` operations.
pub mod ops {
    use super::*;

    /// Every operation you may call, with JSON schemas for its input and output.
    ///
    /// Needs `ops.list` or `content:read` in the manifest's `[permissions]`.
    pub fn list() -> crate::Result<OperationList> {
        #[derive(Serialize)]
        struct Input {
        }
        crate::call("ops.list", &Input {  })
    }

}

/// The `project` operations.
pub mod project {
    use super::*;

    /// Create an empty project.
    ///
    /// Needs `project.create` or `content:write` in the manifest's `[permissions]`.
    pub fn create(name: &str) -> crate::Result<ProjectName> {
        #[derive(Serialize)]
        struct Input<'a> {
            name: &'a str,
        }
        crate::call("project.create", &Input { name })
    }

    /// Delete a project, and everything in it, for good. It must not be open in Hammer.
    ///
    /// Needs `project.delete` (by name) in the manifest's `[permissions]`.
    pub fn delete(project: &str) -> crate::Result<ProjectName> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
        }
        crate::call("project.delete", &Input { project })
    }

    /// The optional inputs of [`export`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct ProjectExportOptions {
        /// Limits the export to these scenes; omitted exports the whole story.
        #[serde(rename = "sceneIds")]
        #[serde(skip_serializing_if = "Option::is_none")]
        pub scene_ids: Option<Vec<i32>>,
        #[serde(rename = "treatTopLevelAsChapters")]
        #[serde(skip_serializing_if = "Option::is_none")]
        pub treat_top_level_as_chapters: Option<bool>,
    }

    /// Export a project, or some of its scenes, in one of the formats from export.formats.
    ///
    /// Needs `project.export` or `content:read` in the manifest's `[permissions]`.
    pub fn export(project: &str, format: &str, options: ProjectExportOptions) -> crate::Result<ExportedFile> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            format: &'a str,
            #[serde(flatten)]
            options: ProjectExportOptions,
        }
        crate::call("project.export", &Input { project, format, options })
    }

    /// The optional inputs of [`import`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct ProjectImportOptions {
        /// Left out, the title the file gives itself.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub name: Option<String>,
        #[serde(rename = "markdownSplit")]
        #[serde(skip_serializing_if = "Option::is_none")]
        pub markdown_split: Option<MarkdownSplit>,
        #[serde(rename = "rtfSplit")]
        #[serde(skip_serializing_if = "Option::is_none")]
        pub rtf_split: Option<RtfSplit>,
        /// A regular expression for the lines that start a chapter; left out, chapter, part, prologue, and epilogue.
        #[serde(rename = "chapterPattern")]
        #[serde(skip_serializing_if = "Option::is_none")]
        pub chapter_pattern: Option<String>,
        /// Put each chapter's scenes in a group.
        #[serde(rename = "chapterGroups")]
        #[serde(skip_serializing_if = "Option::is_none")]
        pub chapter_groups: Option<bool>,
    }

    /// Create a project from a Markdown or RTF manuscript, split into scenes by its headings or a chapter pattern.
    ///
    /// Needs `project.import` or `content:write` in the manifest's `[permissions]`.
    pub fn import(format: ImportFileFormat, content: &[u8], options: ProjectImportOptions) -> crate::Result<ProjectImported> {
        #[derive(Serialize)]
        struct Input<'a> {
            format: ImportFileFormat,
            #[serde(serialize_with = "crate::base64::serialize")]
            content: &'a [u8],
            #[serde(flatten)]
            options: ProjectImportOptions,
        }
        crate::call("project.import", &Input { format, content, options })
    }

    /// A project's details: author, language, tags, word count goal, cached totals, and sync linkage.
    ///
    /// Needs `project.info` or `content:read` in the manifest's `[permissions]`.
    pub fn info(project: &str) -> crate::Result<ProjectInfo> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
        }
        crate::call("project.info", &Input { project })
    }

    /// List every project with its word count and when it was last edited.
    ///
    /// Needs `project.list` or `content:read` in the manifest's `[permissions]`.
    pub fn list() -> crate::Result<ProjectList> {
        #[derive(Serialize)]
        struct Input {
        }
        crate::call("project.list", &Input {  })
    }

    /// Rename a project. It must not be open in Hammer.
    ///
    /// Needs `project.rename` or `content:write` in the manifest's `[permissions]`.
    pub fn rename(project: &str, name: &str) -> crate::Result<ProjectName> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            name: &'a str,
        }
        crate::call("project.rename", &Input { project, name })
    }

}

/// The `scene` operations.
pub mod scene {
    use super::*;

    /// Add markdown to the end of a scene's text, as a new paragraph.
    ///
    /// Needs `scene.append` or `content:write` in the manifest's `[permissions]`.
    pub fn append(project: &str, id: i32, markdown: &str) -> crate::Result<SceneWordCount> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
            markdown: &'a str,
        }
        crate::call("scene.append", &Input { project, id, markdown })
    }

    /// Archive a scene: take it out of the story, keeping its text, drafts, and notes.
    ///
    /// Needs `scene.archive` or `content:write` in the manifest's `[permissions]`.
    pub fn archive(project: &str, id: i32) -> crate::Result<SceneItemRef> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
        }
        crate::call("scene.archive", &Input { project, id })
    }

    /// A project's archived scenes.
    ///
    /// Needs `scene.archived` or `content:read` in the manifest's `[permissions]`.
    pub fn archived(project: &str) -> crate::Result<ArchivedScenes> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
        }
        crate::call("scene.archived", &Input { project })
    }

    /// The optional inputs of [`create`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct SceneCreateOptions {
        #[serde(skip_serializing_if = "Option::is_none")]
        pub kind: Option<SceneKind>,
        /// The group to create it in; left out, the top level.
        #[serde(rename = "parentId")]
        #[serde(skip_serializing_if = "Option::is_none")]
        pub parent_id: Option<i32>,
        /// Its position among its siblings; left out, the end.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub index: Option<i32>,
    }

    /// Create an empty scene or group, at the end of its parent unless an index is given.
    ///
    /// Needs `scene.create` or `content:write` in the manifest's `[permissions]`.
    pub fn create(project: &str, name: &str, options: SceneCreateOptions) -> crate::Result<SceneItemRef> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            name: &'a str,
            #[serde(flatten)]
            options: SceneCreateOptions,
        }
        crate::call("scene.create", &Input { project, name, options })
    }

    /// Delete a scene, archived or not, or an empty group, for good.
    ///
    /// Needs `scene.delete` (by name) in the manifest's `[permissions]`.
    pub fn delete(project: &str, id: i32) -> crate::Result<SceneItemRef> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
        }
        crate::call("scene.delete", &Input { project, id })
    }

    /// The optional inputs of [`r#move`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct SceneMoveOptions {
        /// The group to move into; left out, the top level.
        #[serde(rename = "parentId")]
        #[serde(skip_serializing_if = "Option::is_none")]
        pub parent_id: Option<i32>,
    }

    /// Move a scene or group to a position within a group, or the top level when parentId is left out. index is its position there after the move.
    ///
    /// Needs `scene.move` or `content:write` in the manifest's `[permissions]`.
    pub fn r#move(project: &str, id: i32, index: i32, options: SceneMoveOptions) -> crate::Result<SceneItemRef> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
            index: i32,
            #[serde(flatten)]
            options: SceneMoveOptions,
        }
        crate::call("scene.move", &Input { project, id, index, options })
    }

    /// A scene's markdown, including unsaved edits, with its outline, notes, and tags.
    ///
    /// Needs `scene.read` or `content:read` in the manifest's `[permissions]`.
    pub fn read(project: &str, id: i32) -> crate::Result<SceneText> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
        }
        crate::call("scene.read", &Input { project, id })
    }

    /// Rename a scene or group.
    ///
    /// Needs `scene.rename` or `content:write` in the manifest's `[permissions]`.
    pub fn rename(project: &str, id: i32, name: &str) -> crate::Result<SceneItemRef> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
            name: &'a str,
        }
        crate::call("scene.rename", &Input { project, id, name })
    }

    /// A project's scenes and groups in story order, with word counts.
    ///
    /// Needs `scene.tree` or `content:read` in the manifest's `[permissions]`.
    pub fn tree(project: &str) -> crate::Result<SceneTree> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
        }
        crate::call("scene.tree", &Input { project })
    }

    /// Return an archived scene to the story, at the end of the top level.
    ///
    /// Needs `scene.unarchive` or `content:write` in the manifest's `[permissions]`.
    pub fn unarchive(project: &str, id: i32) -> crate::Result<SceneItemRef> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
        }
        crate::call("scene.unarchive", &Input { project, id })
    }

    /// The optional inputs of [`write`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct SceneWriteOptions {
        /// The new draft's name, in draft mode only.
        #[serde(rename = "draftName")]
        #[serde(skip_serializing_if = "Option::is_none")]
        pub draft_name: Option<String>,
    }

    /// Replace a scene's text with markdown. Mode draft saves it as a new draft of the scene and leaves the scene alone. Mode live replaces the scene's text, saving the old text as a draft first.
    ///
    /// Needs `scene.write` or `content:write` in the manifest's `[permissions]`.
    pub fn write(project: &str, id: i32, mode: WriteMode, markdown: &str, options: SceneWriteOptions) -> crate::Result<SceneWriteResult> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
            mode: WriteMode,
            markdown: &'a str,
            #[serde(flatten)]
            options: SceneWriteOptions,
        }
        crate::call("scene.write", &Input { project, id, mode, markdown, options })
    }

    /// The `scene.meta` operations.
    pub mod meta {
        use super::*;

        /// A scene's outline, notes, tags, and references: the entries confirmed as in it, and those dismissed.
        ///
        /// Needs `scene.meta.read` or `content:read` in the manifest's `[permissions]`.
        pub fn read(project: &str, id: i32) -> crate::Result<SceneMeta> {
            #[derive(Serialize)]
            struct Input<'a> {
                project: &'a str,
                id: i32,
            }
            crate::call("scene.meta.read", &Input { project, id })
        }

        /// The optional inputs of [`write`]; leave any out with `..Default::default()`.
        #[derive(Debug, Clone, Default, PartialEq, Serialize)]
        pub struct SceneMetaWriteOptions {
            #[serde(skip_serializing_if = "Option::is_none")]
            pub outline: Option<String>,
            #[serde(skip_serializing_if = "Option::is_none")]
            pub notes: Option<String>,
            #[serde(skip_serializing_if = "Option::is_none")]
            pub tags: Option<Vec<String>>,
        }

        /// Change a scene's outline, notes, or tags. Fields left out keep their value.
        ///
        /// Needs `scene.meta.write` or `content:write` in the manifest's `[permissions]`.
        pub fn write(project: &str, id: i32, options: SceneMetaWriteOptions) -> crate::Result<SceneMeta> {
            #[derive(Serialize)]
            struct Input<'a> {
                project: &'a str,
                id: i32,
                #[serde(flatten)]
                options: SceneMetaWriteOptions,
            }
            crate::call("scene.meta.write", &Input { project, id, options })
        }

    }

    /// The `scene.read` operations.
    pub mod read {
        use super::*;

        /// The optional inputs of [`many`]; leave any out with `..Default::default()`.
        #[derive(Debug, Clone, Default, PartialEq, Serialize)]
        pub struct SceneReadManyOptions {
            /// A group whose scenes, at any depth, to read.
            #[serde(skip_serializing_if = "Option::is_none")]
            pub group: Option<i32>,
            #[serde(skip_serializing_if = "Option::is_none")]
            pub ids: Option<Vec<i32>>,
            /// The previous page's next.
            #[serde(skip_serializing_if = "Option::is_none")]
            pub after: Option<i32>,
            #[serde(rename = "maxWords")]
            #[serde(skip_serializing_if = "Option::is_none")]
            pub max_words: Option<i32>,
        }

        /// Scenes in story order with their markdown, metadata, and the groups they sit in, a page of about maxWords, counting outlines and notes, at a time: every scene, a group's, or those in ids. Archived scenes are left out. Pass next as after for the following page; it is null on the last.
        ///
        /// Needs `scene.read.many` or `content:read` in the manifest's `[permissions]`.
        pub fn many(project: &str, options: SceneReadManyOptions) -> crate::Result<ScenePage> {
            #[derive(Serialize)]
            struct Input<'a> {
                project: &'a str,
                #[serde(flatten)]
                options: SceneReadManyOptions,
            }
            crate::call("scene.read.many", &Input { project, options })
        }

    }

    /// The `scene.references` operations.
    pub mod references {
        use super::*;

        /// The optional inputs of [`set`]; leave any out with `..Default::default()`.
        #[derive(Debug, Clone, Default, PartialEq, Serialize)]
        pub struct SceneReferencesSetOptions {
            #[serde(skip_serializing_if = "Option::is_none")]
            pub confirm: Option<Vec<i32>>,
            #[serde(skip_serializing_if = "Option::is_none")]
            pub dismiss: Option<Vec<i32>>,
            #[serde(skip_serializing_if = "Option::is_none")]
            pub clear: Option<Vec<i32>>,
        }

        /// Change which entries a scene references. confirm marks entries as in the scene, and un-dismisses them; dismiss marks entries as only mentioned, so name matching stops adding them; clear forgets entries either way, so a later match can add them again.
        ///
        /// Needs `scene.references.set` or `content:write` in the manifest's `[permissions]`.
        pub fn set(project: &str, id: i32, options: SceneReferencesSetOptions) -> crate::Result<SceneMeta> {
            #[derive(Serialize)]
            struct Input<'a> {
                project: &'a str,
                id: i32,
                #[serde(flatten)]
                options: SceneReferencesSetOptions,
            }
            crate::call("scene.references.set", &Input { project, id, options })
        }

    }

}

/// The `stats` operations.
pub mod stats {
    use super::*;

    /// The optional inputs of [`activity`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct StatsActivityOptions {
        /// First day included, in the device's time zone; omitted for no lower bound. An ISO 8601 date, such as `2026-03-01`.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub from: Option<String>,
        /// Last day included; omitted for no upper bound. An ISO 8601 date, such as `2026-03-01`.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub to: Option<String>,
    }

    /// Words written per day over a date range, plus lifetime words per device.
    ///
    /// Needs `stats.activity` or `content:read` in the manifest's `[permissions]`.
    pub fn activity(project: &str, options: StatsActivityOptions) -> crate::Result<Activity> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            #[serde(flatten)]
            options: StatsActivityOptions,
        }
        crate::call("stats.activity", &Input { project, options })
    }

    /// The optional inputs of [`project`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct StatsProjectOptions {
        /// Recalculate even when the cached statistics are current.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub recalculate: Option<bool>,
    }

    /// A project's statistics, as its Home screen shows them.
    ///
    /// Needs `stats.project` or `content:read` in the manifest's `[permissions]`.
    pub fn project(project: &str, options: StatsProjectOptions) -> crate::Result<ProjectStats> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            #[serde(flatten)]
            options: StatsProjectOptions,
        }
        crate::call("stats.project", &Input { project, options })
    }

    /// The optional inputs of [`sessions`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct StatsSessionsOptions {
        /// First day included, in the device's time zone; omitted for no lower bound. An ISO 8601 date, such as `2026-03-01`.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub from: Option<String>,
        /// Last day included; omitted for no upper bound. An ISO 8601 date, such as `2026-03-01`.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub to: Option<String>,
    }

    /// Writing sessions over a date range, from every device.
    ///
    /// Needs `stats.sessions` or `content:read` in the manifest's `[permissions]`.
    pub fn sessions(project: &str, options: StatsSessionsOptions) -> crate::Result<Sessions> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            #[serde(flatten)]
            options: StatsSessionsOptions,
        }
        crate::call("stats.sessions", &Input { project, options })
    }

}

/// The `sync` operations.
pub mod sync {
    use super::*;

    /// The optional inputs of [`run`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct SyncRunOptions {
        /// Sync only this project; account changes and ideas still sync.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub project: Option<String>,
        #[serde(rename = "onConflict")]
        #[serde(skip_serializing_if = "Option::is_none")]
        pub on_conflict: Option<ConflictChoice>,
    }

    /// Sync the account and every linked project with the server, as Sync all does. A project with a conflict is left for the app.
    ///
    /// Needs `sync.run` or `account:write` in the manifest's `[permissions]`.
    pub fn run(options: SyncRunOptions) -> crate::Result<SyncRunResult> {
        #[derive(Serialize)]
        struct Input {
            #[serde(flatten)]
            options: SyncRunOptions,
        }
        crate::call("sync.run", &Input { options })
    }

    /// Each project's link to the sync server, its last sync, and how many of its changes are waiting to sync.
    ///
    /// Needs `sync.status` or `account:read` in the manifest's `[permissions]`.
    pub fn status() -> crate::Result<SyncStatus> {
        #[derive(Serialize)]
        struct Input {
        }
        crate::call("sync.status", &Input {  })
    }

}

/// The `tag` operations.
pub mod tag {
    use super::*;

    /// Every scene, note, entry, and timeline event carrying a tag.
    ///
    /// Needs `tag.find` or `content:read` in the manifest's `[permissions]`.
    pub fn find(project: &str, tag: &str) -> crate::Result<TaggedEntities> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            tag: &'a str,
        }
        crate::call("tag.find", &Input { project, tag })
    }

    /// The optional inputs of [`list`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct TagListOptions {
        #[serde(skip_serializing_if = "Option::is_none")]
        pub kind: Option<EntityKind>,
        #[serde(skip_serializing_if = "Option::is_none")]
        pub limit: Option<i32>,
    }

    /// The tags used in a project, most used first, optionally counting one kind of entity.
    ///
    /// Needs `tag.list` or `content:read` in the manifest's `[permissions]`.
    pub fn list(project: &str, options: TagListOptions) -> crate::Result<Tags> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            #[serde(flatten)]
            options: TagListOptions,
        }
        crate::call("tag.list", &Input { project, options })
    }

}

/// The `timeline` operations.
pub mod timeline {
    use super::*;

    /// The optional inputs of [`create`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct TimelineCreateOptions {
        /// Free text, such as "Day 3" or "Spring, 1802".
        #[serde(skip_serializing_if = "Option::is_none")]
        pub date: Option<String>,
        #[serde(skip_serializing_if = "Option::is_none")]
        pub tags: Option<Vec<String>>,
        /// Its position in the timeline; left out, the end.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub index: Option<i32>,
    }

    /// Add an event to a project's timeline, at the end unless an index is given.
    ///
    /// Needs `timeline.create` or `content:write` in the manifest's `[permissions]`.
    pub fn create(project: &str, content: &str, options: TimelineCreateOptions) -> crate::Result<TimelineEntry> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            content: &'a str,
            #[serde(flatten)]
            options: TimelineCreateOptions,
        }
        crate::call("timeline.create", &Input { project, content, options })
    }

    /// Delete a timeline event for good.
    ///
    /// Needs `timeline.delete` (by name) in the manifest's `[permissions]`.
    pub fn delete(project: &str, id: i32) -> crate::Result<TimelineEntry> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
        }
        crate::call("timeline.delete", &Input { project, id })
    }

    /// A project's timeline events in order.
    ///
    /// Needs `timeline.list` or `content:read` in the manifest's `[permissions]`.
    pub fn list(project: &str) -> crate::Result<Timeline> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
        }
        crate::call("timeline.list", &Input { project })
    }

    /// Move a timeline event to a position; index is its position after the move.
    ///
    /// Needs `timeline.move` or `content:write` in the manifest's `[permissions]`.
    pub fn r#move(project: &str, id: i32, index: i32) -> crate::Result<TimelineEntry> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
            index: i32,
        }
        crate::call("timeline.move", &Input { project, id, index })
    }

    /// One timeline event.
    ///
    /// Needs `timeline.read` or `content:read` in the manifest's `[permissions]`.
    pub fn read(project: &str, id: i32) -> crate::Result<TimelineEntry> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
        }
        crate::call("timeline.read", &Input { project, id })
    }

    /// The optional inputs of [`update`]; leave any out with `..Default::default()`.
    #[derive(Debug, Clone, Default, PartialEq, Serialize)]
    pub struct TimelineUpdateOptions {
        /// Left out, unchanged; empty, cleared.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub date: Option<String>,
        #[serde(skip_serializing_if = "Option::is_none")]
        pub tags: Option<Vec<String>>,
    }

    /// Replace a timeline event's text, and its date or tags when given. An empty date clears it.
    ///
    /// Needs `timeline.update` or `content:write` in the manifest's `[permissions]`.
    pub fn update(project: &str, id: i32, content: &str, options: TimelineUpdateOptions) -> crate::Result<TimelineEntry> {
        #[derive(Serialize)]
        struct Input<'a> {
            project: &'a str,
            id: i32,
            content: &'a str,
            #[serde(flatten)]
            options: TimelineUpdateOptions,
        }
        crate::call("timeline.update", &Input { project, id, content, options })
    }

}