lemmy-js-client 0.17.0-rc.2 → 0.17.0-rc.20

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,61 @@ 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
+ GetSiteConfig = 60,
68
+ SaveSiteConfig = 61,
69
+ PostJoin = 62,
70
+ CommunityJoin = 63,
71
+ ChangePassword = 64,
72
+ GetSiteMetadata = 65,
73
+ BlockCommunity = 66,
74
+ BlockPerson = 67,
75
+ CreateCommentReport = 68,
76
+ ResolveCommentReport = 69,
77
+ ListCommentReports = 70,
78
+ CreatePostReport = 71,
79
+ ResolvePostReport = 72,
80
+ ListPostReports = 73,
81
+ GetReportCount = 74,
82
+ GetUnreadCount = 75,
83
+ VerifyEmail = 76
82
84
  }
83
85
  /**
84
86
  * Different sort types used in lemmy.
@@ -142,45 +144,13 @@ export declare enum SearchType {
142
144
  Users = "Users",
143
145
  Url = "Url"
144
146
  }
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
- * ```
154
- */
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;
177
- }
178
147
  /**
179
148
  * A holder for a site's metadata ( such as opengraph tags ), used for post links.
180
149
  */
181
- export interface SiteMetadata {
182
- title?: string;
183
- description?: string;
184
- image?: string;
185
- html?: string;
150
+ export declare class SiteMetadata {
151
+ title: Option<string>;
152
+ description: Option<string>;
153
+ image: Option<string>;
154
+ html: Option<string>;
155
+ constructor(init: SiteMetadata);
186
156
  }
@@ -1,6 +1,15 @@
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.SearchType = exports.ListingType = exports.SortType = exports.UserOperation = exports.VERSION = void 0;
10
+ var monads_1 = require("@sniptt/monads");
11
+ var class_transformer_1 = require("class-transformer");
12
+ var utils_1 = require("../utils");
4
13
  exports.VERSION = "v3";
5
14
  /**
6
15
  * All of the websocket operations available.
@@ -29,60 +38,61 @@ var UserOperation;
29
38
  UserOperation[UserOperation["RemovePost"] = 19] = "RemovePost";
30
39
  UserOperation[UserOperation["LockPost"] = 20] = "LockPost";
31
40
  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";
41
+ UserOperation[UserOperation["MarkPostAsRead"] = 22] = "MarkPostAsRead";
42
+ UserOperation[UserOperation["SavePost"] = 23] = "SavePost";
43
+ UserOperation[UserOperation["EditCommunity"] = 24] = "EditCommunity";
44
+ UserOperation[UserOperation["DeleteCommunity"] = 25] = "DeleteCommunity";
45
+ UserOperation[UserOperation["RemoveCommunity"] = 26] = "RemoveCommunity";
46
+ UserOperation[UserOperation["FollowCommunity"] = 27] = "FollowCommunity";
47
+ UserOperation[UserOperation["GetPersonDetails"] = 28] = "GetPersonDetails";
48
+ UserOperation[UserOperation["GetReplies"] = 29] = "GetReplies";
49
+ UserOperation[UserOperation["GetPersonMentions"] = 30] = "GetPersonMentions";
50
+ UserOperation[UserOperation["MarkPersonMentionAsRead"] = 31] = "MarkPersonMentionAsRead";
51
+ UserOperation[UserOperation["GetModlog"] = 32] = "GetModlog";
52
+ UserOperation[UserOperation["BanFromCommunity"] = 33] = "BanFromCommunity";
53
+ UserOperation[UserOperation["AddModToCommunity"] = 34] = "AddModToCommunity";
54
+ UserOperation[UserOperation["CreateSite"] = 35] = "CreateSite";
55
+ UserOperation[UserOperation["EditSite"] = 36] = "EditSite";
56
+ UserOperation[UserOperation["GetSite"] = 37] = "GetSite";
57
+ UserOperation[UserOperation["AddAdmin"] = 38] = "AddAdmin";
58
+ UserOperation[UserOperation["GetUnreadRegistrationApplicationCount"] = 39] = "GetUnreadRegistrationApplicationCount";
59
+ UserOperation[UserOperation["ListRegistrationApplications"] = 40] = "ListRegistrationApplications";
60
+ UserOperation[UserOperation["ApproveRegistrationApplication"] = 41] = "ApproveRegistrationApplication";
61
+ UserOperation[UserOperation["BanPerson"] = 42] = "BanPerson";
62
+ UserOperation[UserOperation["GetBannedPersons"] = 43] = "GetBannedPersons";
63
+ UserOperation[UserOperation["Search"] = 44] = "Search";
64
+ UserOperation[UserOperation["ResolveObject"] = 45] = "ResolveObject";
65
+ UserOperation[UserOperation["MarkAllAsRead"] = 46] = "MarkAllAsRead";
66
+ UserOperation[UserOperation["SaveUserSettings"] = 47] = "SaveUserSettings";
67
+ UserOperation[UserOperation["TransferCommunity"] = 48] = "TransferCommunity";
68
+ UserOperation[UserOperation["LeaveAdmin"] = 49] = "LeaveAdmin";
69
+ UserOperation[UserOperation["DeleteAccount"] = 50] = "DeleteAccount";
70
+ UserOperation[UserOperation["PasswordReset"] = 51] = "PasswordReset";
71
+ UserOperation[UserOperation["PasswordChange"] = 52] = "PasswordChange";
72
+ UserOperation[UserOperation["CreatePrivateMessage"] = 53] = "CreatePrivateMessage";
73
+ UserOperation[UserOperation["EditPrivateMessage"] = 54] = "EditPrivateMessage";
74
+ UserOperation[UserOperation["DeletePrivateMessage"] = 55] = "DeletePrivateMessage";
75
+ UserOperation[UserOperation["MarkPrivateMessageAsRead"] = 56] = "MarkPrivateMessageAsRead";
76
+ UserOperation[UserOperation["GetPrivateMessages"] = 57] = "GetPrivateMessages";
77
+ UserOperation[UserOperation["UserJoin"] = 58] = "UserJoin";
78
+ UserOperation[UserOperation["GetComments"] = 59] = "GetComments";
79
+ UserOperation[UserOperation["GetSiteConfig"] = 60] = "GetSiteConfig";
80
+ UserOperation[UserOperation["SaveSiteConfig"] = 61] = "SaveSiteConfig";
81
+ UserOperation[UserOperation["PostJoin"] = 62] = "PostJoin";
82
+ UserOperation[UserOperation["CommunityJoin"] = 63] = "CommunityJoin";
83
+ UserOperation[UserOperation["ChangePassword"] = 64] = "ChangePassword";
84
+ UserOperation[UserOperation["GetSiteMetadata"] = 65] = "GetSiteMetadata";
85
+ UserOperation[UserOperation["BlockCommunity"] = 66] = "BlockCommunity";
86
+ UserOperation[UserOperation["BlockPerson"] = 67] = "BlockPerson";
87
+ UserOperation[UserOperation["CreateCommentReport"] = 68] = "CreateCommentReport";
88
+ UserOperation[UserOperation["ResolveCommentReport"] = 69] = "ResolveCommentReport";
89
+ UserOperation[UserOperation["ListCommentReports"] = 70] = "ListCommentReports";
90
+ UserOperation[UserOperation["CreatePostReport"] = 71] = "CreatePostReport";
91
+ UserOperation[UserOperation["ResolvePostReport"] = 72] = "ResolvePostReport";
92
+ UserOperation[UserOperation["ListPostReports"] = 73] = "ListPostReports";
93
+ UserOperation[UserOperation["GetReportCount"] = 74] = "GetReportCount";
94
+ UserOperation[UserOperation["GetUnreadCount"] = 75] = "GetUnreadCount";
95
+ UserOperation[UserOperation["VerifyEmail"] = 76] = "VerifyEmail";
86
96
  })(UserOperation = exports.UserOperation || (exports.UserOperation = {}));
87
97
  /**
88
98
  * Different sort types used in lemmy.
@@ -149,3 +159,57 @@ var SearchType;
149
159
  SearchType["Users"] = "Users";
150
160
  SearchType["Url"] = "Url";
151
161
  })(SearchType = exports.SearchType || (exports.SearchType = {}));
162
+ /**
163
+ * A holder for a site's metadata ( such as opengraph tags ), used for post links.
164
+ */
165
+ var SiteMetadata = /** @class */ (function () {
166
+ function SiteMetadata(init) {
167
+ Object.assign(this, init);
168
+ }
169
+ __decorate([
170
+ (0, class_transformer_1.Transform)(function (_a) {
171
+ var value = _a.value;
172
+ return (0, monads_1.Some)(value);
173
+ }, { toClassOnly: true }),
174
+ (0, class_transformer_1.Transform)(function (_a) {
175
+ var value = _a.value;
176
+ return (0, utils_1.toUndefined)(value);
177
+ }, { toPlainOnly: true }),
178
+ (0, class_transformer_1.Expose)()
179
+ ], SiteMetadata.prototype, "title", void 0);
180
+ __decorate([
181
+ (0, class_transformer_1.Transform)(function (_a) {
182
+ var value = _a.value;
183
+ return (0, monads_1.Some)(value);
184
+ }, { toClassOnly: true }),
185
+ (0, class_transformer_1.Transform)(function (_a) {
186
+ var value = _a.value;
187
+ return (0, utils_1.toUndefined)(value);
188
+ }, { toPlainOnly: true }),
189
+ (0, class_transformer_1.Expose)()
190
+ ], SiteMetadata.prototype, "description", void 0);
191
+ __decorate([
192
+ (0, class_transformer_1.Transform)(function (_a) {
193
+ var value = _a.value;
194
+ return (0, monads_1.Some)(value);
195
+ }, { toClassOnly: true }),
196
+ (0, class_transformer_1.Transform)(function (_a) {
197
+ var value = _a.value;
198
+ return (0, utils_1.toUndefined)(value);
199
+ }, { toPlainOnly: true }),
200
+ (0, class_transformer_1.Expose)()
201
+ ], SiteMetadata.prototype, "image", void 0);
202
+ __decorate([
203
+ (0, class_transformer_1.Transform)(function (_a) {
204
+ var value = _a.value;
205
+ return (0, monads_1.Some)(value);
206
+ }, { toClassOnly: true }),
207
+ (0, class_transformer_1.Transform)(function (_a) {
208
+ var value = _a.value;
209
+ return (0, utils_1.toUndefined)(value);
210
+ }, { toPlainOnly: true }),
211
+ (0, class_transformer_1.Expose)()
212
+ ], SiteMetadata.prototype, "html", void 0);
213
+ return SiteMetadata;
214
+ }());
215
+ exports.SiteMetadata = SiteMetadata;