diff --git a/copy_generated_types_from_lemmy.sh b/copy_generated_types_from_lemmy.sh index a8955284..5b045584 100755 --- a/copy_generated_types_from_lemmy.sh +++ b/copy_generated_types_from_lemmy.sh @@ -35,5 +35,5 @@ find src/types -type f -name '*.ts' -exec sed -i 's/bigint/number/g' {} + node putTypesInIndex.js -prettier -w src +pnpm prettier -w src diff --git a/src/http.ts b/src/http.ts index 06bb90cb..7c7c5764 100644 --- a/src/http.ts +++ b/src/http.ts @@ -21,6 +21,7 @@ import { CreateComment } from "./types/CreateComment"; import { CreateCommentLike } from "./types/CreateCommentLike"; import { CreateCommentReport } from "./types/CreateCommentReport"; import { CreateCommunity } from "./types/CreateCommunity"; +import { CreateCommunityTag } from "./types/CreateCommunityTag"; import { CreateCustomEmoji } from "./types/CreateCustomEmoji"; import { CreateOAuthProvider } from "./types/CreateOAuthProvider"; import { CreatePost } from "./types/CreatePost"; @@ -33,6 +34,7 @@ import { CustomEmojiResponse } from "./types/CustomEmojiResponse"; import { DeleteAccount } from "./types/DeleteAccount"; import { DeleteComment } from "./types/DeleteComment"; import { DeleteCommunity } from "./types/DeleteCommunity"; +import { DeleteCommunityTag } from "./types/DeleteCommunityTag"; import { DeleteCustomEmoji } from "./types/DeleteCustomEmoji"; import { DeleteOAuthProvider } from "./types/DeleteOAuthProvider"; import { DeletePost } from "./types/DeletePost"; @@ -72,6 +74,8 @@ import { GetUnreadCountResponse } from "./types/GetUnreadCountResponse"; import { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse"; import { ListCommunities } from "./types/ListCommunities"; import { ListCommunitiesResponse } from "./types/ListCommunitiesResponse"; +import { ListCommunityTags } from "./types/ListCommunityTags"; +import { ListCommunityTagsResponse } from "./types/ListCommunityTagsResponse"; import { ListRegistrationApplications } from "./types/ListRegistrationApplications"; import { ListRegistrationApplicationsResponse } from "./types/ListRegistrationApplicationsResponse"; import { LockPost } from "./types/LockPost"; @@ -107,6 +111,8 @@ import { Search } from "./types/Search"; import { SearchResponse } from "./types/SearchResponse"; import { SiteResponse } from "./types/SiteResponse"; import { TransferCommunity } from "./types/TransferCommunity"; +import { UpdateCommunityTag } from "./types/UpdateCommunityTag"; +import { UpdatePostTags } from "./types/UpdatePostTags"; import { VerifyEmail } from "./types/VerifyEmail"; import { DeleteImageParamsI, @@ -199,6 +205,7 @@ import { Security, Tags, } from "tsoa"; +import { CommunityTagResponse } from "./types/CommunityTagResponse"; enum HttpType { Get = "GET", @@ -2068,6 +2075,97 @@ export class LemmyHttp extends Controller { ); } + /** + * @summary Create a community tag. + */ + @Security("bearerAuth") + @Post("/community/post_tag") + @Tags("Community") + createCommunityTag( + @Body() form: CreateCommunityTag, + @Inject() options?: RequestOptions, + ) { + return this.#wrapper( + HttpType.Post, + "/community/post_tag", + form, + options, + ); + } + + /** + * @summary Update a community tag. + */ + @Security("bearerAuth") + @Put("/community/post_tag") + @Tags("Community") + updateCommunityTag( + @Body() form: UpdateCommunityTag, + @Inject() options?: RequestOptions, + ) { + return this.#wrapper( + HttpType.Put, + "/community/post_tag", + form, + options, + ); + } + + /** + * @summary List community tags. + */ + @Security("bearerAuth") + @Security({}) + @Get("/community/post_tag/list") + @Tags("Community") + listCommunityTags( + @Queries() form: ListCommunityTags, + @Inject() options?: RequestOptions, + ) { + return this.#wrapper( + HttpType.Get, + "/community/post_tag/list", + form, + options, + ); + } + + /** + * @summary Delete a community tag. + */ + @Security("bearerAuth") + @Post("/community/post_tag") + @Tags("Community") + deleteCommunityTag( + @Body() form: DeleteCommunityTag, + @Inject() options?: RequestOptions, + ) { + return this.#wrapper( + HttpType.Delete, + "/community/post_tag", + form, + options, + ); + } + + /** + * @summary Update post tags. + */ + @Security("bearerAuth") + @Put("/post/tags") + @Tags("Post") + updatePostTags( + @Body() form: UpdatePostTags, + @Inject() options?: RequestOptions, + ) { + return this.#wrapper( + HttpType.Put, + "/post/tags", + form, + options, + ); + } + /** * @summary Create a new oauth provider method */ diff --git a/src/index.ts b/src/index.ts index e6f5c5b2..01baf29e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -64,12 +64,14 @@ export { CommunityReportId } from "./types/CommunityReportId"; export { CommunityReportView } from "./types/CommunityReportView"; export { CommunityResponse } from "./types/CommunityResponse"; export { CommunitySortType } from "./types/CommunitySortType"; +export { CommunityTagResponse } from "./types/CommunityTagResponse"; export { CommunityView } from "./types/CommunityView"; export { CommunityVisibility } from "./types/CommunityVisibility"; export { CreateComment } from "./types/CreateComment"; export { CreateCommentLike } from "./types/CreateCommentLike"; export { CreateCommentReport } from "./types/CreateCommentReport"; export { CreateCommunity } from "./types/CreateCommunity"; +export { CreateCommunityTag } from "./types/CreateCommunityTag"; export { CreateCustomEmoji } from "./types/CreateCustomEmoji"; export { CreateOAuthProvider } from "./types/CreateOAuthProvider"; export { CreatePost } from "./types/CreatePost"; @@ -88,6 +90,7 @@ export { DbUrl } from "./types/DbUrl"; export { DeleteAccount } from "./types/DeleteAccount"; export { DeleteComment } from "./types/DeleteComment"; export { DeleteCommunity } from "./types/DeleteCommunity"; +export { DeleteCommunityTag } from "./types/DeleteCommunityTag"; export { DeleteCustomEmoji } from "./types/DeleteCustomEmoji"; export { DeleteImageParams } from "./types/DeleteImageParams"; export { DeleteOAuthProvider } from "./types/DeleteOAuthProvider"; @@ -157,6 +160,8 @@ export { ListCommunities } from "./types/ListCommunities"; export { ListCommunitiesResponse } from "./types/ListCommunitiesResponse"; export { ListCommunityPendingFollows } from "./types/ListCommunityPendingFollows"; export { ListCommunityPendingFollowsResponse } from "./types/ListCommunityPendingFollowsResponse"; +export { ListCommunityTags } from "./types/ListCommunityTags"; +export { ListCommunityTagsResponse } from "./types/ListCommunityTagsResponse"; export { ListCustomEmojis } from "./types/ListCustomEmojis"; export { ListCustomEmojisResponse } from "./types/ListCustomEmojisResponse"; export { ListInbox } from "./types/ListInbox"; @@ -323,6 +328,8 @@ export { Tagline } from "./types/Tagline"; export { TaglineId } from "./types/TaglineId"; export { TaglineResponse } from "./types/TaglineResponse"; export { TransferCommunity } from "./types/TransferCommunity"; +export { UpdateCommunityTag } from "./types/UpdateCommunityTag"; +export { UpdatePostTags } from "./types/UpdatePostTags"; export { UpdateTagline } from "./types/UpdateTagline"; export { UpdateTotp } from "./types/UpdateTotp"; export { UpdateTotpResponse } from "./types/UpdateTotpResponse"; diff --git a/src/types/CommunityTagResponse.ts b/src/types/CommunityTagResponse.ts new file mode 100644 index 00000000..e6022019 --- /dev/null +++ b/src/types/CommunityTagResponse.ts @@ -0,0 +1,9 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CommunityId } from "./CommunityId"; +import type { TagId } from "./TagId"; + +export type CommunityTagResponse = { + id: TagId; + name: string; + community_id: CommunityId; +}; diff --git a/src/types/CreateCommunityTag.ts b/src/types/CreateCommunityTag.ts new file mode 100644 index 00000000..59f5932a --- /dev/null +++ b/src/types/CreateCommunityTag.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 { CommunityId } from "./CommunityId"; + +/** + * Create a tag for a community. + */ +export type CreateCommunityTag = { + community_id: CommunityId; + id_slug: string; + name: string; +}; diff --git a/src/types/DeleteCommunityTag.ts b/src/types/DeleteCommunityTag.ts new file mode 100644 index 00000000..9c0e505f --- /dev/null +++ b/src/types/DeleteCommunityTag.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { TagId } from "./TagId"; + +/** + * Delete a community tag. + */ +export type DeleteCommunityTag = { tag_id: TagId }; diff --git a/src/types/EditPost.ts b/src/types/EditPost.ts index a70e2b65..6b1f37d4 100644 --- a/src/types/EditPost.ts +++ b/src/types/EditPost.ts @@ -1,7 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { LanguageId } from "./LanguageId"; import type { PostId } from "./PostId"; -import type { TagId } from "./TagId"; /** * Edit a post. @@ -24,7 +23,6 @@ export type EditPost = { * Instead of fetching a thumbnail, use a custom one. */ custom_thumbnail?: string; - tags?: Array; /** * Time when this post should be scheduled. Null means publish immediately. */ diff --git a/src/types/ListCommunityTags.ts b/src/types/ListCommunityTags.ts new file mode 100644 index 00000000..bdf4f972 --- /dev/null +++ b/src/types/ListCommunityTags.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CommunityId } from "./CommunityId"; + +/** + * List tags for a community. + */ +export type ListCommunityTags = { community_id: CommunityId }; diff --git a/src/types/ListCommunityTagsResponse.ts b/src/types/ListCommunityTagsResponse.ts new file mode 100644 index 00000000..3b51b712 --- /dev/null +++ b/src/types/ListCommunityTagsResponse.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 { CommunityTagResponse } from "./CommunityTagResponse"; + +export type ListCommunityTagsResponse = { tags: Array }; diff --git a/src/types/PostTags.ts b/src/types/PostTags.ts index 4c88826f..58896467 100644 --- a/src/types/PostTags.ts +++ b/src/types/PostTags.ts @@ -4,4 +4,4 @@ import type { Tag } from "./Tag"; /** * we wrap this in a struct so we can implement FromSqlRow for it */ -export type PostTags = { tags: Array }; +export type PostTags = Array; diff --git a/src/types/UpdateCommunityTag.ts b/src/types/UpdateCommunityTag.ts new file mode 100644 index 00000000..efe88a69 --- /dev/null +++ b/src/types/UpdateCommunityTag.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { TagId } from "./TagId"; + +/** + * Update a community tag. + */ +export type UpdateCommunityTag = { tag_id: TagId; name: string }; diff --git a/src/types/UpdatePostTags.ts b/src/types/UpdatePostTags.ts new file mode 100644 index 00000000..51cf8b73 --- /dev/null +++ b/src/types/UpdatePostTags.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PostId } from "./PostId"; +import type { TagId } from "./TagId"; + +/** + * Update tags for a post. + */ +export type UpdatePostTags = { post_id: PostId; tags: Array }; diff --git a/tsconfig.json b/tsconfig.json index d9c7f76e..c1275523 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "noImplicitAny": true, "lib": ["es2017", "es7", "es6", "dom"], "outDir": "./dist", - "target": "ES2015", + "target": "ES2020", "experimentalDecorators": true, "strictNullChecks": true, "moduleResolution": "Node",