From a8f4298f06148bd286d69402b2845d0df140afd0 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 15 May 2022 15:26:40 -0400 Subject: [PATCH 1/2] Use enum types in API. Fixes #51 --- src/interfaces/api/comment.ts | 11 +++-------- src/interfaces/api/community.ts | 12 +++--------- src/interfaces/api/person.ts | 13 ++++--------- src/interfaces/api/post.ts | 14 +++----------- src/interfaces/api/site.ts | 17 ++++------------- 5 files changed, 17 insertions(+), 50 deletions(-) diff --git a/src/interfaces/api/comment.ts b/src/interfaces/api/comment.ts index 11f63f9..3ad4d0a 100644 --- a/src/interfaces/api/comment.ts +++ b/src/interfaces/api/comment.ts @@ -1,3 +1,4 @@ +import { ListingType, SortType } from "../others"; import { CommentReportView, CommentView } from "../views"; export interface CreateComment { @@ -77,14 +78,8 @@ export interface CreateCommentLike { * To get posts for a federated community by name, use `name@instance.tld` . */ export interface GetComments { - /** - * The [[ListingType]]. - */ - type_?: string; - /** - * The [[SortType]]. - */ - sort?: string; + type_?: ListingType; + sort?: SortType; page?: number; limit?: number; community_id?: number; diff --git a/src/interfaces/api/community.ts b/src/interfaces/api/community.ts index ddb97e3..a9c0ff3 100644 --- a/src/interfaces/api/community.ts +++ b/src/interfaces/api/community.ts @@ -1,3 +1,4 @@ +import { ListingType, SortType } from "../others"; import { Site } from "../source"; import { CommunityModeratorView, @@ -39,15 +40,8 @@ export interface CommunityResponse { } export interface ListCommunities { - /** - * The [[ListingType]]. - */ - type_?: string; - - /** - * The [[SortType]]. - */ - sort?: string; + type_?: ListingType; + sort?: SortType; page?: number; limit?: number; auth?: string; diff --git a/src/interfaces/api/person.ts b/src/interfaces/api/person.ts index 8272552..ffc4e55 100644 --- a/src/interfaces/api/person.ts +++ b/src/interfaces/api/person.ts @@ -1,3 +1,4 @@ +import { SortType } from "../others"; import { CommentView, CommunityModeratorView, @@ -127,7 +128,7 @@ export interface GetPersonDetails { * To get details for a federated user, use `person@instance.tld`. */ username?: string; - sort?: string; + sort?: SortType; page?: number; limit?: number; community_id?: number; @@ -186,10 +187,7 @@ export interface BanPersonResponse { } export interface GetReplies { - /** - * The [[SortType]]. - */ - sort?: string; + sort?: SortType; page?: number; limit?: number; unread_only?: boolean; @@ -197,10 +195,7 @@ export interface GetReplies { } export interface GetPersonMentions { - /** - * The [[SortType]]. - */ - sort?: string; + sort?: SortType; page?: number; limit?: number; unread_only?: boolean; diff --git a/src/interfaces/api/post.ts b/src/interfaces/api/post.ts index 651bed4..2012dd1 100644 --- a/src/interfaces/api/post.ts +++ b/src/interfaces/api/post.ts @@ -1,4 +1,4 @@ -import { SiteMetadata } from ".."; +import { ListingType, SiteMetadata, SortType } from "../others"; import { CommentView, CommunityModeratorView, @@ -35,16 +35,8 @@ export interface GetPostResponse { } export interface GetPosts { - /** - * The [[ListingType]]. - * - * Post listing types are `All, Subscribed, Community` - */ - type_?: string; - /** - * The [[SortType]]. - */ - sort?: string; + type_?: ListingType; + sort?: SortType; page?: number; limit?: number; community_id?: number; diff --git a/src/interfaces/api/site.ts b/src/interfaces/api/site.ts index c28084b..82688ab 100644 --- a/src/interfaces/api/site.ts +++ b/src/interfaces/api/site.ts @@ -1,3 +1,4 @@ +import { ListingType, SearchType, SortType } from "../others"; import { CommentView, CommunityBlockView, @@ -30,22 +31,12 @@ export interface Search { * The search query string. */ q: string; - - /** - * The [[SearchType]]. - */ - type_?: string; + type_?: SearchType; community_id?: number; community_name?: string; creator_id?: number; - /** - * The [[SortType]]. - */ - sort?: string; - /** - * The [[ListingType]]. - */ - listing_type?: string; + sort?: SortType; + listing_type?: ListingType; page?: number; limit?: number; auth?: string; From 0a61424ca97328d4dff095b7bae81eeb72d0201d Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 15 May 2022 15:26:59 -0400 Subject: [PATCH 2/2] v0.17.0-rc.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 153bbdc..dc5f9c1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lemmy-js-client", "description": "A javascript / typescript client for Lemmy", - "version": "0.16.4-rc.2", + "version": "0.17.0-rc.9", "author": "Dessalines ", "license": "AGPL-3.0", "main": "./dist/index.js",