emusks 2.0.4 → 2.0.5
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/build/graphql.js +5 -13
- package/package.json +1 -1
- package/src/graphql.js +34 -12
- package/src/helpers/account.js +267 -269
- package/src/helpers/bookmarks.js +101 -103
- package/src/helpers/communities.js +236 -238
- package/src/helpers/dms.js +129 -131
- package/src/helpers/index.js +50 -31
- package/src/helpers/lists.js +222 -224
- package/src/helpers/media.js +137 -139
- package/src/helpers/notifications.js +42 -44
- package/src/helpers/search.js +117 -119
- package/src/helpers/spaces.js +47 -49
- package/src/helpers/syndication.js +23 -25
- package/src/helpers/timelines.js +76 -78
- package/src/helpers/topics.js +87 -89
- package/src/helpers/trends.js +74 -76
- package/src/helpers/tweets.js +302 -304
- package/src/helpers/users.js +287 -289
- package/src/index.js +23 -19
- package/src/static/graphql.js +1 -1
package/src/helpers/users.js
CHANGED
|
@@ -1,321 +1,319 @@
|
|
|
1
1
|
import parseTimeline from "../parsers/timeline.js";
|
|
2
2
|
import parseUser from "../parsers/user.js";
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
});
|
|
316
|
+
export async function recommendations(params = {}) {
|
|
317
|
+
const res = await this.v1_1("users/recommendations", { params });
|
|
318
|
+
return await res.json();
|
|
319
|
+
}
|