rettiwt-api 1.0.6 → 1.0.7
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/dist/{queries → graphql/queries}/RootQuery.d.ts +0 -0
- package/dist/{queries → graphql/queries}/RootQuery.js +4 -3
- package/dist/graphql/queries/RootQuery.js.map +1 -0
- package/dist/{resolvers → graphql/resolvers}/AccountResolver.d.ts +1 -1
- package/dist/{resolvers → graphql/resolvers}/AccountResolver.js +0 -0
- package/dist/graphql/resolvers/AccountResolver.js.map +1 -0
- package/dist/{resolvers → graphql/resolvers}/ResolverBase.d.ts +1 -1
- package/dist/{resolvers → graphql/resolvers}/ResolverBase.js +0 -0
- package/dist/graphql/resolvers/ResolverBase.js.map +1 -0
- package/dist/{resolvers → graphql/resolvers}/TweetResolver.d.ts +10 -9
- package/dist/{resolvers → graphql/resolvers}/TweetResolver.js +51 -35
- package/dist/graphql/resolvers/TweetResolver.js.map +1 -0
- package/dist/{resolvers → graphql/resolvers}/UserResolver.d.ts +5 -4
- package/dist/{resolvers → graphql/resolvers}/UserResolver.js +51 -35
- package/dist/graphql/resolvers/UserResolver.js.map +1 -0
- package/dist/{models/graphql → graphql/types}/Global.d.ts +0 -0
- package/dist/{models/graphql → graphql/types}/Global.js +0 -0
- package/dist/graphql/types/Global.js.map +1 -0
- package/dist/graphql/types/TweetTypes.d.ts +4 -0
- package/dist/{models/graphql → graphql/types}/TweetTypes.js +5 -7
- package/dist/graphql/types/TweetTypes.js.map +1 -0
- package/dist/graphql/types/UserTypes.d.ts +3 -0
- package/dist/{models/graphql → graphql/types}/UserTypes.js +9 -11
- package/dist/graphql/types/UserTypes.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/server.js +3 -3
- package/dist/server.js.map +1 -1
- package/dist/services/AuthService.js +2 -2
- package/dist/services/AuthService.js.map +1 -1
- package/dist/services/CacheService.d.ts +3 -3
- package/dist/services/CacheService.js +22 -75
- package/dist/services/CacheService.js.map +1 -1
- package/dist/services/FetcherService.d.ts +3 -2
- package/dist/services/FetcherService.js +11 -29
- package/dist/services/FetcherService.js.map +1 -1
- package/dist/services/data/TweetService.d.ts +6 -6
- package/dist/services/data/TweetService.js +44 -27
- package/dist/services/data/TweetService.js.map +1 -1
- package/dist/services/data/UserAccountService.d.ts +3 -3
- package/dist/services/data/UserAccountService.js +22 -8
- package/dist/services/data/UserAccountService.js.map +1 -1
- package/dist/services/data/UserService.d.ts +42 -0
- package/dist/services/data/UserService.js +255 -0
- package/dist/services/data/UserService.js.map +1 -0
- package/dist/services/helper/Extractors.js +1 -1
- package/dist/services/helper/Extractors.js.map +1 -1
- package/dist/services/helper/Parser.d.ts +1 -1
- package/dist/services/helper/Parser.js +4 -3
- package/dist/services/helper/Parser.js.map +1 -1
- package/dist/services/helper/Urls.d.ts +2 -2
- package/dist/services/helper/Urls.js +19 -3
- package/dist/services/helper/Urls.js.map +1 -1
- package/dist/services/helper/deserializers/Tweets.d.ts +12 -0
- package/dist/services/helper/deserializers/Tweets.js +92 -0
- package/dist/services/helper/deserializers/Tweets.js.map +1 -0
- package/dist/services/{accounting/Flows.d.ts → helper/deserializers/User.d.ts} +0 -0
- package/dist/services/helper/deserializers/User.js +2 -0
- package/dist/services/helper/deserializers/User.js.map +1 -0
- package/dist/services/helper/deserializers/Users.d.ts +7 -0
- package/dist/services/helper/deserializers/Users.js +27 -0
- package/dist/services/helper/deserializers/Users.js.map +1 -0
- package/dist/services/helper/extractors/TweetExtractors.d.ts +0 -0
- package/dist/services/helper/extractors/TweetExtractors.js +2 -0
- package/dist/services/helper/extractors/TweetExtractors.js.map +1 -0
- package/dist/services/helper/extractors/Tweets.d.ts +32 -0
- package/dist/services/helper/extractors/Tweets.js +264 -0
- package/dist/services/helper/extractors/Tweets.js.map +1 -0
- package/dist/services/helper/extractors/UserExtractors.d.ts +45 -0
- package/dist/services/helper/extractors/UserExtractors.js +176 -0
- package/dist/services/helper/extractors/UserExtractors.js.map +1 -0
- package/dist/services/helper/extractors/Users.d.ts +20 -0
- package/dist/services/helper/extractors/Users.js +151 -0
- package/dist/services/helper/extractors/Users.js.map +1 -0
- package/dist/services/helper/urls/Authentication.d.ts +4 -0
- package/dist/services/helper/urls/Authentication.js +11 -0
- package/dist/services/helper/urls/Authentication.js.map +1 -0
- package/dist/services/helper/urls/Tweets.d.ts +32 -0
- package/dist/services/helper/urls/Tweets.js +51 -0
- package/dist/services/helper/urls/Tweets.js.map +1 -0
- package/dist/services/helper/urls/Urls.d.ts +4 -0
- package/dist/services/helper/urls/Urls.js +11 -0
- package/dist/services/helper/urls/Urls.js.map +1 -0
- package/dist/services/helper/urls/Users.d.ts +31 -0
- package/dist/services/helper/urls/Users.js +66 -0
- package/dist/services/helper/urls/Users.js.map +1 -0
- package/dist/types/{graphql/Errors.d.ts → Errors.d.ts} +0 -0
- package/dist/types/{graphql/Errors.js → Errors.js} +0 -0
- package/dist/types/Errors.js.map +1 -0
- package/dist/types/Resolvers.d.ts +9 -0
- package/dist/types/Resolvers.js +3 -0
- package/dist/types/Resolvers.js.map +1 -0
- package/dist/types/Tweet.d.ts +1 -0
- package/dist/types/Tweet.js.map +1 -1
- package/dist/types/User.d.ts +19 -0
- package/dist/types/User.js +4 -0
- package/dist/types/User.js.map +1 -0
- package/dist/types/data/Errors.d.ts +26 -0
- package/dist/types/data/Errors.js +36 -0
- package/dist/types/data/Errors.js.map +1 -0
- package/dist/types/data/Service.d.ts +29 -0
- package/dist/types/data/Service.js +19 -0
- package/dist/types/data/Service.js.map +1 -0
- package/dist/types/data/Tweet.d.ts +41 -0
- package/dist/types/data/Tweet.js +5 -0
- package/dist/types/data/Tweet.js.map +1 -0
- package/dist/types/data/User.d.ts +19 -0
- package/dist/types/data/User.js +4 -0
- package/dist/types/data/User.js.map +1 -0
- package/dist/types/raw/http/Error.d.ts +34 -0
- package/dist/types/raw/{user/Users.js → http/Error.js} +1 -1
- package/dist/types/raw/http/Error.js.map +1 -0
- package/dist/types/raw/http/Response.d.ts +34 -0
- package/dist/types/raw/http/Response.js +3 -0
- package/dist/types/raw/http/Response.js.map +1 -0
- package/package.json +1 -1
- package/src/{queries → graphql/queries}/RootQuery.ts +5 -4
- package/src/{resolvers → graphql/resolvers}/AccountResolver.ts +21 -21
- package/src/{resolvers → graphql/resolvers}/ResolverBase.ts +1 -1
- package/src/{resolvers → graphql/resolvers}/TweetResolver.ts +43 -30
- package/src/{resolvers → graphql/resolvers}/UserResolver.ts +41 -27
- package/src/{models/graphql → graphql/types}/Global.ts +0 -0
- package/src/{models/graphql → graphql/types}/TweetTypes.ts +9 -11
- package/src/{models/graphql → graphql/types}/UserTypes.ts +13 -15
- package/src/index.ts +2 -2
- package/src/server.ts +3 -3
- package/src/services/AuthService.ts +1 -1
- package/src/services/CacheService.ts +6 -8
- package/src/services/FetcherService.ts +11 -14
- package/src/services/data/TweetService.ts +53 -37
- package/src/services/data/UserService.ts +187 -0
- package/src/services/helper/Parser.ts +6 -4
- package/src/services/helper/{Deserializers.ts → deserializers/Tweets.ts} +3 -28
- package/src/services/helper/deserializers/Users.ts +26 -0
- package/src/services/helper/extractors/Tweets.ts +252 -0
- package/src/services/helper/extractors/Users.ts +137 -0
- package/src/services/helper/urls/Authentication.ts +6 -0
- package/src/services/helper/urls/Tweets.ts +46 -0
- package/src/services/helper/urls/Users.ts +62 -0
- package/src/types/Resolvers.ts +9 -0
- package/src/types/data/Errors.ts +28 -0
- package/src/types/{Service.ts → data/Service.ts} +4 -5
- package/src/types/{Tweet.ts → data/Tweet.ts} +1 -0
- package/src/types/{UserAccount.ts → data/User.ts} +0 -0
- package/tsconfig.json +2 -2
- package/dist/models/graphql/Global.js.map +0 -1
- package/dist/models/graphql/TweetTypes.d.ts +0 -6
- package/dist/models/graphql/TweetTypes.js.map +0 -1
- package/dist/models/graphql/UserTypes.d.ts +0 -3
- package/dist/models/graphql/UserTypes.js.map +0 -1
- package/dist/queries/RootQuery.js.map +0 -1
- package/dist/resolvers/AccountResolver.js.map +0 -1
- package/dist/resolvers/ResolverBase.js.map +0 -1
- package/dist/resolvers/TweetResolver.js.map +0 -1
- package/dist/resolvers/UserResolver.js.map +0 -1
- package/dist/services/AccountsService.d.ts +0 -17
- package/dist/services/AccountsService.js +0 -171
- package/dist/services/AccountsService.js.map +0 -1
- package/dist/services/accounting/AccountsService.d.ts +0 -20
- package/dist/services/accounting/AccountsService.js +0 -147
- package/dist/services/accounting/AccountsService.js.map +0 -1
- package/dist/services/accounting/Flows.js +0 -2
- package/dist/services/accounting/Flows.js.map +0 -1
- package/dist/services/accounting/LoginFlows.d.ts +0 -20
- package/dist/services/accounting/LoginFlows.js +0 -70
- package/dist/services/accounting/LoginFlows.js.map +0 -1
- package/dist/test/Test.js +0 -2
- package/dist/test/Test.js.map +0 -1
- package/dist/types/graphql/Errors.js.map +0 -1
- package/dist/types/raw/user/Users.d.ts +0 -120
- package/dist/types/raw/user/Users.js.map +0 -1
- package/src/services/data/UserAccountService.ts +0 -176
- package/src/services/helper/Extractors.ts +0 -455
- package/src/services/helper/Urls.ts +0 -109
- package/src/types/graphql/Errors.ts +0 -16
- package/src/types/raw/user/Tweets.ts +0 -2847
|
@@ -1,455 +0,0 @@
|
|
|
1
|
-
// TYPES
|
|
2
|
-
import { DataErrors } from '../../types/graphql/Errors';
|
|
3
|
-
import RawUser from '../../types/raw/user/User';
|
|
4
|
-
import RawUserFollowers from '../../types/raw/user/Followers';
|
|
5
|
-
import RawUserFollowing from '../../types/raw/user/Following';
|
|
6
|
-
import RawUserLikes from '../../types/raw/user/Likes';
|
|
7
|
-
import RawUserTweets from '../../types/raw/user/Tweets';
|
|
8
|
-
import RawTweet from '../../types/raw/tweet/Tweet';
|
|
9
|
-
import RawTweets from '../../types/raw/tweet/Tweets';
|
|
10
|
-
import RawLikers from '../../types/raw/tweet/Favouriters';
|
|
11
|
-
import RawRetweeters from '../../types/raw/tweet/Retweeters';
|
|
12
|
-
|
|
13
|
-
// PARSERS
|
|
14
|
-
import * as Parsers from './Parser';
|
|
15
|
-
|
|
16
|
-
/* USERS */
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @returns The raw user account data formatted and sorted into required and additional data
|
|
20
|
-
* @param res The raw response received from Twitter
|
|
21
|
-
*/
|
|
22
|
-
export function extractUserAccountDetails(res: RawUser): {
|
|
23
|
-
required: any[],
|
|
24
|
-
cursor: string,
|
|
25
|
-
users: any[],
|
|
26
|
-
tweets: any[]
|
|
27
|
-
} {
|
|
28
|
-
let required: any[] = []; // To store the reqruied raw data
|
|
29
|
-
let cursor: string = ''; // To store the cursor to next batch
|
|
30
|
-
let users: any[] = []; // To store additional user data
|
|
31
|
-
let tweets: any[] = []; // To store additional tweet data
|
|
32
|
-
|
|
33
|
-
// If user not found or account suspended
|
|
34
|
-
if (Parsers.isJSONEmpty(res.data) || Parsers.isJSONEmpty(res.data.user) || res.data.user.result.__typename !== 'User') {
|
|
35
|
-
throw new Error(DataErrors.UserNotFound);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Destructuring user account data
|
|
39
|
-
required.push(res.data.user.result);
|
|
40
|
-
users.push(res.data.user.result);
|
|
41
|
-
|
|
42
|
-
// Returning the data
|
|
43
|
-
return {
|
|
44
|
-
required: required,
|
|
45
|
-
cursor: cursor,
|
|
46
|
-
users: users,
|
|
47
|
-
tweets: tweets
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @returns The raw user following/followers data formatted and sorted into required and additional data
|
|
53
|
-
* @param res The raw response received from TwitterAPI
|
|
54
|
-
*/
|
|
55
|
-
export function extractUserFollow(res: RawUserFollowers | RawUserFollowing): {
|
|
56
|
-
required: any[],
|
|
57
|
-
cursor: string,
|
|
58
|
-
users: any[],
|
|
59
|
-
tweets: any[]
|
|
60
|
-
} {
|
|
61
|
-
let required: any[] = []; // To store the reqruied raw data
|
|
62
|
-
let cursor: string = ''; // To store the cursor to next batch
|
|
63
|
-
let users: any[] = []; // To store additional user data
|
|
64
|
-
let tweets: any[] = []; // To store additional tweet data
|
|
65
|
-
|
|
66
|
-
// If user does not exist
|
|
67
|
-
if (Parsers.isJSONEmpty(res.data.user)) {
|
|
68
|
-
throw new Error(DataErrors.UserNotFound);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Extracting the raw list
|
|
72
|
-
res.data.user.result.timeline.timeline.instructions.forEach(item => {
|
|
73
|
-
if (item.type === 'TimelineAddEntries') {
|
|
74
|
-
// Destructuring data
|
|
75
|
-
item.entries?.forEach(entry => {
|
|
76
|
-
// If entry is of type user and user account exists
|
|
77
|
-
if (entry.entryId.indexOf('user') != -1 && entry.content.itemContent?.user_results.result.__typename ==='User') {
|
|
78
|
-
required.push(entry.content.itemContent.user_results.result);
|
|
79
|
-
users.push(entry.content.itemContent.user_results.result);
|
|
80
|
-
}
|
|
81
|
-
// If entry is of type cursor
|
|
82
|
-
else if (entry.entryId.indexOf('cursor-bottom') != -1) {
|
|
83
|
-
cursor = entry.content.value ?? '';
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// Returning the data
|
|
90
|
-
return {
|
|
91
|
-
required: required,
|
|
92
|
-
cursor: cursor,
|
|
93
|
-
users: users,
|
|
94
|
-
tweets: tweets
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* @returns The raw user likes data formatted and sorted into required and additional data
|
|
100
|
-
* @param res The raw response received from TwitterAPI
|
|
101
|
-
*/
|
|
102
|
-
export function extractUserLikes(res: RawUserLikes): {
|
|
103
|
-
required: any[],
|
|
104
|
-
cursor: string,
|
|
105
|
-
users: any[],
|
|
106
|
-
tweets: any[]
|
|
107
|
-
} {
|
|
108
|
-
let required: any[] = []; // To store the reqruied raw data
|
|
109
|
-
let cursor: string = ''; // To store the cursor to next batch
|
|
110
|
-
let users: any[] = []; // To store additional user data
|
|
111
|
-
let tweets: any[] = []; // To store additional tweet data
|
|
112
|
-
|
|
113
|
-
// If user does not exist
|
|
114
|
-
if (Parsers.isJSONEmpty(res.data.user)) {
|
|
115
|
-
throw new Error(DataErrors.UserNotFound);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Extracting the raw list
|
|
119
|
-
res.data.user.result.timeline_v2.timeline.instructions.forEach(item => {
|
|
120
|
-
if (item.type === 'TimelineAddEntries') {
|
|
121
|
-
// Destructuring data
|
|
122
|
-
item.entries.forEach(entry => {
|
|
123
|
-
// If entry is of type tweet and tweet exists
|
|
124
|
-
if (entry.entryId.indexOf('tweet') != -1 && entry.content.itemContent?.tweet_results.result.__typename === 'Tweet') {
|
|
125
|
-
required.push(entry.content.itemContent.tweet_results.result);
|
|
126
|
-
users.push(entry.content.itemContent.tweet_results.result.core.user_results.result);
|
|
127
|
-
tweets.push(entry.content.itemContent.tweet_results.result);
|
|
128
|
-
}
|
|
129
|
-
// If entry is of type cursor
|
|
130
|
-
else if (entry.entryId.indexOf('cursor-bottom') != -1) {
|
|
131
|
-
cursor = entry.content.value ?? '';
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// Returning the data
|
|
138
|
-
return {
|
|
139
|
-
required: required,
|
|
140
|
-
cursor: cursor,
|
|
141
|
-
users: users,
|
|
142
|
-
tweets: tweets
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* @returns The raw tweets data formatted and sorted into required and additional data
|
|
148
|
-
* @param res The raw response received from TwitterAPI
|
|
149
|
-
*/
|
|
150
|
-
export function extractUserTweets(res: RawUserTweets): {
|
|
151
|
-
required: any[],
|
|
152
|
-
cursor: string,
|
|
153
|
-
users: any[],
|
|
154
|
-
tweets: any[]
|
|
155
|
-
} {
|
|
156
|
-
let required: any[] = []; // To store the reqruied raw data
|
|
157
|
-
let cursor: string = ''; // To store the cursor to next batch
|
|
158
|
-
let users: any[] = []; // To store additional user data
|
|
159
|
-
let tweets: any[] = []; // To store additional tweet data
|
|
160
|
-
|
|
161
|
-
// Getting the raw tweet list
|
|
162
|
-
let dataTweets = res.data.user.result.timeline_v2.timeline.instructions.filter(item => item.type === 'TimelineAddEntries')[0].entries;
|
|
163
|
-
|
|
164
|
-
// Destructuring tweets, if not empty
|
|
165
|
-
if (!Parsers.isJSONEmpty(dataTweets)) {
|
|
166
|
-
// Iterating through the json array of tweets
|
|
167
|
-
for (let entry of dataTweets) {
|
|
168
|
-
// If the entry is a tweet
|
|
169
|
-
if(entry.entryId.indexOf('tweet') != -1) {
|
|
170
|
-
required.push(entry.content.itemContent?.tweet_results.result);
|
|
171
|
-
tweets.push(entry.content.itemContent?.tweet_results.result);
|
|
172
|
-
users.push(entry.content.itemContent?.tweet_results.result.core.user_results.result);
|
|
173
|
-
}
|
|
174
|
-
// If the entry is a cursor
|
|
175
|
-
else if(entry.entryId.indexOf('cursor-bottom') != -1) {
|
|
176
|
-
cursor = entry.content.value as string;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return {
|
|
182
|
-
required: required,
|
|
183
|
-
cursor: cursor,
|
|
184
|
-
users: users,
|
|
185
|
-
tweets: tweets
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/* TWEETS */
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* @returns The raw tweets data formatted and sorted into required and additional data
|
|
193
|
-
* @param res The raw response received from TwitterAPI
|
|
194
|
-
*/
|
|
195
|
-
export function extractTweets(res: RawTweets): {
|
|
196
|
-
required: any[],
|
|
197
|
-
cursor: string,
|
|
198
|
-
users: any[],
|
|
199
|
-
tweets: any[]
|
|
200
|
-
} {
|
|
201
|
-
let required: any[] = []; // To store the reqruied raw data
|
|
202
|
-
let cursor: string = ''; // To store the cursor to next batch
|
|
203
|
-
let users: any[] = []; // To store additional user data
|
|
204
|
-
let tweets: any[] = []; // To store additional tweet data
|
|
205
|
-
|
|
206
|
-
// Getting raw tweet list
|
|
207
|
-
let dataTweets = res.globalObjects.tweets;
|
|
208
|
-
|
|
209
|
-
// Getting raw users list
|
|
210
|
-
let dataUsers = res.globalObjects.users;
|
|
211
|
-
|
|
212
|
-
// Destructuring tweets, if not empty
|
|
213
|
-
if (!Parsers.isJSONEmpty(dataTweets)) {
|
|
214
|
-
// Iterating through the json array of tweets
|
|
215
|
-
for (let key of Object.keys(dataTweets)) {
|
|
216
|
-
required.push({ rest_id: dataTweets[key].id_str, legacy: dataTweets[key] });
|
|
217
|
-
tweets.push({ rest_id: dataTweets[key].id_str, legacy: dataTweets[key] });
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Destructuring users, if not empty
|
|
222
|
-
if (!Parsers.isJSONEmpty(dataUsers)) {
|
|
223
|
-
// Iterating through the json array of users
|
|
224
|
-
for (let key of Object.keys(dataUsers)) {
|
|
225
|
-
users.push({ rest_id: dataUsers[key].id_str, legacy: dataUsers[key] });
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// Getting the cursor to next batch
|
|
230
|
-
// If not first batch
|
|
231
|
-
if (res.timeline.instructions.length > 2) {
|
|
232
|
-
cursor = res.timeline.instructions[2]?.replaceEntry.entry.content.operation?.cursor.value ?? '';
|
|
233
|
-
}
|
|
234
|
-
// If first batch
|
|
235
|
-
else {
|
|
236
|
-
cursor = res.timeline.instructions[0].addEntries?.entries.filter(item => item.entryId.indexOf('cursor-bottom') != -1)[0].content.operation?.cursor.value ?? '';
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// Returning the data
|
|
240
|
-
return {
|
|
241
|
-
required: required,
|
|
242
|
-
cursor: cursor,
|
|
243
|
-
users: users,
|
|
244
|
-
tweets: tweets
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* @returns The raw tweet data formatted and sorted into required and additional data
|
|
250
|
-
* @param res The raw response received from TwitterAPI
|
|
251
|
-
* @param tweetId The rest id of the tweet to fetch
|
|
252
|
-
*/
|
|
253
|
-
export function extractTweet(res: RawTweet, tweetId: string): {
|
|
254
|
-
required: any[],
|
|
255
|
-
cursor: string,
|
|
256
|
-
users: any[],
|
|
257
|
-
tweets: any[]
|
|
258
|
-
} {
|
|
259
|
-
let required: any[] = []; // To store the reqruied raw data
|
|
260
|
-
let cursor: string = ''; // To store the cursor to next batch
|
|
261
|
-
let users: any[] = []; // To store additional user data
|
|
262
|
-
let tweets: any[] = []; // To store additional tweet data
|
|
263
|
-
|
|
264
|
-
// If tweet does not exist
|
|
265
|
-
if (Parsers.isJSONEmpty(res.data)) {
|
|
266
|
-
throw new Error(DataErrors.TweetNotFound);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// Destructuring the received raw data
|
|
270
|
-
res.data.threaded_conversation_with_injections_v2.instructions.filter(item => item['type'] === 'TimelineAddEntries')[0].entries?.forEach(entry => {
|
|
271
|
-
// If entry is of type tweet and tweet exists
|
|
272
|
-
if (entry.entryId.indexOf('tweet') != -1 && entry.content.itemContent?.tweet_results?.result.__typename === 'Tweet') {
|
|
273
|
-
// If this is the required tweet
|
|
274
|
-
if (entry.entryId.indexOf(tweetId) != -1) {
|
|
275
|
-
required.push(entry.content.itemContent.tweet_results.result);
|
|
276
|
-
}
|
|
277
|
-
tweets.push(entry.content.itemContent.tweet_results.result);
|
|
278
|
-
users.push(entry.content.itemContent.tweet_results.result.core.user_results.result);
|
|
279
|
-
}
|
|
280
|
-
// If entry if of type conversation
|
|
281
|
-
else if (entry.entryId.indexOf('conversationthread') != -1) {
|
|
282
|
-
// Iterating over the conversation
|
|
283
|
-
entry.content.items?.forEach(item => {
|
|
284
|
-
// If item is of type tweet and tweet exists
|
|
285
|
-
if (item.entryId.indexOf('tweet') != -1 && item.item.itemContent.tweet_results?.result.__typename === 'Tweet') {
|
|
286
|
-
required.push(item.item.itemContent.tweet_results.result);
|
|
287
|
-
tweets.push(item.item.itemContent.tweet_results.result);
|
|
288
|
-
users.push(item.item.itemContent.tweet_results.result.core.user_results.result);
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
// Returning the data
|
|
295
|
-
return {
|
|
296
|
-
required: required,
|
|
297
|
-
cursor: cursor,
|
|
298
|
-
users: users,
|
|
299
|
-
tweets: tweets
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* @returns The raw tweet likers data formatted and sorted into required and additional data
|
|
305
|
-
* @param res The raw response received from TwitterAPI
|
|
306
|
-
*/
|
|
307
|
-
export function extractTweetLikers(res: RawLikers): {
|
|
308
|
-
required: any[],
|
|
309
|
-
cursor: string,
|
|
310
|
-
users: any[],
|
|
311
|
-
tweets: any[]
|
|
312
|
-
} {
|
|
313
|
-
let required: any[] = []; // To store the reqruied raw data
|
|
314
|
-
let cursor: string = ''; // To store the cursor to next batch
|
|
315
|
-
let users: any[] = []; // To store additional user data
|
|
316
|
-
let tweets: any[] = []; // To store additional tweet data
|
|
317
|
-
|
|
318
|
-
// If tweet does not exist
|
|
319
|
-
if (Parsers.isJSONEmpty(res.data.favoriters_timeline)) {
|
|
320
|
-
throw new Error(DataErrors.TweetNotFound);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// Destructuring raw list of likers
|
|
324
|
-
res.data.favoriters_timeline.timeline.instructions.filter(item => item.type === 'TimelineAddEntries')[0].entries.forEach(entry => {
|
|
325
|
-
// If entry is of type user and user exists
|
|
326
|
-
if (entry.entryId.indexOf('user') != -1 && entry.content.itemContent?.user_results.result.__typename === 'User') {
|
|
327
|
-
required.push(entry.content.itemContent.user_results.result);
|
|
328
|
-
users.push(entry.content.itemContent.user_results.result);
|
|
329
|
-
}
|
|
330
|
-
// If entry is of type cursor
|
|
331
|
-
else if (entry.entryId.indexOf('cursor-bottom') != -1) {
|
|
332
|
-
cursor = entry.content.value ?? '';
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
// Returning the data
|
|
337
|
-
return {
|
|
338
|
-
required: required,
|
|
339
|
-
cursor: cursor,
|
|
340
|
-
users: users,
|
|
341
|
-
tweets: tweets
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* @returns The raw tweet retweeters data formatted and sorted into required and additional data
|
|
347
|
-
* @param res The raw response received from TwitterAPI
|
|
348
|
-
*/
|
|
349
|
-
export function extractTweetRetweeters(res: RawRetweeters): {
|
|
350
|
-
required: any[],
|
|
351
|
-
cursor: string,
|
|
352
|
-
users: any[],
|
|
353
|
-
tweets: any[]
|
|
354
|
-
} {
|
|
355
|
-
let required: any[] = []; // To store the reqruied raw data
|
|
356
|
-
let cursor: string = ''; // To store the cursor to next batch
|
|
357
|
-
let users: any[] = []; // To store additional user data
|
|
358
|
-
let tweets: any[] = []; // To store additional tweet data
|
|
359
|
-
|
|
360
|
-
// If tweet does not exist
|
|
361
|
-
if (Parsers.isJSONEmpty(res.data.retweeters_timeline)) {
|
|
362
|
-
throw new Error(DataErrors.TweetNotFound);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// Destructuring raw list of retweeters
|
|
366
|
-
res.data.retweeters_timeline.timeline.instructions.filter(item => item.type === 'TimelineAddEntries')[0].entries.forEach(entry => {
|
|
367
|
-
// If entry is of type user and user exists
|
|
368
|
-
if (entry.entryId.indexOf('user') != -1 && entry.content.itemContent?.user_results.result.__typename === 'User') {
|
|
369
|
-
required.push(entry.content.itemContent.user_results.result);
|
|
370
|
-
users.push(entry.content.itemContent.user_results.result);
|
|
371
|
-
}
|
|
372
|
-
// If entry is of type cursor
|
|
373
|
-
else if (entry.entryId.indexOf('cursor-bottom') != -1) {
|
|
374
|
-
cursor = entry.content.value ?? '';
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
// Returning the data
|
|
379
|
-
return {
|
|
380
|
-
required: required,
|
|
381
|
-
cursor: cursor,
|
|
382
|
-
users: users,
|
|
383
|
-
tweets: tweets
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* @returns The raw tweet replies data formatted and sorted into required and additional data
|
|
389
|
-
* @param res The raw response received from TwitterAPI
|
|
390
|
-
* @param tweetId The id of the tweet whose replies must be extracted
|
|
391
|
-
*/
|
|
392
|
-
export function extractTweetReplies(res: RawTweet, tweetId: string): {
|
|
393
|
-
required: any[],
|
|
394
|
-
cursor: string,
|
|
395
|
-
users: any[],
|
|
396
|
-
tweets: any[]
|
|
397
|
-
} {
|
|
398
|
-
let required: any[] = []; // To store the reqruied raw data
|
|
399
|
-
let cursor: string = ''; // To store the cursor to next batch
|
|
400
|
-
let users: any[] = []; // To store additional user data
|
|
401
|
-
let tweets: any[] = []; // To store additional tweet data
|
|
402
|
-
|
|
403
|
-
// If tweet does not exist
|
|
404
|
-
if (Parsers.isJSONEmpty(res.data)) {
|
|
405
|
-
throw new Error(DataErrors.TweetNotFound);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// Destructuring the received raw data
|
|
409
|
-
//@ts-ignore
|
|
410
|
-
res.data.threaded_conversation_with_injections.instructions.filter(item => item.type === 'TimelineAddEntries')[0].entries.map(entry => {
|
|
411
|
-
// If entry is of type tweet
|
|
412
|
-
if (entry.entryId.indexOf('tweet') != -1) {
|
|
413
|
-
// If tweet exists
|
|
414
|
-
if(entry.content.itemContent?.tweet_results?.result.__typename === 'Tweet') {
|
|
415
|
-
tweets.push(entry.content.itemContent.tweet_results.result);
|
|
416
|
-
users.push(entry.content.itemContent.tweet_results.result.core.user_results.result);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
// If entry if of type conversation/reply
|
|
420
|
-
else if (entry.entryId.indexOf('conversationthread') != -1) {
|
|
421
|
-
// If tweet exists
|
|
422
|
-
if(entry.content.items?.at(0)?.item.itemContent.tweet_results?.result.__typename === 'Tweet') {
|
|
423
|
-
// Adding the 1st entry, which is a reply, to required list
|
|
424
|
-
required.push(entry.content.items[0].item.itemContent.tweet_results?.result);
|
|
425
|
-
tweets.push(entry.content.items[0].item.itemContent.tweet_results?.result);
|
|
426
|
-
users.push(entry.content.items[0].item.itemContent.tweet_results?.result.core.user_results.result);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// Iterating over the rest of the conversation
|
|
430
|
-
//@ts-ignore
|
|
431
|
-
entry.content.items.forEach(item => {
|
|
432
|
-
// If item is of type tweet
|
|
433
|
-
if (item.entryId.indexOf('tweet') != -1) {
|
|
434
|
-
// If tweet exists
|
|
435
|
-
if(item.item.itemContent.tweet_results?.result.__typename === 'Tweet') {
|
|
436
|
-
tweets.push(item.item.itemContent.tweet_results.result);
|
|
437
|
-
users.push(item.item.itemContent.tweet_results.result.core.user_results.result);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
// If entry is of type bottom cursor
|
|
443
|
-
else if (entry.entryId.indexOf('cursor-bottom') != -1) {
|
|
444
|
-
cursor = entry.content.itemContent?.value ?? '';
|
|
445
|
-
}
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
// Returning the data
|
|
449
|
-
return {
|
|
450
|
-
required: required,
|
|
451
|
-
cursor: cursor,
|
|
452
|
-
users: users,
|
|
453
|
-
tweets: tweets
|
|
454
|
-
};
|
|
455
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @returns The url for fetching a guest token
|
|
3
|
-
*/
|
|
4
|
-
export function guestTokenUrl(): string {
|
|
5
|
-
return `https://api.twitter.com/1.1/guest/activate.json`;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @returns The url for fetching user account details.
|
|
10
|
-
* @param screenName The screen name of the target user
|
|
11
|
-
*/
|
|
12
|
-
export function userAccountUrl(screenName: string): string {
|
|
13
|
-
return `https://api.twitter.com/graphql/hVhfo_TquFTmgL7gYwf91Q/UserByScreenName?variables=%7B%22screen_name%22%3A%22${screenName}%22%2C%22withSafetyModeUserFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%7D`
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @returns The url for fetching user account details.
|
|
18
|
-
* @param restid The restId of the target user
|
|
19
|
-
*/
|
|
20
|
-
export function userAccountByIdUrl(restId: string): string {
|
|
21
|
-
return `https://api.twitter.com/graphql/mi_IjXgFyr41N9zkszPz9w/UserByRestId?variables=%7B%22userId%22%3A%22${restId}%22%2C%22withSafetyModeUserFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%7D`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @returns The url for fetching the list of users followed bu target user.
|
|
26
|
-
* @param userId The rest id of the target user
|
|
27
|
-
* @param count The batch size of the list of following
|
|
28
|
-
* @param cursor The cursor to next batch
|
|
29
|
-
*/
|
|
30
|
-
export function userFollowingUrl(userId: string, count: number, cursor: string): string {
|
|
31
|
-
return `https://api.twitter.com/graphql/mSnjZc5CTm2Z5Lu_i4XsPQ/Following?variables=%7B%22userId%22%3A%22${userId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22includePromotedContent%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @return The url for fetching the list of followers of the target user
|
|
36
|
-
* @param userId The rest id of the target user
|
|
37
|
-
* @param count The batch size for the list of followers
|
|
38
|
-
* @param cursor The cusor to next batch
|
|
39
|
-
*/
|
|
40
|
-
export function userFollowersUrl(userId: string, count: number, cursor: string): string {
|
|
41
|
-
return `https://api.twitter.com/graphql/nwlAnaw7oKXcVLi91ehy7Q/Followers?variables=%7B%22userId%22%3A%22${userId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22includePromotedContent%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @returns The url for fetching the list of tweets liked by the target user
|
|
46
|
-
* @param userId The rest id of the target user
|
|
47
|
-
* @param count The batch size for the list of tweets
|
|
48
|
-
* @param cursor The cusor to next batch
|
|
49
|
-
*/
|
|
50
|
-
export function userLikesUrl(userId: string, count: number, cursor: string): string {
|
|
51
|
-
return `https://api.twitter.com/graphql/gP4ZKghLd4tpILgS6VudAQ/Likes?variables=%7B%22userId%22%3A%22${userId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22includePromotedContent%22%3Afalse%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withClientEventToken%22%3Afalse%2C%22withBirdwatchNotes%22%3Afalse%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @returns The url for fetching the list of tweets made by the target user
|
|
56
|
-
* @param userId The rest id of the target user
|
|
57
|
-
* @param count The batch size for the list of tweets
|
|
58
|
-
* @param cursor The cursor to next batch
|
|
59
|
-
*/
|
|
60
|
-
export function userTweetsUrl(userId: string, count: number, cursor: string): string {
|
|
61
|
-
return `https://api.twitter.com/graphql/MsEBEnQjKQCsRlAbC6qKcA/UserTweets?variables=%7B%22userId%22%3A%22${userId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22includePromotedContent%22%3Atrue%2C%22withQuickPromoteEligibilityTweetFields%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @returns The url for fetching the list of tweets matching the given filter
|
|
66
|
-
* @param query The query to be used for searching tweets
|
|
67
|
-
* @param count The number of tweets to fetch
|
|
68
|
-
* @param cursor The cusor to next batch *
|
|
69
|
-
*/
|
|
70
|
-
export function tweetsUrl(query: string, count: number, cursor: string): string {
|
|
71
|
-
return `https://api.twitter.com/2/search/adaptive.json?include_want_retweets=1&include_quote_count=true&include_reply_count=1&tweet_mode=extended&include_entities=true&include_user_entities=true&simple_quoted_tweet=true&q=${query}&tweet_search_mode=live&count=${count}&query_source=typed_query&cursor=${encodeURIComponent(cursor)}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @returns The url for fetching the details of a given tweet
|
|
76
|
-
* @param tweetId The rest id of the target tweet
|
|
77
|
-
*/
|
|
78
|
-
export function tweetDetailsUrl(tweetId: string): string {
|
|
79
|
-
return `https://api.twitter.com/graphql/lXI2kaM2hgmbf7h42kpxuA/TweetDetail?variables=%7B%22focalTweetId%22%3A%22${tweetId}%22%2C%22referrer%22%3A%22profile%22%2C%22with_rux_injections%22%3Afalse%2C%22includePromotedContent%22%3Atrue%2C%22withCommunity%22%3Atrue%2C%22withQuickPromoteEligibilityTweetFields%22%3Atrue%2C%22withBirdwatchNotes%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @returns The url for fetching the list of replies to a given tweet
|
|
84
|
-
* @param tweetId The rest of the target tweet
|
|
85
|
-
* @param cursor The curor to next batch
|
|
86
|
-
*/
|
|
87
|
-
export function tweetRepliesUrl(tweetId: string, cursor: string): string {
|
|
88
|
-
return `https://api.twitter.com/graphql/lXI2kaM2hgmbf7h42kpxuA/TweetDetail?variables=%7B%22focalTweetId%22%3A%22${tweetId}%22%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22referrer%22%3A%22tweet%22%2C%22with_rux_injections%22%3Afalse%2C%22includePromotedContent%22%3Atrue%2C%22withCommunity%22%3Atrue%2C%22withQuickPromoteEligibilityTweetFields%22%3Atrue%2C%22withBirdwatchNotes%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @returns The url for fetching the list of users who liked a given tweet
|
|
93
|
-
* @param tweetId The rest id of the target tweet
|
|
94
|
-
* @param count The batch size of the list of users
|
|
95
|
-
* @param cursor The curor to next batch
|
|
96
|
-
*/
|
|
97
|
-
export function tweetLikesUrl(tweetId: string, count: number, cursor: string): string {
|
|
98
|
-
return `https://api.twitter.com/graphql/56ZwFC3Vui31fF8IYX8EGA/Favoriters?variables=%7B%22tweetId%22%3A%22${tweetId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22includePromotedContent%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @returns The url for fetching the list of user who retweeted the given tweet
|
|
103
|
-
* @param tweetId The rest id of the target tweet
|
|
104
|
-
* @param count The batch size of the list of users
|
|
105
|
-
* @param cursor The curor to next batch
|
|
106
|
-
*/
|
|
107
|
-
export function tweetRetweetUrl(tweetId: string, count: number, cursor: string): string {
|
|
108
|
-
return `https://api.twitter.com/graphql/Wd7DVeLqMj_JQiTL0tjJwQ/Retweeters?variables=%7B%22tweetId%22%3A%22${tweetId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${encodeURIComponent(cursor)}%22%2C%22includePromotedContent%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Atrue%2C%22withDownvotePerspective%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Atrue%7D&features=%7B%22responsive_web_twitter_blue_verified_badge_is_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22view_counts_public_visibility_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_uc_gql_enabled%22%3Atrue%2C%22vibe_api_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Afalse%2C%22interactive_text_enabled%22%3Atrue%2C%22responsive_web_text_conversations_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D`;
|
|
109
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @summary Collection of different types of validation errors
|
|
3
|
-
*/
|
|
4
|
-
export enum ValidationErrors {
|
|
5
|
-
InvalidTweetFilter = "Atleast one of fromUsers/toUsers/mentions/hashtags/words argument is required",
|
|
6
|
-
NoUserIdentification = "Either userName or id must be given"
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @summary Stores all the different type of error messages that are returned by services
|
|
11
|
-
*/
|
|
12
|
-
export enum DataErrors {
|
|
13
|
-
UserNotFound = "An account with given username/id was not found",
|
|
14
|
-
TweetNotFound = "A tweet with the given id was not found",
|
|
15
|
-
NoTweetsFound = "No tweets matching the given criteria found"
|
|
16
|
-
};
|