lemmy-js-client 0.17.0-rc.3 → 0.17.0-rc.32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,3 +1,4 @@
1
+ import { Option } from "@sniptt/monads";
1
2
  export declare const VERSION = "v3";
2
3
  /**
3
4
  * All of the websocket operations available.
@@ -25,60 +26,59 @@ export declare enum UserOperation {
25
26
  RemovePost = 19,
26
27
  LockPost = 20,
27
28
  StickyPost = 21,
28
- SavePost = 22,
29
- EditCommunity = 23,
30
- DeleteCommunity = 24,
31
- RemoveCommunity = 25,
32
- FollowCommunity = 26,
33
- GetPersonDetails = 27,
34
- GetReplies = 28,
35
- GetPersonMentions = 29,
36
- MarkPersonMentionAsRead = 30,
37
- GetModlog = 31,
38
- BanFromCommunity = 32,
39
- AddModToCommunity = 33,
40
- CreateSite = 34,
41
- EditSite = 35,
42
- GetSite = 36,
43
- AddAdmin = 37,
44
- GetUnreadRegistrationApplicationCount = 38,
45
- ListRegistrationApplications = 39,
46
- ApproveRegistrationApplication = 40,
47
- BanPerson = 41,
48
- GetBannedPersons = 42,
49
- Search = 43,
50
- ResolveObject = 44,
51
- MarkAllAsRead = 45,
52
- SaveUserSettings = 46,
53
- TransferCommunity = 47,
54
- LeaveAdmin = 48,
55
- DeleteAccount = 49,
56
- PasswordReset = 50,
57
- PasswordChange = 51,
58
- CreatePrivateMessage = 52,
59
- EditPrivateMessage = 53,
60
- DeletePrivateMessage = 54,
61
- MarkPrivateMessageAsRead = 55,
62
- GetPrivateMessages = 56,
63
- UserJoin = 57,
64
- GetComments = 58,
65
- GetSiteConfig = 59,
66
- SaveSiteConfig = 60,
67
- PostJoin = 61,
68
- CommunityJoin = 62,
69
- ChangePassword = 63,
70
- GetSiteMetadata = 64,
71
- BlockCommunity = 65,
72
- BlockPerson = 66,
73
- CreateCommentReport = 67,
74
- ResolveCommentReport = 68,
75
- ListCommentReports = 69,
76
- CreatePostReport = 70,
77
- ResolvePostReport = 71,
78
- ListPostReports = 72,
79
- GetReportCount = 73,
80
- GetUnreadCount = 74,
81
- VerifyEmail = 75
29
+ MarkPostAsRead = 22,
30
+ SavePost = 23,
31
+ EditCommunity = 24,
32
+ DeleteCommunity = 25,
33
+ RemoveCommunity = 26,
34
+ FollowCommunity = 27,
35
+ GetPersonDetails = 28,
36
+ GetReplies = 29,
37
+ GetPersonMentions = 30,
38
+ MarkPersonMentionAsRead = 31,
39
+ GetModlog = 32,
40
+ BanFromCommunity = 33,
41
+ AddModToCommunity = 34,
42
+ CreateSite = 35,
43
+ EditSite = 36,
44
+ GetSite = 37,
45
+ AddAdmin = 38,
46
+ GetUnreadRegistrationApplicationCount = 39,
47
+ ListRegistrationApplications = 40,
48
+ ApproveRegistrationApplication = 41,
49
+ BanPerson = 42,
50
+ GetBannedPersons = 43,
51
+ Search = 44,
52
+ ResolveObject = 45,
53
+ MarkAllAsRead = 46,
54
+ SaveUserSettings = 47,
55
+ TransferCommunity = 48,
56
+ LeaveAdmin = 49,
57
+ DeleteAccount = 50,
58
+ PasswordReset = 51,
59
+ PasswordChange = 52,
60
+ CreatePrivateMessage = 53,
61
+ EditPrivateMessage = 54,
62
+ DeletePrivateMessage = 55,
63
+ MarkPrivateMessageAsRead = 56,
64
+ GetPrivateMessages = 57,
65
+ UserJoin = 58,
66
+ GetComments = 59,
67
+ PostJoin = 60,
68
+ CommunityJoin = 61,
69
+ ChangePassword = 62,
70
+ GetSiteMetadata = 63,
71
+ BlockCommunity = 64,
72
+ BlockPerson = 65,
73
+ CreateCommentReport = 66,
74
+ ResolveCommentReport = 67,
75
+ ListCommentReports = 68,
76
+ CreatePostReport = 69,
77
+ ResolvePostReport = 70,
78
+ ListPostReports = 71,
79
+ GetReportCount = 72,
80
+ GetUnreadCount = 73,
81
+ VerifyEmail = 74
82
82
  }
83
83
  /**
84
84
  * Different sort types used in lemmy.
@@ -143,44 +143,20 @@ export declare enum SearchType {
143
143
  Url = "Url"
144
144
  }
145
145
  /**
146
- * A websocket response. Includes the return type.
147
- * Can be used like:
148
- *
149
- * ```ts
150
- * if (op == UserOperation.Search) {
151
- * let data = wsJsonToRes<SearchResponse>(msg).data;
152
- * }
153
- * ```
146
+ * Different Subscribed states
154
147
  */
