emusks 2.0.4 → 2.0.6

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.
@@ -1,321 +1,319 @@
1
1
  import parseTimeline from "../parsers/timeline.js";
2
2
  import parseUser from "../parsers/user.js";
3
3
 
4
- export default (client) => ({
5
- async get(userId) {
6
- const res = await client.graphql("UserByRestId", {
7
- variables: { userId, withSafetyModeUserFields: true },
8
- fieldToggles: { withAuxiliaryUserLabels: false },
9
- });
10
- const user = res?.data?.user?.result;
11
- return user ? parseUser(user) : res;
12
- },
4
+ export async function get(userId) {
5
+ const res = await this.graphql("UserByRestId", {
6
+ variables: { userId, withSafetyModeUserFields: true },
7
+ fieldToggles: { withAuxiliaryUserLabels: false },
8
+ });
9
+ const user = res?.data?.user?.result;
10
+ return user ? parseUser(user) : res;
11
+ }
13
12
 
14
- async getByUsername(username) {
15
- const res = await client.graphql("UserByScreenName", {
16
- variables: { screen_name: username, withSafetyModeUserFields: true },
17
- fieldToggles: { withAuxiliaryUserLabels: false },
18
- });
19
- const user = res?.data?.user?.result;
20
- return user ? parseUser(user) : res;
21
- },
13
+ export async function getByUsername(username) {
14
+ const res = await this.graphql("UserByScreenName", {
15
+ variables: { screen_name: username, withSafetyModeUserFields: true },
16
+ fieldToggles: { withAuxiliaryUserLabels: false },
17
+ });
18
+ const user = res?.data?.user?.result;
19
+ return user ? parseUser(user) : res;
20
+ }
22
21
 
23
- async getMany(userIds) {
24
- const res = await client.graphql("UsersByRestIds", {
25
- variables: { userIds, withSafetyModeUserFields: true },
26
- fieldToggles: { withAuxiliaryUserLabels: false },
27
- });
28
- const users = res?.data?.users || [];
29
- return Array.isArray(users)
30
- ? users.map((u) => (u?.result ? parseUser(u.result) : u))
31
- : res;
32
- },
22
+ export async function getMany(userIds) {
23
+ const res = await this.graphql("UsersByRestIds", {
24
+ variables: { userIds, withSafetyModeUserFields: true },
25
+ fieldToggles: { withAuxiliaryUserLabels: false },
26
+ });
27
+ const users = res?.data?.users || [];
28
+ return Array.isArray(users)
29
+ ? users.map((u) => (u?.result ? parseUser(u.result) : u))
30
+ : res;
31
+ }
33
32
 
34
- async getManyByUsername(screenNames) {
35
- const res = await client.graphql("UsersByScreenNames", {
36
- variables: { screen_names: screenNames, withSafetyModeUserFields: true },
37
- fieldToggles: { withAuxiliaryUserLabels: false },
38
- });
39
- const users = res?.data?.users || [];
40
- return Array.isArray(users)
41
- ? users.map((u) => (u?.result ? parseUser(u.result) : u))
42
- : res;
43
- },
33
+ export async function getManyByUsername(screenNames) {
34
+ const res = await this.graphql("UsersByScreenNames", {
35
+ variables: { screen_names: screenNames, withSafetyModeUserFields: true },
36
+ fieldToggles: { withAuxiliaryUserLabels: false },
37
+ });
38
+ const users = res?.data?.users || [];
39
+ return Array.isArray(users)
40
+ ? users.map((u) => (u?.result ? parseUser(u.result) : u))
41
+ : res;
42
+ }
44
43
 
45
- async tweets(userId, opts = {}) {
46
- const raw = await client.graphql("UserTweets", {
47
- variables: {
48
- userId,
49
- count: opts.count || 20,
50
- cursor: opts.cursor,
51
- includePromotedContent: true,
52
- withQuickPromoteEligibilityTweetFields: true,
53
- withVoice: true,
54
- withV2Timeline: true,
55
- ...opts.variables,
56
- },
57
- fieldToggles: {
58
- withArticlePlainText: false,
59
- withArticleRichContentState: false,
60
- withAuxiliaryUserLabels: false,
61
- },
62
- });
63
- return parseTimeline(raw);
64
- },
44
+ export async function tweets(userId, opts = {}) {
45
+ const raw = await this.graphql("UserTweets", {
46
+ variables: {
47
+ userId,
48
+ count: opts.count || 20,
49
+ cursor: opts.cursor,
50
+ includePromotedContent: true,
51
+ withQuickPromoteEligibilityTweetFields: true,
52
+ withVoice: true,
53
+ withV2Timeline: true,
54
+ ...opts.variables,
55
+ },
56
+ fieldToggles: {
57
+ withArticlePlainText: false,
58
+ withArticleRichContentState: false,
59
+ withAuxiliaryUserLabels: false,
60
+ },
61
+ });
62
+ return parseTimeline(raw);
63
+ }
65
64
 
66
- async replies(userId, opts = {}) {
67
- const raw = await client.graphql("UserTweetsAndReplies", {
68
- variables: {
69
- userId,
70
- count: opts.count || 20,
71
- cursor: opts.cursor,
72
- includePromotedContent: true,
73
- withCommunity: true,
74
- withVoice: true,
75
- withV2Timeline: true,
76
- ...opts.variables,
77
- },
78
- fieldToggles: {
79
- withArticlePlainText: false,
80
- withArticleRichContentState: false,
81
- withAuxiliaryUserLabels: false,
82
- },
83
- });
84
- return parseTimeline(raw);
85
- },
65
+ export async function replies(userId, opts = {}) {
66
+ const raw = await this.graphql("UserTweetsAndReplies", {
67
+ variables: {
68
+ userId,
69
+ count: opts.count || 20,
70
+ cursor: opts.cursor,
71
+ includePromotedContent: true,
72
+ withCommunity: true,
73
+ withVoice: true,
74
+ withV2Timeline: true,
75
+ ...opts.variables,
76
+ },
77
+ fieldToggles: {
78
+ withArticlePlainText: false,
79
+ withArticleRichContentState: false,
80
+ withAuxiliaryUserLabels: false,
81
+ },
82
+ });
83
+ return parseTimeline(raw);
84
+ }
86
85
 
87
- async media(userId, opts = {}) {
88
- const raw = await client.graphql("UserMedia", {
89
- variables: {
90
- userId,
91
- count: opts.count || 20,
92
- cursor: opts.cursor,
93
- includePromotedContent: false,
94
- withClientEventToken: false,
95
- withBirdwatchNotes: false,
96
- withVoice: true,
97
- withV2Timeline: true,
98
- ...opts.variables,
99
- },
100
- fieldToggles: {
101
- withArticlePlainText: false,
102
- withArticleRichContentState: false,
103
- withAuxiliaryUserLabels: false,
104
- },
105
- });
106
- return parseTimeline(raw);
107
- },
86
+ export async function userMedia(userId, opts = {}) {
87
+ const raw = await this.graphql("UserMedia", {
88
+ variables: {
89
+ userId,
90
+ count: opts.count || 20,
91
+ cursor: opts.cursor,
92
+ includePromotedContent: false,
93
+ withClientEventToken: false,
94
+ withBirdwatchNotes: false,
95
+ withVoice: true,
96
+ withV2Timeline: true,
97
+ ...opts.variables,
98
+ },
99
+ fieldToggles: {
100
+ withArticlePlainText: false,
101
+ withArticleRichContentState: false,
102
+ withAuxiliaryUserLabels: false,
103
+ },
104
+ });
105
+ return parseTimeline(raw);
106
+ }
108
107
 
109
- async highlights(userId, opts = {}) {
110
- const raw = await client.graphql("UserHighlightsTweets", {
111
- variables: {
112
- userId,
113
- count: opts.count || 20,
114
- cursor: opts.cursor,
115
- includePromotedContent: true,
116
- withVoice: true,
117
- ...opts.variables,
118
- },
119
- fieldToggles: {
120
- withArticlePlainText: false,
121
- withArticleRichContentState: false,
122
- withAuxiliaryUserLabels: false,
123
- },
124
- });
125
- return parseTimeline(raw);
126
- },
108
+ export async function highlights(userId, opts = {}) {
109
+ const raw = await this.graphql("UserHighlightsTweets", {
110
+ variables: {
111
+ userId,
112
+ count: opts.count || 20,
113
+ cursor: opts.cursor,
114
+ includePromotedContent: true,
115
+ withVoice: true,
116
+ ...opts.variables,
117
+ },
118
+ fieldToggles: {
119
+ withArticlePlainText: false,
120
+ withArticleRichContentState: false,
121
+ withAuxiliaryUserLabels: false,
122
+ },
123
+ });
124
+ return parseTimeline(raw);
125
+ }
127
126
 
128
- async followers(userId, opts = {}) {
129
- const raw = await client.graphql("Followers", {
130
- variables: {
131
- userId,
132
- count: opts.count || 20,
133
- cursor: opts.cursor,
134
- includePromotedContent: false,
135
- },
136
- });
137
- return parseTimeline(raw);
138
- },
127
+ export async function followers(userId, opts = {}) {
128
+ const raw = await this.graphql("Followers", {
129
+ variables: {
130
+ userId,
131
+ count: opts.count || 20,
132
+ cursor: opts.cursor,
133
+ includePromotedContent: false,
134
+ },
135
+ });
136
+ return parseTimeline(raw);
137
+ }
139
138
 
140
- async following(userId, opts = {}) {
141
- const raw = await client.graphql("Following", {
142
- variables: {
143
- userId,
144
- count: opts.count || 20,
145
- cursor: opts.cursor,
146
- includePromotedContent: false,
147
- },
148
- });
149
- return parseTimeline(raw);
150
- },
139
+ export async function following(userId, opts = {}) {
140
+ const raw = await this.graphql("Following", {
141
+ variables: {
142
+ userId,
143
+ count: opts.count || 20,
144
+ cursor: opts.cursor,
145
+ includePromotedContent: false,
146
+ },
147
+ });
148
+ return parseTimeline(raw);
149
+ }
151
150
 
152
- async verifiedFollowers(userId, opts = {}) {
153
- const raw = await client.graphql("BlueVerifiedFollowers", {
154
- variables: {
155
- userId,
156
- count: opts.count || 20,
157
- cursor: opts.cursor,
158
- includePromotedContent: false,
159
- },
160
- });
161
- return parseTimeline(raw);
162
- },
151
+ export async function verifiedFollowers(userId, opts = {}) {
152
+ const raw = await this.graphql("BlueVerifiedFollowers", {
153
+ variables: {
154
+ userId,
155
+ count: opts.count || 20,
156
+ cursor: opts.cursor,
157
+ includePromotedContent: false,
158
+ },
159
+ });
160
+ return parseTimeline(raw);
161
+ }
163
162
 
164
- async followersYouKnow(userId, opts = {}) {
165
- const raw = await client.graphql("FollowersYouKnow", {
166
- variables: {
167
- userId,
168
- count: opts.count || 20,
169
- cursor: opts.cursor,
170
- includePromotedContent: false,
171
- },
172
- });
173
- return parseTimeline(raw);
174
- },
163
+ export async function followersYouKnow(userId, opts = {}) {
164
+ const raw = await this.graphql("FollowersYouKnow", {
165
+ variables: {
166
+ userId,
167
+ count: opts.count || 20,
168
+ cursor: opts.cursor,
169
+ includePromotedContent: false,
170
+ },
171
+ });
172
+ return parseTimeline(raw);
173
+ }
175
174
 
176
- async follow(userId) {
177
- const res = await client.v1_1("friendships/create", {
178
- body: JSON.stringify({ user_id: userId }),
179
- });
180
- const json = await res.json();
181
- return json ? parseUser(json) : res;
182
- },
175
+ export async function follow(userId) {
176
+ const res = await this.v1_1("friendships/create", {
177
+ body: JSON.stringify({ user_id: userId }),
178
+ });
179
+ const json = await res.json();
180
+ return json ? parseUser(json) : res;
181
+ }
183
182
 
184
- async unfollow(userId) {
185
- const res = await client.v1_1("friendships/destroy", {
186
- body: JSON.stringify({ user_id: userId }),
187
- });
188
- const json = await res.json();
189
- return json ? parseUser(json) : res;
190
- },
183
+ export async function unfollow(userId) {
184
+ const res = await this.v1_1("friendships/destroy", {
185
+ body: JSON.stringify({ user_id: userId }),
186
+ });
187
+ const json = await res.json();
188
+ return json ? parseUser(json) : res;
189
+ }
191
190
 
192
- async block(userId) {
193
- const res = await client.v1_1("blocks/create", {
194
- body: JSON.stringify({ user_id: userId }),
195
- });
196
- const json = await res.json();
197
- return json ? parseUser(json) : res;
198
- },
191
+ export async function block(userId) {
192
+ const res = await this.v1_1("blocks/create", {
193
+ body: JSON.stringify({ user_id: userId }),
194
+ });
195
+ const json = await res.json();
196
+ return json ? parseUser(json) : res;
197
+ }
199
198
 
200
- async unblock(userId) {
201
- const res = await client.v1_1("blocks/destroy", {
202
- body: JSON.stringify({ user_id: userId }),
203
- });
204
- const json = await res.json();
205
- return json ? parseUser(json) : res;
206
- },
199
+ export async function unblock(userId) {
200
+ const res = await this.v1_1("blocks/destroy", {
201
+ body: JSON.stringify({ user_id: userId }),
202
+ });
203
+ const json = await res.json();
204
+ return json ? parseUser(json) : res;
205
+ }
207
206
 
208
- async mute(userId) {
209
- const res = await client.v1_1("mutes/users/create", {
210
- body: JSON.stringify({ user_id: userId }),
211
- });
212
- const json = await res.json();
213
- return json ? parseUser(json) : res;
214
- },
207
+ export async function mute(userId) {
208
+ const res = await this.v1_1("mutes/users/create", {
209
+ body: JSON.stringify({ user_id: userId }),
210
+ });
211
+ const json = await res.json();
212
+ return json ? parseUser(json) : res;
213
+ }
215
214
 
216
- async unmute(userId) {
217
- const res = await client.v1_1("mutes/users/destroy", {
218
- body: JSON.stringify({ user_id: userId }),
219
- });
220
- const json = await res.json();
221
- return json ? parseUser(json) : res;
222
- },
215
+ export async function unmute(userId) {
216
+ const res = await this.v1_1("mutes/users/destroy", {
217
+ body: JSON.stringify({ user_id: userId }),
218
+ });
219
+ const json = await res.json();
220
+ return json ? parseUser(json) : res;
221
+ }
223
222
 
224
- async removeFollower(userId) {
225
- return await client.graphql("RemoveFollower", {
226
- body: { variables: { target_user_id: userId } },
227
- });
228
- },
223
+ export async function removeFollower(userId) {
224
+ return await this.graphql("RemoveFollower", {
225
+ body: { variables: { target_user_id: userId } },
226
+ });
227
+ }
229
228
 
230
- async blocked(opts = {}) {
231
- const raw = await client.graphql("BlockedAccountsAll", {
232
- variables: {
233
- count: opts.count || 20,
234
- cursor: opts.cursor,
235
- includePromotedContent: false,
236
- },
237
- });
238
- return parseTimeline(raw);
239
- },
229
+ export async function blocked(opts = {}) {
230
+ const raw = await this.graphql("BlockedAccountsAll", {
231
+ variables: {
232
+ count: opts.count || 20,
233
+ cursor: opts.cursor,
234
+ includePromotedContent: false,
235
+ },
236
+ });
237
+ return parseTimeline(raw);
238
+ }
240
239
 
241
- async muted(opts = {}) {
242
- const raw = await client.graphql("MutedAccounts", {
243
- variables: {
244
- count: opts.count || 20,
245
- cursor: opts.cursor,
246
- includePromotedContent: false,
247
- },
248
- });
249
- return parseTimeline(raw);
250
- },
240
+ export async function muted(opts = {}) {
241
+ const raw = await this.graphql("MutedAccounts", {
242
+ variables: {
243
+ count: opts.count || 20,
244
+ cursor: opts.cursor,
245
+ includePromotedContent: false,
246
+ },
247
+ });
248
+ return parseTimeline(raw);
249
+ }
251
250
 
252
- async lookup(params = {}) {
253
- const res = await client.v1_1("users/lookup", { params });
254
- return await res.json();
255
- },
251
+ export async function lookup(params = {}) {
252
+ const res = await this.v1_1("users/lookup", { params });
253
+ return await res.json();
254
+ }
256
255
 
257
- async updateProfile(params = {}) {
258
- const res = await client.v1_1("account/update_profile", {
259
- body: JSON.stringify(params),
260
- });
261
- const json = await res.json();
262
- return json ? parseUser(json) : res;
263
- },
256
+ export async function updateProfile(params = {}) {
257
+ const res = await this.v1_1("account/update_profile", {
258
+ body: JSON.stringify(params),
259
+ });
260
+ const json = await res.json();
261
+ return json ? parseUser(json) : res;
262
+ }
264
263
 
265
- async updateProfileImage(imageData) {
266
- const res = await client.v1_1("account/update_profile_image", {
267
- body: JSON.stringify({ image: imageData }),
268
- });
269
- return await res.json();
270
- },
264
+ export async function updateProfileImage(imageData) {
265
+ const res = await this.v1_1("account/update_profile_image", {
266
+ body: JSON.stringify({ image: imageData }),
267
+ });
268
+ return await res.json();
269
+ }
271
270
 
272
- async updateProfileBanner(bannerData) {
273
- const res = await client.v1_1("account/update_profile_banner", {
274
- body: JSON.stringify({ banner: bannerData }),
275
- });
276
- return await res.json();
277
- },
271
+ export async function updateProfileBanner(bannerData) {
272
+ const res = await this.v1_1("account/update_profile_banner", {
273
+ body: JSON.stringify({ banner: bannerData }),
274
+ });
275
+ return await res.json();
276
+ }
278
277
 
279
- async removeProfileBanner() {
280
- const res = await client.v1_1("account/remove_profile_banner", {});
281
- return await res.json();
282
- },
278
+ export async function removeProfileBanner() {
279
+ const res = await this.v1_1("account/remove_profile_banner", {});
280
+ return await res.json();
281
+ }
283
282
 
284
- async subscriptions(userId, opts = {}) {
285
- const raw = await client.graphql("UserCreatorSubscriptions", {
286
- variables: {
287
- userId,
288
- count: opts.count || 20,
289
- cursor: opts.cursor,
290
- },
291
- });
292
- return parseTimeline(raw);
293
- },
283
+ export async function subscriptions(userId, opts = {}) {
284
+ const raw = await this.graphql("UserCreatorSubscriptions", {
285
+ variables: {
286
+ userId,
287
+ count: opts.count || 20,
288
+ cursor: opts.cursor,
289
+ },
290
+ });
291
+ return parseTimeline(raw);
292
+ }
294
293
 
295
- async subscribers(userId, opts = {}) {
296
- const raw = await client.graphql("UserCreatorSubscribers", {
297
- variables: {
298
- userId,
299
- count: opts.count || 20,
300
- cursor: opts.cursor,
301
- },
302
- });
303
- return parseTimeline(raw);
304
- },
294
+ export async function subscribers(userId, opts = {}) {
295
+ const raw = await this.graphql("UserCreatorSubscribers", {
296
+ variables: {
297
+ userId,
298
+ count: opts.count || 20,
299
+ cursor: opts.cursor,
300
+ },
301
+ });
302
+ return parseTimeline(raw);
303
+ }
305
304
 
306
- async superFollowers(opts = {}) {
307
- const raw = await client.graphql("SuperFollowers", {
308
- variables: {
309
- count: opts.count || 20,
310
- cursor: opts.cursor,
311
- includePromotedContent: false,
312
- },
313
- });
314
- return parseTimeline(raw);
315
- },
305
+ export async function superFollowers(opts = {}) {
306
+ const raw = await this.graphql("SuperFollowers", {
307
+ variables: {
308
+ count: opts.count || 20,
309
+ cursor: opts.cursor,
310
+ includePromotedContent: false,
311
+ },
312
+ });
313
+ return parseTimeline(raw);
314
+ }
316
315
 
317
- async recommendations(params = {}) {
318
- const res = await client.v1_1("users/recommendations", { params });
319
- return await res.json();
320
- },
321
- });
316
+ export async function recommendations(params = {}) {
317
+ const res = await this.v1_1("users/recommendations", { params });
318
+ return await res.json();
319
+ }