Skip to content

Commit e23c5dd

Browse files
committed
add new data type from doc to ts v2
1 parent 8073628 commit e23c5dd

File tree

5 files changed

+52
-7
lines changed

5 files changed

+52
-7
lines changed

src/resources/Posts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export interface IPosts {
1313
body: Object,
1414
id: number | null,
1515
}): Promise<PostsData>;
16-
like(params: { id: number | null }): Promise<string>;
17-
unlike(params: { id: number | null }): Promise<string>;
16+
like(params: { id: number | null }): Promise<PostsData>;
17+
unlike(params: { id: number | null }): Promise<PostsData>;
1818
flag(params: {
1919
id: number | null,
2020
post_action_type_id: number,

src/resources/Tags.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { buildQueryString } from '../utils';
22
import { DiscourseInterface } from '../index';
3+
import { TagsListData } from '../types/Tags';
34

45
interface TopicParams {
56
tag?: string;
@@ -9,8 +10,8 @@ interface TopicParams {
910
}
1011

1112
export interface ITags {
12-
getTopic(params: TopicParams): Promise<unknown>;
13-
getTopicsForCategory(params: TopicParams): Promise<unknown>;
13+
getTopic(params: TopicParams): Promise<TagsListData>;
14+
getTopicsForCategory(params: TopicParams): Promise<TagsListData>;
1415
}
1516
export default function Tags(discourse: DiscourseInterface) {
1617
this.getTopic = async ({ tag, ...inputs }: { tag?: string } = {}) => {

src/resources/Topics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { buildQueryString } from '../utils';
22
import { DiscourseInterface } from '../index';
3-
import { GetTopicData, GetTopicsData } from '../types/Topics';
3+
import { GetTopicData, GetTopicsData, TopicByUserName } from '../types/Topics';
44
import { PostsData } from '../types/Posts';
55

66
interface TopicParams {
@@ -15,7 +15,7 @@ export interface ITopics {
1515
getTopic(params: TopicParams): Promise<GetTopicsData>;
1616
getTopicPosts(params: TopicParams): Promise<GetTopicData>;
1717
deleteTopic(params: TopicParams): Promise<string>;
18-
getTopicsByUsername(params: TopicParams): Promise<unknown>;
18+
getTopicsByUsername(params: TopicParams): Promise<TopicByUserName>;
1919
createTopic(params: TopicParams): Promise<PostsData>;
2020
}
2121

src/types/Tags.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
export interface TagsGroupData {
2+
tag_groups: [
3+
{
4+
id: number,
5+
name: string,
6+
tag_names: string[],
7+
parent_tag_name: string,
8+
one_per_topic: boolean,
9+
},
10+
];
11+
}
12+
13+
export interface TagsListData {
14+
topic_list: {
15+
can_create_topic: boolean,
16+
draft: null,
17+
draft_key: string,
18+
draft_sequence: number,
19+
per_page: number,
20+
tags: TagData[],
21+
topics: [],
22+
};
23+
}
24+
25+
export interface TagData {
26+
id: number;
27+
name: string;
28+
topic_count: number;
29+
staff: boolean;
30+
}

src/types/Topics.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { PostsData } from './Posts';
2+
import { DiscourseUser } from './Users';
23

34
// ToDo clean up
45

@@ -294,7 +295,7 @@ export type DiscourseTopicSummaryType = {
294295
user_id: number,
295296
primary_group_id: {},
296297
}>,
297-
participants: Array<{
298+
participants?: Array<{
298299
extras: string,
299300
description: string,
300301
user_id: number,
@@ -311,3 +312,16 @@ export type DiscourseTopicList = {
311312
more_topics_url: string, // If more than 1 page
312313
topics: Array<DiscourseTopicSummaryType>,
313314
};
315+
316+
export type TopicByUserName = {
317+
users: DiscourseUser[],
318+
primary_groups: [],
319+
topic_list: {
320+
can_create_topic: true,
321+
draft: null,
322+
draft_key: 'new_topic',
323+
draft_sequence: 1,
324+
per_page: 30,
325+
topics: DiscourseTopicSummaryType[],
326+
},
327+
};

0 commit comments

Comments
 (0)