rettiwt-api 1.2.0 → 1.3.1
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/enums/Errors.d.ts +2 -1
- package/dist/enums/Errors.js +1 -0
- package/dist/enums/Errors.js.map +1 -1
- package/dist/graphql/queries/RootQuery.js.map +1 -1
- package/dist/graphql/resolvers/TweetResolver.d.ts +5 -5
- package/dist/graphql/resolvers/TweetResolver.js +4 -4
- package/dist/graphql/resolvers/TweetResolver.js.map +1 -1
- package/dist/graphql/types/UserTypes.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/models/args/TweetListArgs.js +2 -2
- package/dist/models/args/TweetListArgs.js.map +1 -1
- package/dist/models/args/UserListArgs.js +2 -2
- package/dist/models/args/UserListArgs.js.map +1 -1
- package/dist/models/data/Tweet.d.ts +3 -3
- package/dist/models/data/Tweet.js.map +1 -1
- package/dist/models/data/User.d.ts +2 -2
- package/dist/models/data/User.js.map +1 -1
- package/dist/services/data/TweetService.d.ts +2 -2
- package/dist/services/data/TweetService.js +8 -9
- package/dist/services/data/TweetService.js.map +1 -1
- package/dist/services/data/UserService.js +12 -22
- package/dist/services/data/UserService.js.map +1 -1
- package/dist/services/helper/Headers.js +20 -20
- package/dist/services/helper/Headers.js.map +1 -1
- package/dist/services/helper/extractors/Tweets.d.ts +5 -14
- package/dist/services/helper/extractors/Tweets.js +25 -89
- package/dist/services/helper/extractors/Tweets.js.map +1 -1
- package/dist/services/helper/extractors/Users.d.ts +4 -13
- package/dist/services/helper/extractors/Users.js +1 -53
- package/dist/services/helper/extractors/Users.js.map +1 -1
- package/dist/services/util/FetcherService.d.ts +3 -3
- package/dist/services/util/FetcherService.js +10 -22
- package/dist/services/util/FetcherService.js.map +1 -1
- package/dist/types/Args.d.ts +0 -27
- package/dist/types/Args.js +0 -1
- package/dist/types/Args.js.map +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/AccountService.html +17 -17
- package/docs/classes/AuthCookie.html +7 -7
- package/docs/classes/AuthService.html +7 -7
- package/docs/classes/CacheService.html +7 -7
- package/docs/classes/Cursor.html +3 -3
- package/docs/classes/CursoredData.html +4 -4
- package/docs/classes/DataValidationError.html +24 -23
- package/docs/classes/FetcherService.html +15 -15
- package/docs/classes/Tweet.html +16 -16
- package/docs/classes/TweetEntities.html +8 -8
- package/docs/classes/TweetFilter.html +58 -56
- package/docs/classes/TweetListArgs.html +4 -4
- package/docs/classes/TweetService.html +15 -15
- package/docs/classes/User.html +18 -18
- package/docs/classes/UserListArgs.html +4 -4
- package/docs/classes/UserService.html +15 -15
- package/docs/enums/HttpMethods.html +3 -3
- package/docs/functions/Rettiwt.html +5 -4
- package/docs/index.html +4 -3
- package/docs/interfaces/IAuthCookie.html +5 -5
- package/docs/interfaces/ICursor.html +2 -2
- package/docs/interfaces/ICursoredData.html +3 -3
- package/docs/interfaces/IDataContext.html +4 -4
- package/docs/interfaces/IDataValidationError.html +109 -0
- package/docs/interfaces/IListArgs.html +3 -3
- package/docs/interfaces/ITweet.html +13 -13
- package/docs/interfaces/ITweetEntities.html +5 -5
- package/docs/interfaces/ITweetFilter.html +42 -42
- package/docs/interfaces/IUser.html +15 -15
- package/docs/modules.html +8 -6
- package/package.json +3 -2
- package/src/enums/Errors.ts +2 -1
- package/src/graphql/queries/RootQuery.ts +1 -1
- package/src/graphql/resolvers/TweetResolver.ts +12 -59
- package/src/graphql/types/UserTypes.ts +1 -1
- package/src/index.ts +5 -3
- package/src/models/args/TweetListArgs.ts +2 -2
- package/src/models/args/UserListArgs.ts +1 -1
- package/src/models/data/Tweet.ts +3 -3
- package/src/models/data/User.ts +2 -2
- package/src/services/data/TweetService.ts +25 -22
- package/src/services/data/UserService.ts +38 -42
- package/src/services/helper/Headers.ts +32 -32
- package/src/services/helper/Parser.ts +2 -2
- package/src/services/helper/extractors/Tweets.ts +35 -97
- package/src/services/helper/extractors/Users.ts +11 -62
- package/src/services/util/FetcherService.ts +13 -20
- package/src/types/Args.ts +0 -37
- package/Dockerfile +0 -9
- package/dist/models/args/TweetFilter.d.ts +0 -65
- package/dist/models/args/TweetFilter.js +0 -121
- package/dist/models/args/TweetFilter.js.map +0 -1
- package/dist/models/errors/DataValidationError.d.ts +0 -20
- package/dist/models/errors/DataValidationError.js +0 -23
- package/dist/models/errors/DataValidationError.js.map +0 -1
- package/dist/twitter/Url.d.ts +0 -22
- package/dist/twitter/Url.js +0 -32
- package/dist/twitter/Url.js.map +0 -1
- package/dist/twitter/enums/Resources.d.ts +0 -15
- package/dist/twitter/enums/Resources.js +0 -21
- package/dist/twitter/enums/Resources.js.map +0 -1
- package/dist/twitter/params/Query.d.ts +0 -67
- package/dist/twitter/params/Query.js +0 -64
- package/dist/twitter/params/Query.js.map +0 -1
- package/dist/twitter/payloads/Args.d.ts +0 -16
- package/dist/twitter/payloads/Args.js +0 -16
- package/dist/twitter/payloads/Args.js.map +0 -1
- package/dist/twitter/payloads/Features.d.ts +0 -28
- package/dist/twitter/payloads/Features.js +0 -37
- package/dist/twitter/payloads/Features.js.map +0 -1
- package/dist/twitter/payloads/Variables.d.ts +0 -41
- package/dist/twitter/payloads/Variables.js +0 -64
- package/dist/twitter/payloads/Variables.js.map +0 -1
- package/dist/twitter/types/request/Query.d.ts +0 -86
- package/dist/twitter/types/request/Query.js +0 -4
- package/dist/twitter/types/request/Query.js.map +0 -1
- package/dist/twitter/types/tweet/Favouriters.d.ts +0 -164
- package/dist/twitter/types/tweet/Favouriters.js +0 -3
- package/dist/twitter/types/tweet/Favouriters.js.map +0 -1
- package/dist/twitter/types/tweet/Retweeters.d.ts +0 -171
- package/dist/twitter/types/tweet/Retweeters.js +0 -3
- package/dist/twitter/types/tweet/Retweeters.js.map +0 -1
- package/dist/twitter/types/tweet/Tweet.d.ts +0 -746
- package/dist/twitter/types/tweet/Tweet.js +0 -3
- package/dist/twitter/types/tweet/Tweet.js.map +0 -1
- package/dist/twitter/types/tweet/Tweets.d.ts +0 -386
- package/dist/twitter/types/tweet/Tweets.js +0 -3
- package/dist/twitter/types/tweet/Tweets.js.map +0 -1
- package/dist/twitter/types/user/Followers.d.ts +0 -176
- package/dist/twitter/types/user/Followers.js +0 -3
- package/dist/twitter/types/user/Followers.js.map +0 -1
- package/dist/twitter/types/user/Following.d.ts +0 -176
- package/dist/twitter/types/user/Following.js +0 -3
- package/dist/twitter/types/user/Following.js.map +0 -1
- package/dist/twitter/types/user/Likes.d.ts +0 -1059
- package/dist/twitter/types/user/Likes.js +0 -3
- package/dist/twitter/types/user/Likes.js.map +0 -1
- package/dist/twitter/types/user/Tweets.d.ts +0 -1512
- package/dist/twitter/types/user/Tweets.js +0 -3
- package/dist/twitter/types/user/Tweets.js.map +0 -1
- package/dist/twitter/types/user/User.d.ts +0 -117
- package/dist/twitter/types/user/User.js +0 -3
- package/dist/twitter/types/user/User.js.map +0 -1
- package/src/models/args/TweetFilter.ts +0 -140
- package/src/models/errors/DataValidationError.ts +0 -29
- package/src/twitter/Url.ts +0 -37
- package/src/twitter/enums/Resources.ts +0 -15
- package/src/twitter/params/Query.ts +0 -100
- package/src/twitter/payloads/Args.ts +0 -21
- package/src/twitter/payloads/Features.ts +0 -33
- package/src/twitter/payloads/Variables.ts +0 -73
- package/src/twitter/types/request/Query.ts +0 -91
- package/src/twitter/types/tweet/Favouriters.ts +0 -193
- package/src/twitter/types/tweet/Retweeters.ts +0 -201
- package/src/twitter/types/tweet/Tweet.ts +0 -882
- package/src/twitter/types/tweet/Tweets.ts +0 -444
- package/src/twitter/types/user/Followers.ts +0 -208
- package/src/twitter/types/user/Following.ts +0 -208
- package/src/twitter/types/user/Likes.ts +0 -1247
- package/src/twitter/types/user/Tweets.ts +0 -1747
- package/src/twitter/types/user/User.ts +0 -135
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Tweets.js","sourceRoot":"","sources":["../../../../src/twitter/types/user/Tweets.ts"],"names":[],"mappings":""}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
export default interface Root {
|
|
2
|
-
data: Data;
|
|
3
|
-
}
|
|
4
|
-
export interface Data {
|
|
5
|
-
user: User;
|
|
6
|
-
}
|
|
7
|
-
export interface User {
|
|
8
|
-
result: Result;
|
|
9
|
-
}
|
|
10
|
-
export interface Result {
|
|
11
|
-
__typename: string;
|
|
12
|
-
id: string;
|
|
13
|
-
rest_id: string;
|
|
14
|
-
affiliates_highlighted_label: AffiliatesHighlightedLabel;
|
|
15
|
-
has_nft_avatar: boolean;
|
|
16
|
-
legacy: Legacy;
|
|
17
|
-
smart_blocked_by: boolean;
|
|
18
|
-
smart_blocking: boolean;
|
|
19
|
-
super_follow_eligible: boolean;
|
|
20
|
-
super_followed_by: boolean;
|
|
21
|
-
super_following: boolean;
|
|
22
|
-
legacy_extended_profile: LegacyExtendedProfile;
|
|
23
|
-
is_profile_translatable: boolean;
|
|
24
|
-
}
|
|
25
|
-
export interface AffiliatesHighlightedLabel {
|
|
26
|
-
}
|
|
27
|
-
export interface Legacy {
|
|
28
|
-
blocked_by: boolean;
|
|
29
|
-
blocking: boolean;
|
|
30
|
-
can_dm: boolean;
|
|
31
|
-
can_media_tag: boolean;
|
|
32
|
-
created_at: string;
|
|
33
|
-
default_profile: boolean;
|
|
34
|
-
default_profile_image: boolean;
|
|
35
|
-
description: string;
|
|
36
|
-
entities: Entities;
|
|
37
|
-
fast_followers_count: number;
|
|
38
|
-
favourites_count: number;
|
|
39
|
-
follow_request_sent: boolean;
|
|
40
|
-
followed_by: boolean;
|
|
41
|
-
followers_count: number;
|
|
42
|
-
following: boolean;
|
|
43
|
-
friends_count: number;
|
|
44
|
-
has_custom_timelines: boolean;
|
|
45
|
-
is_translator: boolean;
|
|
46
|
-
listed_count: number;
|
|
47
|
-
location: string;
|
|
48
|
-
media_count: number;
|
|
49
|
-
muting: boolean;
|
|
50
|
-
name: string;
|
|
51
|
-
normal_followers_count: number;
|
|
52
|
-
notifications: boolean;
|
|
53
|
-
pinned_tweet_ids_str: any[];
|
|
54
|
-
possibly_sensitive: boolean;
|
|
55
|
-
profile_banner_extensions: ProfileBannerExtensions;
|
|
56
|
-
profile_banner_url: string;
|
|
57
|
-
profile_image_extensions: ProfileImageExtensions;
|
|
58
|
-
profile_image_url_https: string;
|
|
59
|
-
profile_interstitial_type: string;
|
|
60
|
-
protected: boolean;
|
|
61
|
-
screen_name: string;
|
|
62
|
-
statuses_count: number;
|
|
63
|
-
translator_type: string;
|
|
64
|
-
verified: boolean;
|
|
65
|
-
want_retweets: boolean;
|
|
66
|
-
withheld_in_countries: any[];
|
|
67
|
-
}
|
|
68
|
-
export interface Entities {
|
|
69
|
-
description: Description;
|
|
70
|
-
}
|
|
71
|
-
export interface Description {
|
|
72
|
-
urls: any[];
|
|
73
|
-
}
|
|
74
|
-
export interface ProfileBannerExtensions {
|
|
75
|
-
mediaColor: MediaColor;
|
|
76
|
-
}
|
|
77
|
-
export interface MediaColor {
|
|
78
|
-
r: R;
|
|
79
|
-
}
|
|
80
|
-
export interface R {
|
|
81
|
-
ok: Ok;
|
|
82
|
-
}
|
|
83
|
-
export interface Ok {
|
|
84
|
-
palette: Palette[];
|
|
85
|
-
}
|
|
86
|
-
export interface Palette {
|
|
87
|
-
percentage: number;
|
|
88
|
-
rgb: Rgb;
|
|
89
|
-
}
|
|
90
|
-
export interface Rgb {
|
|
91
|
-
blue: number;
|
|
92
|
-
green: number;
|
|
93
|
-
red: number;
|
|
94
|
-
}
|
|
95
|
-
export interface ProfileImageExtensions {
|
|
96
|
-
mediaColor: MediaColor2;
|
|
97
|
-
}
|
|
98
|
-
export interface MediaColor2 {
|
|
99
|
-
r: R2;
|
|
100
|
-
}
|
|
101
|
-
export interface R2 {
|
|
102
|
-
ok: Ok2;
|
|
103
|
-
}
|
|
104
|
-
export interface Ok2 {
|
|
105
|
-
palette: Palette2[];
|
|
106
|
-
}
|
|
107
|
-
export interface Palette2 {
|
|
108
|
-
percentage: number;
|
|
109
|
-
rgb: Rgb2;
|
|
110
|
-
}
|
|
111
|
-
export interface Rgb2 {
|
|
112
|
-
blue: number;
|
|
113
|
-
green: number;
|
|
114
|
-
red: number;
|
|
115
|
-
}
|
|
116
|
-
export interface LegacyExtendedProfile {
|
|
117
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../../src/twitter/types/user/User.ts"],"names":[],"mappings":""}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
// PACKAGE
|
|
2
|
-
import { IsArray, IsBoolean, IsNumberString, IsString, IsOptional, IsDateString, validateSync } from 'class-validator';
|
|
3
|
-
|
|
4
|
-
// TYPES
|
|
5
|
-
import { ITweetFilter } from '../../types/Args';
|
|
6
|
-
import { DataValidationError } from '../errors/DataValidationError';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The this to be used for fetching tweets from Twitter.
|
|
10
|
-
*
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export class TweetFilter implements ITweetFilter {
|
|
14
|
-
/** The list of words to search. */
|
|
15
|
-
@IsArray()
|
|
16
|
-
@IsString({ each: true })
|
|
17
|
-
@IsOptional()
|
|
18
|
-
words?: string[];
|
|
19
|
-
|
|
20
|
-
/** The list of hashtags to search.
|
|
21
|
-
*
|
|
22
|
-
* @remarks
|
|
23
|
-
* '#' must be excluded from the hashtag!
|
|
24
|
-
*/
|
|
25
|
-
@IsArray()
|
|
26
|
-
@IsString({ each: true })
|
|
27
|
-
@IsOptional()
|
|
28
|
-
hashtags?: string[];
|
|
29
|
-
|
|
30
|
-
/** The list of usernames whose tweets are to be searched.
|
|
31
|
-
*
|
|
32
|
-
* @remarks
|
|
33
|
-
* '@' must be excluded from the username!
|
|
34
|
-
*/
|
|
35
|
-
@IsArray()
|
|
36
|
-
@IsString({ each: true })
|
|
37
|
-
@IsOptional()
|
|
38
|
-
fromUsers?: string[];
|
|
39
|
-
|
|
40
|
-
/** The list of username to whom the tweets to be searched, are adressed.
|
|
41
|
-
*
|
|
42
|
-
* @remarks
|
|
43
|
-
* '@' must be excluded from the username!
|
|
44
|
-
*/
|
|
45
|
-
@IsArray()
|
|
46
|
-
@IsString({ each: true })
|
|
47
|
-
@IsOptional()
|
|
48
|
-
toUsers?: string[];
|
|
49
|
-
|
|
50
|
-
/** The list of username mentioned in the tweets to search.
|
|
51
|
-
*
|
|
52
|
-
* @remarks
|
|
53
|
-
* '@' must be excluded from the username!
|
|
54
|
-
*/
|
|
55
|
-
@IsArray()
|
|
56
|
-
@IsString({ each: true })
|
|
57
|
-
@IsOptional()
|
|
58
|
-
mentions?: string[];
|
|
59
|
-
|
|
60
|
-
/** The date starting from which tweets are to be searched.
|
|
61
|
-
*
|
|
62
|
-
* @remarks
|
|
63
|
-
* Must be in the format YYYY-MM-DD.
|
|
64
|
-
*/
|
|
65
|
-
@IsOptional()
|
|
66
|
-
@IsDateString()
|
|
67
|
-
startDate?: string;
|
|
68
|
-
|
|
69
|
-
/** The date upto which tweets are to be searched.
|
|
70
|
-
*
|
|
71
|
-
* @remarks
|
|
72
|
-
* Must be in the format YYYY-MM-DD.
|
|
73
|
-
*/
|
|
74
|
-
@IsOptional()
|
|
75
|
-
@IsDateString()
|
|
76
|
-
endDate?: string;
|
|
77
|
-
|
|
78
|
-
/** The id of the tweet, after which the tweets are to be searched. */
|
|
79
|
-
@IsNumberString()
|
|
80
|
-
@IsOptional()
|
|
81
|
-
sinceId?: string;
|
|
82
|
-
|
|
83
|
-
/** The id of the tweet which is quoted in the tweets to search. */
|
|
84
|
-
@IsNumberString()
|
|
85
|
-
@IsOptional()
|
|
86
|
-
quoted?: string;
|
|
87
|
-
|
|
88
|
-
/** Whether to fetch tweets that are links or not.
|
|
89
|
-
*
|
|
90
|
-
* @defaultValue false
|
|
91
|
-
*/
|
|
92
|
-
@IsBoolean()
|
|
93
|
-
@IsOptional()
|
|
94
|
-
links?: boolean;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* @param this The incoming this in JSON format.
|
|
98
|
-
*/
|
|
99
|
-
constructor(filter: TweetFilter) {
|
|
100
|
-
this.endDate = filter.endDate;
|
|
101
|
-
this.fromUsers = filter.fromUsers;
|
|
102
|
-
this.hashtags = filter.hashtags;
|
|
103
|
-
this.links = filter.links;
|
|
104
|
-
this.mentions = filter.mentions;
|
|
105
|
-
this.quoted = filter.quoted;
|
|
106
|
-
this.sinceId = filter.sinceId;
|
|
107
|
-
this.startDate = filter.startDate;
|
|
108
|
-
this.toUsers = filter.toUsers;
|
|
109
|
-
this.words = filter.words;
|
|
110
|
-
|
|
111
|
-
// Validating the this
|
|
112
|
-
const validationResult = validateSync(this);
|
|
113
|
-
|
|
114
|
-
// If valiation error occured
|
|
115
|
-
if (validationResult.length) {
|
|
116
|
-
throw new DataValidationError(validationResult);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Converts this object to it's string representation.
|
|
122
|
-
*
|
|
123
|
-
* @returns 'this' object's string representation.
|
|
124
|
-
*/
|
|
125
|
-
toString() {
|
|
126
|
-
return [
|
|
127
|
-
this.words ? this.words.join(' ') : '',
|
|
128
|
-
this.hashtags ? `(${this.hashtags.map(hashtag => '#' + hashtag).join(' OR ')})` : '',
|
|
129
|
-
this.fromUsers ? `(${this.fromUsers.map(user => `from:${user}`).join(' OR ')})` : '',
|
|
130
|
-
this.toUsers ? `(${this.toUsers.map(user => `to:${user}`).join(' OR ')})` : '',
|
|
131
|
-
this.mentions ? `(${this.mentions.map(mention => '@' + mention).join(' OR ')})` : '',
|
|
132
|
-
this.startDate ? `since:${this.startDate}` : '',
|
|
133
|
-
this.endDate ? `until:${this.endDate}` : '',
|
|
134
|
-
this.sinceId ? `since_id:${this.sinceId}` : '',
|
|
135
|
-
this.quoted ? `quoted_tweet_id:${this.quoted}` : ''
|
|
136
|
-
]
|
|
137
|
-
.filter(item => item !== '()' && item !== '')
|
|
138
|
-
.join(' ') + (!this.links ? ' -this:links' : '');
|
|
139
|
-
}
|
|
140
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// PACKAGES
|
|
2
|
-
import { ValidationError } from "class-validator";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Error when any fields of a JSON data fails to validate.
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
8
|
-
*
|
|
9
|
-
* @param errorDetails The details of about the specific fields that failed to validate.
|
|
10
|
-
*/
|
|
11
|
-
export class DataValidationError implements Error {
|
|
12
|
-
/** The name of the error. */
|
|
13
|
-
name: string;
|
|
14
|
-
|
|
15
|
-
/** The user-friendly error message. */
|
|
16
|
-
message: string;
|
|
17
|
-
|
|
18
|
-
/** The error data. */
|
|
19
|
-
data: ValidationError[];
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @param data The error details.
|
|
23
|
-
*/
|
|
24
|
-
constructor(errorDetails: ValidationError[]) {
|
|
25
|
-
this.name = 'ValidationError';
|
|
26
|
-
this.message = 'One or more validation errors occured. Refer to data for details';
|
|
27
|
-
this.data = errorDetails;
|
|
28
|
-
}
|
|
29
|
-
}
|
package/src/twitter/Url.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// ENUMS
|
|
2
|
-
import { ResourceType } from "./enums/Resources";
|
|
3
|
-
|
|
4
|
-
// PAYLOADS
|
|
5
|
-
import { Args } from './payloads/Args';
|
|
6
|
-
import { Query } from './params/Query';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A class that deals with generation of URLs to various resources on Twitter.
|
|
10
|
-
*/
|
|
11
|
-
export class Url {
|
|
12
|
-
/** The base Twitter API url. */
|
|
13
|
-
private baseUrl: string = 'https://api.twitter.com';
|
|
14
|
-
|
|
15
|
-
/** The fully initialized target resource URL. */
|
|
16
|
-
public fullUrl: string;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Initializes a URL for fetching the specified resource, using the given arguments.
|
|
20
|
-
*
|
|
21
|
-
* @param resourceType The type of resource to fetch.
|
|
22
|
-
* @param args Any additional arguments.
|
|
23
|
-
*/
|
|
24
|
-
constructor(resourceType: ResourceType, args: Args) {
|
|
25
|
-
/**
|
|
26
|
-
* Initializing full URL along with additional URL parameters.
|
|
27
|
-
*/
|
|
28
|
-
this.fullUrl = `${this.baseUrl}${resourceType}?${new Query(resourceType, args).toString()}`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @returns The string representation of thi Url.
|
|
33
|
-
*/
|
|
34
|
-
public toString(): string {
|
|
35
|
-
return this.fullUrl;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The different types of resources that can be fetched.
|
|
3
|
-
*/
|
|
4
|
-
export enum ResourceType {
|
|
5
|
-
'TWEETS' = '/2/search/adaptive.json',
|
|
6
|
-
'TWEET_DETAILS' = '/graphql/lXI2kaM2hgmbf7h42kpxuA/TweetDetail',
|
|
7
|
-
'TWEET_LIKES' = '/graphql/56ZwFC3Vui31fF8IYX8EGA/Favoriters',
|
|
8
|
-
'TWEET_RETWEETS' = '/graphql/Wd7DVeLqMj_JQiTL0tjJwQ/Retweeters',
|
|
9
|
-
'USER_DETAILS' = '/graphql/hVhfo_TquFTmgL7gYwf91Q/UserByScreenName',
|
|
10
|
-
'USER_DETAILS_BY_ID' = '/graphql/mi_IjXgFyr41N9zkszPz9w/UserByRestId',
|
|
11
|
-
'USER_TWEETS' = '/graphql/xxLjoOBBPpYBHbBTI-hevQ/UserTweetsAndReplies',
|
|
12
|
-
'USER_FOLLOWING' = '/graphql/mSnjZc5CTm2Z5Lu_i4XsPQ/Following',
|
|
13
|
-
'USER_FOLLOWERS' = '/graphql/nwlAnaw7oKXcVLi91ehy7Q/Followers',
|
|
14
|
-
'USER_LIKES' = '/graphql/gP4ZKghLd4tpILgS6VudAQ/Likes'
|
|
15
|
-
};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// PAYLOADS
|
|
2
|
-
import { Variables } from '../payloads/Variables';
|
|
3
|
-
import { Features } from '../payloads/Features';
|
|
4
|
-
import { Args } from '../payloads/Args';
|
|
5
|
-
|
|
6
|
-
// TYPES
|
|
7
|
-
import { IQuery } from '../types/request/Query';
|
|
8
|
-
|
|
9
|
-
// ENUMS
|
|
10
|
-
import { ResourceType } from '../enums/Resources';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The URL query parameters that must be sent while making requests to Twitter API.
|
|
14
|
-
*/
|
|
15
|
-
export class Query implements IQuery {
|
|
16
|
-
cards_platform?: string;
|
|
17
|
-
count?: number;
|
|
18
|
-
cursor?: string;
|
|
19
|
-
ext?: string;
|
|
20
|
-
include_blocked_by?: number;
|
|
21
|
-
include_blocking?: number;
|
|
22
|
-
include_can_dm?: number;
|
|
23
|
-
include_can_media_tag?: number;
|
|
24
|
-
include_cards?: number;
|
|
25
|
-
include_entities?: boolean = true;
|
|
26
|
-
include_ext_alt_text?: boolean;
|
|
27
|
-
include_ext_collab_control?: boolean;
|
|
28
|
-
include_ext_edit_control?: boolean;
|
|
29
|
-
include_ext_has_nft_avatar?: number;
|
|
30
|
-
include_ext_is_blue_verified?: number;
|
|
31
|
-
include_ext_limited_action_results?: boolean;
|
|
32
|
-
include_ext_media_availability?: boolean;
|
|
33
|
-
include_ext_media_color?: boolean;
|
|
34
|
-
include_ext_sensitive_media_warning?: boolean;
|
|
35
|
-
include_ext_trusted_friends_metadata?: boolean;
|
|
36
|
-
include_ext_verified_type?: number;
|
|
37
|
-
include_ext_views?: boolean;
|
|
38
|
-
include_followed_by?: number;
|
|
39
|
-
include_mute_edge?: number;
|
|
40
|
-
include_profile_interstitial_type?: number;
|
|
41
|
-
include_quote_count?: boolean = true;
|
|
42
|
-
include_reply_count?: number = 1;
|
|
43
|
-
include_user_entities?: boolean = true;
|
|
44
|
-
include_want_retweets?: number = 1;
|
|
45
|
-
pc?: number;
|
|
46
|
-
q?: string;
|
|
47
|
-
query_source?: string;
|
|
48
|
-
send_error_codes?: boolean;
|
|
49
|
-
simple_quoted_tweet?: boolean;
|
|
50
|
-
skip_status?: number;
|
|
51
|
-
spelling_corrections?: number;
|
|
52
|
-
tweet_mode?: string = 'extended';
|
|
53
|
-
tweet_search_mode?: string = 'live';
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Variables for fetching data.
|
|
57
|
-
*/
|
|
58
|
-
variables?: string;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Additional data features that must be fetched.
|
|
62
|
-
*/
|
|
63
|
-
features?: string;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Initializes the URL parameters.
|
|
67
|
-
*
|
|
68
|
-
* @param resourceType The type of resource requested.
|
|
69
|
-
* @param args Additional user-defined arguments to be sent in the request.
|
|
70
|
-
*/
|
|
71
|
-
constructor(resourceType: ResourceType, args: Args) {
|
|
72
|
-
/**
|
|
73
|
-
* Only the endpoint for fetching tweets (using advanced search) requires the parameters defined in this class.
|
|
74
|
-
* All other endpoints required only 'variables' and 'features' fields.
|
|
75
|
-
*/
|
|
76
|
-
if (resourceType == ResourceType.TWEETS) {
|
|
77
|
-
this.q = encodeURIComponent(args.query ?? '');
|
|
78
|
-
this.count = args.count;
|
|
79
|
-
this.cursor = args.cursor;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
this.variables = new Variables(resourceType, args).toString();
|
|
83
|
-
this.features = new Features().toString();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Converts this object to it's string representation.
|
|
89
|
-
*
|
|
90
|
-
* @returns 'this' object's string representation;
|
|
91
|
-
*/
|
|
92
|
-
toString(): string {
|
|
93
|
-
/**
|
|
94
|
-
* This first filters out all the empty paramters.
|
|
95
|
-
* Then it formats each parameter key value pair as 'key=value'.
|
|
96
|
-
* Then it joins the list of all formatted parameters using '&' as a separator.
|
|
97
|
-
*/
|
|
98
|
-
return Object.entries(this).filter(([key, value]) => value).map(([key, value]) => `${key}=${value}`).join('&');
|
|
99
|
-
}
|
|
100
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// TYPES
|
|
2
|
-
import { IArgs } from '../types/request/Query';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The arguments for fetching cursored list.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export class Args implements IArgs {
|
|
10
|
-
/** The query string that may be used to filter data. */
|
|
11
|
-
query?: string;
|
|
12
|
-
|
|
13
|
-
/** The rest id of the data item to be requested. */
|
|
14
|
-
id?: string;
|
|
15
|
-
|
|
16
|
-
/** The number of data items to fetch. */
|
|
17
|
-
count?: number;
|
|
18
|
-
|
|
19
|
-
/** The cursor to the batch of data to fetch. */
|
|
20
|
-
cursor?: string;
|
|
21
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// TYPES
|
|
2
|
-
import { IFeatures } from '../types/request/Query';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The additional features that may be fetched while making requests to Twitter API.
|
|
6
|
-
*/
|
|
7
|
-
export class Features implements IFeatures {
|
|
8
|
-
graphql_is_translatable_rweb_tweet_is_translatable_enabled = false;
|
|
9
|
-
interactive_text_enabled = false;
|
|
10
|
-
longform_notetweets_consumption_enabled = false;
|
|
11
|
-
responsive_web_edit_tweet_api_enabled = false;
|
|
12
|
-
responsive_web_enhance_cards_enabled = false;
|
|
13
|
-
responsive_web_graphql_timeline_navigation_enabled = false;
|
|
14
|
-
responsive_web_text_conversations_enabled = false;
|
|
15
|
-
responsive_web_twitter_blue_verified_badge_is_enabled = false;
|
|
16
|
-
responsive_web_uc_gql_enabled = false;
|
|
17
|
-
standardized_nudges_misinfo = false;
|
|
18
|
-
tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled = false;
|
|
19
|
-
tweetypie_unmention_optimization_enabled = false;
|
|
20
|
-
verified_phone_label_enabled = false;
|
|
21
|
-
vibe_api_enabled = false;
|
|
22
|
-
view_counts_everywhere_api_enabled = false;
|
|
23
|
-
view_counts_public_visibility_enabled = false;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Converts this object to it's string representation.
|
|
27
|
-
*
|
|
28
|
-
* @returns 'this' object's string representation.
|
|
29
|
-
*/
|
|
30
|
-
toString(): string {
|
|
31
|
-
return `${encodeURIComponent(JSON.stringify(this))}`;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// PAYLOADS
|
|
2
|
-
import { Args } from './Args';
|
|
3
|
-
|
|
4
|
-
// TYPES
|
|
5
|
-
import { IVariables } from '../types/request/Query';
|
|
6
|
-
|
|
7
|
-
// ENUMS
|
|
8
|
-
import { ResourceType } from '../enums/Resources';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The variables that must be sent as payload while making requests to Twitter API.
|
|
12
|
-
*/
|
|
13
|
-
export class Variables implements IVariables {
|
|
14
|
-
tweetId?: string;
|
|
15
|
-
focalTweetId?: string;
|
|
16
|
-
userId?: string;
|
|
17
|
-
screen_name?: string;
|
|
18
|
-
count?: number;
|
|
19
|
-
cursor?: string;
|
|
20
|
-
includePromotedContent: boolean = false;
|
|
21
|
-
referrer: string = '';
|
|
22
|
-
withBirdwatchNotes: boolean = false;
|
|
23
|
-
withCommunity: boolean = false;
|
|
24
|
-
withDownvotePerspective: boolean = false;
|
|
25
|
-
withQuickPromoteEligibilityTweetFields: boolean = false;
|
|
26
|
-
withReactionsMetadata: boolean = false;
|
|
27
|
-
withReactionsPerspective: boolean = false;
|
|
28
|
-
withSuperFollowsTweetFields: boolean = false;
|
|
29
|
-
withSuperFollowsUserFields: boolean = false;
|
|
30
|
-
withV2Timeline: boolean = true;
|
|
31
|
-
withVoice: boolean = false;
|
|
32
|
-
with_rux_injections: boolean = false;
|
|
33
|
-
withClientEventToken: boolean = false;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Initializes the appropriate Variables object based on the requred resource type and parameters.
|
|
37
|
-
*
|
|
38
|
-
* @param resourceType The type of resource that is requested.
|
|
39
|
-
* @param args The additional user-defined arguments for fetching the resource.
|
|
40
|
-
*/
|
|
41
|
-
constructor(resourceType: ResourceType, args: Args) {
|
|
42
|
-
if (resourceType == ResourceType.TWEET_DETAILS) {
|
|
43
|
-
this.focalTweetId = args.id;
|
|
44
|
-
this.count = args.count;
|
|
45
|
-
this.cursor = args.cursor;
|
|
46
|
-
}
|
|
47
|
-
else if (resourceType == ResourceType.TWEET_LIKES || resourceType == ResourceType.TWEET_RETWEETS) {
|
|
48
|
-
this.tweetId = args.id;
|
|
49
|
-
this.count = args.count;
|
|
50
|
-
this.cursor = args.cursor;
|
|
51
|
-
}
|
|
52
|
-
else if (resourceType == ResourceType.USER_DETAILS) {
|
|
53
|
-
this.screen_name = args.id;
|
|
54
|
-
}
|
|
55
|
-
else if (resourceType == ResourceType.USER_DETAILS_BY_ID) {
|
|
56
|
-
this.userId = args.id;
|
|
57
|
-
}
|
|
58
|
-
else if (resourceType == ResourceType.USER_FOLLOWERS || resourceType == ResourceType.USER_FOLLOWING || resourceType == ResourceType.USER_LIKES || resourceType == ResourceType.USER_TWEETS) {
|
|
59
|
-
this.userId = args.id;
|
|
60
|
-
this.count = args.count;
|
|
61
|
-
this.cursor = args.cursor;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Converts this object to it's string representation.
|
|
67
|
-
*
|
|
68
|
-
* @returns 'this' object's string representation.
|
|
69
|
-
*/
|
|
70
|
-
toString(): string {
|
|
71
|
-
return `${encodeURIComponent(JSON.stringify(this))}`;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
export interface IArgs {
|
|
2
|
-
query?: string;
|
|
3
|
-
id?: string;
|
|
4
|
-
count?: number;
|
|
5
|
-
cursor?: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export interface IVariables {
|
|
9
|
-
tweetId?: string;
|
|
10
|
-
focalTweetId?: string;
|
|
11
|
-
userId?: string;
|
|
12
|
-
screen_name?: string;
|
|
13
|
-
count?: number;
|
|
14
|
-
cursor?: string;
|
|
15
|
-
includePromotedContent: boolean;
|
|
16
|
-
referrer: string;
|
|
17
|
-
withBirdwatchNotes: boolean;
|
|
18
|
-
withCommunity: boolean;
|
|
19
|
-
withDownvotePerspective: boolean;
|
|
20
|
-
withQuickPromoteEligibilityTweetFields: boolean;
|
|
21
|
-
withReactionsMetadata: boolean;
|
|
22
|
-
withReactionsPerspective: boolean;
|
|
23
|
-
withSuperFollowsTweetFields: boolean;
|
|
24
|
-
withSuperFollowsUserFields: boolean;
|
|
25
|
-
withV2Timeline: boolean;
|
|
26
|
-
withVoice: boolean;
|
|
27
|
-
with_rux_injections: boolean;
|
|
28
|
-
withClientEventToken: boolean;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface IFeatures {
|
|
34
|
-
graphql_is_translatable_rweb_tweet_is_translatable_enabled: boolean;
|
|
35
|
-
interactive_text_enabled: boolean;
|
|
36
|
-
longform_notetweets_consumption_enabled: boolean;
|
|
37
|
-
responsive_web_edit_tweet_api_enabled: boolean;
|
|
38
|
-
responsive_web_enhance_cards_enabled: boolean;
|
|
39
|
-
responsive_web_graphql_timeline_navigation_enabled: boolean;
|
|
40
|
-
responsive_web_text_conversations_enabled: boolean;
|
|
41
|
-
responsive_web_twitter_blue_verified_badge_is_enabled: boolean;
|
|
42
|
-
responsive_web_uc_gql_enabled: boolean;
|
|
43
|
-
standardized_nudges_misinfo: boolean;
|
|
44
|
-
tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled: boolean;
|
|
45
|
-
tweetypie_unmention_optimization_enabled: boolean;
|
|
46
|
-
verified_phone_label_enabled: boolean;
|
|
47
|
-
vibe_api_enabled: boolean;
|
|
48
|
-
view_counts_everywhere_api_enabled: boolean;
|
|
49
|
-
view_counts_public_visibility_enabled: boolean;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface IQuery {
|
|
53
|
-
cards_platform?: string;
|
|
54
|
-
count?: number;
|
|
55
|
-
cursor?: string;
|
|
56
|
-
ext?: string;
|
|
57
|
-
include_blocked_by?: number;
|
|
58
|
-
include_blocking?: number;
|
|
59
|
-
include_can_dm?: number;
|
|
60
|
-
include_can_media_tag?: number;
|
|
61
|
-
include_cards?: number;
|
|
62
|
-
include_entities?: boolean;
|
|
63
|
-
include_ext_alt_text?: boolean;
|
|
64
|
-
include_ext_collab_control?: boolean;
|
|
65
|
-
include_ext_edit_control?: boolean;
|
|
66
|
-
include_ext_has_nft_avatar?: number;
|
|
67
|
-
include_ext_is_blue_verified?: number;
|
|
68
|
-
include_ext_limited_action_results?: boolean;
|
|
69
|
-
include_ext_media_availability?: boolean;
|
|
70
|
-
include_ext_media_color?: boolean;
|
|
71
|
-
include_ext_sensitive_media_warning?: boolean;
|
|
72
|
-
include_ext_trusted_friends_metadata?: boolean;
|
|
73
|
-
include_ext_verified_type?: number;
|
|
74
|
-
include_ext_views?: boolean;
|
|
75
|
-
include_followed_by?: number;
|
|
76
|
-
include_mute_edge?: number;
|
|
77
|
-
include_profile_interstitial_type?: number;
|
|
78
|
-
include_quote_count?: boolean;
|
|
79
|
-
include_reply_count?: number;
|
|
80
|
-
include_user_entities?: boolean;
|
|
81
|
-
include_want_retweets?: number;
|
|
82
|
-
pc?: number;
|
|
83
|
-
q?: string;
|
|
84
|
-
query_source?: string;
|
|
85
|
-
send_error_codes?: boolean;
|
|
86
|
-
simple_quoted_tweet?: boolean;
|
|
87
|
-
skip_status?: number;
|
|
88
|
-
spelling_corrections?: number;
|
|
89
|
-
tweet_mode?: string;
|
|
90
|
-
tweet_search_mode?: string;
|
|
91
|
-
}
|