lemmy-js-client 0.11.4-rc.9 → 0.12.3-rc.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Aggregate data for a person.
3
+ */
1
4
  export interface PersonAggregates {
2
5
  id: number;
3
6
  person_id: number;
@@ -6,6 +9,9 @@ export interface PersonAggregates {
6
9
  comment_count: number;
7
10
  comment_score: number;
8
11
  }
12
+ /**
13
+ * Aggregate data for your site.
14
+ */
9
15
  export interface SiteAggregates {
10
16
  id: number;
11
17
  site_id: number;
@@ -13,11 +19,26 @@ export interface SiteAggregates {
13
19
  posts: number;
14
20
  comments: number;
15
21
  communities: number;
22
+ /**
23
+ * Active users per day.
24
+ */
16
25
  users_active_day: number;
26
+ /**
27
+ * Active users per week.
28
+ */
17
29
  users_active_week: number;
30
+ /**
31
+ * Active users per month.
32
+ */
18
33
  users_active_month: number;
34
+ /**
35
+ * Active users per year.
36
+ */
19
37
  users_active_half_year: number;
20
38
  }
39
+ /**
40
+ * Aggregate data for your post.
41
+ */
21
42
  export interface PostAggregates {
22
43
  id: number;
23
44
  post_id: number;
@@ -25,20 +46,41 @@ export interface PostAggregates {
25
46
  score: number;
26
47
  upvotes: number;
27
48
  downvotes: number;
49
+ /**
50
+ * Newest comment time, limited to 2 days, to prevent necrobumping.
51
+ */
28
52
  newest_comment_time_necro: string;
29
53
  newest_comment_time: string;
30
54
  }
55
+ /**
56
+ * Aggregate data for your community.
57
+ */
31
58
  export interface CommunityAggregates {
32
59
  id: number;
33
60
  community_id: number;
34
61
  subscribers: number;
35
62
  posts: number;
36
63
  comments: number;
64
+ /**
65
+ * Active users per day.
66
+ */
37
67
  users_active_day: number;
68
+ /**
69
+ * Active users per week.
70
+ */
38
71
  users_active_week: number;
72
+ /**
73
+ * Active users per month.
74
+ */
39
75
  users_active_month: number;
76
+ /**
77
+ * Active users per year.
78
+ */
40
79
  users_active_half_year: number;
41
80
  }
81
+ /**
82
+ * Aggregate data for your comment.
83
+ */
42
84
  export interface CommentAggregates {
43
85
  id: number;
44
86
  comment_id: number;
@@ -3,12 +3,18 @@ export interface CreateComment {
3
3
  content: string;
4
4
  parent_id?: number;
5
5
  post_id: number;
6
+ /**
7
+ * An optional front end ID, to tell which is comment is coming back.
8
+ */
6
9
  form_id?: string;
7
10
  auth: string;
8
11
  }
9
12
  export interface EditComment {
10
13
  content: string;
11
14
  comment_id: number;
15
+ /**
16
+ * An optional front end ID, to tell which is comment is coming back.
17
+ */
12
18
  form_id?: string;
13
19
  auth: string;
14
20
  }
@@ -45,6 +51,9 @@ export interface SaveComment {
45
51
  export interface CommentResponse {
46
52
  comment_view: CommentView;
47
53
  recipient_ids: number[];
54
+ /**
55
+ * An optional front end ID, to tell which is comment is coming back.
56
+ */
48
57
  form_id?: string;
49
58
  }
50
59
  export interface CreateCommentLike {
@@ -55,10 +64,17 @@ export interface CreateCommentLike {
55
64
  /**
56
65
  * Comment listing types are `All, Subscribed, Community`
57
66
  *
58
- * `community_name` can only be used for local communities. To get posts for a federated community, pass `community_id` instead.
67
+ * You can use either `community_id` or `community_name` as an id.
68
+ * To get posts for a federated community by name, use `name@instance.tld` .
59
69
  */
60
70
  export interface GetComments {
71
+ /**
72
+ * The [[ListingType]].
73
+ */
61
74
  type_?: string;
75
+ /**
76
+ * The [[SortType]].
77
+ */
62
78
  sort?: string;
63
79
  page?: number;
64
80
  limit?: number;
@@ -75,24 +91,23 @@ export interface CreateCommentReport {
75
91
  reason: string;
76
92
  auth: string;
77
93
  }
78
- export interface CreateCommentReportResponse {
79
- success: boolean;
94
+ export interface CommentReportResponse {
95
+ comment_report_view: CommentReportView;
80
96
  }
81
97
  export interface ResolveCommentReport {
82
98
  report_id: number;
83
99
  resolved: boolean;
84
100
  auth: string;
85
101
  }
86
- export interface ResolveCommentReportResponse {
87
- report_id: number;
88
- resolved: boolean;
89
- }
90
102
  export interface ListCommentReports {
91
103
  page?: number;
92
104
  limit?: number;
93
- community?: number;
105
+ /**
106
+ * if no community is given, it returns reports for all communities moderated by the auth user.
107
+ */
108
+ community_id?: number;
94
109
  auth: string;
95
110
  }
96
111
  export interface ListCommentReportsResponse {
97
- comments: CommentReportView[];
112
+ comment_reports: CommentReportView[];
98
113
  }
@@ -1,4 +1,9 @@
1
1
  import { CommunityModeratorView, CommunityView, PersonViewSafe } from '../views';
2
+ /**
3
+ * You can use either `id` or `name` as an id.
4
+ *
5
+ * To get a federated community by name, use `name@instance.tld` .
6
+ */
2
7
  export interface GetCommunity {
3
8
  id?: number;
4
9
  name?: string;
@@ -22,7 +27,13 @@ export interface CommunityResponse {
22
27
  community_view: CommunityView;
23
28
  }
24
29
  export interface ListCommunities {
30
+ /**
31
+ * The [[ListingType]].
32
+ */
25
33
  type_?: string;
34
+ /**
35
+ * The [[SortType]].
36
+ */
26
37
  sort?: string;
27
38
  page?: number;
28
39
  limit?: number;
@@ -35,6 +46,9 @@ export interface BanFromCommunity {
35
46
  community_id: number;
36
47
  person_id: number;
37
48
  ban: boolean;
49
+ /**
50
+ * Removes/Restores their comments and posts for that community.
51
+ */
38
52
  remove_data?: boolean;
39
53
  reason?: string;
40
54
  expires?: number;
@@ -4,7 +4,9 @@ export interface Login {
4
4
  password: string;
5
5
  }
6
6
  /**
7
- * Only the first user will be able to be the admin.
7
+ * Register a new user.
8
+ *
9
+ * Only the first user to register will be able to be the admin.
8
10
  */
9
11
  export interface Register {
10
12
  username: string;
@@ -12,23 +14,51 @@ export interface Register {
12
14
  password: string;
13
15
  password_verify: string;
14
16
  show_nsfw: boolean;
17
+ /**
18
+ * Captcha is only checked if these are enabled in the server.
19
+ */
15
20
  captcha_uuid?: string;
16
21
  captcha_answer?: string;
17
22
  }
18
23
  export interface GetCaptcha {
19
24
  }
20
25
  export interface GetCaptchaResponse {
26
+ /**
27
+ * Will be undefined if captchas are disabled.
28
+ */
21
29
  ok?: CaptchaResponse;
22
30
  }
23
31
  export interface CaptchaResponse {
32
+ /**
33
+ * A Base64 encoded png.
34
+ */
24
35
  png: string;
36
+ /**
37
+ * A Base64 encoded wav file.
38
+ */
25
39
  wav?: string;
40
+ /**
41
+ * A UUID to match the one given on request.
42
+ */
26
43
  uuid: string;
27
44
  }
28
45
  export interface SaveUserSettings {
29
46
  show_nsfw?: boolean;
47
+ /**
48
+ * Default for this is `browser`.
49
+ */
30
50
  theme?: string;
51
+ /**
52
+ * The [[SortType]].
53
+ *
54
+ * The Sort types from above, zero indexed as a number
55
+ */
31
56
  default_sort_type?: number;
57
+ /**
58
+ * The [[ListingType]].
59
+ *
60
+ * Post listing types are `All, Subscribed, Community`
61
+ */
32
62
  default_listing_type?: number;
33
63
  lang?: string;
34
64
  avatar?: string;
@@ -58,11 +88,11 @@ export interface ChangePassword {
58
88
  export interface LoginResponse {
59
89
  jwt: string;
60
90
  }
61
- /**
62
- * `username` can only be used for local users. To get details for a federated user, pass `user_id` instead.
63
- */
64
91
  export interface GetPersonDetails {
65
92
  person_id?: number;
93
+ /**
94
+ * To get details for a federated user, use `person@instance.tld`.
95
+ */
66
96
  username?: string;
67
97
  sort?: string;
68
98
  page?: number;
@@ -97,6 +127,9 @@ export interface AddAdminResponse {
97
127
  export interface BanPerson {
98
128
  person_id: number;
99
129
  ban: boolean;
130
+ /**
131
+ * Removes/Restores their comments, posts, and communities
132
+ */
100
133
  remove_data?: boolean;
101
134
  reason?: string;
102
135
  expires?: number;
@@ -107,6 +140,9 @@ export interface BanPersonResponse {
107
140
  banned: boolean;
108
141
  }
109
142
  export interface GetReplies {
143
+ /**
144
+ * The [[SortType]].
145
+ */
110
146
  sort?: string;
111
147
  page?: number;
112
148
  limit?: number;
@@ -114,6 +150,9 @@ export interface GetReplies {
114
150
  auth: string;
115
151
  }
116
152
  export interface GetPersonMentions {
153
+ /**
154
+ * The [[SortType]].
155
+ */
117
156
  sort?: string;
118
157
  page?: number;
119
158
  limit?: number;
@@ -177,15 +216,15 @@ export interface PrivateMessagesResponse {
177
216
  export interface PrivateMessageResponse {
178
217
  private_message_view: PrivateMessageView;
179
218
  }
180
- /**
181
- * If a community is supplied, returns the report count for only that community, otherwise returns the report count for all communities the user moderates.
182
- */
183
219
  export interface GetReportCount {
184
- community?: number;
220
+ /**
221
+ * If a community is supplied, returns the report count for only that community, otherwise returns the report count for all communities the user moderates.
222
+ */
223
+ community_id?: number;
185
224
  auth: string;
186
225
  }
187
226
  export interface GetReportCountResponse {
188
- community?: number;
227
+ community_id?: number;
189
228
  comment_reports: number;
190
229
  post_reports: number;
191
230
  }
@@ -1,3 +1,4 @@
1
+ import { SiteMetadata } from '..';
1
2
  import { CommunityView, CommentView, CommunityModeratorView, PostReportView, PostView } from '../views';
2
3
  export interface CreatePost {
3
4
  name: string;
@@ -21,17 +22,23 @@ export interface GetPostResponse {
21
22
  moderators: CommunityModeratorView[];
22
23
  online: number;
23
24
  }
24
- /**
25
- * Post listing types are `All, Subscribed, Community`
26
- *
27
- * `community_name` can only be used for local communities. To get posts for a federated community, pass `community_id` instead.
28
- */
29
25
  export interface GetPosts {
26
+ /**
27
+ * The [[ListingType]].
28
+ *
29
+ * Post listing types are `All, Subscribed, Community`
30
+ */
30
31
  type_?: string;
32
+ /**
33
+ * The [[SortType]].
34
+ */
31
35
  sort?: string;
32
36
  page?: number;
33
37
  limit?: number;
34
38
  community_id?: number;
39
+ /**
40
+ * To get posts for a federated community by name, use `name@instance.tld` .
41
+ */
35
42
  community_name?: string;
36
43
  saved_only?: boolean;
37
44
  auth?: string;
@@ -39,11 +46,11 @@ export interface GetPosts {
39
46
  export interface GetPostsResponse {
40
47
  posts: PostView[];
41
48
  }
42
- /**
43
- * `score` can be 0, -1, or 1
44
- */
45
49
  export interface CreatePostLike {
46
50
  post_id: number;
51
+ /**
52
+ * `score` can be 0, -1, or 1. Anything else will be rejected.
53
+ */
47
54
  score: number;
48
55
  auth: string;
49
56
  }
@@ -95,24 +102,32 @@ export interface CreatePostReport {
95
102
  reason: string;
96
103
  auth: string;
97
104
  }
98
- export interface CreatePostReportResponse {
99
- success: boolean;
105
+ export interface PostReportResponse {
106
+ post_report_view: PostReportView;
100
107
  }
101
108
  export interface ResolvePostReport {
102
109
  report_id: number;
110
+ /**
111
+ * Either resolve or unresolve a report.
112
+ */
103
113
  resolved: boolean;
104
114
  auth: string;
105
115
  }
106
- export interface ResolvePostReportResponse {
107
- report_id: number;
108
- resolved: boolean;
109
- }
110
116
  export interface ListPostReports {
111
117
  page?: number;
112
118
  limit?: number;
119
+ /**
120
+ * if no community is given, it returns reports for all communities moderated by the auth user.
121
+ */
113
122
  community?: number;
114
123
  auth: string;
115
124
  }
116
125
  export interface ListPostReportsResponse {
117
- posts: PostReportView[];
126
+ post_reports: PostReportView[];
127
+ }
128
+ export interface GetSiteMetadata {
129
+ url: string;
130
+ }
131
+ export interface GetSiteMetadataResponse {
132
+ metadata: SiteMetadata;
118
133
  }
@@ -1,21 +1,36 @@
1
1
  import { CommunityBlockView, CommunityFollowerView, CommunityModeratorView, LocalUserSettingsView, PersonBlockView } from '../views';
2
- import { CommentView, CommunityView, ModAddCommunityView, ModAddView, ModBanFromCommunityView, ModBanView, ModLockPostView, ModRemoveCommentView, ModRemoveCommunityView, ModRemovePostView, ModStickyPostView, PostView, SiteView, PersonViewSafe } from '../views';
2
+ import { CommentView, CommunityView, ModAddCommunityView, ModTransferCommunityView, ModAddView, ModBanFromCommunityView, ModBanView, ModLockPostView, ModRemoveCommentView, ModRemoveCommunityView, ModRemovePostView, ModStickyPostView, PostView, SiteView, PersonViewSafe } from '../views';
3
3
  /**
4
- * Search types are `All, Comments, Posts, Communities, Users, Url`
4
+ * Search lemmy for different types of data.
5
5
  */
6
6
  export interface Search {
7
+ /**
8
+ * The search query string.
9
+ */
7
10
  q: string;
11
+ /**
12
+ * The [[SearchType]].
13
+ */
8
14
  type_?: string;
9
15
  community_id?: number;
10
16
  community_name?: string;
11
17
  creator_id?: number;
18
+ /**
19
+ * The [[SortType]].
20
+ */
12
21
  sort?: string;
22
+ /**
23
+ * The [[ListingType]].
24
+ */
13
25
  listing_type?: string;
14
26
  page?: number;
15
27
  limit?: number;
16
28
  auth?: string;
17
29
  }
18
30
  export interface SearchResponse {
31
+ /**
32
+ * The [[SearchType]].
33
+ */
19
34
  type_: string;
20
35
  comments: CommentView[];
21
36
  posts: PostView[];
@@ -37,6 +52,7 @@ export interface GetModlogResponse {
37
52
  banned_from_community: ModBanFromCommunityView[];
38
53
  banned: ModBanView[];
39
54
  added_to_community: ModAddCommunityView[];
55
+ transferred_to_community: ModTransferCommunityView[];
40
56
  added: ModAddView[];
41
57
  }
42
58
  export interface CreateSite {
@@ -70,14 +86,23 @@ export interface SiteResponse {
70
86
  site_view: SiteView;
71
87
  }
72
88
  export interface GetSiteResponse {
89
+ /**
90
+ * Optional, because the site might not be set up yet.
91
+ */
73
92
  site_view?: SiteView;
74
93
  admins: PersonViewSafe[];
75
94
  banned: PersonViewSafe[];
76
95
  online: number;
77
96
  version: string;
97
+ /**
98
+ * If you're logged in, you'll get back extra user info.
99
+ */
78
100
  my_user?: MyUserInfo;
79
101
  federated_instances?: FederatedInstances;
80
102
  }
103
+ /**
104
+ * Your user info, such as blocks, follows, etc.
105
+ */
81
106
  export interface MyUserInfo {
82
107
  local_user_view: LocalUserSettingsView;
83
108
  follows: CommunityFollowerView[];
@@ -104,3 +129,13 @@ export interface FederatedInstances {
104
129
  allowed?: string[];
105
130
  blocked?: string[];
106
131
  }
132
+ export interface ResolveObject {
133
+ q: string;
134
+ auth?: string;
135
+ }
136
+ export interface ResolveObjectResponse {
137
+ comment?: CommentView;
138
+ post?: PostView;
139
+ community?: CommunityView;
140
+ person?: PersonViewSafe;
141
+ }
@@ -1,6 +1,6 @@
1
1
  export declare const VERSION = "v3";
2
2
  /**
3
- * All of the websocket operations available
3
+ * All of the websocket operations available.
4
4
  */
5
5
  export declare enum UserOperation {
6
6
  Login = 0,
@@ -43,46 +43,91 @@ export declare enum UserOperation {
43
43
  AddAdmin = 37,
44
44
  BanPerson = 38,
45
45
  Search = 39,
46
- MarkAllAsRead = 40,
47
- SaveUserSettings = 41,
48
- TransferCommunity = 42,
49
- TransferSite = 43,
50
- DeleteAccount = 44,
51
- PasswordReset = 45,
52
- PasswordChange = 46,
53
- CreatePrivateMessage = 47,
54
- EditPrivateMessage = 48,
55
- DeletePrivateMessage = 49,
56
- MarkPrivateMessageAsRead = 50,
57
- GetPrivateMessages = 51,
58
- UserJoin = 52,
59
- GetComments = 53,
60
- GetSiteConfig = 54,
61
- SaveSiteConfig = 55,
62
- PostJoin = 56,
63
- CommunityJoin = 57,
64
- ChangePassword = 58,
65
- BlockCommunity = 59,
66
- BlockPerson = 60
46
+ ResolveObject = 40,
47
+ MarkAllAsRead = 41,
48
+ SaveUserSettings = 42,
49
+ TransferCommunity = 43,
50
+ TransferSite = 44,
51
+ DeleteAccount = 45,
52
+ PasswordReset = 46,
53
+ PasswordChange = 47,
54
+ CreatePrivateMessage = 48,
55
+ EditPrivateMessage = 49,
56
+ DeletePrivateMessage = 50,
57
+ MarkPrivateMessageAsRead = 51,
58
+ GetPrivateMessages = 52,
59
+ UserJoin = 53,
60
+ GetComments = 54,
61
+ GetSiteConfig = 55,
62
+ SaveSiteConfig = 56,
63
+ PostJoin = 57,
64
+ CommunityJoin = 58,
65
+ ChangePassword = 59,
66
+ GetSiteMetadata = 60,
67
+ BlockCommunity = 61,
68
+ BlockPerson = 62,
69
+ CreateCommentReport = 63,
70
+ ResolveCommentReport = 64,
71
+ ListCommentReports = 65,
72
+ CreatePostReport = 66,
73
+ ResolvePostReport = 67,
74
+ ListPostReports = 68,
75
+ GetReportCount = 69
67
76
  }
77
+ /**
78
+ * Different sort types used in lemmy.
79
+ */
68
80
  export declare enum SortType {
81
+ /**
82
+ * Posts sorted by the most recent comment.
83
+ */
69
84
  Active = "Active",
85
+ /**
86
+ * Posts sorted by the published time.
87
+ */
70
88
  Hot = "Hot",
71
89
  New = "New",
90
+ /**
91
+ * The top posts for this last day.
92
+ */
72
93
  TopDay = "TopDay",
94
+ /**
95
+ * The top posts for this last week.
96
+ */
73
97
  TopWeek = "TopWeek",
98
+ /**
99
+ * The top posts for this last month.
100
+ */
74
101
  TopMonth = "TopMonth",
102
+ /**
103
+ * The top posts for this last year.
104
+ */
75
105
  TopYear = "TopYear",
106
+ /**
107
+ * The top posts of all time.
108
+ */
76
109
  TopAll = "TopAll",
110
+ /**
111
+ * Posts sorted by the most comments.
112
+ */
77
113
  MostComments = "MostComments",
114
+ /**
115
+ * Posts sorted by the newest comments, with no necrobumping. IE a forum sort.
116
+ */
78
117
  NewComments = "NewComments"
79
118
  }
119
+ /**
120
+ * The different listing types for post and comment fetches.
121
+ */
80
122
  export declare enum ListingType {
81
123
  All = "All",
82
124
  Local = "Local",
83
125
  Subscribed = "Subscribed",
84
126
  Community = "Community"
85
127
  }
128
+ /**
129
+ * Search types for lemmy's search.
130
+ */
86
131
  export declare enum SearchType {
87
132
  All = "All",
88
133
  Comments = "Comments",
@@ -91,13 +136,45 @@ export declare enum SearchType {
91
136
  Users = "Users",
92
137
  Url = "Url"
93
138
  }
139
+ /**
140
+ * A websocket response. Includes the return type.
141
+ * Can be used like:
142
+ *
143
+ * ```ts
144
+ * if (op == UserOperation.Search) {
145
+ * let data = wsJsonToRes<SearchResponse>(msg).data;
146
+ * }
147
+ * ```
148
+ */
94
149
  export interface WebSocketResponse<ResponseType> {
95
150
  op: UserOperation;
151
+ /**
152
+ * This contains the data for a websocket response.
153
+ *
154
+ * The correct response type if given is in [[LemmyHttp]].
155
+ */
96
156
  data: ResponseType;
97
157
  }
158
+ /**
159
+ * A websocket JSON response that includes the errors.
160
+ */
98
161
  export interface WebSocketJsonResponse<ResponseType> {
99
162
  op?: string;
163
+ /**
164
+ * This contains the data for a websocket response.
165
+ *
166
+ * The correct response type if given is in [[LemmyHttp]].
167
+ */
100
168
  data?: ResponseType;
101
169
  error?: string;
102
170
  reconnect?: boolean;
103
171
  }
172
+ /**
173
+ * A holder for a site's metadata ( such as opengraph tags ), used for post links.
174
+ */
175
+ export interface SiteMetadata {
176
+ title?: string;
177
+ description?: string;
178
+ image?: string;
179
+ html?: string;
180
+ }