aboutsummaryrefslogtreecommitdiff
path: root/common/src/api.rs
blob: bec33bab2cceeaeca524b5700deff8649ff3d737 (plain)
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
/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2026 metamuffin <metamuffin.org>
*/

use jellyobject::{Object, Tag, enums, fields};

fields! {
    QUERY_PARENT: u64 = b"prnt";
    QUERY_SEARCH: &str = b"sear";
    QUERY_KIND: Tag = b"kind"; // multi
    QUERY_SORT: Tag = b"sort"; // one of RTYP_*, NU_RATING, NO_DURATION, NO_NAME
    QUERY_SORT_ASCENDING: () = b"sasc";

    VIEW_TITLE: &str = b"titl";
    VIEW_MESSAGE: Object = b"mesg";
    VIEW_NODE_PAGE: Object = b"npag";
    VIEW_NODE_LIST: Object = b"nlis"; // multi
    VIEW_PLAYER: Object = b"play";
    VIEW_STATGROUP: Object = b"stag";
    VIEW_STATTEXT: Object = b"stat";
    VIEW_ACCOUNT_LOGIN: () = b"acli";
    VIEW_ACCOUNT_LOGOUT: () = b"aclo";
    VIEW_ACCOUNT_SET_PASSWORD: &str = b"acsp";
    VIEW_ADMIN_DASHBOARD: () = b"adda";
    VIEW_ADMIN_IMPORT: Object = b"adim";
    VIEW_ADMIN_INFO: Object = b"adin";
    VIEW_ADMIN_LOG: Object = b"adlo";
    VIEW_USER_SETTINGS: Object = b"uset";

    ADMIN_IMPORT_BUSY: () = b"busy";
    ADMIN_IMPORT_ERROR: &str = b"erro"; // multi
    ADMIN_INFO_TITLE: &str = b"aiti";
    ADMIN_INFO_TEXT: &str = b"aite";
    ADMIN_LOG_MESSAGE: &str = b"aite";

    NKU_NODE: Object = b"node";
    NKU_UDATA: Object = b"udat";
    NKU_ROLE: &str = b"role";

    NODELIST_TITLE: &str = b"titl";
    NODELIST_DISPLAYSTYLE: Tag = b"dsty";
    NODELIST_ITEM: Object = b"item"; // multi

    MESSAGE_KIND: &str = b"kind";
    MESSAGE_TEXT: &str = b"text";

    STATGROUP_TITLE: &str = b"titl";
    STATGROUP_BIN: Object = b"bin1";

    STAT_NAME: &str = b"name";
    STAT_COUNT: u64 = b"cont";
    STAT_TOTAL_SIZE: u64 = b"tlsz";
    STAT_TOTAL_DURATION: f64 = b"tldu";
    STAT_MAX_SIZE: u64 = b"mxsz";
    STAT_MAX_DURATION: f64 = b"mxdu";
}

enums! {
    NLSTYLE_GRID = b"grid";
    NLSTYLE_INLINE = b"inli";
    NLSTYLE_LIST = b"list";
    NLSTYLE_HIGHLIGHT = b"hglt";
}

// use crate::user::{NodeUserData, User};
// use std::{collections::BTreeMap, sync::Arc, time::Duration};
// pub struct ApiNodeResponse {
//     pub parents: NodesWithUdata,
//     pub children: NodesWithUdata,
//     pub node: Arc<Node>,
//     pub userdata: NodeUserData,
// }

// pub struct ApiSearchResponse {
//     pub count: usize,
//     pub results: NodesWithUdata,
//     pub duration: Duration,
// }

// pub struct ApiItemsResponse {
//     pub count: usize,
//     pub pages: usize,
//     pub items: NodesWithUdata,
// }

// pub struct ApiHomeResponse {
//     pub toplevel: NodesWithUdata,
//     pub categories: Vec<(String, NodesWithUdata)>,
// }

// pub struct ApiStatsResponse {
//     pub kinds: BTreeMap<NodeKind, StatsBin>,
//     pub total: StatsBin,
// }

// pub struct ApiAdminUsersResponse {
//     pub users: Vec<User>,
// }

// #[derive(Default, Serialize, Deserialize)]
// pub struct StatsBin {
//     pub runtime: f64,
//     pub size: u64,
//     pub count: usize,
//     pub max_runtime: f64,
//     pub max_runtime_node: String,
//     pub max_size: u64,
//     pub max_size_node: String,
// }