-
Notifications
You must be signed in to change notification settings - Fork 14
/
akismet-api.d.ts
74 lines (61 loc) · 1.92 KB
/
akismet-api.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
declare module "akismet-api" {
// Main Akismet Client Class
export class AkismetClient {
constructor(options: AkismetClientOptions);
verifyKey(
callback?: (err: Error, isValid: boolean) => void
): Promise<boolean>;
checkSpam(
comment: Comment,
callback?: (err: Error, isSpam: boolean) => void
): Promise<boolean>;
submitSpam(
comment: Comment,
callback?: (err: Error) => void
): Promise<void>;
submitHam(
comment: Comment,
callback?: (err: Error) => void
): Promise<void>;
}
// Legacy props
export type Client = AkismetClient;
export type client = (options: AkismetClientOptions) => AkismetClient;
// Types
interface AkismetClientOptions {
blog: string;
key: string;
host?: string;
protocol?: string;
version?: string;
userAgent?: string;
blog_lang?: string;
lang?: string; // Alias for prev prop
blog_charset?: string;
charset?: string; // Alias for prev prop
}
// Require only one of these two types
type Comment = (CommentWithIP) | (CommentWithUserIP);
// BaseComment with either `ip` or `user_up`
type CommentWithIP = { ip: string; } & BaseComment;
type CommentWithUserIP = { user_ip: string; } & BaseComment;
// BaseComment is composed of Allowed Keys, all optional
type BaseComment =
Partial<Record<CommentKeys, string>>
& Partial<Record<TestKeys, boolean | string>>;
// Allowed Keys
type TestKeys = 'is_test' | 'isTest';
type CommentKeys = 'user_ip' | 'ip'
| 'user_agent' | 'useragent'
| 'referrer' | 'referer'
| 'comment_author' | 'name'
| 'comment_author_email' | 'email'
| 'comment_content' | 'content'
| 'comment_type' | 'type'
| 'comment_date_gmt' | 'date'
| 'permalink'
| 'comment_post_modified_gmt' | 'permalinkDate'
| 'comment_author_url' | 'url'
| 'user_role' | 'role'
| 'honeypot' | 'honeypot_field_name';
}