-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
159 lines (135 loc) · 3.67 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// import { SuperAgentRequest } from 'superagent';
export namespace discourseApi {
declare function discourse(
config: discourseApi.DiscourseApiConfiguration,
): discourseApi.DiscourseApi;
export type discourse = typeof discourse & discourseApi.UtilsEnums;
export type SuperAgentRequest = SuperAgentRequest;
export interface DiscourseApi {
tagGroups: TagGroups;
categories: Categories;
groups: Groups;
topics: Topics;
posts: Posts;
enums: Enums;
utils: Utils;
}
export interface UtilsEnums {
enums: Enums;
utils: Utils;
}
export interface DiscourseApiShuttle {
authGet: (url: String) => (params?: Params) => Promise<Object>;
authPost: (url: String) => (body?: Params) => Promise<Object>;
authPut: (url: String) => (body?: Params) => Promise<Object>;
authDelete: (url: String) => (params?: Params) => Promise<Object>;
}
export interface DiscourseApiConfiguration {
api_key: string;
api_username?: string;
api_url: string;
}
export interface Params {
[key: string]: string | number;
asPropOf?: string;
}
export interface Req extends Request {
toJSON(): { method: string; url: string; data: any; headers: Headers };
}
export interface Category {
[key: string]: any;
id: number;
}
export interface Topic {
[key: string]: any;
id: number;
slug: string;
post_stream: Post[];
}
export interface Group {
[key: string]: any;
id: number;
}
export interface Post {
[key: string]: any;
id: number;
}
export interface TagGroup {
[key: string]: any;
id: number;
}
export interface Categories {
getAll(): Promise<Category[]>;
get(id: number): Promise<Category>;
create(c: Category): Promise<Category>;
update(cat: Category): Promise<Category>;
getAboutTopic(cat: Category): Promise<Topic>;
permissionsMatch(seed: Category, existing: Category): boolean;
stripPermissions(cat: Category): Category;
}
export interface Groups {
get(params: Params): Promise<Group>;
create(g: Group): Promise<Group>;
update(g: Group): Promise<Group>;
}
export interface Posts {
get(id: number): Promise<Post>;
update(p: Post): Promise<Post>;
}
export interface TagGroups {
getAll(): Promise<TagGroup[]>;
update(tg: TagGroup): Promise<TagGroup>;
create(tg: TagGroup): Promise<TagGroup>;
differ(seed: TagGroup, existing: TagGroup): boolean;
}
export interface Tags {
getAll(): Promise<Tag[]>;
}
export interface Topics {
get(id: number): Promise<Topic>;
update(t: Topic): Promise<Topic>;
getPostId(t: Topic): number;
invite(id: number, { user: ?string, groupNames: ?string[], email: ?string, customMessage: ?string }): Promise<Topic>;
}
export interface Visibility {
nobody: 0;
onlyAdmins: 1;
modsAndAdmins: 2;
membersModsAndAdmins: 3;
everyone: 99;
}
export interface Trust {
new: 0;
basic: 1;
member: 2;
regular: 3;
leader: 4;
}
export interface Permission {
create_reply_see: 1;
reply_see: 2;
see: 3;
}
export interface Notification {
muted: 0;
regular: 1;
tracking: 2;
watching: 3;
watching_first_post: 4;
}
export interface Enums {
visibility: Visibility;
trust: Trust;
permission: Permission;
notification: Notification;
}
export interface Utils {
paramsAsPropsOf: (params: Params) => (asPropsOf: string) => Params;
mapObjKeys: (mapKey: (key: string, value: any) => string) => (obj: any) => any;
flattenObj: (obj: any) => any;
splitProps: (
predicate: (v: any, k: string | number) => boolean,
obj: any,
) => { left: any; right: any };
}
}