diff --git a/copy_generated_types_from_lemmy.sh b/copy_generated_types_from_lemmy.sh index a2e1ee5..dc40742 100755 --- a/copy_generated_types_from_lemmy.sh +++ b/copy_generated_types_from_lemmy.sh @@ -30,6 +30,9 @@ rm src/types/Sensitive.ts # Change all the bigints to numbers find src/types -type f -name '*.ts' -exec sed -i 's/bigint/number/g' {} + +# on MacOS: +# find src/types -type f -name '*.ts' -exec sed -i '' -e 's/bigint/number/g' {} \; + node putTypesInIndex.js prettier -w src diff --git a/src/http.ts b/src/http.ts index ad456a5..c95eaf9 100644 --- a/src/http.ts +++ b/src/http.ts @@ -22,6 +22,7 @@ import { CreateCommentLike } from "./types/CreateCommentLike"; import { CreateCommentReport } from "./types/CreateCommentReport"; import { CreateCommunity } from "./types/CreateCommunity"; import { CreateCustomEmoji } from "./types/CreateCustomEmoji"; +import { CreateOAuthProvider } from "./types/CreateOAuthProvider"; import { CreatePost } from "./types/CreatePost"; import { CreatePostLike } from "./types/CreatePostLike"; import { CreatePostReport } from "./types/CreatePostReport"; @@ -33,15 +34,18 @@ import { DeleteAccount } from "./types/DeleteAccount"; import { DeleteComment } from "./types/DeleteComment"; import { DeleteCommunity } from "./types/DeleteCommunity"; import { DeleteCustomEmoji } from "./types/DeleteCustomEmoji"; +import { DeleteOAuthProvider } from "./types/DeleteOAuthProvider"; import { DeletePost } from "./types/DeletePost"; import { DeletePrivateMessage } from "./types/DeletePrivateMessage"; import { DistinguishComment } from "./types/DistinguishComment"; import { EditComment } from "./types/EditComment"; import { EditCommunity } from "./types/EditCommunity"; import { EditCustomEmoji } from "./types/EditCustomEmoji"; +import { EditOAuthProvider } from "./types/EditOAuthProvider"; import { EditPost } from "./types/EditPost"; import { EditPrivateMessage } from "./types/EditPrivateMessage"; import { EditSite } from "./types/EditSite"; +import { OAuthProvider } from "./types/OAuthProvider"; import { FeaturePost } from "./types/FeaturePost"; import { FollowCommunity } from "./types/FollowCommunity"; import { GetCaptchaResponse } from "./types/GetCaptchaResponse"; @@ -139,6 +143,7 @@ import { ListCommentLikesResponse } from "./types/ListCommentLikesResponse"; import { HidePost } from "./types/HidePost"; import { ListMedia } from "./types/ListMedia"; import { ListMediaResponse } from "./types/ListMediaResponse"; +import { AuthenticateWithOauth } from "./types/AuthenticateWithOauth"; import { GetRegistrationApplication } from "./types/GetRegistrationApplication"; enum HttpType { @@ -1434,6 +1439,58 @@ export class LemmyHttp { ); } + /** + * Create a new oauth provider method + * + * `HTTP.POST /oauth_provider` + */ + createOAuthProvider(form: CreateOAuthProvider) { + return this.#wrapper( + HttpType.Post, + "/oauth_provider", + form, + ); + } + + /** + * Edit an existing oauth provider method + * + * `HTTP.PUT /oauth_provider` + */ + editOAuthProvider(form: EditOAuthProvider) { + return this.#wrapper( + HttpType.Put, + "/oauth_provider", + form, + ); + } + + /** + * Delete an oauth provider method + * + * `HTTP.Post /oauth_provider/delete` + */ + deleteOAuthProvider(form: DeleteOAuthProvider) { + return this.#wrapper( + HttpType.Post, + "/oauth_provider/delete", + form, + ); + } + + /** + * Authenticate with OAuth + * + * `HTTP.Post /oauth/authenticate` + */ + authenticateWithOAuth(form: AuthenticateWithOauth) { + return this.#wrapper( + HttpType.Post, + "/oauth/authenticate", + form, + ); + } + /** * Fetch federated instances. * diff --git a/src/index.ts b/src/index.ts index ae03320..a7d3d6b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,6 +13,7 @@ export { AdminPurgePersonView } from "./types/AdminPurgePersonView"; export { AdminPurgePost } from "./types/AdminPurgePost"; export { AdminPurgePostView } from "./types/AdminPurgePostView"; export { ApproveRegistrationApplication } from "./types/ApproveRegistrationApplication"; +export { AuthenticateWithOauth } from "./types/AuthenticateWithOauth"; export { BanFromCommunity } from "./types/BanFromCommunity"; export { BanFromCommunityResponse } from "./types/BanFromCommunityResponse"; export { BanPerson } from "./types/BanPerson"; @@ -42,7 +43,6 @@ export { CommentSortType } from "./types/CommentSortType"; export { CommentView } from "./types/CommentView"; export { Community } from "./types/Community"; export { CommunityAggregates } from "./types/CommunityAggregates"; -export { CommunityBlockView } from "./types/CommunityBlockView"; export { CommunityFollowerView } from "./types/CommunityFollowerView"; export { CommunityId } from "./types/CommunityId"; export { CommunityModeratorView } from "./types/CommunityModeratorView"; @@ -54,6 +54,7 @@ export { CreateCommentLike } from "./types/CreateCommentLike"; export { CreateCommentReport } from "./types/CreateCommentReport"; export { CreateCommunity } from "./types/CreateCommunity"; export { CreateCustomEmoji } from "./types/CreateCustomEmoji"; +export { CreateOAuthProvider } from "./types/CreateOAuthProvider"; export { CreatePost } from "./types/CreatePost"; export { CreatePostLike } from "./types/CreatePostLike"; export { CreatePostReport } from "./types/CreatePostReport"; @@ -69,12 +70,14 @@ export { DeleteAccount } from "./types/DeleteAccount"; export { DeleteComment } from "./types/DeleteComment"; export { DeleteCommunity } from "./types/DeleteCommunity"; export { DeleteCustomEmoji } from "./types/DeleteCustomEmoji"; +export { DeleteOAuthProvider } from "./types/DeleteOAuthProvider"; export { DeletePost } from "./types/DeletePost"; export { DeletePrivateMessage } from "./types/DeletePrivateMessage"; export { DistinguishComment } from "./types/DistinguishComment"; export { EditComment } from "./types/EditComment"; export { EditCommunity } from "./types/EditCommunity"; export { EditCustomEmoji } from "./types/EditCustomEmoji"; +export { EditOAuthProvider } from "./types/EditOAuthProvider"; export { EditPost } from "./types/EditPost"; export { EditPrivateMessage } from "./types/EditPrivateMessage"; export { EditSite } from "./types/EditSite"; @@ -114,7 +117,6 @@ export { HideCommunity } from "./types/HideCommunity"; export { HidePost } from "./types/HidePost"; export { ImageDetails } from "./types/ImageDetails"; export { Instance } from "./types/Instance"; -export { InstanceBlockView } from "./types/InstanceBlockView"; export { InstanceId } from "./types/InstanceId"; export { InstanceWithFederationState } from "./types/InstanceWithFederationState"; export { Language } from "./types/Language"; @@ -127,6 +129,7 @@ export { ListCommentReports } from "./types/ListCommentReports"; export { ListCommentReportsResponse } from "./types/ListCommentReportsResponse"; export { ListCommunities } from "./types/ListCommunities"; export { ListCommunitiesResponse } from "./types/ListCommunitiesResponse"; +export { ListLoginsResponse } from "./types/ListLoginsResponse"; export { ListMedia } from "./types/ListMedia"; export { ListMediaResponse } from "./types/ListMediaResponse"; export { ListPostLikes } from "./types/ListPostLikes"; @@ -181,13 +184,17 @@ export { ModTransferCommunityView } from "./types/ModTransferCommunityView"; export { ModlogActionType } from "./types/ModlogActionType"; export { ModlogListParams } from "./types/ModlogListParams"; export { MyUserInfo } from "./types/MyUserInfo"; +export { OAuthAccount } from "./types/OAuthAccount"; +export { OAuthProvider } from "./types/OAuthProvider"; +export { OAuthProviderId } from "./types/OAuthProviderId"; +export { OAuthProviderInsertForm } from "./types/OAuthProviderInsertForm"; +export { OAuthProviderUpdateForm } from "./types/OAuthProviderUpdateForm"; export { OpenGraphData } from "./types/OpenGraphData"; export { PaginationCursor } from "./types/PaginationCursor"; export { PasswordChangeAfterReset } from "./types/PasswordChangeAfterReset"; export { PasswordReset } from "./types/PasswordReset"; export { Person } from "./types/Person"; export { PersonAggregates } from "./types/PersonAggregates"; -export { PersonBlockView } from "./types/PersonBlockView"; export { PersonId } from "./types/PersonId"; export { PersonMention } from "./types/PersonMention"; export { PersonMentionId } from "./types/PersonMentionId"; @@ -214,6 +221,7 @@ export { PrivateMessageReportView } from "./types/PrivateMessageReportView"; export { PrivateMessageResponse } from "./types/PrivateMessageResponse"; export { PrivateMessageView } from "./types/PrivateMessageView"; export { PrivateMessagesResponse } from "./types/PrivateMessagesResponse"; +export { PublicOAuthProvider } from "./types/PublicOAuthProvider"; export { PurgeComment } from "./types/PurgeComment"; export { PurgeCommunity } from "./types/PurgeCommunity"; export { PurgePerson } from "./types/PurgePerson"; diff --git a/src/types/AuthenticateWithOauth.ts b/src/types/AuthenticateWithOauth.ts new file mode 100644 index 0000000..157a5ce --- /dev/null +++ b/src/types/AuthenticateWithOauth.ts @@ -0,0 +1,10 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface AuthenticateWithOauth { + code: string; + oauth_provider_id: string; + redirect_uri: string; + show_nsfw?: boolean; + username?: string; + answer?: string; +} diff --git a/src/types/CommunityBlockView.ts b/src/types/CommunityBlockView.ts deleted file mode 100644 index ac51d13..0000000 --- a/src/types/CommunityBlockView.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Community } from "./Community"; -import type { Person } from "./Person"; - -export interface CommunityBlockView { - person: Person; - community: Community; -} diff --git a/src/types/CreateOAuthProvider.ts b/src/types/CreateOAuthProvider.ts new file mode 100644 index 0000000..5ad31d3 --- /dev/null +++ b/src/types/CreateOAuthProvider.ts @@ -0,0 +1,16 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface CreateOAuthProvider { + display_name: string; + issuer: string; + authorization_endpoint: string; + token_endpoint: string; + userinfo_endpoint: string; + id_claim: string; + client_id: string; + client_secret: string; + scopes: string; + auto_verify_email: boolean; + account_linking_enabled: boolean; + enabled: boolean; +} diff --git a/src/types/CreateSite.ts b/src/types/CreateSite.ts index 3cb7431..7be2e77 100644 --- a/src/types/CreateSite.ts +++ b/src/types/CreateSite.ts @@ -46,6 +46,7 @@ export interface CreateSite { blocked_instances?: Array; taglines?: Array; registration_mode?: RegistrationMode; + oauth_registration?: boolean; content_warning?: string; default_post_listing_mode?: PostListingMode; } diff --git a/src/types/DeleteOAuthProvider.ts b/src/types/DeleteOAuthProvider.ts new file mode 100644 index 0000000..c7c5675 --- /dev/null +++ b/src/types/DeleteOAuthProvider.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { OAuthProviderId } from "./OAuthProviderId"; + +export interface DeleteOAuthProvider { + id: OAuthProviderId; +} diff --git a/src/types/EditOAuthProvider.ts b/src/types/EditOAuthProvider.ts new file mode 100644 index 0000000..c90c2fc --- /dev/null +++ b/src/types/EditOAuthProvider.ts @@ -0,0 +1,16 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { OAuthProviderId } from "./OAuthProviderId"; + +export interface EditOAuthProvider { + id: OAuthProviderId; + display_name: string | null; + authorization_endpoint: string | null; + token_endpoint: string | null; + userinfo_endpoint: string | null; + id_claim: string | null; + client_secret: string | null; + scopes: string | null; + auto_verify_email: boolean | null; + account_linking_enabled: boolean | null; + enabled: boolean | null; +} diff --git a/src/types/EditSite.ts b/src/types/EditSite.ts index ef98f5e..f515221 100644 --- a/src/types/EditSite.ts +++ b/src/types/EditSite.ts @@ -47,6 +47,7 @@ export interface EditSite { blocked_urls?: Array; taglines?: Array; registration_mode?: RegistrationMode; + oauth_registration?: boolean; reports_email_admins?: boolean; content_warning?: string; default_post_listing_mode?: PostListingMode; diff --git a/src/types/GetSiteResponse.ts b/src/types/GetSiteResponse.ts index 0419901..8408b9f 100644 --- a/src/types/GetSiteResponse.ts +++ b/src/types/GetSiteResponse.ts @@ -4,7 +4,9 @@ import type { Language } from "./Language"; import type { LanguageId } from "./LanguageId"; import type { LocalSiteUrlBlocklist } from "./LocalSiteUrlBlocklist"; import type { MyUserInfo } from "./MyUserInfo"; +import type { OAuthProvider } from "./OAuthProvider"; import type { PersonView } from "./PersonView"; +import type { PublicOAuthProvider } from "./PublicOAuthProvider"; import type { SiteView } from "./SiteView"; import type { Tagline } from "./Tagline"; @@ -17,5 +19,7 @@ export interface GetSiteResponse { discussion_languages: Array; taglines: Array; custom_emojis: Array; + oauth_providers?: Array; + admin_oauth_providers?: Array; blocked_urls: Array; } diff --git a/src/types/InstanceBlockView.ts b/src/types/InstanceBlockView.ts deleted file mode 100644 index 38087ca..0000000 --- a/src/types/InstanceBlockView.ts +++ /dev/null @@ -1,10 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Instance } from "./Instance"; -import type { Person } from "./Person"; -import type { Site } from "./Site"; - -export interface InstanceBlockView { - person: Person; - instance: Instance; - site?: Site; -} diff --git a/src/types/LemmyErrorType.ts b/src/types/LemmyErrorType.ts index 9ae0e71..d892595 100644 --- a/src/types/LemmyErrorType.ts +++ b/src/types/LemmyErrorType.ts @@ -46,6 +46,7 @@ export type LemmyErrorType = | { error: "couldnt_find_comment_reply" } | { error: "couldnt_find_private_message" } | { error: "couldnt_find_activity" } + | { error: "couldnt_find_oauth_provider" } | { error: "person_is_blocked" } | { error: "community_is_blocked" } | { error: "instance_is_blocked" } @@ -73,7 +74,9 @@ export type LemmyErrorType = | { error: "invalid_default_post_listing_type" } | { error: "registration_closed" } | { error: "registration_application_answer_required" } + | { error: "registration_username_required" } | { error: "email_already_exists" } + | { error: "username_already_exists" } | { error: "federation_forbidden_by_strict_allow_list" } | { error: "person_is_banned_from_community" } | { error: "object_is_not_public" } @@ -166,5 +169,11 @@ export type LemmyErrorType = | { error: "cant_block_local_instance" } | { error: "url_without_domain" } | { error: "inbox_timeout" } + | { error: "oauth_authorization_invalid" } + | { error: "oauth_login_failed" } + | { error: "oauth_registration_closed" } + | { error: "couldnt_delete_oauth_provider" } | { error: "unknown"; message: string } + | { error: "cant_delete_site" } + | { error: "url_length_overflow" } | { error: "cant_delete_site" }; diff --git a/src/types/ListLoginsResponse.ts b/src/types/ListLoginsResponse.ts new file mode 100644 index 0000000..4a4c705 --- /dev/null +++ b/src/types/ListLoginsResponse.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { LoginToken } from "./LoginToken"; + +export interface ListLoginsResponse { + logins: Array; +} diff --git a/src/types/LocalSite.ts b/src/types/LocalSite.ts index 0d2e24b..8d18f67 100644 --- a/src/types/LocalSite.ts +++ b/src/types/LocalSite.ts @@ -11,7 +11,6 @@ export interface LocalSite { site_id: SiteId; site_setup: boolean; enable_downvotes: boolean; - enable_nsfw: boolean; community_creation_admin_only: boolean; require_email_verification: boolean; application_question?: string; @@ -33,4 +32,5 @@ export interface LocalSite { federation_signed_fetch: boolean; default_post_listing_mode: PostListingMode; default_sort_type: SortType; + oauth_registration: boolean; } diff --git a/src/types/LocalUser.ts b/src/types/LocalUser.ts index 86cd81a..3057f43 100644 --- a/src/types/LocalUser.ts +++ b/src/types/LocalUser.ts @@ -16,7 +16,6 @@ export interface LocalUser { interface_language: string; show_avatars: boolean; send_notifications_to_email: boolean; - show_scores: boolean; show_bot_accounts: boolean; show_read_posts: boolean; email_verified: boolean; diff --git a/src/types/LocalUserVoteDisplayMode.ts b/src/types/LocalUserVoteDisplayMode.ts index 141c02a..ae93552 100644 --- a/src/types/LocalUserVoteDisplayMode.ts +++ b/src/types/LocalUserVoteDisplayMode.ts @@ -1,8 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { LocalUserId } from "./LocalUserId"; export interface LocalUserVoteDisplayMode { - local_user_id: LocalUserId; score: boolean; upvotes: boolean; downvotes: boolean; diff --git a/src/types/MyUserInfo.ts b/src/types/MyUserInfo.ts index ddde119..70ec784 100644 --- a/src/types/MyUserInfo.ts +++ b/src/types/MyUserInfo.ts @@ -1,18 +1,18 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { CommunityBlockView } from "./CommunityBlockView"; +import type { Community } from "./Community"; import type { CommunityFollowerView } from "./CommunityFollowerView"; import type { CommunityModeratorView } from "./CommunityModeratorView"; -import type { InstanceBlockView } from "./InstanceBlockView"; +import type { Instance } from "./Instance"; import type { LanguageId } from "./LanguageId"; import type { LocalUserView } from "./LocalUserView"; -import type { PersonBlockView } from "./PersonBlockView"; +import type { Person } from "./Person"; export interface MyUserInfo { local_user_view: LocalUserView; follows: Array; moderates: Array; - community_blocks: Array; - instance_blocks: Array; - person_blocks: Array; + community_blocks: Array; + instance_blocks: Array; + person_blocks: Array; discussion_languages: Array; } diff --git a/src/types/OAuthAccount.ts b/src/types/OAuthAccount.ts new file mode 100644 index 0000000..7d0c418 --- /dev/null +++ b/src/types/OAuthAccount.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { LocalUserId } from "./LocalUserId"; +import type { OAuthProviderId } from "./OAuthProviderId"; + +export interface OAuthAccount { + local_user_id: LocalUserId; + oauth_provider_id: OAuthProviderId; + oauth_user_id: string; + published: string; + updated?: string; +} diff --git a/src/types/OAuthProvider.ts b/src/types/OAuthProvider.ts new file mode 100644 index 0000000..ffcfa03 --- /dev/null +++ b/src/types/OAuthProvider.ts @@ -0,0 +1,19 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { OAuthProviderId } from "./OAuthProviderId"; + +export interface OAuthProvider { + id: OAuthProviderId; + display_name: string; + issuer: string; + authorization_endpoint: string; + token_endpoint: string; + userinfo_endpoint: string; + id_claim: string; + client_id: string; + scopes: string; + auto_verify_email: boolean; + account_linking_enabled: boolean; + enabled: boolean; + published: string; + updated?: string; +} diff --git a/src/types/OAuthProviderId.ts b/src/types/OAuthProviderId.ts new file mode 100644 index 0000000..a688d40 --- /dev/null +++ b/src/types/OAuthProviderId.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type OAuthProviderId = number; diff --git a/src/types/OAuthProviderInsertForm.ts b/src/types/OAuthProviderInsertForm.ts new file mode 100644 index 0000000..0a8d182 --- /dev/null +++ b/src/types/OAuthProviderInsertForm.ts @@ -0,0 +1,16 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface OAuthProviderInsertForm { + display_name: string; + issuer: string; + authorization_endpoint: string; + token_endpoint: string; + userinfo_endpoint: string; + id_claim: string; + client_id: string; + client_secret: string; + scopes: string; + auto_verify_email: boolean; + account_linking_enabled: boolean; + enabled: boolean; +} diff --git a/src/types/OAuthProviderUpdateForm.ts b/src/types/OAuthProviderUpdateForm.ts new file mode 100644 index 0000000..c25f8d3 --- /dev/null +++ b/src/types/OAuthProviderUpdateForm.ts @@ -0,0 +1,15 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface OAuthProviderUpdateForm { + display_name: string | null; + authorization_endpoint: string; + token_endpoint: string; + userinfo_endpoint: string; + id_claim: string | null; + client_secret: string | null; + scopes: string | null; + auto_verify_email: boolean | null; + account_linking_enabled: boolean | null; + enabled: boolean | null; + updated: string | null | null; +} diff --git a/src/types/PersonBlockView.ts b/src/types/PersonBlockView.ts deleted file mode 100644 index 28a6764..0000000 --- a/src/types/PersonBlockView.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Person } from "./Person"; - -export interface PersonBlockView { - person: Person; - target: Person; -} diff --git a/src/types/PublicOAuthProvider.ts b/src/types/PublicOAuthProvider.ts new file mode 100644 index 0000000..9d5d0a0 --- /dev/null +++ b/src/types/PublicOAuthProvider.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { OAuthProvider } from "./OAuthProvider"; + +export type PublicOAuthProvider = OAuthProvider; diff --git a/src/types/Search.ts b/src/types/Search.ts index da9817e..6973e82 100644 --- a/src/types/Search.ts +++ b/src/types/Search.ts @@ -15,4 +15,5 @@ export interface Search { listing_type?: ListingType; page?: number; limit?: number; + post_title_only?: boolean; }