rettiwt-api 1.1.2 → 1.1.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/README.md +32 -7
- package/dist/endpoints/Endpoints.d.ts +14 -0
- package/dist/endpoints/Endpoints.js +20 -0
- package/dist/endpoints/Endpoints.js.map +1 -0
- package/dist/endpoints/Url.d.ts +5 -0
- package/dist/endpoints/Url.js +12 -0
- package/dist/endpoints/Url.js.map +1 -0
- package/dist/enums/Endpoints.d.ts +25 -0
- package/dist/enums/Endpoints.js +31 -0
- package/dist/enums/Endpoints.js.map +1 -0
- package/dist/enums/Errors.d.ts +20 -0
- package/dist/enums/Errors.js +28 -0
- package/dist/enums/Errors.js.map +1 -0
- package/dist/enums/HTTP.d.ts +17 -0
- package/dist/enums/HTTP.js +23 -0
- package/dist/enums/HTTP.js.map +1 -0
- package/dist/graphql/enums/Errors.d.ts +21 -0
- package/dist/graphql/enums/Errors.js +29 -0
- package/dist/graphql/enums/Errors.js.map +1 -0
- package/dist/graphql/queries/RootQuery.js +10 -3
- package/dist/graphql/queries/RootQuery.js.map +1 -1
- package/dist/graphql/resolvers/AccountResolver.d.ts +3 -3
- package/dist/graphql/resolvers/AccountResolver.js.map +1 -1
- package/dist/graphql/resolvers/ResolverBase.d.ts +14 -3
- package/dist/graphql/resolvers/ResolverBase.js +13 -1
- package/dist/graphql/resolvers/ResolverBase.js.map +1 -1
- package/dist/graphql/resolvers/TweetResolver.d.ts +3 -3
- package/dist/graphql/resolvers/TweetResolver.js +30 -18
- package/dist/graphql/resolvers/TweetResolver.js.map +1 -1
- package/dist/graphql/resolvers/UserResolver.d.ts +13 -4
- package/dist/graphql/resolvers/UserResolver.js +83 -18
- package/dist/graphql/resolvers/UserResolver.js.map +1 -1
- package/dist/graphql/types/Errors.d.ts +20 -0
- package/dist/graphql/types/Errors.js +28 -0
- package/dist/graphql/types/Errors.js.map +1 -0
- package/dist/graphql/types/TweetTypes.js +2 -2
- package/dist/graphql/types/TweetTypes.js.map +1 -1
- package/dist/graphql/types/UserTypes.js +1 -1
- package/dist/graphql/types/UserTypes.js.map +1 -1
- package/dist/index.d.ts +31 -15
- package/dist/index.js +32 -17
- package/dist/index.js.map +1 -1
- package/dist/middlewares/Authentication.d.ts +0 -0
- package/dist/middlewares/Authentication.js +2 -0
- package/dist/middlewares/Authentication.js.map +1 -0
- package/dist/models/args/TweetFilter.d.ts +59 -0
- package/dist/models/args/TweetFilter.js +101 -0
- package/dist/models/args/TweetFilter.js.map +1 -0
- package/dist/models/args/TweetListArgs.d.ts +21 -0
- package/dist/models/args/TweetListArgs.js +54 -0
- package/dist/models/args/TweetListArgs.js.map +1 -0
- package/dist/models/args/UserListArgs.d.ts +21 -0
- package/dist/models/args/UserListArgs.js +54 -0
- package/dist/models/args/UserListArgs.js.map +1 -0
- package/dist/models/auth/AuthCookie.d.ts +21 -0
- package/dist/models/auth/AuthCookie.js +33 -0
- package/dist/models/auth/AuthCookie.js.map +1 -0
- package/dist/models/data/CursoredData.d.ts +34 -0
- package/dist/models/data/CursoredData.js +42 -0
- package/dist/models/data/CursoredData.js.map +1 -0
- package/dist/models/data/DataValidationError.d.ts +18 -0
- package/dist/models/data/DataValidationError.js +21 -0
- package/dist/models/data/DataValidationError.js.map +1 -0
- package/dist/models/data/Errors.d.ts +18 -0
- package/dist/models/data/Errors.js +21 -0
- package/dist/models/data/Errors.js.map +1 -0
- package/dist/models/data/Service.d.ts +33 -0
- package/dist/models/data/Service.js +41 -0
- package/dist/models/data/Service.js.map +1 -0
- package/dist/models/data/Tweet.d.ts +53 -0
- package/dist/models/data/Tweet.js +104 -0
- package/dist/models/data/Tweet.js.map +1 -0
- package/dist/models/data/User.d.ts +41 -0
- package/dist/models/data/User.js +32 -0
- package/dist/models/data/User.js.map +1 -0
- package/dist/models/errors/DataValidationError.d.ts +20 -0
- package/dist/models/errors/DataValidationError.js +23 -0
- package/dist/models/errors/DataValidationError.js.map +1 -0
- package/dist/models/query/Variables.d.ts +2 -0
- package/dist/models/query/Variables.js +10 -0
- package/dist/models/query/Variables.js.map +1 -0
- package/dist/requests/Url.d.ts +5 -0
- package/dist/requests/Url.js +12 -0
- package/dist/requests/Url.js.map +1 -0
- package/dist/requests/payloads/Variables.d.ts +23 -0
- package/dist/requests/payloads/Variables.js +24 -0
- package/dist/requests/payloads/Variables.js.map +1 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.js +9 -10
- package/dist/server.js.map +1 -1
- package/dist/services/accounts/AccountService.d.ts +6 -0
- package/dist/services/accounts/AccountService.js +6 -0
- package/dist/services/accounts/AccountService.js.map +1 -1
- package/dist/services/auth/AccountService.d.ts +88 -0
- package/dist/services/auth/AccountService.js +392 -0
- package/dist/services/auth/AccountService.js.map +1 -0
- package/dist/services/auth/AuthService.d.ts +31 -0
- package/dist/services/auth/AuthService.js +118 -0
- package/dist/services/auth/AuthService.js.map +1 -0
- package/dist/services/auth/LoginFlows.d.ts +77 -0
- package/dist/services/auth/LoginFlows.js +92 -0
- package/dist/services/auth/LoginFlows.js.map +1 -0
- package/dist/services/data/TweetService.d.ts +46 -16
- package/dist/services/data/TweetService.js +71 -54
- package/dist/services/data/TweetService.js.map +1 -1
- package/dist/services/data/UserService.d.ts +58 -19
- package/dist/services/data/UserService.js +104 -68
- package/dist/services/data/UserService.js.map +1 -1
- package/dist/services/helper/Headers.d.ts +4 -4
- package/dist/services/helper/Headers.js.map +1 -1
- package/dist/services/helper/Parser.d.ts +2 -2
- package/dist/services/helper/Parser.js.map +1 -1
- package/dist/services/helper/extractors/Tweets.d.ts +6 -6
- package/dist/services/helper/extractors/Tweets.js +1 -1
- package/dist/services/helper/extractors/Tweets.js.map +1 -1
- package/dist/services/helper/extractors/Users.d.ts +10 -4
- package/dist/services/helper/extractors/Users.js +54 -2
- package/dist/services/helper/extractors/Users.js.map +1 -1
- package/dist/services/helper/payloads/LoginFlows.d.ts +77 -0
- package/dist/services/helper/payloads/LoginFlows.js +92 -0
- package/dist/services/helper/payloads/LoginFlows.js.map +1 -0
- package/dist/services/helper/urls/Users.d.ts +8 -1
- package/dist/services/helper/urls/Users.js +12 -2
- package/dist/services/helper/urls/Users.js.map +1 -1
- package/dist/services/util/CacheService.d.ts +33 -0
- package/dist/services/util/CacheService.js +96 -0
- package/dist/services/util/CacheService.js.map +1 -0
- package/dist/services/util/FetcherService.d.ts +65 -0
- package/dist/services/util/FetcherService.js +214 -0
- package/dist/services/util/FetcherService.js.map +1 -0
- package/dist/types/Args.d.ts +38 -0
- package/dist/types/Args.js +5 -0
- package/dist/types/Args.js.map +1 -0
- package/dist/types/Authentication.d.ts +17 -2
- package/dist/types/Authentication.js +1 -0
- package/dist/types/Authentication.js.map +1 -1
- package/dist/types/Query.d.ts +80 -0
- package/dist/types/Query.js +3 -0
- package/dist/types/Query.js.map +1 -0
- package/dist/types/Resolvers.d.ts +5 -4
- package/dist/types/Rettiwt.d.ts +16 -0
- package/dist/types/Rettiwt.js +3 -0
- package/dist/types/Rettiwt.js.map +1 -0
- package/dist/types/Service.d.ts +15 -23
- package/dist/types/Service.js +2 -16
- package/dist/types/Service.js.map +1 -1
- package/dist/types/Tweet.d.ts +25 -19
- package/dist/types/Tweet.js +0 -2
- package/dist/types/Tweet.js.map +1 -1
- package/dist/types/User.d.ts +35 -0
- package/dist/types/User.js +3 -0
- package/dist/types/User.js.map +1 -0
- package/dist/types/args/TweetFilter.d.ts +54 -0
- package/dist/types/args/TweetFilter.js +96 -0
- package/dist/types/args/TweetFilter.js.map +1 -0
- package/dist/types/args/TweetListArg.d.ts +10 -0
- package/dist/types/args/TweetListArg.js +42 -0
- package/dist/types/args/TweetListArg.js.map +1 -0
- package/dist/types/args/TweetListArgs.d.ts +20 -0
- package/dist/types/args/TweetListArgs.js +52 -0
- package/dist/types/args/TweetListArgs.js.map +1 -0
- package/dist/types/args/UserListArgs.d.ts +16 -0
- package/dist/types/args/UserListArgs.js +48 -0
- package/dist/types/args/UserListArgs.js.map +1 -0
- package/dist/types/data/TweetFilter.d.ts +49 -0
- package/dist/types/data/TweetFilter.js +63 -0
- package/dist/types/data/TweetFilter.js.map +1 -0
- package/dist/types/interfaces/Args.d.ts +38 -0
- package/dist/types/interfaces/Args.js +5 -0
- package/dist/types/interfaces/Args.js.map +1 -0
- package/dist/types/interfaces/Authentication.d.ts +40 -0
- package/dist/types/interfaces/Authentication.js +5 -0
- package/dist/types/interfaces/Authentication.js.map +1 -0
- package/dist/types/interfaces/Resolvers.d.ts +14 -0
- package/dist/types/interfaces/Resolvers.js +3 -0
- package/dist/types/interfaces/Resolvers.js.map +1 -0
- package/dist/types/interfaces/Rettiwt.d.ts +16 -0
- package/dist/types/interfaces/Rettiwt.js +3 -0
- package/dist/types/interfaces/Rettiwt.js.map +1 -0
- package/dist/types/interfaces/Service.d.ts +13 -0
- package/dist/types/interfaces/Service.js +3 -0
- package/dist/types/interfaces/Service.js.map +1 -0
- package/dist/types/interfaces/Services.d.ts +13 -0
- package/dist/types/interfaces/Services.js +3 -0
- package/dist/types/interfaces/Services.js.map +1 -0
- package/dist/types/interfaces/Tweet.d.ts +46 -0
- package/dist/types/interfaces/Tweet.js +3 -0
- package/dist/types/interfaces/Tweet.js.map +1 -0
- package/dist/types/interfaces/TweetFilter.d.ts +0 -0
- package/dist/types/interfaces/TweetFilter.js +2 -0
- package/dist/types/interfaces/TweetFilter.js.map +1 -0
- package/{src/types/data/User.ts → dist/types/interfaces/User.d.ts} +35 -51
- package/dist/types/interfaces/User.js +3 -0
- package/dist/types/interfaces/User.js.map +1 -0
- package/dist/types/raw/data/tweet/Favouriters.d.ts +164 -0
- package/dist/types/raw/data/tweet/Favouriters.js +3 -0
- package/dist/types/raw/data/tweet/Favouriters.js.map +1 -0
- package/dist/types/raw/data/tweet/Retweeters.d.ts +171 -0
- package/dist/types/raw/data/tweet/Retweeters.js +3 -0
- package/dist/types/raw/data/tweet/Retweeters.js.map +1 -0
- package/dist/types/raw/data/tweet/Tweet.d.ts +746 -0
- package/dist/types/raw/data/tweet/Tweet.js +3 -0
- package/dist/types/raw/data/tweet/Tweet.js.map +1 -0
- package/dist/types/raw/data/tweet/Tweets.d.ts +386 -0
- package/dist/types/raw/data/tweet/Tweets.js +3 -0
- package/dist/types/raw/data/tweet/Tweets.js.map +1 -0
- package/dist/types/raw/data/user/Followers.d.ts +176 -0
- package/dist/types/raw/data/user/Followers.js +3 -0
- package/dist/types/raw/data/user/Followers.js.map +1 -0
- package/dist/types/raw/data/user/Following.d.ts +176 -0
- package/dist/types/raw/data/user/Following.js +3 -0
- package/dist/types/raw/data/user/Following.js.map +1 -0
- package/dist/types/raw/data/user/Likes.d.ts +1059 -0
- package/dist/types/raw/data/user/Likes.js +3 -0
- package/dist/types/raw/data/user/Likes.js.map +1 -0
- package/dist/types/raw/data/user/User.d.ts +117 -0
- package/dist/types/raw/data/user/User.js +3 -0
- package/dist/types/raw/data/user/User.js.map +1 -0
- package/dist/types/raw/query/tweet/Details.d.ts +80 -0
- package/dist/types/raw/query/tweet/Details.js +5 -0
- package/dist/types/raw/query/tweet/Details.js.map +1 -0
- package/dist/types/raw/query/tweet/Engagements.d.ts +29 -0
- package/dist/types/raw/query/tweet/Engagements.js +3 -0
- package/dist/types/raw/query/tweet/Engagements.js.map +1 -0
- package/dist/types/raw/query/tweet/Likes.d.ts +29 -0
- package/dist/types/raw/query/tweet/Likes.js +3 -0
- package/dist/types/raw/query/tweet/Likes.js.map +1 -0
- package/dist/types/raw/query/tweet/Retweets.d.ts +29 -0
- package/dist/types/raw/query/tweet/Retweets.js +3 -0
- package/dist/types/raw/query/tweet/Retweets.js.map +1 -0
- package/dist/types/raw/query/tweet/Search.d.ts +40 -0
- package/dist/types/raw/query/tweet/Search.js +3 -0
- package/dist/types/raw/query/tweet/Search.js.map +1 -0
- package/dist/types/raw/query/tweet/TweetDetails.d.ts +34 -0
- package/dist/types/raw/query/tweet/TweetDetails.js +5 -0
- package/dist/types/raw/query/tweet/TweetDetails.js.map +1 -0
- package/dist/types/raw/query/tweet/TweetLike.d.ts +29 -0
- package/dist/types/raw/query/tweet/TweetLike.js +3 -0
- package/dist/types/raw/query/tweet/TweetLike.js.map +1 -0
- package/dist/types/raw/query/tweet/TweetLikes.d.ts +29 -0
- package/dist/types/raw/query/tweet/TweetLikes.js +3 -0
- package/dist/types/raw/query/tweet/TweetLikes.js.map +1 -0
- package/dist/types/raw/query/tweet/TweetRetweets.d.ts +0 -0
- package/dist/types/raw/query/tweet/TweetRetweets.js +2 -0
- package/dist/types/raw/query/tweet/TweetRetweets.js.map +1 -0
- package/dist/types/raw/query/user/Details.d.ts +34 -0
- package/dist/types/raw/query/user/Details.js +3 -0
- package/dist/types/raw/query/user/Details.js.map +1 -0
- package/dist/types/raw/user/Tweets.d.ts +668 -1584
- package/dist/types/services/args/TweetFilter.d.ts +50 -0
- package/dist/types/services/args/TweetFilter.js +76 -0
- package/dist/types/services/args/TweetFilter.js.map +1 -0
- package/package.json +6 -3
- package/src/enums/Errors.ts +21 -0
- package/src/graphql/enums/Errors.ts +22 -0
- package/src/graphql/queries/RootQuery.ts +11 -4
- package/src/graphql/resolvers/AccountResolver.ts +3 -3
- package/src/graphql/resolvers/ResolverBase.ts +19 -5
- package/src/graphql/resolvers/TweetResolver.ts +26 -17
- package/src/graphql/resolvers/UserResolver.ts +75 -20
- package/src/graphql/types/TweetTypes.ts +2 -2
- package/src/graphql/types/UserTypes.ts +4 -4
- package/src/index.ts +39 -17
- package/src/models/args/TweetFilter.ts +119 -0
- package/src/models/args/TweetListArgs.ts +47 -0
- package/src/models/args/UserListArgs.ts +47 -0
- package/src/models/auth/AuthCookie.ts +43 -0
- package/src/models/data/CursoredData.ts +45 -0
- package/src/models/data/Tweet.ts +118 -0
- package/src/models/data/User.ts +72 -0
- package/src/models/errors/DataValidationError.ts +29 -0
- package/src/server.ts +9 -10
- package/src/services/{accounts → auth}/AccountService.ts +71 -19
- package/src/services/auth/AuthService.ts +81 -0
- package/src/services/data/TweetService.ts +81 -62
- package/src/services/data/UserService.ts +118 -80
- package/src/services/helper/Headers.ts +4 -4
- package/src/services/helper/Parser.ts +2 -2
- package/src/services/helper/extractors/Tweets.ts +7 -7
- package/src/services/helper/extractors/Users.ts +60 -5
- package/src/services/helper/urls/Users.ts +39 -23
- package/src/services/{CacheService.ts → util/CacheService.ts} +4 -1
- package/src/services/{FetcherService.ts → util/FetcherService.ts} +19 -11
- package/src/types/Args.ts +49 -0
- package/src/types/Authentication.ts +29 -7
- package/src/types/Resolvers.ts +5 -4
- package/src/types/Rettiwt.ts +20 -0
- package/src/types/Service.ts +24 -0
- package/src/types/Tweet.ts +61 -0
- package/src/types/User.ts +48 -0
- package/src/types/raw/user/Tweets.ts +1747 -0
- package/tsconfig.json +2 -2
- package/src/services/AuthService.ts +0 -68
- package/src/services/helper/deserializers/Tweets.ts +0 -70
- package/src/services/helper/deserializers/Users.ts +0 -26
- package/src/types/data/Errors.ts +0 -37
- package/src/types/data/Service.ts +0 -55
- package/src/types/data/Tweet.ts +0 -123
- package/src/types/raw/auth/Cookie.ts +0 -16
- /package/src/{types → enums}/HTTP.ts +0 -0
- /package/src/services/{accounts → helper/payloads}/LoginFlows.ts +0 -0
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
// SERVICES
|
|
2
|
-
import { FetcherService } from '../FetcherService';
|
|
3
|
-
import { AuthService } from '../AuthService';
|
|
2
|
+
import { FetcherService } from '../util/FetcherService';
|
|
3
|
+
import { AuthService } from '../auth/AuthService';
|
|
4
|
+
|
|
5
|
+
// MODELS
|
|
6
|
+
import { User } from '../../models/data/User';
|
|
7
|
+
import { UserListArgs } from '../../models/args/UserListArgs';
|
|
8
|
+
import { Tweet } from '../../models/data/Tweet';
|
|
4
9
|
|
|
5
10
|
// TYPES
|
|
6
|
-
import {
|
|
7
|
-
import { Tweet } from '../../types/data/Tweet';
|
|
8
|
-
import { CursoredData } from '../../types/data/Service';
|
|
11
|
+
import { CursoredData } from '../../models/data/CursoredData';
|
|
9
12
|
import { Result as TweetData } from '../../types/raw/tweet/Tweet';
|
|
10
13
|
import RawUser, { Result as UserData } from '../../types/raw/user/User';
|
|
14
|
+
import RawUserTweets from '../../types/raw/user/Tweets';
|
|
11
15
|
import RawUserFollowers from '../../types/raw/user/Followers';
|
|
12
16
|
import RawUserFollowing from '../../types/raw/user/Following';
|
|
13
17
|
import RawUserLikes from '../../types/raw/user/Likes';
|
|
14
|
-
|
|
18
|
+
|
|
19
|
+
// ENUMS
|
|
20
|
+
import { AuthenticationErrors } from '../../enums/Errors';
|
|
15
21
|
|
|
16
22
|
// URLS
|
|
17
23
|
import * as UserUrls from '../helper/urls/Users';
|
|
@@ -19,15 +25,10 @@ import * as UserUrls from '../helper/urls/Users';
|
|
|
19
25
|
// EXTRACTORS
|
|
20
26
|
import * as UserExtractors from '../helper/extractors/Users';
|
|
21
27
|
|
|
22
|
-
// DESERIALIZERS
|
|
23
|
-
import * as UserDeserializers from '../helper/deserializers/Users';
|
|
24
|
-
import * as TweetDeserializers from '../helper/deserializers/Tweets';
|
|
25
|
-
|
|
26
28
|
/**
|
|
27
29
|
* Handles fetching of data related to user account
|
|
28
30
|
*/
|
|
29
31
|
export class UserService extends FetcherService {
|
|
30
|
-
// MEMBER METHODS
|
|
31
32
|
/**
|
|
32
33
|
* @param auth The AuthService instance to use for authentication.
|
|
33
34
|
*/
|
|
@@ -36,13 +37,38 @@ export class UserService extends FetcherService {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
|
-
* @param
|
|
40
|
+
* @param id The id/username of the target user.
|
|
41
|
+
*
|
|
40
42
|
* @returns The details of the given user.
|
|
43
|
+
*
|
|
44
|
+
* @throws {@link Errors.DataErrors.UserNotFound} error, if no user with the given username was found.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
*
|
|
48
|
+
* No cookies are required to use this method.
|
|
41
49
|
*/
|
|
42
|
-
async getUserDetails(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
async getUserDetails(id: string): Promise<User> {
|
|
51
|
+
let res: RawUser;
|
|
52
|
+
|
|
53
|
+
// If id is not a numeric string => username is supplied
|
|
54
|
+
if (isNaN(Number(id))) {
|
|
55
|
+
// Fetching the raw data
|
|
56
|
+
res = await this.request<RawUser>(UserUrls.userDetailsUrl(id), false).then(res => res.data);
|
|
57
|
+
}
|
|
58
|
+
// If id is a numeric string => id is supplied
|
|
59
|
+
else {
|
|
60
|
+
// Getting data from cache
|
|
61
|
+
let cachedData = await this.readData(id);
|
|
62
|
+
|
|
63
|
+
// If data exists in cache
|
|
64
|
+
if (cachedData) {
|
|
65
|
+
return cachedData;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Fetching the raw data
|
|
69
|
+
res = await this.request<RawUser>(UserUrls.userDetailsByIdUrl(id), false).then(res => res.data);
|
|
70
|
+
}
|
|
71
|
+
|
|
46
72
|
// Extracting data
|
|
47
73
|
let data = UserExtractors.extractUserDetails(res);
|
|
48
74
|
|
|
@@ -50,60 +76,71 @@ export class UserService extends FetcherService {
|
|
|
50
76
|
this.cacheData(data);
|
|
51
77
|
|
|
52
78
|
// Parsing data
|
|
53
|
-
let user =
|
|
54
|
-
|
|
79
|
+
let user = new User(data.required[0]);
|
|
80
|
+
|
|
55
81
|
return user;
|
|
56
82
|
}
|
|
57
83
|
|
|
58
84
|
/**
|
|
59
|
-
* @param
|
|
60
|
-
* @
|
|
85
|
+
* @param userId The rest id of the target user.
|
|
86
|
+
* @param count The number of tweets to fetch, must be >= 40 (when no cursor is provided) and <=100.
|
|
87
|
+
* @param cursor The cursor to next batch. If blank, first batch is fetched.
|
|
88
|
+
*
|
|
89
|
+
* @returns The list of tweets nade by the target user.
|
|
90
|
+
*
|
|
91
|
+
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count has been provided.
|
|
92
|
+
* @throws {@link Errors.DataErrors.UserNotFound} error, if invalid count has been provided.
|
|
93
|
+
*
|
|
94
|
+
* @remarks
|
|
95
|
+
*
|
|
96
|
+
* No cookies are required to use this method.
|
|
61
97
|
*/
|
|
62
|
-
async
|
|
63
|
-
//
|
|
64
|
-
let
|
|
98
|
+
async getUserTweets(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
|
|
99
|
+
// Objectifying parameters
|
|
100
|
+
let args: UserListArgs = new UserListArgs(count, cursor);
|
|
65
101
|
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
return cachedData;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Fetchin the raw data
|
|
72
|
-
let res = await this.request<RawUser>(UserUrls.userDetailsByIdUrl(restId), false).then(res => res.data);
|
|
102
|
+
// Fetching the raw data
|
|
103
|
+
let res = await this.request<RawUserTweets>(UserUrls.userTweetsUrl(userId, args.count, args.cursor), false).then(res => res.data);
|
|
73
104
|
|
|
74
105
|
// Extracting data
|
|
75
|
-
let data = UserExtractors.
|
|
106
|
+
let data = UserExtractors.extractUserTweets(res);
|
|
76
107
|
|
|
77
108
|
// Caching data
|
|
78
109
|
this.cacheData(data);
|
|
79
110
|
|
|
80
111
|
// Parsing data
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
return
|
|
112
|
+
let tweets = data.required.map((item: TweetData) => new Tweet(item));
|
|
113
|
+
|
|
114
|
+
return new CursoredData<Tweet>(tweets, data.cursor);
|
|
84
115
|
}
|
|
85
116
|
|
|
86
117
|
/**
|
|
87
118
|
* @param userId The rest id of the target user.
|
|
88
|
-
* @param count The number of following to fetch.
|
|
119
|
+
* @param count The number of following to fetch, must be >= 40 (when no cursor is provided) and <=100.
|
|
89
120
|
* @param cursor The cursor to next batch. If blank, first batch is fetched.
|
|
121
|
+
*
|
|
90
122
|
* @returns The list of users followed by the target user.
|
|
91
|
-
*
|
|
123
|
+
*
|
|
124
|
+
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
125
|
+
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count has been provided.
|
|
126
|
+
* @throws {@link Errors.DataErrors.UserNotFound} error, if invalid count has been provided.
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
*
|
|
130
|
+
* Cookies are required to use this method!
|
|
92
131
|
*/
|
|
93
|
-
async getUserFollowing(userId: string, count
|
|
132
|
+
async getUserFollowing(userId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
94
133
|
// If user is not authenticated, abort
|
|
95
|
-
if(!this.isAuthenticated) {
|
|
96
|
-
throw new Error(
|
|
134
|
+
if (!this.isAuthenticated) {
|
|
135
|
+
throw new Error(AuthenticationErrors.NotAuthenticated);
|
|
97
136
|
}
|
|
98
137
|
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
throw new Error(Errors.ValidationErrors.InvalidCount);
|
|
102
|
-
}
|
|
138
|
+
// Objectifying parameters
|
|
139
|
+
let args: UserListArgs = new UserListArgs(count, cursor);
|
|
103
140
|
|
|
104
141
|
// Fetchin the raw data
|
|
105
|
-
let res = await this.request<RawUserFollowing>(UserUrls.userFollowingUrl(userId, count, cursor)).then(res => res.data);
|
|
106
|
-
|
|
142
|
+
let res = await this.request<RawUserFollowing>(UserUrls.userFollowingUrl(userId, args.count, args.cursor)).then(res => res.data);
|
|
143
|
+
|
|
107
144
|
// Extracting data
|
|
108
145
|
let data = UserExtractors.extractUserFollow(res);
|
|
109
146
|
|
|
@@ -111,35 +148,38 @@ export class UserService extends FetcherService {
|
|
|
111
148
|
this.cacheData(data);
|
|
112
149
|
|
|
113
150
|
// Parsing data
|
|
114
|
-
let users = data.required.map((item: UserData) =>
|
|
151
|
+
let users = data.required.map((item: UserData) => new User(item));
|
|
115
152
|
|
|
116
|
-
return
|
|
117
|
-
list: users,
|
|
118
|
-
next: { value: data.cursor }
|
|
119
|
-
};
|
|
153
|
+
return new CursoredData<User>(users, data.cursor);
|
|
120
154
|
}
|
|
121
155
|
|
|
122
156
|
/**
|
|
123
157
|
* @param userId The rest id of the target user.
|
|
124
|
-
* @param count The number of followers to fetch.
|
|
158
|
+
* @param count The number of followers to fetch, must be >= 40 (when no cursor is provided) and <=100.
|
|
125
159
|
* @param cursor The cursor to next batch. If blank, first batch is fetched.
|
|
160
|
+
*
|
|
126
161
|
* @returns The list of users following the target user.
|
|
127
|
-
*
|
|
162
|
+
*
|
|
163
|
+
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
164
|
+
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count has been provided.
|
|
165
|
+
* @throws {@link Errors.DataErrors.UserNotFound} error, if invalid count has been provided.
|
|
166
|
+
*
|
|
167
|
+
* @remarks
|
|
168
|
+
*
|
|
169
|
+
* Cookies are required to use this method!
|
|
128
170
|
*/
|
|
129
|
-
async getUserFollowers(userId: string, count
|
|
171
|
+
async getUserFollowers(userId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
130
172
|
// If user is not authenticated, abort
|
|
131
173
|
if (!this.isAuthenticated) {
|
|
132
|
-
throw new Error(
|
|
174
|
+
throw new Error(AuthenticationErrors.NotAuthenticated);
|
|
133
175
|
}
|
|
134
176
|
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
throw new Error(Errors.ValidationErrors.InvalidCount);
|
|
138
|
-
}
|
|
177
|
+
// Objectifying parameters
|
|
178
|
+
let args: UserListArgs = new UserListArgs(count, cursor);
|
|
139
179
|
|
|
140
180
|
// Fetching the raw data
|
|
141
|
-
let res = await this.request<RawUserFollowers>(UserUrls.userFollowersUrl(userId, count, cursor)).then(res => res.data);
|
|
142
|
-
|
|
181
|
+
let res = await this.request<RawUserFollowers>(UserUrls.userFollowersUrl(userId, args.count, args.cursor)).then(res => res.data);
|
|
182
|
+
|
|
143
183
|
// Extracting data
|
|
144
184
|
let data = UserExtractors.extractUserFollow(res);
|
|
145
185
|
|
|
@@ -147,35 +187,36 @@ export class UserService extends FetcherService {
|
|
|
147
187
|
this.cacheData(data);
|
|
148
188
|
|
|
149
189
|
// Parsing data
|
|
150
|
-
let users = data.required.map((item: UserData) =>
|
|
190
|
+
let users = data.required.map((item: UserData) => new User(item));
|
|
151
191
|
|
|
152
|
-
return
|
|
153
|
-
list: users,
|
|
154
|
-
next: { value: data.cursor }
|
|
155
|
-
};
|
|
192
|
+
return new CursoredData<User>(users, data.cursor);
|
|
156
193
|
}
|
|
157
194
|
|
|
158
195
|
/**
|
|
159
196
|
* @param userId The rest id of the target user.
|
|
160
197
|
* @param count The number of likes to fetch.
|
|
161
|
-
* @param cursor The cursor to next batch. If blank, first batch is fetched.
|
|
198
|
+
* @param cursor The cursor to next batch. If blank, first batch is fetched, must be >= 40 (when no cursor is provided) and <=100.
|
|
199
|
+
*
|
|
162
200
|
* @returns The list of tweets liked by the target user.
|
|
163
|
-
*
|
|
201
|
+
*
|
|
202
|
+
* @throws {@link AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
203
|
+
*
|
|
204
|
+
* @remarks
|
|
205
|
+
*
|
|
206
|
+
* Cookies are required to use this method!
|
|
164
207
|
*/
|
|
165
|
-
async getUserLikes(userId: string, count
|
|
208
|
+
async getUserLikes(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
|
|
166
209
|
// If user is not authenticated, abort
|
|
167
210
|
if (!this.isAuthenticated) {
|
|
168
|
-
throw new Error(
|
|
211
|
+
throw new Error(AuthenticationErrors.NotAuthenticated);
|
|
169
212
|
}
|
|
170
213
|
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
throw new Error(Errors.ValidationErrors.InvalidCount);
|
|
174
|
-
}
|
|
214
|
+
// Objectifying parameters
|
|
215
|
+
let args: UserListArgs = new UserListArgs(count, cursor);
|
|
175
216
|
|
|
176
217
|
// Fetching the raw data
|
|
177
|
-
let res = await this.request<RawUserLikes>(UserUrls.userLikesUrl(userId, count, cursor)).then(res => res.data);
|
|
178
|
-
|
|
218
|
+
let res = await this.request<RawUserLikes>(UserUrls.userLikesUrl(userId, args.count, args.cursor)).then(res => res.data);
|
|
219
|
+
|
|
179
220
|
// Extracting data
|
|
180
221
|
let data = UserExtractors.extractUserLikes(res);
|
|
181
222
|
|
|
@@ -183,11 +224,8 @@ export class UserService extends FetcherService {
|
|
|
183
224
|
this.cacheData(data);
|
|
184
225
|
|
|
185
226
|
// Parsing data
|
|
186
|
-
let tweets = data.required.map((item: TweetData) =>
|
|
227
|
+
let tweets = data.required.map((item: TweetData) => new Tweet(item));
|
|
187
228
|
|
|
188
|
-
return
|
|
189
|
-
list: tweets,
|
|
190
|
-
next: { value: data.cursor }
|
|
191
|
-
};
|
|
229
|
+
return new CursoredData<Tweet>(tweets, data.cursor);
|
|
192
230
|
}
|
|
193
231
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// TYPES
|
|
2
|
-
import {
|
|
2
|
+
import { IGuestCredentials, IAuthCredentials } from '../../types/Authentication';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @param authToken The authentication token received from Twitter
|
|
@@ -7,7 +7,7 @@ import { GuestCredentials, AuthCredentials } from '../../types/Authentication';
|
|
|
7
7
|
* @param cookie The cookie associated with the logged in account
|
|
8
8
|
* @returns The header required for making authorized HTTP requests
|
|
9
9
|
*/
|
|
10
|
-
export function authorizedHeader(authCred:
|
|
10
|
+
export function authorizedHeader(authCred: IAuthCredentials): any {
|
|
11
11
|
return [
|
|
12
12
|
`sec-ch-ua: "Not_A Brand";v="99", "Microsoft Edge";v="109", "Chromium";v="109"`,
|
|
13
13
|
`x-twitter-client-language: en`,
|
|
@@ -28,7 +28,7 @@ export function authorizedHeader(authCred: AuthCredentials): any {
|
|
|
28
28
|
* @param guestCred The guest credentials to use
|
|
29
29
|
* @returns The header requred for making guest HTTP requests
|
|
30
30
|
*/
|
|
31
|
-
export function guestHeader(guestCred:
|
|
31
|
+
export function guestHeader(guestCred: IGuestCredentials): any {
|
|
32
32
|
return [
|
|
33
33
|
'Accept: */*',
|
|
34
34
|
`authorization: ${guestCred.authToken}`,
|
|
@@ -42,7 +42,7 @@ export function guestHeader(guestCred: GuestCredentials): any {
|
|
|
42
42
|
* @param cookie The cookie to be used
|
|
43
43
|
* @returns The header for making HTTP request for logging in
|
|
44
44
|
*/
|
|
45
|
-
export function loginHeader(guestCred:
|
|
45
|
+
export function loginHeader(guestCred: IGuestCredentials, cookie: string): any {
|
|
46
46
|
return [
|
|
47
47
|
`sec-ch-ua: "Not_A Brand";v="99", "Microsoft Edge";v="109", "Chromium";v="109"`,
|
|
48
48
|
`x-twitter-client-language: en`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// TYPES
|
|
2
|
-
import {
|
|
2
|
+
import { ITweetFilter } from '../../types/Args';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @returns Whether the given json object is empty or not
|
|
@@ -92,7 +92,7 @@ export function normalizeText(text: string): string {
|
|
|
92
92
|
* @param filter The tweet filter to use for getting filtered tweets
|
|
93
93
|
* @returns The same tweet filter, in a URL query format string
|
|
94
94
|
*/
|
|
95
|
-
export function toQueryString(filter:
|
|
95
|
+
export function toQueryString(filter: ITweetFilter): string {
|
|
96
96
|
// Concatenating the input filter arguments to a URL query formatted string
|
|
97
97
|
return [
|
|
98
98
|
filter.words ? filter.words.join(' ') : '',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// TYPES
|
|
2
|
-
import {
|
|
3
|
-
import { DataErrors } from '../../../
|
|
2
|
+
import { IDataExtract } from '../../../types/Resolvers';
|
|
3
|
+
import { DataErrors } from '../../../enums/Errors';
|
|
4
4
|
import RawTweet from '../../../types/raw/tweet/Tweet';
|
|
5
5
|
import RawTweets from '../../../types/raw/tweet/Tweets';
|
|
6
6
|
import RawRetweeters from '../../../types/raw/tweet/Retweeters';
|
|
@@ -13,7 +13,7 @@ import * as Parsers from '../Parser';
|
|
|
13
13
|
* @returns The raw tweets data formatted and sorted into required and additional data
|
|
14
14
|
* @param res The raw response received from TwitterAPI
|
|
15
15
|
*/
|
|
16
|
-
export function extractTweets(res: RawTweets):
|
|
16
|
+
export function extractTweets(res: RawTweets): IDataExtract {
|
|
17
17
|
let required: any[] = []; // To store the reqruied raw data
|
|
18
18
|
let cursor: string = ''; // To store the cursor to next batch
|
|
19
19
|
let users: any[] = []; // To store additional user data
|
|
@@ -63,7 +63,7 @@ export function extractTweets(res: RawTweets): DataExtract {
|
|
|
63
63
|
* @param res The raw response received from TwitterAPI
|
|
64
64
|
* @param tweetId The rest id of the tweet to fetch
|
|
65
65
|
*/
|
|
66
|
-
export function extractTweet(res: RawTweet, tweetId: string):
|
|
66
|
+
export function extractTweet(res: RawTweet, tweetId: string): IDataExtract {
|
|
67
67
|
let required: any[] = []; // To store the reqruied raw data
|
|
68
68
|
let cursor: string = ''; // To store the cursor to next batch
|
|
69
69
|
let users: any[] = []; // To store additional user data
|
|
@@ -112,7 +112,7 @@ export function extractTweet(res: RawTweet, tweetId: string): DataExtract {
|
|
|
112
112
|
* @returns The raw tweet likers data formatted and sorted into required and additional data
|
|
113
113
|
* @param res The raw response received from TwitterAPI
|
|
114
114
|
*/
|
|
115
|
-
export function extractTweetLikers(res: RawLikers):
|
|
115
|
+
export function extractTweetLikers(res: RawLikers): IDataExtract {
|
|
116
116
|
let required: any[] = []; // To store the reqruied raw data
|
|
117
117
|
let cursor: string = ''; // To store the cursor to next batch
|
|
118
118
|
let users: any[] = []; // To store additional user data
|
|
@@ -152,7 +152,7 @@ export function extractTweetLikers(res: RawLikers): DataExtract {
|
|
|
152
152
|
* @returns The raw tweet retweeters data formatted and sorted into required and additional data
|
|
153
153
|
* @param res The raw response received from TwitterAPI
|
|
154
154
|
*/
|
|
155
|
-
export function extractTweetRetweeters(res: RawRetweeters):
|
|
155
|
+
export function extractTweetRetweeters(res: RawRetweeters): IDataExtract {
|
|
156
156
|
let required: any[] = []; // To store the reqruied raw data
|
|
157
157
|
let cursor: string = ''; // To store the cursor to next batch
|
|
158
158
|
let users: any[] = []; // To store additional user data
|
|
@@ -193,7 +193,7 @@ export function extractTweetRetweeters(res: RawRetweeters): DataExtract {
|
|
|
193
193
|
* @param res The raw response received from TwitterAPI
|
|
194
194
|
* @param tweetId The id of the tweet whose replies must be extracted
|
|
195
195
|
*/
|
|
196
|
-
export function extractTweetReplies(res: RawTweet, tweetId: string):
|
|
196
|
+
export function extractTweetReplies(res: RawTweet, tweetId: string): IDataExtract {
|
|
197
197
|
let required: any[] = []; // To store the reqruied raw data
|
|
198
198
|
let cursor: string = ''; // To store the cursor to next batch
|
|
199
199
|
let users: any[] = []; // To store additional user data
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// TYPES
|
|
2
|
-
import {
|
|
3
|
-
import { DataErrors } from '../../../
|
|
2
|
+
import { IDataExtract } from '../../../types/Resolvers'
|
|
3
|
+
import { DataErrors } from '../../../enums/Errors';
|
|
4
4
|
import RawUser from '../../../types/raw/user/User';
|
|
5
|
+
import RawUserTweets from '../../../types/raw/user/Tweets';
|
|
5
6
|
import RawUserFollowers from '../../../types/raw/user/Followers';
|
|
6
7
|
import RawUserFollowing from '../../../types/raw/user/Following';
|
|
7
8
|
import RawUserLikes from '../../../types/raw/user/Likes';
|
|
@@ -13,7 +14,7 @@ import * as Parsers from '../Parser';
|
|
|
13
14
|
* @returns The raw user account data formatted and sorted into required and additional data
|
|
14
15
|
* @param res The raw response received from Twitter
|
|
15
16
|
*/
|
|
16
|
-
export function extractUserDetails(res: RawUser):
|
|
17
|
+
export function extractUserDetails(res: RawUser): IDataExtract {
|
|
17
18
|
let required: any[] = []; // To store the reqruied raw data
|
|
18
19
|
let cursor: string = ''; // To store the cursor to next batch
|
|
19
20
|
let users: any[] = []; // To store additional user data
|
|
@@ -37,11 +38,65 @@ export function extractUserDetails(res: RawUser): DataExtract {
|
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @returns The raw user tweet data formatted and sorted into required and additional data
|
|
43
|
+
* @param res The raw response received from Twitter
|
|
44
|
+
*/
|
|
45
|
+
export function extractUserTweets(res: RawUserTweets): IDataExtract {
|
|
46
|
+
let required: any[] = []; // To store the reqruied raw data
|
|
47
|
+
let cursor: string = ''; // To store the cursor to next batch
|
|
48
|
+
let users: any[] = []; // To store additional user data
|
|
49
|
+
let tweets: any[] = []; // To store additional tweet data
|
|
50
|
+
|
|
51
|
+
// If user does not exist
|
|
52
|
+
if (Parsers.isJSONEmpty(res.data.user)) {
|
|
53
|
+
throw new Error(DataErrors.UserNotFound);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Extracting the raw list
|
|
57
|
+
res.data.user.result.timeline_v2.timeline.instructions.forEach(item => {
|
|
58
|
+
if (item.type === 'TimelineAddEntries') {
|
|
59
|
+
// If no tweets found
|
|
60
|
+
if (item.entries?.length == 2) {
|
|
61
|
+
// Returning the data
|
|
62
|
+
return {
|
|
63
|
+
required: required,
|
|
64
|
+
cursor: cursor,
|
|
65
|
+
users: users,
|
|
66
|
+
tweets: tweets
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Destructuring data
|
|
71
|
+
item.entries.forEach(entry => {
|
|
72
|
+
// If entry is of type tweet and tweet exists
|
|
73
|
+
if (entry.entryId.indexOf('tweet') != -1 && entry.content.itemContent?.tweet_results.result.__typename === 'Tweet') {
|
|
74
|
+
required.push(entry.content.itemContent.tweet_results.result);
|
|
75
|
+
users.push(entry.content.itemContent.tweet_results.result.core.user_results.result);
|
|
76
|
+
tweets.push(entry.content.itemContent.tweet_results.result);
|
|
77
|
+
}
|
|
78
|
+
// If entry is of type cursor
|
|
79
|
+
else if (entry.entryId.indexOf('cursor-bottom') != -1) {
|
|
80
|
+
cursor = entry.content.value ?? '';
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Returning the data
|
|
87
|
+
return {
|
|
88
|
+
required: required,
|
|
89
|
+
cursor: cursor,
|
|
90
|
+
users: users,
|
|
91
|
+
tweets: tweets
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
40
95
|
/**
|
|
41
96
|
* @returns The raw user following/followers data formatted and sorted into required and additional data
|
|
42
97
|
* @param res The raw response received from TwitterAPI
|
|
43
98
|
*/
|
|
44
|
-
export function extractUserFollow(res: RawUserFollowers | RawUserFollowing):
|
|
99
|
+
export function extractUserFollow(res: RawUserFollowers | RawUserFollowing): IDataExtract {
|
|
45
100
|
let required: any[] = []; // To store the reqruied raw data
|
|
46
101
|
let cursor: string = ''; // To store the cursor to next batch
|
|
47
102
|
let users: any[] = []; // To store additional user data
|
|
@@ -94,7 +149,7 @@ export function extractUserFollow(res: RawUserFollowers | RawUserFollowing): Dat
|
|
|
94
149
|
* @returns The raw user likes data formatted and sorted into required and additional data
|
|
95
150
|
* @param res The raw response received from TwitterAPI
|
|
96
151
|
*/
|
|
97
|
-
export function extractUserLikes(res: RawUserLikes):
|
|
152
|
+
export function extractUserLikes(res: RawUserLikes): IDataExtract {
|
|
98
153
|
let required: any[] = []; // To store the reqruied raw data
|
|
99
154
|
let cursor: string = ''; // To store the cursor to next batch
|
|
100
155
|
let users: any[] = []; // To store additional user data
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @param screenName The screen name of the target user
|
|
4
4
|
*/
|
|
5
5
|
export function userDetailsUrl(screenName: string): string {
|
|
6
|
-
|
|
6
|
+
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`;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -11,23 +11,35 @@ export function userDetailsUrl(screenName: string): string {
|
|
|
11
11
|
* @param restid The restId of the target user
|
|
12
12
|
*/
|
|
13
13
|
export function userDetailsByIdUrl(restId: string): string {
|
|
14
|
-
|
|
14
|
+
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`;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @returns The url for fetching the list of
|
|
18
|
+
* @returns The url for fetching the list of tweet made by target user.
|
|
19
|
+
* @param userId The rest id of the target user
|
|
20
|
+
* @param count The batch size of the list of tweets, should be >= 40 and <=100
|
|
21
|
+
* @param cursor The cursor to next batch
|
|
22
|
+
*/
|
|
23
|
+
export function userTweetsUrl(userId: string, count: number, cursor: string): string {
|
|
24
|
+
return `https://api.twitter.com/graphql/xxLjoOBBPpYBHbBTI-hevQ/UserTweetsAndReplies?variables=%7B%22userId%22%3A%22${userId}%22%2C%22count%22%3A${count}%2C%22cursor%22%3A%22${cursor}%22%2C%22includePromotedContent%22%3Atrue%2C%22withCommunity%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`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @returns The url for fetching the list of users followed by target user.
|
|
19
29
|
* @param userId The rest id of the target user
|
|
20
30
|
* @param count The batch size of the list of following, should be >= 40 and <=100
|
|
21
31
|
* @param cursor The cursor to next batch
|
|
22
32
|
*/
|
|
23
33
|
export function userFollowingUrl(userId: string, count: number, cursor: string): string {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Twitter has a ver odd behaviour here.
|
|
36
|
+
* If no cursor is provided, the number of followings fetched is slightly more the given count.
|
|
37
|
+
* If a cursor if provided, the number of followings is sometimes less than the provided count.
|
|
38
|
+
* NO SOLUTION EXISTS AS OF NOW!
|
|
39
|
+
*/
|
|
40
|
+
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(
|
|
41
|
+
cursor,
|
|
42
|
+
)}%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`;
|
|
31
43
|
}
|
|
32
44
|
|
|
33
45
|
/**
|
|
@@ -37,18 +49,20 @@ export function userFollowingUrl(userId: string, count: number, cursor: string):
|
|
|
37
49
|
* @param cursor The cusor to next batch
|
|
38
50
|
*/
|
|
39
51
|
export function userFollowersUrl(userId: string, count: number, cursor: string): string {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Twitter has a very odd behaviour here.
|
|
54
|
+
* If no cursor is provided, the number of followers fetched is equal to count + 20.
|
|
55
|
+
* If a cursor is provided, the number of followers fetched is equal to count.
|
|
56
|
+
* The solution is to check accordingly, if a cursor if provided or not and manipulate the count
|
|
57
|
+
*/
|
|
58
|
+
// If no cursor if provided
|
|
59
|
+
if (!cursor) {
|
|
60
|
+
count = count - 20;
|
|
61
|
+
}
|
|
50
62
|
|
|
51
|
-
|
|
63
|
+
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(
|
|
64
|
+
cursor,
|
|
65
|
+
)}%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`;
|
|
52
66
|
}
|
|
53
67
|
|
|
54
68
|
/**
|
|
@@ -58,5 +72,7 @@ export function userFollowersUrl(userId: string, count: number, cursor: string):
|
|
|
58
72
|
* @param cursor The cusor to next batch
|
|
59
73
|
*/
|
|
60
74
|
export function userLikesUrl(userId: string, count: number, cursor: string): string {
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
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(
|
|
76
|
+
cursor,
|
|
77
|
+
)}%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`;
|
|
78
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import NodeCache from 'node-cache';
|
|
3
3
|
|
|
4
4
|
// PARSERS
|
|
5
|
-
import * as Parsers from '
|
|
5
|
+
import * as Parsers from '../helper/Parser';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Handles reading and writing of data from and to cache.
|
|
@@ -40,7 +40,9 @@ export class CacheService {
|
|
|
40
40
|
* Stores the input data in the cache.
|
|
41
41
|
*
|
|
42
42
|
* @param data The input data to store.
|
|
43
|
+
*
|
|
43
44
|
* @returns Whether writing to cache was successful or not.
|
|
45
|
+
*
|
|
44
46
|
* @remarks In order to cache data, the data to be cached must have a unique 'id' field.
|
|
45
47
|
*/
|
|
46
48
|
public write(data: any): void {
|
|
@@ -62,6 +64,7 @@ export class CacheService {
|
|
|
62
64
|
|
|
63
65
|
/**
|
|
64
66
|
* @param id The id id of the data to be fetched from cache.
|
|
67
|
+
*
|
|
65
68
|
* @returns The data with the given id.
|
|
66
69
|
*/
|
|
67
70
|
public read(id: string): any {
|