lemmy-js-client 1.0.0-export-regex.0 → 1.0.0-image-uploads-request.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -4
- package/dist/http.d.ts +235 -215
- package/dist/http.js +360 -320
- package/dist/index.d.ts +39 -105
- package/dist/index.js +1 -0
- package/dist/other_types.d.ts +5 -5
- package/dist/request_state.d.ts +27 -0
- package/dist/request_state.js +15 -0
- package/dist/types/AdminListUsers.d.ts +2 -1
- package/dist/types/{OAuthProvider.d.ts → AdminOAuthProvider.d.ts} +1 -1
- package/dist/types/AllLemmyErrors.js +1 -4
- package/dist/types/{PasswordChangeAfterReset.d.ts → ChangePasswordAfterReset.d.ts} +1 -1
- package/dist/types/CommentView.d.ts +2 -2
- package/dist/types/Community.d.ts +3 -2
- package/dist/types/CommunityReport.d.ts +1 -1
- package/dist/types/{Tag.d.ts → CommunityTag.d.ts} +6 -4
- package/dist/types/CommunityTagId.d.ts +4 -0
- package/dist/types/CommunityTagsView.d.ts +5 -0
- package/dist/types/CommunityView.d.ts +2 -2
- package/dist/types/CreateCommentReport.d.ts +4 -0
- package/dist/types/CreateCommentWarning.d.ts +8 -0
- package/dist/types/CreateCommunity.d.ts +2 -2
- package/dist/types/CreateCommunityTag.d.ts +3 -1
- package/dist/types/CreateMultiCommunity.d.ts +2 -1
- package/dist/types/CreatePost.d.ts +2 -2
- package/dist/types/CreatePostReport.d.ts +4 -0
- package/dist/types/CreatePostWarning.d.ts +8 -0
- package/dist/types/CreateSite.d.ts +18 -7
- package/dist/types/DeleteCommunityTag.d.ts +3 -2
- package/dist/types/EditCommunity.d.ts +2 -2
- package/dist/types/{UpdateCommunityNotifications.d.ts → EditCommunityNotifications.d.ts} +1 -1
- package/dist/types/EditCommunityTag.d.ts +11 -0
- package/dist/types/{UpdateMultiCommunity.d.ts → EditMultiCommunity.d.ts} +3 -2
- package/dist/types/EditPost.d.ts +2 -2
- package/dist/types/{UpdatePostNotifications.d.ts → EditPostNotifications.d.ts} +1 -1
- package/dist/types/EditSite.d.ts +31 -14
- package/dist/types/{UpdateTagline.d.ts → EditTagline.d.ts} +1 -1
- package/dist/types/{UpdateTotp.d.ts → EditTotp.d.ts} +1 -1
- package/dist/types/EditTotpResponse.d.ts +3 -0
- package/dist/types/GetComments.d.ts +4 -1
- package/dist/types/GetFederatedInstances.d.ts +0 -1
- package/dist/types/GetModlog.d.ts +11 -3
- package/dist/types/GetPersonDetailsResponse.d.ts +2 -0
- package/dist/types/GetPosts.d.ts +7 -1
- package/dist/types/GetSiteResponse.d.ts +9 -3
- package/dist/types/ImageMode.d.ts +4 -0
- package/dist/types/LemmyErrorType.d.ts +4 -15
- package/dist/types/LemmyErrorType.js +1 -0
- package/dist/types/ListCommentLikes.d.ts +0 -1
- package/dist/types/ListCommunities.d.ts +4 -1
- package/dist/types/ListCommunityPendingFollows.d.ts +0 -1
- package/dist/types/ListMedia.d.ts +0 -1
- package/dist/types/ListMultiCommunities.d.ts +14 -1
- package/dist/types/ListNotifications.d.ts +4 -3
- package/dist/types/ListPersonContent.d.ts +3 -1
- package/dist/types/ListPersonHidden.d.ts +0 -1
- package/dist/types/ListPersonLiked.d.ts +0 -1
- package/dist/types/ListPersonRead.d.ts +0 -1
- package/dist/types/ListPersonSaved.d.ts +0 -1
- package/dist/types/ListPersons.d.ts +11 -0
- package/dist/types/ListPostLikes.d.ts +0 -1
- package/dist/types/ListRegistrationApplications.d.ts +0 -1
- package/dist/types/ListReports.d.ts +0 -1
- package/dist/types/ListTaglines.d.ts +0 -1
- package/dist/types/LocalSite.d.ts +32 -12
- package/dist/types/LocalUser.d.ts +2 -2
- package/dist/types/LocalUserSortType.d.ts +4 -0
- package/dist/types/ModEditPost.d.ts +2 -2
- package/dist/types/Modlog.d.ts +11 -0
- package/dist/types/ModlogId.d.ts +1 -0
- package/dist/types/ModlogKind.d.ts +4 -0
- package/dist/types/ModlogKindFilter.d.ts +5 -0
- package/dist/types/ModlogView.d.ts +15 -0
- package/dist/types/MultiCommunity.d.ts +12 -1
- package/dist/types/MultiCommunityListingType.d.ts +4 -0
- package/dist/types/MultiCommunitySortType.d.ts +1 -0
- package/dist/types/MyUserInfo.d.ts +2 -0
- package/dist/types/NodeInfo.d.ts +20 -0
- package/dist/types/NodeInfoServices.d.ts +4 -0
- package/dist/types/NodeInfoSoftware.d.ts +6 -0
- package/dist/types/NodeInfoUsage.d.ts +6 -0
- package/dist/types/NodeInfoUsers.d.ts +5 -0
- package/dist/types/Notification.d.ts +3 -20
- package/dist/types/NotificationData.d.ts +3 -30
- package/dist/types/NotificationTypeFilter.d.ts +5 -0
- package/dist/types/PagedResponse.d.ts +11 -0
- package/dist/types/PaginationCursor.d.ts +5 -1
- package/dist/types/Person.d.ts +1 -0
- package/dist/types/PersonListingType.d.ts +4 -0
- package/dist/types/PersonSortType.d.ts +4 -0
- package/dist/types/PluginMetadata.d.ts +2 -2
- package/dist/types/{PersonSavedCombinedView.d.ts → PostCommentCombinedView.d.ts} +1 -1
- package/dist/types/PostView.d.ts +2 -2
- package/dist/types/PrivateMessage.d.ts +1 -0
- package/dist/types/PublicOAuthProvider.d.ts +27 -2
- package/dist/types/RegistrationApplication.d.ts +1 -0
- package/dist/types/RemoveComment.d.ts +5 -0
- package/dist/types/RemovePost.d.ts +5 -0
- package/dist/types/{PasswordReset.d.ts → ResetPassword.d.ts} +1 -1
- package/dist/types/{SearchCombinedView.d.ts → ResolveObjectView.d.ts} +3 -3
- package/dist/types/SaveUserSettings.d.ts +2 -2
- package/dist/types/Search.d.ts +7 -8
- package/dist/types/SearchResponse.d.ts +17 -6
- package/dist/types/Site.d.ts +2 -3
- package/dist/types/TagColor.d.ts +4 -0
- package/dist/types/UnreadCountsResponse.d.ts +11 -0
- package/package.json +9 -9
- package/dist/types/AdminAdd.d.ts +0 -12
- package/dist/types/AdminAddId.d.ts +0 -1
- package/dist/types/AdminAddView.d.ts +0 -10
- package/dist/types/AdminAllowInstance.d.ts +0 -11
- package/dist/types/AdminAllowInstanceId.d.ts +0 -1
- package/dist/types/AdminAllowInstanceView.d.ts +0 -11
- package/dist/types/AdminBan.d.ts +0 -16
- package/dist/types/AdminBanId.d.ts +0 -1
- package/dist/types/AdminBanView.d.ts +0 -10
- package/dist/types/AdminBlockInstance.d.ts +0 -12
- package/dist/types/AdminBlockInstanceId.d.ts +0 -1
- package/dist/types/AdminBlockInstanceView.d.ts +0 -11
- package/dist/types/AdminListUsersResponse.d.ts +0 -10
- package/dist/types/AdminPurgeComment.d.ts +0 -13
- package/dist/types/AdminPurgeCommentId.d.ts +0 -1
- package/dist/types/AdminPurgeCommentView.d.ts +0 -11
- package/dist/types/AdminPurgeCommunity.d.ts +0 -11
- package/dist/types/AdminPurgeCommunityId.d.ts +0 -1
- package/dist/types/AdminPurgeCommunityView.d.ts +0 -9
- package/dist/types/AdminPurgePerson.d.ts +0 -11
- package/dist/types/AdminPurgePersonId.d.ts +0 -1
- package/dist/types/AdminPurgePersonView.d.ts +0 -9
- package/dist/types/AdminPurgePost.d.ts +0 -13
- package/dist/types/AdminPurgePostId.d.ts +0 -1
- package/dist/types/AdminPurgePostView.d.ts +0 -11
- package/dist/types/AdminRemoveCommunity.d.ts +0 -14
- package/dist/types/AdminRemoveCommunityId.d.ts +0 -1
- package/dist/types/AdminRemoveCommunityView.d.ts +0 -11
- package/dist/types/BanFromCommunityResponse.d.ts +0 -8
- package/dist/types/GetCommentsResponse.d.ts +0 -10
- package/dist/types/GetCommentsSlimResponse.d.ts +0 -10
- package/dist/types/GetCommunityPendingFollowsCountResponse.d.ts +0 -3
- package/dist/types/GetFederatedInstancesResponse.d.ts +0 -10
- package/dist/types/GetFederatedInstancesResponse.js +0 -2
- package/dist/types/GetModlogResponse.d.ts +0 -13
- package/dist/types/GetModlogResponse.js +0 -2
- package/dist/types/GetPostsResponse.d.ts +0 -13
- package/dist/types/GetPostsResponse.js +0 -2
- package/dist/types/GetReportCount.d.ts +0 -7
- package/dist/types/GetReportCount.js +0 -2
- package/dist/types/GetReportCountResponse.d.ts +0 -6
- package/dist/types/GetUnreadCountResponse.d.ts +0 -6
- package/dist/types/GetUnreadRegistrationApplicationCountResponse.d.ts +0 -6
- package/dist/types/InstanceWithFederationState.d.ts +0 -24
- package/dist/types/InstanceWithFederationState.js +0 -2
- package/dist/types/ListCommentLikesResponse.d.ts +0 -13
- package/dist/types/ListCommentLikesResponse.js +0 -2
- package/dist/types/ListCommunitiesResponse.d.ts +0 -13
- package/dist/types/ListCommunitiesResponse.js +0 -2
- package/dist/types/ListCommunityPendingFollowsResponse.d.ts +0 -10
- package/dist/types/ListCommunityPendingFollowsResponse.js +0 -2
- package/dist/types/ListMediaResponse.d.ts +0 -10
- package/dist/types/ListMediaResponse.js +0 -2
- package/dist/types/ListMultiCommunitiesResponse.d.ts +0 -4
- package/dist/types/ListMultiCommunitiesResponse.js +0 -2
- package/dist/types/ListNotificationsResponse.d.ts +0 -13
- package/dist/types/ListNotificationsResponse.js +0 -2
- package/dist/types/ListPersonContentResponse.d.ts +0 -13
- package/dist/types/ListPersonContentResponse.js +0 -2
- package/dist/types/ListPersonHiddenResponse.d.ts +0 -13
- package/dist/types/ListPersonHiddenResponse.js +0 -2
- package/dist/types/ListPersonLikedResponse.d.ts +0 -13
- package/dist/types/ListPersonLikedResponse.js +0 -2
- package/dist/types/ListPersonReadResponse.d.ts +0 -13
- package/dist/types/ListPersonReadResponse.js +0 -2
- package/dist/types/ListPersonSavedResponse.d.ts +0 -13
- package/dist/types/ListPersonSavedResponse.js +0 -2
- package/dist/types/ListPostLikesResponse.d.ts +0 -13
- package/dist/types/ListPostLikesResponse.js +0 -2
- package/dist/types/ListRegistrationApplicationsResponse.d.ts +0 -13
- package/dist/types/ListRegistrationApplicationsResponse.js +0 -2
- package/dist/types/ListReportsResponse.d.ts +0 -13
- package/dist/types/ListReportsResponse.js +0 -2
- package/dist/types/ListTaglinesResponse.d.ts +0 -13
- package/dist/types/ListTaglinesResponse.js +0 -2
- package/dist/types/ModAddToCommunity.d.ts +0 -14
- package/dist/types/ModAddToCommunity.js +0 -2
- package/dist/types/ModAddToCommunityId.d.ts +0 -1
- package/dist/types/ModAddToCommunityView.d.ts +0 -12
- package/dist/types/ModAddToCommunityView.js +0 -2
- package/dist/types/ModBanFromCommunity.d.ts +0 -16
- package/dist/types/ModBanFromCommunity.js +0 -2
- package/dist/types/ModBanFromCommunityId.d.ts +0 -1
- package/dist/types/ModBanFromCommunityView.d.ts +0 -12
- package/dist/types/ModBanFromCommunityView.js +0 -2
- package/dist/types/ModChangeCommunityVisibility.d.ts +0 -11
- package/dist/types/ModChangeCommunityVisibility.js +0 -2
- package/dist/types/ModChangeCommunityVisibilityId.d.ts +0 -1
- package/dist/types/ModChangeCommunityVisibilityView.d.ts +0 -11
- package/dist/types/ModChangeCommunityVisibilityView.js +0 -2
- package/dist/types/ModFeaturePost.d.ts +0 -14
- package/dist/types/ModFeaturePost.js +0 -2
- package/dist/types/ModFeaturePostId.d.ts +0 -1
- package/dist/types/ModFeaturePostId.js +0 -3
- package/dist/types/ModFeaturePostView.d.ts +0 -14
- package/dist/types/ModFeaturePostView.js +0 -2
- package/dist/types/ModLockComment.d.ts +0 -14
- package/dist/types/ModLockComment.js +0 -2
- package/dist/types/ModLockCommentId.d.ts +0 -1
- package/dist/types/ModLockCommentId.js +0 -3
- package/dist/types/ModLockCommentView.d.ts +0 -16
- package/dist/types/ModLockCommentView.js +0 -2
- package/dist/types/ModLockPost.d.ts +0 -14
- package/dist/types/ModLockPost.js +0 -2
- package/dist/types/ModLockPostId.d.ts +0 -1
- package/dist/types/ModLockPostId.js +0 -3
- package/dist/types/ModLockPostView.d.ts +0 -14
- package/dist/types/ModLockPostView.js +0 -2
- package/dist/types/ModRemoveComment.d.ts +0 -14
- package/dist/types/ModRemoveComment.js +0 -2
- package/dist/types/ModRemoveCommentId.d.ts +0 -1
- package/dist/types/ModRemoveCommentId.js +0 -3
- package/dist/types/ModRemoveCommentView.d.ts +0 -16
- package/dist/types/ModRemoveCommentView.js +0 -2
- package/dist/types/ModRemovePost.d.ts +0 -14
- package/dist/types/ModRemovePost.js +0 -2
- package/dist/types/ModRemovePostId.d.ts +0 -1
- package/dist/types/ModRemovePostId.js +0 -3
- package/dist/types/ModRemovePostView.d.ts +0 -14
- package/dist/types/ModRemovePostView.js +0 -2
- package/dist/types/ModTransferCommunity.d.ts +0 -13
- package/dist/types/ModTransferCommunity.js +0 -2
- package/dist/types/ModTransferCommunityId.d.ts +0 -1
- package/dist/types/ModTransferCommunityId.js +0 -3
- package/dist/types/ModTransferCommunityView.d.ts +0 -12
- package/dist/types/ModTransferCommunityView.js +0 -2
- package/dist/types/ModlogActionType.d.ts +0 -4
- package/dist/types/ModlogActionType.js +0 -3
- package/dist/types/ModlogCombinedView.d.ts +0 -55
- package/dist/types/ModlogCombinedView.js +0 -2
- package/dist/types/NotificationDataType.d.ts +0 -4
- package/dist/types/NotificationDataType.js +0 -3
- package/dist/types/OAuthProvider.js +0 -2
- package/dist/types/PasswordChangeAfterReset.js +0 -2
- package/dist/types/PasswordReset.js +0 -2
- package/dist/types/PersonContentCombinedView.d.ts +0 -7
- package/dist/types/PersonContentCombinedView.js +0 -2
- package/dist/types/PersonLikedCombinedView.d.ts +0 -7
- package/dist/types/PersonLikedCombinedView.js +0 -2
- package/dist/types/PersonSavedCombinedView.js +0 -2
- package/dist/types/ReadableFederationState.d.ts +0 -22
- package/dist/types/ReadableFederationState.js +0 -2
- package/dist/types/SearchCombinedView.js +0 -2
- package/dist/types/SearchSortType.d.ts +0 -4
- package/dist/types/SearchSortType.js +0 -3
- package/dist/types/Tag.js +0 -2
- package/dist/types/TagId.d.ts +0 -4
- package/dist/types/TagId.js +0 -3
- package/dist/types/TagsView.d.ts +0 -5
- package/dist/types/TagsView.js +0 -2
- package/dist/types/UntranslatedError.d.ts +0 -14
- package/dist/types/UntranslatedError.js +0 -3
- package/dist/types/UpdateCommunityNotifications.js +0 -2
- package/dist/types/UpdateCommunityTag.d.ts +0 -9
- package/dist/types/UpdateCommunityTag.js +0 -2
- package/dist/types/UpdateMultiCommunity.js +0 -2
- package/dist/types/UpdatePostNotifications.js +0 -2
- package/dist/types/UpdateTagline.js +0 -2
- package/dist/types/UpdateTotp.js +0 -3
- package/dist/types/UpdateTotpResponse.d.ts +0 -3
- package/dist/types/UpdateTotpResponse.js +0 -3
- /package/dist/types/{AdminAdd.js → AdminOAuthProvider.js} +0 -0
- /package/dist/types/{AdminAddView.js → ChangePasswordAfterReset.js} +0 -0
- /package/dist/types/{AdminAllowInstance.js → CommunityTag.js} +0 -0
- /package/dist/types/{AdminAddId.js → CommunityTagId.js} +0 -0
- /package/dist/types/{AdminAllowInstanceView.js → CommunityTagsView.js} +0 -0
- /package/dist/types/{AdminBan.js → CreateCommentWarning.js} +0 -0
- /package/dist/types/{AdminBanView.js → CreatePostWarning.js} +0 -0
- /package/dist/types/{AdminBlockInstance.js → EditCommunityNotifications.js} +0 -0
- /package/dist/types/{AdminBlockInstanceView.js → EditCommunityTag.js} +0 -0
- /package/dist/types/{AdminListUsersResponse.js → EditMultiCommunity.js} +0 -0
- /package/dist/types/{AdminPurgeComment.js → EditPostNotifications.js} +0 -0
- /package/dist/types/{AdminPurgeCommentView.js → EditTagline.js} +0 -0
- /package/dist/types/{AdminAllowInstanceId.js → EditTotp.js} +0 -0
- /package/dist/types/{AdminBanId.js → EditTotpResponse.js} +0 -0
- /package/dist/types/{AdminBlockInstanceId.js → ImageMode.js} +0 -0
- /package/dist/types/{AdminPurgeCommunity.js → ListPersons.js} +0 -0
- /package/dist/types/{AdminPurgeCommentId.js → LocalUserSortType.js} +0 -0
- /package/dist/types/{AdminPurgeCommunityView.js → Modlog.js} +0 -0
- /package/dist/types/{AdminPurgeCommunityId.js → ModlogId.js} +0 -0
- /package/dist/types/{AdminPurgePersonId.js → ModlogKind.js} +0 -0
- /package/dist/types/{AdminPurgePerson.js → ModlogKindFilter.js} +0 -0
- /package/dist/types/{AdminPurgePersonView.js → ModlogView.js} +0 -0
- /package/dist/types/{AdminPurgePostId.js → MultiCommunityListingType.js} +0 -0
- /package/dist/types/{AdminRemoveCommunityId.js → MultiCommunitySortType.js} +0 -0
- /package/dist/types/{AdminPurgePost.js → NodeInfo.js} +0 -0
- /package/dist/types/{GetCommunityPendingFollowsCountResponse.js → NodeInfoServices.js} +0 -0
- /package/dist/types/{GetReportCountResponse.js → NodeInfoSoftware.js} +0 -0
- /package/dist/types/{AdminPurgePostView.js → NodeInfoUsage.js} +0 -0
- /package/dist/types/{GetUnreadCountResponse.js → NodeInfoUsers.js} +0 -0
- /package/dist/types/{AdminRemoveCommunity.js → NotificationTypeFilter.js} +0 -0
- /package/dist/types/{AdminRemoveCommunityView.js → PagedResponse.js} +0 -0
- /package/dist/types/{GetUnreadRegistrationApplicationCountResponse.js → PersonListingType.js} +0 -0
- /package/dist/types/{ModAddToCommunityId.js → PersonSortType.js} +0 -0
- /package/dist/types/{BanFromCommunityResponse.js → PostCommentCombinedView.js} +0 -0
- /package/dist/types/{GetCommentsResponse.js → ResetPassword.js} +0 -0
- /package/dist/types/{GetCommentsSlimResponse.js → ResolveObjectView.js} +0 -0
- /package/dist/types/{ModBanFromCommunityId.js → TagColor.js} +0 -0
- /package/dist/types/{ModChangeCommunityVisibilityId.js → UnreadCountsResponse.js} +0 -0
package/README.md
CHANGED
|
@@ -26,7 +26,8 @@ import { LemmyHttp, Login } from "lemmy-js-client";
|
|
|
26
26
|
|
|
27
27
|
// Build the client
|
|
28
28
|
const baseUrl = "https://lemmy.ml";
|
|
29
|
-
const
|
|
29
|
+
const headers = {["x-real-ip": ...]};
|
|
30
|
+
const client: LemmyHttp = new LemmyHttp(baseUrl, { headers });
|
|
30
31
|
|
|
31
32
|
// Build the login form
|
|
32
33
|
const loginForm: Login = {
|
|
@@ -35,15 +36,40 @@ const loginForm: Login = {
|
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
// Login and set the client headers with your jwt
|
|
38
|
-
const
|
|
39
|
-
|
|
39
|
+
const loginRes = await client.login(loginForm);
|
|
40
|
+
|
|
41
|
+
// Make sure its successful
|
|
42
|
+
if (loginRes.state === "success") {
|
|
43
|
+
const jwt = login.data.jwt;
|
|
44
|
+
client.setHeaders({ Authorization: `Bearer ${jwt}` });
|
|
45
|
+
} else if (loginRes.state === "failed") {
|
|
46
|
+
const err = login.err;
|
|
47
|
+
}
|
|
40
48
|
|
|
41
49
|
// Fetch top posts for the day
|
|
42
50
|
const getPostsForm: GetPosts = {
|
|
43
51
|
sort: "TopDay",
|
|
44
52
|
type_: "Local",
|
|
45
53
|
};
|
|
46
|
-
const
|
|
54
|
+
const postsRes = await client.getPosts(getPostsForm);
|
|
55
|
+
|
|
56
|
+
// Handle the different request states
|
|
57
|
+
switch (postsRes.state) {
|
|
58
|
+
case "empty": {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
case "loading": {
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case "failed": {
|
|
65
|
+
const err = postsRes.err;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case "success": {
|
|
69
|
+
const data = postsRes.data;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
47
73
|
```
|
|
48
74
|
|
|
49
75
|
## Development
|