e621 1.0.9 → 2.0.0-dev.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/.node-version +1 -0
  2. package/README.md +116 -187
  3. package/build/package.json +14 -11
  4. package/build/src/index.d.ts +28 -295
  5. package/build/src/index.js +83 -442
  6. package/build/src/modules/Pools.d.ts +120 -0
  7. package/build/src/modules/Pools.js +247 -0
  8. package/build/src/modules/PostSets.d.ts +88 -0
  9. package/build/src/modules/PostSets.js +182 -0
  10. package/build/src/modules/Posts.d.ts +124 -0
  11. package/build/src/modules/Posts.js +323 -0
  12. package/build/src/modules/UserFeedback.d.ts +66 -0
  13. package/build/src/modules/UserFeedback.js +134 -0
  14. package/build/src/modules/Users.d.ts +110 -0
  15. package/build/src/modules/Users.js +248 -0
  16. package/build/src/modules/WikiPages.d.ts +99 -0
  17. package/build/src/modules/WikiPages.js +208 -0
  18. package/build/src/structures/AuthenticatedUser.d.ts +109 -0
  19. package/build/src/structures/AuthenticatedUser.js +128 -0
  20. package/build/src/structures/Pool.d.ts +85 -0
  21. package/build/src/structures/Pool.js +110 -0
  22. package/build/src/structures/PoolHistory.d.ts +42 -0
  23. package/build/src/structures/PoolHistory.js +53 -0
  24. package/build/src/structures/Post.d.ts +147 -0
  25. package/build/src/structures/Post.js +155 -0
  26. package/build/src/structures/PostHistory.d.ts +52 -0
  27. package/build/src/structures/PostHistory.js +93 -0
  28. package/build/src/structures/PostSet.d.ts +71 -0
  29. package/build/src/structures/PostSet.js +91 -0
  30. package/build/src/structures/User.d.ts +62 -0
  31. package/build/src/structures/User.js +80 -0
  32. package/build/src/structures/WikiPage.d.ts +16 -0
  33. package/build/src/structures/WikiPage.js +26 -0
  34. package/build/src/structures/WikiPageHistory.d.ts +37 -0
  35. package/build/src/structures/WikiPageHistory.js +49 -0
  36. package/build/src/types/index.d.ts +92 -0
  37. package/build/src/types/pools.d.ts +60 -0
  38. package/build/src/types/post_sets.d.ts +33 -0
  39. package/build/src/types/posts.d.ts +165 -0
  40. package/build/src/types/user_feedback.d.ts +27 -0
  41. package/build/src/types/users.d.ts +277 -0
  42. package/build/src/types/wiki_pages.d.ts +65 -0
  43. package/build/src/util/FormHelper.d.ts +9 -0
  44. package/build/src/util/FormHelper.js +15 -0
  45. package/build/src/util/MultipartData.d.ts +7 -0
  46. package/build/src/util/MultipartData.js +39 -0
  47. package/build/src/util/RequestHandler.d.ts +37 -0
  48. package/build/src/util/RequestHandler.js +311 -0
  49. package/package.json +14 -11
  50. package/LICENSE +0 -21