155
- export interface WebSocketResponse<ResponseType> {
156
- op: UserOperation;
157
- /**
158
- * This contains the data for a websocket response.
159
- *
160
- * The correct response type if given is in [[LemmyHttp]].
161
- */
162
- data: ResponseType;
163
- }
164
- /**
165
- * A websocket JSON response that includes the errors.
166
- */
167
- export interface WebSocketJsonResponse<ResponseType> {
168
- op?: string;
169
- /**
170
- * This contains the data for a websocket response.
171
- *
172
- * The correct response type if given is in [[LemmyHttp]].
173
- */
174
- data?: ResponseType;
175
- error?: string;
176
- reconnect?: boolean;
148
+ export declare enum SubscribedType {
149
+ Subscribed = "Subscribed",
150
+ NotSubscribed = "NotSubscribed",
151
+ Pending = "Pending"
177
152
  }
178
153
  /**
179
154
  * A holder for a site's metadata ( such as opengraph tags ), used for post links.
180
155
  */
181
- export interface SiteMetadata {
182
- title?: string;
183
- description?: string;
184
- image?: string;
185
- html?: string;
156
+ export declare class SiteMetadata {
157
+ title: Option<string>;
158
+ description: Option<string>;
159
+ image: Option<string>;
160
+ html: Option<string>;
161
+ constructor(init: SiteMetadata);
186
162
  }
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SearchType = exports.ListingType = exports.SortType = exports.UserOperation = exports.VERSION = void 0;
9
+ exports.SiteMetadata = exports.SubscribedType = exports.SearchType = exports.ListingType = exports.SortType = exports.UserOperation = exports.VERSION = void 0;
10
+ var class_transformer_1 = require("class-transformer");
11
+ var utils_1 = require("../utils");
4
12
  exports.VERSION = "v3";
5
13
  /**
6
14
  * All of the websocket operations available.
@@ -29,60 +37,59 @@ var UserOperation;
29
37
  UserOperation[UserOperation["RemovePost"] = 19] = "RemovePost";
30
38
  UserOperation[UserOperation["LockPost"] = 20] = "LockPost";
31
39
  UserOperation[UserOperation["StickyPost"] = 21] = "StickyPost";
32
- UserOperation[UserOperation["SavePost"] = 22] = "SavePost";
33
- UserOperation[UserOperation["EditCommunity"] = 23] = "EditCommunity";
34
- UserOperation[UserOperation["DeleteCommunity"] = 24] = "DeleteCommunity";
35
- UserOperation[UserOperation["RemoveCommunity"] = 25] = "RemoveCommunity";
36
- UserOperation[UserOperation["FollowCommunity"] = 26] = "FollowCommunity";
37
- UserOperation[UserOperation["GetPersonDetails"] = 27] = "GetPersonDetails";
38
- UserOperation[UserOperation["GetReplies"] = 28] = "GetReplies";
39
- UserOperation[UserOperation["GetPersonMentions"] = 29] = "GetPersonMentions";
40
- UserOperation[UserOperation["MarkPersonMentionAsRead"] = 30] = "MarkPersonMentionAsRead";
41
- UserOperation[UserOperation["GetModlog"] = 31] = "GetModlog";
42
- UserOperation[UserOperation["BanFromCommunity"] = 32] = "BanFromCommunity";
43
- UserOperation[UserOperation["AddModToCommunity"] = 33] = "AddModToCommunity";
44
- UserOperation[UserOperation["CreateSite"] = 34] = "CreateSite";
45
- UserOperation[UserOperation["EditSite"] = 35] = "EditSite";
46
- UserOperation[UserOperation["GetSite"] = 36] = "GetSite";
47
- UserOperation[UserOperation["AddAdmin"] = 37] = "AddAdmin";
48
- UserOperation[UserOperation["GetUnreadRegistrationApplicationCount"] = 38] = "GetUnreadRegistrationApplicationCount";
49
- UserOperation[UserOperation["ListRegistrationApplications"] = 39] = "ListRegistrationApplications";
50
- UserOperation[UserOperation["ApproveRegistrationApplication"] = 40] = "ApproveRegistrationApplication";
51
- UserOperation[UserOperation["BanPerson"] = 41] = "BanPerson";
52
- UserOperation[UserOperation["GetBannedPersons"] = 42] = "GetBannedPersons";
53
- UserOperation[UserOperation["Search"] = 43] = "Search";
54
- UserOperation[UserOperation["ResolveObject"] = 44] = "ResolveObject";
55
- UserOperation[UserOperation["MarkAllAsRead"] = 45] = "MarkAllAsRead";
56
- UserOperation[UserOperation["SaveUserSettings"] = 46] = "SaveUserSettings";
57
- UserOperation[UserOperation["TransferCommunity"] = 47] = "TransferCommunity";
58
- UserOperation[UserOperation["LeaveAdmin"] = 48] = "LeaveAdmin";
59
- UserOperation[UserOperation["DeleteAccount"] = 49] = "DeleteAccount";
60
- UserOperation[UserOperation["PasswordReset"] = 50] = "PasswordReset";
61
- UserOperation[UserOperation["PasswordChange"] = 51] = "PasswordChange";
62
- UserOperation[UserOperation["CreatePrivateMessage"] = 52] = "CreatePrivateMessage";
63
- UserOperation[UserOperation["EditPrivateMessage"] = 53] = "EditPrivateMessage";
64
- UserOperation[UserOperation["DeletePrivateMessage"] = 54] = "DeletePrivateMessage";
65
- UserOperation[UserOperation["MarkPrivateMessageAsRead"] = 55] = "MarkPrivateMessageAsRead";
66
- UserOperation[UserOperation["GetPrivateMessages"] = 56] = "GetPrivateMessages";
67
- UserOperation[UserOperation["UserJoin"] = 57] = "UserJoin";
68
- UserOperation[UserOperation["GetComments"] = 58] = "GetComments";
69
- UserOperation[UserOperation["GetSiteConfig"] = 59] = "GetSiteConfig";
70
- UserOperation[UserOperation["SaveSiteConfig"] = 60] = "SaveSiteConfig";
71
- UserOperation[UserOperation["PostJoin"] = 61] = "PostJoin";
72
- UserOperation[UserOperation["CommunityJoin"] = 62] = "CommunityJoin";
73
- UserOperation[UserOperation["ChangePassword"] = 63] = "ChangePassword";
74
- UserOperation[UserOperation["GetSiteMetadata"] = 64] = "GetSiteMetadata";
75
- UserOperation[UserOperation["BlockCommunity"] = 65] = "BlockCommunity";
76
- UserOperation[UserOperation["BlockPerson"] = 66] = "BlockPerson";
77
- UserOperation[UserOperation["CreateCommentReport"] = 67] = "CreateCommentReport";
78
- UserOperation[UserOperation["ResolveCommentReport"] = 68] = "ResolveCommentReport";
79
- UserOperation[UserOperation["ListCommentReports"] = 69] = "ListCommentReports";
80
- UserOperation[UserOperation["CreatePostReport"] = 70] = "CreatePostReport";
81
- UserOperation[UserOperation["ResolvePostReport"] = 71] = "ResolvePostReport";
82
- UserOperation[UserOperation["ListPostReports"] = 72] = "ListPostReports";
83
- UserOperation[UserOperation["GetReportCount"] = 73] = "GetReportCount";
84
- UserOperation[UserOperation["GetUnreadCount"] = 74] = "GetUnreadCount";
85
- UserOperation[UserOperation["VerifyEmail"] = 75] = "VerifyEmail";
40
+ UserOperation[UserOperation["MarkPostAsRead"] = 22] = "MarkPostAsRead";
41
+ UserOperation[UserOperation["SavePost"] = 23] = "SavePost";
42
+ UserOperation[UserOperation["EditCommunity"] = 24] = "EditCommunity";
43
+ UserOperation[UserOperation["DeleteCommunity"] = 25] = "DeleteCommunity";
44
+ UserOperation[UserOperation["RemoveCommunity"] = 26] = "RemoveCommunity";
45
+ UserOperation[UserOperation["FollowCommunity"] = 27] = "FollowCommunity";
46
+ UserOperation[UserOperation["GetPersonDetails"] = 28] = "GetPersonDetails";
47
+ UserOperation[UserOperation["GetReplies"] = 29] = "GetReplies";
48
+ UserOperation[UserOperation["GetPersonMentions"] = 30] = "GetPersonMentions";
49
+ UserOperation[UserOperation["MarkPersonMentionAsRead"] = 31] = "MarkPersonMentionAsRead";
50
+ UserOperation[UserOperation["GetModlog"] = 32] = "GetModlog";
51
+ UserOperation[UserOperation["BanFromCommunity"] = 33] = "BanFromCommunity";
52
+ UserOperation[UserOperation["AddModToCommunity"] = 34] = "AddModToCommunity";
53
+ UserOperation[UserOperation["CreateSite"] = 35] = "CreateSite";
54
+ UserOperation[UserOperation["EditSite"] = 36] = "EditSite";
55
+ UserOperation[UserOperation["GetSite"] = 37] = "GetSite";
56
+ UserOperation[UserOperation["AddAdmin"] = 38] = "AddAdmin";
57
+ UserOperation[UserOperation["GetUnreadRegistrationApplicationCount"] = 39] = "GetUnreadRegistrationApplicationCount";
58
+ UserOperation[UserOperation["ListRegistrationApplications"] = 40] = "ListRegistrationApplications";
59
+ UserOperation[UserOperation["ApproveRegistrationApplication"] = 41] = "ApproveRegistrationApplication";
60
+ UserOperation[UserOperation["BanPerson"] = 42] = "BanPerson";
61
+ UserOperation[UserOperation["GetBannedPersons"] = 43] = "GetBannedPersons";
62
+ UserOperation[UserOperation["Search"] = 44] = "Search";
63
+ UserOperation[UserOperation["ResolveObject"] = 45] = "ResolveObject";
64
+ UserOperation[UserOperation["MarkAllAsRead"] = 46] = "MarkAllAsRead";
65
+ UserOperation[UserOperation["SaveUserSettings"] = 47] = "SaveUserSettings";
66
+ UserOperation[UserOperation["TransferCommunity"] = 48] = "TransferCommunity";
67
+ UserOperation[UserOperation["LeaveAdmin"] = 49] = "LeaveAdmin";
68
+ UserOperation[UserOperation["DeleteAccount"] = 50] = "DeleteAccount";
69
+ UserOperation[UserOperation["PasswordReset"] = 51] = "PasswordReset";
70
+ UserOperation[UserOperation["PasswordChange"] = 52] = "PasswordChange";
71
+ UserOperation[UserOperation["CreatePrivateMessage"] = 53] = "CreatePrivateMessage";
72
+ UserOperation[UserOperation["EditPrivateMessage"] = 54] = "EditPrivateMessage";
73
+ UserOperation[UserOperation["DeletePrivateMessage"] = 55] = "DeletePrivateMessage";
74
+ UserOperation[UserOperation["MarkPrivateMessageAsRead"] = 56] = "MarkPrivateMessageAsRead";
75
+ UserOperation[UserOperation["GetPrivateMessages"] = 57] = "GetPrivateMessages";
76
+ UserOperation[UserOperation["UserJoin"] = 58] = "UserJoin";
77
+ UserOperation[UserOperation["GetComments"] = 59] = "GetComments";
78
+ UserOperation[UserOperation["PostJoin"] = 60] = "PostJoin";
79
+ UserOperation[UserOperation["CommunityJoin"] = 61] = "CommunityJoin";
80
+ UserOperation[UserOperation["ChangePassword"] = 62] = "ChangePassword";
81
+ UserOperation[UserOperation["GetSiteMetadata"] = 63] = "GetSiteMetadata";
82
+ UserOperation[UserOperation["BlockCommunity"] = 64] = "BlockCommunity";
83
+ UserOperation[UserOperation["BlockPerson"] = 65] = "BlockPerson";
84
+ UserOperation[UserOperation["CreateCommentReport"] = 66] = "CreateCommentReport";
85
+ UserOperation[UserOperation["ResolveCommentReport"] = 67] = "ResolveCommentReport";
86
+ UserOperation[UserOperation["ListCommentReports"] = 68] = "ListCommentReports";
87
+ UserOperation[UserOperation["CreatePostReport"] = 69] = "CreatePostReport";
88
+ UserOperation[UserOperation["ResolvePostReport"] = 70] = "ResolvePostReport";
89
+ UserOperation[UserOperation["ListPostReports"] = 71] = "ListPostReports";
90
+ UserOperation[UserOperation["GetReportCount"] = 72] = "GetReportCount";
91
+ UserOperation[UserOperation["GetUnreadCount"] = 73] = "GetUnreadCount";
92
+ UserOperation[UserOperation["VerifyEmail"] = 74] = "VerifyEmail";
86
93
  })(UserOperation = exports.UserOperation || (exports.UserOperation = {}));
87
94
  /**
88
95
  * Different sort types used in lemmy.
@@ -149,3 +156,66 @@ var SearchType;
149
156
  SearchType["Users"] = "Users";
150
157
  SearchType["Url"] = "Url";
151
158
  })(SearchType = exports.SearchType || (exports.SearchType = {}));
159
+ /**
160
+ * Different Subscribed states
161
+ */
162
+ var SubscribedType;
163
+ (function (SubscribedType) {
164
+ SubscribedType["Subscribed"] = "Subscribed";
165
+ SubscribedType["NotSubscribed"] = "NotSubscribed";
166
+ SubscribedType["Pending"] = "Pending";
167
+ })(SubscribedType = exports.SubscribedType || (exports.SubscribedType = {}));
168
+ /**
169
+ * A holder for a site's metadata ( such as opengraph tags ), used for post links.
170
+ */
171
+ var SiteMetadata = /** @class */ (function () {
172
+ function SiteMetadata(init) {
173
+ Object.assign(this, init);
174
+ }
175
+ __decorate([
176
+ (0, class_transformer_1.Transform)(function (_a) {
177
+ var value = _a.value;
178
+ return (0, utils_1.toOption)(value);
179
+ }, { toClassOnly: true }),
180
+ (0, class_transformer_1.Transform)(function (_a) {
181
+ var value = _a.value;
182
+ return (0, utils_1.toUndefined)(value);
183
+ }, { toPlainOnly: true }),
184
+ (0, class_transformer_1.Expose)()
185
+ ], SiteMetadata.prototype, "title", void 0);
186
+ __decorate([
187
+ (0, class_transformer_1.Transform)(function (_a) {
188
+ var value = _a.value;
189
+ return (0, utils_1.toOption)(value);
190
+ }, { toClassOnly: true }),
191
+ (0, class_transformer_1.Transform)(function (_a) {
192
+ var value = _a.value;
193
+ return (0, utils_1.toUndefined)(value);
194
+ }, { toPlainOnly: true }),
195
+ (0, class_transformer_1.Expose)()
196
+ ], SiteMetadata.prototype, "description", void 0);
197
+ __decorate([
198
+ (0, class_transformer_1.Transform)(function (_a) {
199
+ var value = _a.value;
200
+ return (0, utils_1.toOption)(value);
201
+ }, { toClassOnly: true }),
202
+ (0, class_transformer_1.Transform)(function (_a) {
203
+ var value = _a.value;
204
+ return (0, utils_1.toUndefined)(value);
205
+ }, { toPlainOnly: true }),
206
+ (0, class_transformer_1.Expose)()
207
+ ], SiteMetadata.prototype, "image", void 0);
208
+ __decorate([
209
+ (0, class_transformer_1.Transform)(function (_a) {
210
+ var value = _a.value;
211
+ return (0, utils_1.toOption)(value);
212
+ }, { toClassOnly: true }),
213
+ (0, class_transformer_1.Transform)(function (_a) {
214
+ var value = _a.value;
215
+ return (0, utils_1.toUndefined)(value);
216
+ }, { toPlainOnly: true }),
217
+ (0, class_transformer_1.Expose)()
218
+ ], SiteMetadata.prototype, "html", void 0);
219
+ return SiteMetadata;
220
+ }());
221
+ exports.SiteMetadata = SiteMetadata;