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.
- package/.node-version +1 -0
- package/README.md +116 -187
- package/build/package.json +14 -11
- package/build/src/index.d.ts +28 -295
- package/build/src/index.js +83 -442
- package/build/src/modules/Pools.d.ts +120 -0
- package/build/src/modules/Pools.js +247 -0
- package/build/src/modules/PostSets.d.ts +88 -0
- package/build/src/modules/PostSets.js +182 -0
- package/build/src/modules/Posts.d.ts +124 -0
- package/build/src/modules/Posts.js +323 -0
- package/build/src/modules/UserFeedback.d.ts +66 -0
- package/build/src/modules/UserFeedback.js +134 -0
- package/build/src/modules/Users.d.ts +110 -0
- package/build/src/modules/Users.js +248 -0
- package/build/src/modules/WikiPages.d.ts +99 -0
- package/build/src/modules/WikiPages.js +208 -0
- package/build/src/structures/AuthenticatedUser.d.ts +109 -0
- package/build/src/structures/AuthenticatedUser.js +128 -0
- package/build/src/structures/Pool.d.ts +85 -0
- package/build/src/structures/Pool.js +110 -0
- package/build/src/structures/PoolHistory.d.ts +42 -0
- package/build/src/structures/PoolHistory.js +53 -0
- package/build/src/structures/Post.d.ts +147 -0
- package/build/src/structures/Post.js +155 -0
- package/build/src/structures/PostHistory.d.ts +52 -0
- package/build/src/structures/PostHistory.js +93 -0
- package/build/src/structures/PostSet.d.ts +71 -0
- package/build/src/structures/PostSet.js +91 -0
- package/build/src/structures/User.d.ts +62 -0
- package/build/src/structures/User.js +80 -0
- package/build/src/structures/WikiPage.d.ts +16 -0
- package/build/src/structures/WikiPage.js +26 -0
- package/build/src/structures/WikiPageHistory.d.ts +37 -0
- package/build/src/structures/WikiPageHistory.js +49 -0
- package/build/src/types/index.d.ts +92 -0
- package/build/src/types/pools.d.ts +60 -0
- package/build/src/types/post_sets.d.ts +33 -0
- package/build/src/types/posts.d.ts +165 -0
- package/build/src/types/user_feedback.d.ts +27 -0
- package/build/src/types/users.d.ts +277 -0
- package/build/src/types/wiki_pages.d.ts +65 -0
- package/build/src/util/FormHelper.d.ts +9 -0
- package/build/src/util/FormHelper.js +15 -0
- package/build/src/util/MultipartData.d.ts +7 -0
- package/build/src/util/MultipartData.js +39 -0
- package/build/src/util/RequestHandler.d.ts +37 -0
- package/build/src/util/RequestHandler.js +311 -0
- package/package.json +14 -11
- package/LICENSE +0 -21
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type User from "./User";
|
|
2
|
+
import type Pool from "./Pool";
|
|
3
|
+
import type { PoolCategory, PoolHistoryProperties } from "../types";
|
|
4
|
+
import type E621 from "..";
|
|
5
|
+
export default class PoolHistory implements PoolHistoryProperties {
|
|
6
|
+
private main;
|
|
7
|
+
id: number;
|
|
8
|
+
pool_id: number;
|
|
9
|
+
post_ids: Array<number>;
|
|
10
|
+
added_post_ids: Array<number>;
|
|
11
|
+
removed_post_ids: Array<number>;
|
|
12
|
+
updater_id: number;
|
|
13
|
+
description: string;
|
|
14
|
+
description_changed: boolean;
|
|
15
|
+
name: string;
|
|
16
|
+
created_at: string;
|
|
17
|
+
updated_at: string;
|
|
18
|
+
is_active: boolean;
|
|
19
|
+
is_deleted: boolean;
|
|
20
|
+
category: PoolCategory;
|
|
21
|
+
version: number;
|
|
22
|
+
constructor(main: E621, info: PoolHistoryProperties);
|
|
23
|
+
/**
|
|
24
|
+
* Get the updater for this history
|
|
25
|
+
*
|
|
26
|
+
* @returns {Promise<User | null>}
|
|
27
|
+
*/
|
|
28
|
+
getUpdater(): Promise<User | null>;
|
|
29
|
+
/**
|
|
30
|
+
* Get the pool object for this history
|
|
31
|
+
*
|
|
32
|
+
* @returns {Promise<Pool | null>}
|
|
33
|
+
*/
|
|
34
|
+
getPool(): Promise<Pool | null>;
|
|
35
|
+
/**
|
|
36
|
+
* Revert the pool to this version
|
|
37
|
+
*
|
|
38
|
+
* * Requires Authentication
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
revertTo(): Promise<null>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class PoolHistory {
|
|
4
|
+
main;
|
|
5
|
+
id;
|
|
6
|
+
pool_id;
|
|
7
|
+
post_ids;
|
|
8
|
+
added_post_ids;
|
|
9
|
+
removed_post_ids;
|
|
10
|
+
updater_id;
|
|
11
|
+
description;
|
|
12
|
+
description_changed;
|
|
13
|
+
name;
|
|
14
|
+
created_at;
|
|
15
|
+
updated_at;
|
|
16
|
+
is_active;
|
|
17
|
+
is_deleted;
|
|
18
|
+
category;
|
|
19
|
+
version;
|
|
20
|
+
constructor(main, info) {
|
|
21
|
+
Object.assign(this, info);
|
|
22
|
+
Object.defineProperty(this, "main", {
|
|
23
|
+
value: main,
|
|
24
|
+
configurable: false,
|
|
25
|
+
enumerable: false,
|
|
26
|
+
writable: false
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the updater for this history
|
|
31
|
+
*
|
|
32
|
+
* @returns {Promise<User | null>}
|
|
33
|
+
*/
|
|
34
|
+
async getUpdater() { return this.main.users.get(this.updater_id); }
|
|
35
|
+
/**
|
|
36
|
+
* Get the pool object for this history
|
|
37
|
+
*
|
|
38
|
+
* @returns {Promise<Pool | null>}
|
|
39
|
+
*/
|
|
40
|
+
async getPool() { return this.main.pools.get(this.pool_id); }
|
|
41
|
+
/**
|
|
42
|
+
* Revert the pool to this version
|
|
43
|
+
*
|
|
44
|
+
* * Requires Authentication
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
async revertTo() {
|
|
48
|
+
this.main.request.authCheck("PoolHistory#revertTo");
|
|
49
|
+
return this.main.pools.revert(this.pool_id, this.id);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.default = PoolHistory;
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUG9vbEhpc3RvcnkuanM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ENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQyxDQUFDO0lBRzdEOzs7OztPQUtHO0lBQ0gsS0FBSyxDQUFDLFFBQVE7UUFDYixJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsc0JBQXNCLENBQUMsQ0FBQztRQUNwRCxPQUFPLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFFLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQztJQUN0RCxDQUFDO0NBQ0Q7QUFwREQsOEJBb0RDIn0=
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type PostSet from "./PostSet";
|
|
2
|
+
import type User from "./User";
|
|
3
|
+
import Pool from "./Pool";
|
|
4
|
+
import type { PostProperties, Ratings, ModifyPostOptions, PostVoteResult } from "../types";
|
|
5
|
+
import type E621 from "..";
|
|
6
|
+
export default class Post implements PostProperties {
|
|
7
|
+
private main;
|
|
8
|
+
id: number;
|
|
9
|
+
created_at: string;
|
|
10
|
+
updated_at: string;
|
|
11
|
+
file: {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
ext: string;
|
|
15
|
+
size: number;
|
|
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, {
|
|
30
|
+
type: string;
|
|
31
|
+
height: number;
|
|
32
|
+
width: number;
|
|
33
|
+
urls: Array<string | null>;
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
score: Record<"up" | "down" | "total", number>;
|
|
37
|
+
tags: Record<"general" | "species" | "character" | "copyright" | "artist" | "invalid" | "lore" | "meta", Array<string>>;
|
|
38
|
+
locked_tags: Array<string>;
|
|
39
|
+
change_seq: number;
|
|
40
|
+
flags: Record<"pending" | "flagged" | "note_locked" | "status_locked" | "rating_locked" | "deleted", boolean>;
|
|
41
|
+
rating: Ratings;
|
|
42
|
+
fav_count: number;
|
|
43
|
+
sources: Array<string>;
|
|
44
|
+
pools: Array<number>;
|
|
45
|
+
relationships: {
|
|
46
|
+
parent_id: number | null;
|
|
47
|
+
has_childeren: boolean;
|
|
48
|
+
has_active_childeren: boolean;
|
|
49
|
+
childeren: Array<number>;
|
|
50
|
+
};
|
|
51
|
+
approver_id: number | null;
|
|
52
|
+
uploader_id: number;
|
|
53
|
+
description: string;
|
|
54
|
+
comment_count: number;
|
|
55
|
+
is_favorited: boolean;
|
|
56
|
+
has_notes: boolean;
|
|
57
|
+
duration: number | null;
|
|
58
|
+
constructor(main: E621, info: PostProperties);
|
|
59
|
+
/**
|
|
60
|
+
* Get the user object for creator of this post
|
|
61
|
+
*
|
|
62
|
+
* @returns {Promise<User | null>}
|
|
63
|
+
*/
|
|
64
|
+
getUploader(): Promise<User | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Get the user object for approver of this post (will be null if self approved)
|
|
67
|
+
*
|
|
68
|
+
* @returns {Promise<User | null>}
|
|
69
|
+
*/
|
|
70
|
+
getApprover(): Promise<User | null>;
|
|
71
|
+
/**
|
|
72
|
+
* Add this post to a set
|
|
73
|
+
*
|
|
74
|
+
* * Requires Authentication
|
|
75
|
+
*
|
|
76
|
+
* @param {number} id - the id of the set to add this post to
|
|
77
|
+
* @returns {Promise<PostSet>}
|
|
78
|
+
*/
|
|
79
|
+
addToSet(id: number): Promise<PostSet>;
|
|
80
|
+
/**
|
|
81
|
+
* Remove this post from a set
|
|
82
|
+
*
|
|
83
|
+
* * Requires Authentication
|
|
84
|
+
*
|
|
85
|
+
* @param {number} id - the id of the set to remove this post from
|
|
86
|
+
* @returns {Promise<PostSet>}
|
|
87
|
+
*/
|
|
88
|
+
removeFromSet(id: number): Promise<PostSet>;
|
|
89
|
+
/**
|
|
90
|
+
* Add this post to a pool
|
|
91
|
+
*
|
|
92
|
+
* * Requires Authentication
|
|
93
|
+
*
|
|
94
|
+
* @param {number} id - the id of the pool to add this post to
|
|
95
|
+
* @returns {Promise<Pool>}
|
|
96
|
+
*/
|
|
97
|
+
addToPool(id: number): Promise<Pool>;
|
|
98
|
+
/**
|
|
99
|
+
* Remove this post from a pool
|
|
100
|
+
*
|
|
101
|
+
* * Requires Authentication
|
|
102
|
+
*
|
|
103
|
+
* @param {number} id - the id of the pool to remove this post from
|
|
104
|
+
* @returns {Promise<Pool>}
|
|
105
|
+
*/
|
|
106
|
+
removeFromPool(id: number): Promise<Pool>;
|
|
107
|
+
/**
|
|
108
|
+
* Modify a post
|
|
109
|
+
*
|
|
110
|
+
* * Requires Authentication
|
|
111
|
+
*
|
|
112
|
+
* @param {object} options
|
|
113
|
+
* @param {string} [options.editReason] - the reason for the edit
|
|
114
|
+
* @param {(Array<string> | string)} [options.addTags] - the tags to add to the post
|
|
115
|
+
* @param {(Array<string> | string)} [options.removeTags] - the tags to remove from the post
|
|
116
|
+
* @param {(Array<string> | string)} [options.addSources] - the sources to add to the post
|
|
117
|
+
* @param {(Array<string> | string)} [options.removeSources] - the sources to remove from the post
|
|
118
|
+
* @param {Ratings} [options.rating] - the rating for the post
|
|
119
|
+
* @param {string} [options.description] - the description of the post
|
|
120
|
+
* @param {number} [options.parentID] - the parent of the post
|
|
121
|
+
* @param {boolean} [options.hasEmbeddedNotes] - I don't know what this is, api docs list it though
|
|
122
|
+
* @param {boolean} [options.ratingLocked] - upload as rating locked (requires privileged)
|
|
123
|
+
* @param {boolean} [options.noteLocked] - upload as rating locked (requires janitor)
|
|
124
|
+
* @param {boolean} [options.statusLocked] - upload as rating locked (requires admin)
|
|
125
|
+
* @param {boolean} [options.hideFromAnonymous] - upload as rating locked (requires admin)
|
|
126
|
+
* @param {boolean} [options.hideFromSearch] - upload as rating locked (requires admin)
|
|
127
|
+
* @param {string} [options.backgroundColor] - the background color of the post (requires janitor)
|
|
128
|
+
* @param {(Array<string> | string)} [options.lockedTags] - tags to lock on the post (requires admin)
|
|
129
|
+
* @returns {Promise<Post>}
|
|
130
|
+
*/
|
|
131
|
+
modify(options: ModifyPostOptions): Promise<Post>;
|
|
132
|
+
/**
|
|
133
|
+
* Vote on this post
|
|
134
|
+
*
|
|
135
|
+
* * Requires Authentication
|
|
136
|
+
*
|
|
137
|
+
* @param {boolean} up - if the vote should be up or down
|
|
138
|
+
* @returns {Promise<PostVoteResult>}
|
|
139
|
+
*/
|
|
140
|
+
vote(up: boolean): Promise<PostVoteResult>;
|
|
141
|
+
/**
|
|
142
|
+
* Remove tags from this post with implication checks (this WILL fire a request for EVERY SINGLE TAG specified.)
|
|
143
|
+
*
|
|
144
|
+
* @param tags
|
|
145
|
+
*/
|
|
146
|
+
removeTagsWithImplicationChecks(tags: Array<string> | string): Promise<void>;
|
|
147
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Post {
|
|
4
|
+
main;
|
|
5
|
+
id;
|
|
6
|
+
created_at;
|
|
7
|
+
updated_at;
|
|
8
|
+
file;
|
|
9
|
+
preview;
|
|
10
|
+
sample;
|
|
11
|
+
score;
|
|
12
|
+
tags;
|
|
13
|
+
locked_tags;
|
|
14
|
+
change_seq;
|
|
15
|
+
flags;
|
|
16
|
+
rating;
|
|
17
|
+
fav_count;
|
|
18
|
+
sources;
|
|
19
|
+
pools;
|
|
20
|
+
relationships;
|
|
21
|
+
approver_id;
|
|
22
|
+
uploader_id;
|
|
23
|
+
description;
|
|
24
|
+
comment_count;
|
|
25
|
+
is_favorited;
|
|
26
|
+
has_notes;
|
|
27
|
+
duration;
|
|
28
|
+
constructor(main, info) {
|
|
29
|
+
Object.assign(this, info);
|
|
30
|
+
Object.defineProperty(this, "main", {
|
|
31
|
+
value: main,
|
|
32
|
+
configurable: false,
|
|
33
|
+
enumerable: false,
|
|
34
|
+
writable: false
|
|
35
|
+
});
|
|
36
|
+
// blacklisted or deleted
|
|
37
|
+
if (this.file.url === null)
|
|
38
|
+
this.file.url = this.flags.deleted ? this.main.request.deletedImageURL : this.main.request.constructURL(this.file.md5, "original", this.file.ext);
|
|
39
|
+
if (this.preview.url === null)
|
|
40
|
+
this.preview.url = this.flags.deleted ? this.main.request.deletedImageURL : this.main.request.constructURL(this.file.md5, "preview", this.file.ext);
|
|
41
|
+
if (this.sample.has && this.sample.url === null)
|
|
42
|
+
this.sample.url = this.flags.deleted ? this.main.request.deletedImageURL : this.main.request.constructURL(this.file.md5, "sample", this.file.ext);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the user object for creator of this post
|
|
46
|
+
*
|
|
47
|
+
* @returns {Promise<User | null>}
|
|
48
|
+
*/
|
|
49
|
+
async getUploader() { return this.main.users.get(this.uploader_id); }
|
|
50
|
+
/**
|
|
51
|
+
* Get the user object for approver of this post (will be null if self approved)
|
|
52
|
+
*
|
|
53
|
+
* @returns {Promise<User | null>}
|
|
54
|
+
*/
|
|
55
|
+
async getApprover() { return this.approver_id === null ? null : this.main.users.get(this.approver_id); }
|
|
56
|
+
/**
|
|
57
|
+
* Add this post to a set
|
|
58
|
+
*
|
|
59
|
+
* * Requires Authentication
|
|
60
|
+
*
|
|
61
|
+
* @param {number} id - the id of the set to add this post to
|
|
62
|
+
* @returns {Promise<PostSet>}
|
|
63
|
+
*/
|
|
64
|
+
async addToSet(id) {
|
|
65
|
+
this.main.request.authCheck("Post#addToSet");
|
|
66
|
+
return this.main.postSets.addPost(id, this.id);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Remove this post from a set
|
|
70
|
+
*
|
|
71
|
+
* * Requires Authentication
|
|
72
|
+
*
|
|
73
|
+
* @param {number} id - the id of the set to remove this post from
|
|
74
|
+
* @returns {Promise<PostSet>}
|
|
75
|
+
*/
|
|
76
|
+
async removeFromSet(id) {
|
|
77
|
+
this.main.request.authCheck("Post#removeFromSet");
|
|
78
|
+
return this.main.postSets.removePost(id, this.id);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Add this post to a pool
|
|
82
|
+
*
|
|
83
|
+
* * Requires Authentication
|
|
84
|
+
*
|
|
85
|
+
* @param {number} id - the id of the pool to add this post to
|
|
86
|
+
* @returns {Promise<Pool>}
|
|
87
|
+
*/
|
|
88
|
+
async addToPool(id) {
|
|
89
|
+
this.main.request.authCheck("Post#addToPool");
|
|
90
|
+
return this.main.pools.addPost(id, this.id);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Remove this post from a pool
|
|
94
|
+
*
|
|
95
|
+
* * Requires Authentication
|
|
96
|
+
*
|
|
97
|
+
* @param {number} id - the id of the pool to remove this post from
|
|
98
|
+
* @returns {Promise<Pool>}
|
|
99
|
+
*/
|
|
100
|
+
async removeFromPool(id) {
|
|
101
|
+
this.main.request.authCheck("Post#removeFromPool");
|
|
102
|
+
return this.main.pools.removePost(id, this.id);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Modify a post
|
|
106
|
+
*
|
|
107
|
+
* * Requires Authentication
|
|
108
|
+
*
|
|
109
|
+
* @param {object} options
|
|
110
|
+
* @param {string} [options.editReason] - the reason for the edit
|
|
111
|
+
* @param {(Array<string> | string)} [options.addTags] - the tags to add to the post
|
|
112
|
+
* @param {(Array<string> | string)} [options.removeTags] - the tags to remove from the post
|
|
113
|
+
* @param {(Array<string> | string)} [options.addSources] - the sources to add to the post
|
|
114
|
+
* @param {(Array<string> | string)} [options.removeSources] - the sources to remove from the post
|
|
115
|
+
* @param {Ratings} [options.rating] - the rating for the post
|
|
116
|
+
* @param {string} [options.description] - the description of the post
|
|
117
|
+
* @param {number} [options.parentID] - the parent of the post
|
|
118
|
+
* @param {boolean} [options.hasEmbeddedNotes] - I don't know what this is, api docs list it though
|
|
119
|
+
* @param {boolean} [options.ratingLocked] - upload as rating locked (requires privileged)
|
|
120
|
+
* @param {boolean} [options.noteLocked] - upload as rating locked (requires janitor)
|
|
121
|
+
* @param {boolean} [options.statusLocked] - upload as rating locked (requires admin)
|
|
122
|
+
* @param {boolean} [options.hideFromAnonymous] - upload as rating locked (requires admin)
|
|
123
|
+
* @param {boolean} [options.hideFromSearch] - upload as rating locked (requires admin)
|
|
124
|
+
* @param {string} [options.backgroundColor] - the background color of the post (requires janitor)
|
|
125
|
+
* @param {(Array<string> | string)} [options.lockedTags] - tags to lock on the post (requires admin)
|
|
126
|
+
* @returns {Promise<Post>}
|
|
127
|
+
*/
|
|
128
|
+
async modify(options) {
|
|
129
|
+
this.main.request.authCheck("Post#modify");
|
|
130
|
+
return this.main.posts.modify(this.id, options);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Vote on this post
|
|
134
|
+
*
|
|
135
|
+
* * Requires Authentication
|
|
136
|
+
*
|
|
137
|
+
* @param {boolean} up - if the vote should be up or down
|
|
138
|
+
* @returns {Promise<PostVoteResult>}
|
|
139
|
+
*/
|
|
140
|
+
async vote(up) {
|
|
141
|
+
this.main.request.authCheck("Post#vote");
|
|
142
|
+
return this.main.posts.vote(this.id, up);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Remove tags from this post with implication checks (this WILL fire a request for EVERY SINGLE TAG specified.)
|
|
146
|
+
*
|
|
147
|
+
* @param tags
|
|
148
|
+
*/
|
|
149
|
+
async removeTagsWithImplicationChecks(tags) {
|
|
150
|
+
if (!Array.isArray(tags))
|
|
151
|
+
tags = tags.split(" ");
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.default = Post;
|
|
155
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUG9zdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJ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xFQUFFLENBQUMsQ0FBQztJQUMxQyxDQUFDO0lBRUQ7Ozs7T0FJRztJQUNILEtBQUssQ0FBQywrQkFBK0IsQ0FBQyxJQUE0QjtRQUNqRSxJQUFJLENBQUMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUM7WUFBRSxJQUFJLEdBQUksSUFBSSxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQztJQUNuRCxDQUFDO0NBQ0Q7QUF4TEQsdUJBd0xDIn0=
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type User from "./User";
|
|
2
|
+
import type Post from "./Post";
|
|
3
|
+
import type { PostHistoryProperties, Ratings } from "../types";
|
|
4
|
+
import type E621 from "..";
|
|
5
|
+
export default class PostHistory implements PostHistoryProperties {
|
|
6
|
+
private main;
|
|
7
|
+
id: number;
|
|
8
|
+
post_id: number;
|
|
9
|
+
tags: string;
|
|
10
|
+
updater_id: number;
|
|
11
|
+
updater_name: string;
|
|
12
|
+
updated_at: string;
|
|
13
|
+
rating: Ratings;
|
|
14
|
+
parent_id: number | null;
|
|
15
|
+
source: string;
|
|
16
|
+
description: string;
|
|
17
|
+
reason: string;
|
|
18
|
+
locked_tags: string | null;
|
|
19
|
+
added_tags: Array<string>;
|
|
20
|
+
removed_tags: Array<string>;
|
|
21
|
+
added_locked_tags: Array<string>;
|
|
22
|
+
removed_locked_tags: Array<string>;
|
|
23
|
+
rating_changed: boolean;
|
|
24
|
+
parent_changed: boolean;
|
|
25
|
+
source_changed: boolean;
|
|
26
|
+
description_changed: boolean;
|
|
27
|
+
version: number;
|
|
28
|
+
obsolete_added_tags: string;
|
|
29
|
+
obsolete_removed_tags: string;
|
|
30
|
+
unchanged_tags: string;
|
|
31
|
+
extra: Readonly<Record<"tags" | "lockedTags" | "addedTags" | "removedTags" | "addedLockedTags" | "removedLockedTags" | "obsoleteAddedTags" | "obsoleteRemovedTags" | "unchangedTags" | "sources" | "addedSources" | "removedSources", Array<string>> & Record<"oldRating" | "newRating", Ratings | null>>;
|
|
32
|
+
constructor(main: E621, info: PostHistoryProperties);
|
|
33
|
+
/**
|
|
34
|
+
* Get the updater for this history
|
|
35
|
+
*
|
|
36
|
+
* @returns {Promise<User | null>}
|
|
37
|
+
*/
|
|
38
|
+
getUpdater(): Promise<User | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Get the post object for this history
|
|
41
|
+
*
|
|
42
|
+
* @returns {Promise<Post | null>}
|
|
43
|
+
*/
|
|
44
|
+
getPost(): Promise<Post | null>;
|
|
45
|
+
/**
|
|
46
|
+
* Revert the post to this version
|
|
47
|
+
*
|
|
48
|
+
* * Requires Authentication
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
revertTo(): Promise<null>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class PostHistory {
|
|
4
|
+
main;
|
|
5
|
+
id;
|
|
6
|
+
post_id;
|
|
7
|
+
tags;
|
|
8
|
+
updater_id;
|
|
9
|
+
updater_name;
|
|
10
|
+
updated_at;
|
|
11
|
+
rating;
|
|
12
|
+
parent_id;
|
|
13
|
+
source;
|
|
14
|
+
description;
|
|
15
|
+
reason;
|
|
16
|
+
locked_tags;
|
|
17
|
+
added_tags;
|
|
18
|
+
removed_tags;
|
|
19
|
+
added_locked_tags;
|
|
20
|
+
removed_locked_tags;
|
|
21
|
+
rating_changed;
|
|
22
|
+
parent_changed;
|
|
23
|
+
source_changed;
|
|
24
|
+
description_changed;
|
|
25
|
+
version;
|
|
26
|
+
obsolete_added_tags;
|
|
27
|
+
obsolete_removed_tags;
|
|
28
|
+
unchanged_tags;
|
|
29
|
+
extra;
|
|
30
|
+
constructor(main, info) {
|
|
31
|
+
Object.assign(this, info);
|
|
32
|
+
Object.defineProperty(this, "main", {
|
|
33
|
+
value: main,
|
|
34
|
+
configurable: false,
|
|
35
|
+
enumerable: false,
|
|
36
|
+
writable: false
|
|
37
|
+
});
|
|
38
|
+
this.extra = {
|
|
39
|
+
get tags() { return info.tags.split(" "); },
|
|
40
|
+
get lockedTags() { return (info.locked_tags || "").split(" "); },
|
|
41
|
+
get addedTags() { return info.added_tags; },
|
|
42
|
+
get removedTags() { return info.removed_tags; },
|
|
43
|
+
get addedLockedTags() { return info.added_locked_tags; },
|
|
44
|
+
get removedLockedTags() { return info.added_locked_tags; },
|
|
45
|
+
get obsoleteAddedTags() { return info.obsolete_added_tags.split(" "); },
|
|
46
|
+
get obsoleteRemovedTags() { return info.obsolete_removed_tags.split(" "); },
|
|
47
|
+
get unchangedTags() { return info.unchanged_tags.split(" "); },
|
|
48
|
+
get sources() { return info.source.split("\n").filter(Boolean); },
|
|
49
|
+
// convinence method
|
|
50
|
+
get oldRating() {
|
|
51
|
+
if (!info.rating_changed)
|
|
52
|
+
return null;
|
|
53
|
+
const r = this.removedTags.find(t => t.startsWith("rating:"));
|
|
54
|
+
return !r ? null : r.replace(/rating:/, "");
|
|
55
|
+
},
|
|
56
|
+
// convinence method
|
|
57
|
+
get newRating() {
|
|
58
|
+
if (!info.rating_changed)
|
|
59
|
+
return null;
|
|
60
|
+
const r = this.addedTags.find(t => t.startsWith("rating:"));
|
|
61
|
+
return !r ? null : r.replace(/rating:/, "");
|
|
62
|
+
},
|
|
63
|
+
// convinence method
|
|
64
|
+
get addedSources() { return (this.addedTags.find(t => t.startsWith("source:"))?.replace(/source:/, "") ?? "").split("\n"); },
|
|
65
|
+
// convinence method
|
|
66
|
+
get removedSources() { return (this.removedTags.find(t => t.startsWith("source:"))?.replace(/source:/, "") ?? "").split("\n"); }
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get the updater for this history
|
|
71
|
+
*
|
|
72
|
+
* @returns {Promise<User | null>}
|
|
73
|
+
*/
|
|
74
|
+
async getUpdater() { return this.main.users.get(this.updater_id); }
|
|
75
|
+
/**
|
|
76
|
+
* Get the post object for this history
|
|
77
|
+
*
|
|
78
|
+
* @returns {Promise<Post | null>}
|
|
79
|
+
*/
|
|
80
|
+
async getPost() { return this.main.posts.get(this.post_id); }
|
|
81
|
+
/**
|
|
82
|
+
* Revert the post to this version
|
|
83
|
+
*
|
|
84
|
+
* * Requires Authentication
|
|
85
|
+
*
|
|
86
|
+
*/
|
|
87
|
+
async revertTo() {
|
|
88
|
+
this.main.request.authCheck("PostHistory#revertTo");
|
|
89
|
+
return this.main.posts.revert(this.post_id, this.id);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.default = PostHistory;
|
|
93
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUG9zdEhpc3RvcnkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3RydWN0dXJlcy9Qb3N0SGlzdG9yeS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUtBLE1BQXFCLFdBQVc7SUFDdkIsSUFBSSxDQUFPO0lBQ25CLEVBQUUsQ0FBUztJQUNYLE9BQU8sQ0FBUztJQUNoQixJQUFJLENBQVM7SUFDYixVQUFVLENBQVM7SUFDbkIsWUFBWSxDQUFTO0lBQ3JCLFVBQVUsQ0FBUztJQUNuQixNQUFNLENBQVU7SUFDaEIsU0FBUyxDQUFnQjtJQUN6QixNQUFNLENBQVM7SUFDZixXQUFXLENBQVM7SUFDcEIsTUFBTSxDQUFTO0lBQ2YsV0FBVyxDQUFnQjtJQUMzQixVQUFVLENBQWdCO0lBQzFCLFlBQVksQ0FBZ0I7SUFDNUIsaUJBQWlCLENBQWdCO0lBQ2pDLG1CQUFtQixDQUFnQjtJQUNuQyxjQUFjLENBQVU7SUFDeEIsY0FBYyxDQUFVO0lBQ3hCLGNBQWMsQ0FBVTtJQUN4QixtQkFBbUIsQ0FBVTtJQUM3QixPQUFPLENBQVM7SUFDaEIsbUJBQW1CLENBQVM7SU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yxDQUFDLENBQUMsQ0FBQztJQUc3RDs7Ozs7T0FLRztJQUNILEtBQUssQ0FBQyxRQUFRO1FBQ2IsSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLHNCQUFzQixDQUFDLENBQUM7UUFDcEQsT0FBTyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sRUFBRSxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUM7SUFDdEQsQ0FBQztDQUNEO0FBaEdELDhCQWdHQyJ9
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type Post from "./Post";
|
|
2
|
+
import type User from "./User";
|
|
3
|
+
import type { PostSetProperties, ModifyPostSetOptions } from "../types";
|
|
4
|
+
import type E621 from "..";
|
|
5
|
+
export default class PostSet implements PostSetProperties {
|
|
6
|
+
private main;
|
|
7
|
+
id: number;
|
|
8
|
+
name: string;
|
|
9
|
+
shortname: string;
|
|
10
|
+
description: string;
|
|
11
|
+
is_public: boolean;
|
|
12
|
+
transfer_on_delete: boolean;
|
|
13
|
+
creator_id: number;
|
|
14
|
+
post_ids: Array<number>;
|
|
15
|
+
post_count: number;
|
|
16
|
+
created_at: string;
|
|
17
|
+
updated_at: string;
|
|
18
|
+
constructor(main: E621, info: PostSetProperties);
|
|
19
|
+
/**
|
|
20
|
+
* Get the post objects for the posts in this set
|
|
21
|
+
*
|
|
22
|
+
* @returns {Promise<Array<Post>>}
|
|
23
|
+
*/
|
|
24
|
+
getPosts(): Promise<Post[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Get the user object of the creator of this set
|
|
27
|
+
*
|
|
28
|
+
* @returns {Promise<User | null>}
|
|
29
|
+
*/
|
|
30
|
+
getCreator(): Promise<User | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Add a post to this set
|
|
33
|
+
*
|
|
34
|
+
* * Requires Authentication
|
|
35
|
+
*
|
|
36
|
+
* @param {number} id - the id of the post to add
|
|
37
|
+
* @returns {Promise<PostSet>}
|
|
38
|
+
*/
|
|
39
|
+
addPost(id: number): Promise<PostSet>;
|
|
40
|
+
/**
|
|
41
|
+
* Remove a post from this set
|
|
42
|
+
*
|
|
43
|
+
* * Requires Authentication
|
|
44
|
+
*
|
|
45
|
+
* @param {number} id - the id of the post to remove
|
|
46
|
+
* @returns {Promise<PostSet>}
|
|
47
|
+
*/
|
|
48
|
+
removePost(id: number): Promise<PostSet>;
|
|
49
|
+
/**
|
|
50
|
+
* modify this set
|
|
51
|
+
*
|
|
52
|
+
* * Requires Authentication
|
|
53
|
+
*
|
|
54
|
+
* @param {object} options
|
|
55
|
+
* @param {string} [options.name] - the name of the set
|
|
56
|
+
* @param {string} [options.shortname] - the short name of the set
|
|
57
|
+
* @param {string} [options.escription] - the description of the set
|
|
58
|
+
* @param {boolean} [options.active] - if the set is public
|
|
59
|
+
* @param {boolean} [options.transferOnDeletion] - if deleted posts should be replaced with parents
|
|
60
|
+
* @returns {Promise<PostSet>}
|
|
61
|
+
*/
|
|
62
|
+
modify(options: ModifyPostSetOptions): Promise<PostSet>;
|
|
63
|
+
/**
|
|
64
|
+
* Delete this set
|
|
65
|
+
*
|
|
66
|
+
* * Requires Authentication
|
|
67
|
+
*
|
|
68
|
+
* @returns {Promise<null>}
|
|
69
|
+
*/
|
|
70
|
+
delete(): Promise<null>;
|
|
71
|
+
}
|