@@ -1,296 +1,29 @@
1
- export declare class APIError extends Error {
2
- code: number;
3
- errmessage: string;
4
- method: string;
5
- endpoint: string;
6
- constructor(code: number, message: string, method: string, endpoint: string);
1
+ import type { Options, InstanceOptions } from "./types";
2
+ import RequestHandler from "./util/RequestHandler";
3
+ import Posts from "./modules/Posts";
4
+ import UserFeedback from "./modules/UserFeedback";
5
+ import Users from "./modules/Users";
6
+ import PostSets from "./modules/PostSets";
7
+ import Pools from "./modules/Pools";
8
+ import AuthenticatedUser from "./structures/AuthenticatedUser";
9
+ import Pool from "./structures/Pool";
10
+ import PoolHistory from "./structures/PoolHistory";
11
+ import Post from "./structures/Post";
12
+ import PostSet from "./structures/PostSet";
13
+ import User from "./structures/User";
14
+ import WikiPages from "./modules/WikiPages";
15
+ export default class E621 {
16
+ request: RequestHandler;
17
+ postSets: PostSets;
18
+ pools: Pools;
19
+ posts: Posts;
20
+ userFeedback: UserFeedback;
21
+ users: Users;
22
+ wikiPages: WikiPages;
23
+ private readonly auth;
24
+ readonly options: InstanceOptions;
25
+ constructor(options?: Options);
7
26
  }
8
- export interface Post {
9
- id: number;
10
- created_at: string;
11
- updated_at: string;
12
- file: {
13
- width: number;
14
- height: number;
15
- ext: string;
16
- md5: string;
17
- url: string;
18
- };
19
- preview: {
20
- width: number;
21
- height: number;
22
- url: string;
23
- };
24
- sample: {
25
- has: boolean;
26
- height: number;
27
- width: number;
28
- url: string;
29
- alternates: Record<string, unknown>;
30
- };
31
- score: {
32
- up: number;
33
- down: number;
34
- total: number;
35
- };
36
- tags: Record<"general" | "species" | "character" | "copyright" | "artist" | "invalid" | "lore" | "meta", Array<string>>;
37
- locked_tags: Array<string>;
38
- change_seq: number;
39
- flags: Record<"pending" | "flagged" | "note_locked" | "status_locked" | "rating_locked" | "deleted", boolean>;
40
- rating: "s" | "q" | "e";
41
- fav_count: number;
42
- sources: Array<string>;
43
- pools: Array<number>;
44
- relationships: {
45
- parent_id: number | null;
46
- has_children: boolean;
47
- has_active_children: boolean;
48
- children: Array<number>;
49
- };
50
- approver_id: number | null;
51
- uploader_id: number | null;
52
- description: string;
53
- comment_count: number;
54
- is_favorited: boolean;
55
- has_notes: boolean;
56
- duration: number | null;
57
- }
58
- export interface NullableURLPost {
59
- id: number;
60
- created_at: string;
61
- updated_at: string;
62
- file: {
63
- width: number;
64
- height: number;
65
- ext: string;
66
- md5: string;
67
- url: string | null;
68
- };
69
- preview: {
70
- width: number;
71
- height: number;
72
- url: string | null;
73
- };
74
- sample: {
75
- has: boolean;
76
- height: number;
77
- width: number;
78
- url: string | null;
79
- alternates: Record<string, unknown>;
80
- };
81
- score: {
82
- up: number;
83
- down: number;
84
- total: number;
85
- };
86
- tags: Record<"general" | "species" | "character" | "copyright" | "artist" | "invalid" | "lore" | "meta", Array<string>>;
87
- locked_tags: Array<string>;
88
- change_seq: number;
89
- flags: Record<"pending" | "flagged" | "note_locked" | "status_locked" | "rating_locked" | "deleted", boolean>;
90
- rating: "s" | "q" | "e";
91
- fav_count: number;
92
- sources: Array<string>;
93
- pools: Array<number>;
94
- relationships: {
95
- parent_id: number | null;
96
- has_children: boolean;
97
- has_active_children: boolean;
98
- children: Array<number>;
99
- };
100
- approver_id: number | null;
101
- uploader_id: number | null;
102
- description: string;
103
- comment_count: number;
104
- is_favorited: boolean;
105
- has_notes: boolean;
106
- duration: number | null;
107
- }
108
- export interface UploadLimit {
109
- id: number;
110
- created_at: number;
111
- name: string;
112
- level: number;
113
- base_upload_limit: number;
114
- post_upload_count: number;
115
- post_update_count: number;
116
- note_update_count: number;
117
- is_banned: boolean;
118
- can_approve_posts: boolean;
119
- can_upload_free: boolean;
120
- level_string: string;
121
- avatar_id: number;
122
- show_avatars: boolean;
123
- blacklist_avatars: boolean;
124
- blacklist_users: boolean;
125
- description_collapsed_initially: boolean;
126
- hide_comments: boolean;
127
- show_hidden_comments: boolean;
128
- show_post_statistics: boolean;
129
- has_mail: boolean;
130
- receive_email_notifications: boolean;
131
- enable_keyboard_navigation: boolean;
132
- enable_privacy_mode: boolean;
133
- style_usernames: boolean;
134
- enable_auto_complete: boolean;
135
- has_saved_searches: boolean;
136
- disable_cropped_thumbnails: boolean;
137
- disable_mobile_gestures: boolean;
138
- enable_safe_mode: boolean;
139
- disable_responsive_mode: boolean;
140
- disable_post_tooltips: boolean;
141
- no_flagging: boolean;
142
- no_feedback: boolean;
143
- disable_user_dmails: boolean;
144
- enable_compact_uploader: boolean;
145
- updated_at: string;
146
- email: string;
147
- last_logged_in_at: string;
148
- last_forum_read_at: string;
149
- recent_tags: string;
150
- comment_threshold: number;
151
- default_image_size: string;
152
- favorite_tags: string;
153
- blacklisted_tags: string;
154
- time_zone: string;
155
- per_page: number;
156
- custom_style: string;
157
- favorite_count: number;
158
- api_regen_multiplier: number;
159
- api_burst_limit: number;
160
- remaining_api_limit: number;
161
- statement_timeout: number;
162
- favorite_limit: number;
163
- tag_query_limit: number;
164
- }
165
- declare class E621<N extends boolean = true> {
166
- apiKey: string | null;
167
- username: string | null;
168
- blacklist: Array<string>;
169
- userAgent: string;
170
- fixNullURLs: boolean;
171
- baseDomain: string;
172
- setHost: boolean;
173
- /**
174
- * Construct an instance of E621
175
- *
176
- * @param {string} [username] - your e621 username to use for requests
177
- * @param {string} [apiKey] - an api key to use for requests
178
- * @param {string[]} [blacklist=[]] - a list of tags to use to filter out posts
179
- * @param {string }[userAgent] - A user agent to use for requests
180
- * @param {boolean} [fixNullURLs=true] - If null urls should be converted to proper urls
181
- * @param {string} [baseDomain=this.baseDomain] - The domain to use for api requests
182
- * @param {boolean} [setHost=false] - If we should set the Host header on requests to e621.net (useful for proxies).
183
- * @example new E621();
184
- * @example new E621("YourUsername", "YourAPIKey");
185
- * @example new E621("YourUsername", "YourAPIKey", ["male/male"]);
186
- * @example new E621("YourUsername", "YourAPIKey", ["male/male"], "MyAwesomeProject/1.0.0");
187
- * @example new E621("YourUsername", "YourAPIKey", ["male/male"], "MyAwesomeProject/1.0.0", false);
188
- * @example new E621("YourUsername", "YourAPIKey", ["male/male"], "MyAwesomeProject/1.0.0", false, "mye621.local");
189
- * @example new E621("YourUsername", "YourAPIKey", ["male/male"], "MyAwesomeProject/1.0.0", false, "mye621.local", false);
190
- */
191
- constructor(username?: string, apiKey?: string, blacklist?: Array<string>, userAgent?: string, fixNullURLs?: N, baseDomain?: string, setHost?: boolean);
192
- private get auth();
193
- /**
194
- * Get posts from e621
195
- *
196
- * @param {string[]} [tags=[]] - The tags to fetch posts for, 40 max
197
- * @param {number} [limit=25] - The, maximum amount of posts to get, 320 max
198
- * @param {number} [page=1] - The page of posts to get, see {@link https://e621.net/help/api#posts_list|E621 API Posts#List}
199
- * @returns {Promise<(Post | NullableURLPost)[]>}
200
- * @example getPosts()
201
- * @example getPosts("male bulge");
202
- * @example getPosts(["male", "bulge"]);
203
- * @example getPosts(["male", "bulge"], 5);
204
- * @example getPosts(["male", "bulge"], 5, 1);
205
- */
206
- getPosts(tags?: Array<string> | string, limit?: number, page?: number | string): Promise<Array<N extends true ? Post : NullableURLPost>>;
207
- /**
208
- * Get a specifc post from e621, by id
209
- *
210
- * @param {number} id - The id of the post to get
211
- * @returns {Promise<(Post | NullableURLPost)>}
212
- * @example getPostById(1022094)
213
- */
214
- getPostById(id: number): Promise<(N extends true ? Post : NullableURLPost)>;
215
- /**
216
- * Get a specifc post from e621, by md5
217
- *
218
- * @param {string} md5 - the md5 of the post to get
219
- * @returns {Promise<(Post | NullableURLPost)>}
220
- * @example getPostByMD5("6fd0b0f2237543bfeee5ca9318a97b46")
221
- */
222
- getPostByMD5(md5: string): Promise<(N extends true ? Post : NullableURLPost)>;
223
- /**
224
- * Get a specifc post from e621, by md5
225
- *
226
- * @param {number} id - the id of the post to edit
227
- * @param {string} [reason="Edit via https://npm.im/e621"] - The edit reason
228
- * @param {string} [tagChanges] - the tags to change, see {@link https://e621.net/help/api#posts_update|Posts Update Documentation} (list tag to add, list tag with a minus to remove)
229
- * @param {string} [sourceChanges] - the sources to change, see {@link https://e621.net/help/api#posts_update|Posts Update Documentation} (same as above, with sources)
230
- * @param {number} [parentId] - the id of the parent of this image
231
- * @param {string} [description] - the description of this image
232
- * @param {("s"|"q"|"e")} [rating] - the rating of this image
233
- * @param {boolean} [ratingLocked] - if the rating of this image should be locked
234
- * @param {boolean} [noteLocked] - if this image should be note locked
235
- * @param {boolean} [hasEmbeddedNotes] - if this image has embedded notes
236
- * @returns {Promise<(Post | NullableURLPost)>}
237
- * @example editPost(1022094, "I dunno", "dog -cat")
238
- * @example editPost(1022094, "I dunno", undefined, "-https://furaffinity.net/(...) https://inkbunny.net/(...)")
239
- * @example editPost(1022094, "I dunno", undefined, undefined, 1097929)
240
- * @example editPost(1022094, "I dunno", undefined, undefined, undefined, "Some stuff here")
241
- * @example editPost(1022094, "I dunno", undefined, undefined, undefined, undefined, "e")
242
- * @example editPost(1022094, "I dunno", undefined, undefined, undefined, undefined, undefined, true)
243
- * @example editPost(1022094, "I dunno", undefined, undefined, undefined, undefined, undefined, undefined, false)
244
- * @example editPost(1022094, "I dunno", undefined, undefined, undefined, undefined, undefined, undefined, undefined, true)
245
- */
246
- editPost(id: number, reason?: string, tagChanges?: string, sourceChanges?: string, parentId?: number, description?: string, rating?: "s" | "q" | "e", ratingLocked?: boolean, noteLocked?: boolean, hasEmbeddedNotes?: boolean): Promise<(N extends true ? Post : NullableURLPost)>;
247
- /**
248
- *
249
- * @param {string} fileURL - the url of the file to send to Discord
250
- * @param {(string[]|string)} tags - the tags to put on the post -- if you upload a post with less than 4 tags, e621 mods will not like you
251
- * @param {("s"|"q"|"e")} rating - the rating for the image
252
- * @param {(string[]|string)} [sources] - The sources of the image
253
- * @param {string} [description] - A description for the post
254
- * @param {number} [parent] - id of the parent post of this image
255
- * @param {string} [referer] - I dunno
256
- * @param {string} [md5Confirmation] - the md5 of the provided fileURL, to confirm it matches
257
- * @example createPost("https://pbs.twimg.com/media/EbOwnXpXkAIC5ZX.jpg:orig", ["gaokun", "bulge", "penis_outline" (...)], "e")
258
- * @example createPost("https://pbs.twimg.com/media/EbOwnXpXkAIC5ZX.jpg:orig", ["gaokun", "bulge", "penis_outline" (...)], "e", ["https://twitter.com/Gaokunx3", "https://twitter.com/Gaokunx3/status/1275559030522556417"])
259
- * @example createPost("https://pbs.twimg.com/media/EbOwnXpXkAIC5ZX.jpg:orig", ["gaokun", "bulge", "penis_outline" (...)], "e", ["https://twitter.com/Gaokunx3", "https://twitter.com/Gaokunx3/status/1275559030522556417"], "Some Description Stuff Here")
260
- * @example createPost("https://pbs.twimg.com/media/EbOwnXpXkAIC5ZX.jpg:orig", ["gaokun", "bulge", "penis_outline" (...)], "e", ["https://twitter.com/Gaokunx3", "https://twitter.com/Gaokunx3/status/1275559030522556417"], "Some Description Stuff Here", 1234)
261
- * @example createPost("https://pbs.twimg.com/media/EbOwnXpXkAIC5ZX.jpg:orig", ["gaokun", "bulge", "penis_outline" (...)], "e", ["https://twitter.com/Gaokunx3", "https://twitter.com/Gaokunx3/status/1275559030522556417"], "Some Description Stuff Here", 1234, "https://npm.im/e621")
262
- * @example createPost("https://pbs.twimg.com/media/EbOwnXpXkAIC5ZX.jpg:orig", ["gaokun", "bulge", "penis_outline" (...)], "e", ["https://twitter.com/Gaokunx3", "https://twitter.com/Gaokunx3/status/1275559030522556417"], "Some Description Stuff Here", 1234, "https://npm.im/e621", "abcdefghijklmnopqrstuvwxyz123456")
263
- * @returns
264
- */
265
- createPost(fileURL: string, tags: string | Array<string>, rating: "s" | "q" | "e", sources?: Array<string> | string, description?: string, parent?: number, referer?: string, md5Confirmation?: string): Promise<{
266
- success: boolean;
267
- location: string;
268
- post_id: number;
269
- }>;
270
- private filterPosts;
271
- /**
272
- * Convert null urls on a post into proper urls.
273
- *
274
- * @param {NullableURLPost} p - The post to fix
275
- * @returns {Post}
276
- */
277
- fixURL(p: NullableURLPost): Post;
278
- /**
279
- * Construct a url from its md5 counterpart
280
- *
281
- * @param {string} md5 - the md5
282
- * @param {string} [ext="png"] - The extension, assumed png if not provided
283
- * @param {boolean} [preview=false]
284
- */
285
- constructURLFromMD5(md5: string, ext?: string, preview?: boolean): string;
286
- /**
287
- * Fetch your "upload limit" info (this seems to just be general account info, along with upload limit)
288
- *
289
- * authentication is REQUIRED
290
- *
291
- * @returns {Promise<UploadLimit>}
292
- */
293
- getUploadLimit(): Promise<UploadLimit>;
294
- }
295
- export default E621;
296
- export { E621 };
27
+ export * from "./types";
28
+ export { APIError } from "./util/RequestHandler";
29
+ export { AuthenticatedUser, Pool, PoolHistory, Post, PostSet, User };