rettiwt-api 1.1.0 → 1.1.2
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/.github/workflows/build-docs.yml +27 -0
- package/README.md +3 -1
- package/dist/Test.d.ts +0 -0
- package/dist/Test.js +2 -0
- package/dist/Test.js.map +1 -0
- package/dist/index.d.ts +16 -5
- package/dist/index.js +22 -8
- package/dist/index.js.map +1 -1
- package/dist/models/graphql/Global.d.ts +4 -0
- package/dist/models/graphql/Global.js +13 -0
- package/dist/models/graphql/Global.js.map +1 -0
- package/dist/models/graphql/TweetTypes.d.ts +6 -0
- package/dist/models/graphql/TweetTypes.js +156 -0
- package/dist/models/graphql/TweetTypes.js.map +1 -0
- package/dist/models/graphql/UserTypes.d.ts +3 -0
- package/dist/models/graphql/UserTypes.js +139 -0
- package/dist/models/graphql/UserTypes.js.map +1 -0
- package/dist/queries/RootQuery.d.ts +4 -0
- package/dist/queries/RootQuery.js +70 -0
- package/dist/queries/RootQuery.js.map +1 -0
- package/dist/resolvers/AccountResolver.d.ts +12 -0
- package/dist/resolvers/AccountResolver.js +84 -0
- package/dist/resolvers/AccountResolver.js.map +1 -0
- package/dist/resolvers/ResolverBase.d.ts +5 -0
- package/dist/resolvers/ResolverBase.js +11 -0
- package/dist/resolvers/ResolverBase.js.map +1 -0
- package/dist/resolvers/TweetResolver.d.ts +54 -0
- package/dist/resolvers/TweetResolver.js +332 -0
- package/dist/resolvers/TweetResolver.js.map +1 -0
- package/dist/resolvers/UserResolver.d.ts +38 -0
- package/dist/resolvers/UserResolver.js +253 -0
- package/dist/resolvers/UserResolver.js.map +1 -0
- package/dist/services/AuthService.d.ts +6 -2
- package/dist/services/AuthService.js +4 -3
- package/dist/services/AuthService.js.map +1 -1
- package/dist/services/CacheService.d.ts +12 -7
- package/dist/services/CacheService.js +12 -7
- package/dist/services/CacheService.js.map +1 -1
- package/dist/services/FetcherService.d.ts +32 -12
- package/dist/services/FetcherService.js +45 -14
- package/dist/services/FetcherService.js.map +1 -1
- package/dist/services/accounts/AccountService.d.ts +23 -6
- package/dist/services/accounts/AccountService.js +48 -9
- package/dist/services/accounts/AccountService.js.map +1 -1
- package/dist/services/data/TrendService.d.ts +17 -0
- package/dist/services/data/TrendService.js +116 -0
- package/dist/services/data/TrendService.js.map +1 -0
- package/dist/services/data/TweetService.d.ts +22 -15
- package/dist/services/data/TweetService.js +22 -15
- package/dist/services/data/TweetService.js.map +1 -1
- package/dist/services/data/UserAccountService.d.ts +42 -0
- package/dist/services/data/UserAccountService.js +239 -0
- package/dist/services/data/UserAccountService.js.map +1 -0
- package/dist/services/data/UserService.d.ts +21 -15
- package/dist/services/data/UserService.js +21 -15
- package/dist/services/data/UserService.js.map +1 -1
- package/dist/services/helper/Deserializers.d.ts +19 -0
- package/dist/services/helper/Deserializers.js +115 -0
- package/dist/services/helper/Deserializers.js.map +1 -0
- package/dist/services/helper/Extractors.d.ts +104 -0
- package/dist/services/helper/Extractors.js +432 -0
- package/dist/services/helper/Extractors.js.map +1 -0
- package/dist/services/helper/Urls.d.ts +85 -0
- package/dist/services/helper/Urls.js +130 -0
- package/dist/services/helper/Urls.js.map +1 -0
- package/dist/services/helper/extractors/Trends.d.ts +3 -0
- package/dist/services/helper/extractors/Trends.js +51 -0
- package/dist/services/helper/extractors/Trends.js.map +1 -0
- package/dist/services/helper/urls/Trends.d.ts +7 -0
- package/dist/services/helper/urls/Trends.js +13 -0
- package/dist/services/helper/urls/Trends.js.map +1 -0
- package/dist/types/Authentication.d.ts +27 -2
- package/dist/types/Authentication.js.map +1 -1
- package/dist/types/HTTP.d.ts +3 -1
- package/dist/types/HTTP.js +3 -1
- package/dist/types/HTTP.js.map +1 -1
- package/dist/types/Resolvers.d.ts +6 -1
- package/dist/types/Service.d.ts +30 -0
- package/dist/types/Service.js +19 -0
- package/dist/types/Service.js.map +1 -0
- package/dist/types/Trends.d.ts +50 -0
- package/dist/types/Trends.js +3 -0
- package/dist/types/Trends.js.map +1 -0
- package/dist/types/Tweet.d.ts +40 -0
- package/dist/types/Tweet.js +5 -0
- package/dist/types/Tweet.js.map +1 -0
- package/dist/types/UserAccount.d.ts +19 -0
- package/dist/types/UserAccount.js +4 -0
- package/dist/types/UserAccount.js.map +1 -0
- package/dist/types/data/Errors.d.ts +13 -4
- package/dist/types/data/Errors.js +12 -3
- package/dist/types/data/Errors.js.map +1 -1
- package/dist/types/data/Service.d.ts +19 -5
- package/dist/types/data/Service.js +6 -3
- package/dist/types/data/Service.js.map +1 -1
- package/dist/types/data/Tweet.d.ts +60 -3
- package/dist/types/data/Tweet.js +0 -1
- package/dist/types/data/Tweet.js.map +1 -1
- package/dist/types/data/User.d.ts +20 -1
- package/dist/types/data/User.js +0 -1
- package/dist/types/data/User.js.map +1 -1
- package/dist/types/graphql/Errors.d.ts +15 -0
- package/dist/types/graphql/Errors.js +23 -0
- package/dist/types/graphql/Errors.js.map +1 -0
- package/dist/types/raw/general/Trends.d.ts +324 -0
- package/dist/types/raw/general/Trends.js +3 -0
- package/dist/types/raw/general/Trends.js.map +1 -0
- package/dist/types/raw/user/Tweets.d.ts +2428 -0
- package/dist/types/raw/user/Tweets.js +3 -0
- package/dist/types/raw/user/Tweets.js.map +1 -0
- package/package.json +5 -4
- package/src/index.ts +19 -6
- package/src/services/AuthService.ts +13 -7
- package/src/services/CacheService.ts +12 -7
- package/src/services/FetcherService.ts +62 -21
- package/src/services/accounts/AccountService.ts +61 -12
- package/src/services/data/TweetService.ts +25 -18
- package/src/services/data/UserService.ts +21 -15
- package/src/types/Authentication.ts +27 -2
- package/src/types/HTTP.ts +4 -2
- package/src/types/Resolvers.ts +14 -6
- package/src/types/data/Errors.ts +13 -4
- package/src/types/data/Service.ts +28 -11
- package/src/types/data/Tweet.ts +109 -31
- package/src/types/data/User.ts +47 -17
|
@@ -1,16 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The guest credentials for guest authentication.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
3
5
|
*/
|
|
4
6
|
export interface GuestCredentials {
|
|
7
|
+
/** The bearer token from twitter.com.
|
|
8
|
+
*
|
|
9
|
+
* @remarks This is a static bearer token from twitter.com.
|
|
10
|
+
*/
|
|
5
11
|
authToken: string,
|
|
12
|
+
/** The guest token.
|
|
13
|
+
*
|
|
14
|
+
* @remarks This is generated from twitter.com by calling GETTING https://api.twitter.com/1.1/guest/activate.json endpoint.
|
|
15
|
+
*/
|
|
6
16
|
guestToken: string
|
|
7
17
|
};
|
|
8
18
|
|
|
9
19
|
/**
|
|
10
|
-
*
|
|
20
|
+
* The credentials for authenticated/logged in users.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
11
23
|
*/
|
|
12
24
|
export interface AuthCredentials {
|
|
25
|
+
/** The bearer token from twitter.com.
|
|
26
|
+
*
|
|
27
|
+
* @remarks This is a static bearer token from twitter.com.
|
|
28
|
+
*/
|
|
13
29
|
authToken: string,
|
|
30
|
+
/** The guest token.
|
|
31
|
+
*
|
|
32
|
+
* @remarks This is generated from twitter.com by calling GETTING https://api.twitter.com/1.1/guest/activate.json endpoint.
|
|
33
|
+
*/
|
|
14
34
|
csrfToken: string,
|
|
35
|
+
/** The cookie of the twitter account, which is used to authenticate against twitter.
|
|
36
|
+
*
|
|
37
|
+
* @remarks The cookie can be obtained/scraped from any one of the outgoing HTTP request headers to twitter.com.
|
|
38
|
+
* It can also be obtained after logging in to twitter, from the 'set-cookie' field of response.
|
|
39
|
+
*/
|
|
15
40
|
cookie: string
|
|
16
41
|
};
|
package/src/types/HTTP.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The different types of http status codes
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
3
5
|
*/
|
|
4
6
|
export enum HttpStatus {
|
|
5
7
|
BadRequest = 400,
|
|
@@ -12,4 +14,4 @@ export enum HttpStatus {
|
|
|
12
14
|
InternalServerError = 500,
|
|
13
15
|
BadGateway = 502,
|
|
14
16
|
ServiceUnavailable = 503
|
|
15
|
-
};
|
|
17
|
+
};
|
package/src/types/Resolvers.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The data returned from extractor methods.
|
|
3
|
+
* @internal
|
|
3
4
|
*/
|
|
4
5
|
export interface DataExtract {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
/** The required data. */
|
|
7
|
+
required: any;
|
|
8
|
+
|
|
9
|
+
/** The cursor string to the next batch of data. */
|
|
10
|
+
cursor: string;
|
|
11
|
+
|
|
12
|
+
/** Additional extracted user details. */
|
|
13
|
+
users: any;
|
|
14
|
+
|
|
15
|
+
/** Additional extracted tweet details */
|
|
16
|
+
tweets: any;
|
|
17
|
+
}
|
package/src/types/data/Errors.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Different types of error messages related to authentication.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
3
5
|
*/
|
|
4
6
|
export enum AuthenticationErrors {
|
|
5
7
|
NotAuthenticated = "Cannot fetch this data without authentication",
|
|
8
|
+
InvalidEmail = "No Twitter account found for the given email address",
|
|
9
|
+
InvalidUsername = "Incorrect username given for the given Twitter account",
|
|
10
|
+
InvalidPassword = "Incorrect password given for the given Twitter account"
|
|
6
11
|
};
|
|
7
12
|
|
|
8
13
|
/**
|
|
9
|
-
*
|
|
14
|
+
* Different types error messages for validation errors.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
10
17
|
*/
|
|
11
18
|
export enum ValidationErrors {
|
|
12
19
|
InvalidTweetFilter = "Atleast one of fromUsers/toUsers/mentions/hashtags/words argument is required",
|
|
@@ -15,7 +22,9 @@ export enum ValidationErrors {
|
|
|
15
22
|
};
|
|
16
23
|
|
|
17
24
|
/**
|
|
18
|
-
*
|
|
25
|
+
* Different type of error messages that are returned by services.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
19
28
|
*/
|
|
20
29
|
export enum DataErrors {
|
|
21
30
|
UserNotFound = "An account with given username/id was not found",
|
|
@@ -25,4 +34,4 @@ export enum DataErrors {
|
|
|
25
34
|
NoRetweetersFound = "No retweeters found for the tweet with the given id",
|
|
26
35
|
NoFollowsFound = "No follow details were found for the user with the given id",
|
|
27
36
|
NoLikedTweetsFound = "No liked tweets were found for the user with the given id"
|
|
28
|
-
};
|
|
37
|
+
};
|
|
@@ -4,16 +4,20 @@ import { TweetService } from "../../services/data/TweetService";
|
|
|
4
4
|
import { UserService } from "../../services/data/UserService";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* The cursor to the batch of data to be fetched.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
8
10
|
*/
|
|
9
11
|
export class Cursor {
|
|
10
12
|
// MEMBER DATA
|
|
11
|
-
|
|
13
|
+
/** The cursor string. */
|
|
14
|
+
value: string;
|
|
12
15
|
|
|
13
16
|
// MEMBER DATA
|
|
14
17
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
18
|
+
* Initializes a new cursor from the given cursor string.
|
|
19
|
+
*
|
|
20
|
+
* @param cursorStr The string representation of the cursor.
|
|
17
21
|
*/
|
|
18
22
|
constructor(cursorStr: string) {
|
|
19
23
|
this.value = cursorStr;
|
|
@@ -21,18 +25,31 @@ export class Cursor {
|
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/**
|
|
24
|
-
*
|
|
28
|
+
* The data that us fetched batch-wise along with a cursor.
|
|
29
|
+
*
|
|
30
|
+
* @typeParam Type - The type of data present in the list.
|
|
31
|
+
* @public
|
|
25
32
|
*/
|
|
26
33
|
export interface CursoredData<Type> {
|
|
27
|
-
list
|
|
28
|
-
|
|
34
|
+
/** The list of data of the given type. */
|
|
35
|
+
list: Type[];
|
|
36
|
+
|
|
37
|
+
/** The cursor to the next batch of data. */
|
|
38
|
+
next: Cursor;
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
/**
|
|
32
|
-
*
|
|
42
|
+
* The data context from where data is to be fetched.
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
33
45
|
*/
|
|
34
46
|
export interface DataContext {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
/** Handles data related to users. */
|
|
48
|
+
users: UserService,
|
|
49
|
+
|
|
50
|
+
/** Handles data related to tweets. */
|
|
51
|
+
tweets: TweetService,
|
|
52
|
+
|
|
53
|
+
/** Handles account related operations. */
|
|
54
|
+
account: AccountService
|
|
38
55
|
}
|
package/src/types/data/Tweet.ts
CHANGED
|
@@ -1,45 +1,123 @@
|
|
|
1
|
-
// This file contains various objects related to handling of Tweets made by a user
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
2
|
+
* The filter to be used for fetching tweets from Twitter.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
5
|
*/
|
|
6
6
|
export interface TweetFilter {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
/** The list of words to search. */
|
|
8
|
+
words?: string[];
|
|
9
|
+
|
|
10
|
+
/** The list of hashtags to search.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* '#' must be excluded from the hashtag!
|
|
14
|
+
*/
|
|
15
|
+
hashtags?: string[];
|
|
16
|
+
|
|
17
|
+
/** The list of usernames whose tweets are to be searched.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* '@' must be excluded from the username!
|
|
21
|
+
*/
|
|
22
|
+
fromUsers?: string[];
|
|
23
|
+
|
|
24
|
+
/** The list of username to whom the tweets to be searched, are adressed.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* '@' must be excluded from the username!
|
|
28
|
+
*/
|
|
29
|
+
toUsers?: string[];
|
|
30
|
+
|
|
31
|
+
/** The list of username mentioned in the tweets to search.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* '@' must be excluded from the username!
|
|
35
|
+
*/
|
|
36
|
+
mentions?: string[];
|
|
37
|
+
|
|
38
|
+
/** The date starting from which tweets are to be searched.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* Must be in the format YYYY-MM-DD.
|
|
42
|
+
*/
|
|
43
|
+
startDate?: string;
|
|
44
|
+
|
|
45
|
+
/** The date upto which tweets are to be searched.
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* Must be in the format YYYY-MM-DD.
|
|
49
|
+
*/
|
|
50
|
+
endDate?: string;
|
|
51
|
+
|
|
52
|
+
/** The id of the tweet, after which the tweets are to be searched. */
|
|
53
|
+
sinceId?: string;
|
|
54
|
+
|
|
55
|
+
/** The id of the tweet which is quoted in the tweets to search. */
|
|
56
|
+
quoted?: string;
|
|
57
|
+
|
|
58
|
+
/** Whether to fetch tweets that are links or not.
|
|
59
|
+
*
|
|
60
|
+
* @defaultValue false
|
|
61
|
+
*/
|
|
62
|
+
links?: boolean;
|
|
17
63
|
};
|
|
18
64
|
|
|
19
65
|
/**
|
|
20
|
-
*
|
|
66
|
+
* The different types parsed entities like urls, media, mentions, hashtags, etc.
|
|
67
|
+
*
|
|
68
|
+
* @public
|
|
21
69
|
*/
|
|
22
70
|
export interface TweetEntities {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
71
|
+
/** The list of hashtags mentioned in the tweet. */
|
|
72
|
+
hashtags: string[];
|
|
73
|
+
|
|
74
|
+
/** The list of urls mentioned in the tweet. */
|
|
75
|
+
urls: string[];
|
|
76
|
+
|
|
77
|
+
/** The list of IDs of users mentioned in the tweet. */
|
|
78
|
+
mentionedUsers: string[];
|
|
79
|
+
|
|
80
|
+
/** The list of urls to various media mentioned in the tweet. */
|
|
81
|
+
media: string[];
|
|
27
82
|
}
|
|
28
83
|
|
|
29
84
|
/**
|
|
30
|
-
*
|
|
85
|
+
* The details of a single Tweet.
|
|
31
86
|
*/
|
|
32
87
|
export interface Tweet {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
88
|
+
/** The rest id of the tweet. */
|
|
89
|
+
id: string;
|
|
90
|
+
|
|
91
|
+
/** The rest id of the user who made the tweet. */
|
|
92
|
+
tweetBy: string;
|
|
93
|
+
|
|
94
|
+
/** The date and time of creation of the tweet, in UTC string format. */
|
|
95
|
+
createdAt: string;
|
|
96
|
+
|
|
97
|
+
/** Additional tweet entities like urls, mentions, etc. */
|
|
98
|
+
entities: TweetEntities;
|
|
99
|
+
|
|
100
|
+
/** The rest id of the tweet which is quoted in the tweet. */
|
|
101
|
+
quoted: string;
|
|
102
|
+
|
|
103
|
+
/** The full text content of the tweet. */
|
|
104
|
+
fullText: string;
|
|
105
|
+
|
|
106
|
+
/** The rest id of the user to which the tweet is a reply. */
|
|
107
|
+
replyTo: string;
|
|
108
|
+
|
|
109
|
+
/** The language in which the tweet is written. */
|
|
110
|
+
lang: string;
|
|
111
|
+
|
|
112
|
+
/** The number of quotes of the tweet. */
|
|
113
|
+
quoteCount: number;
|
|
114
|
+
|
|
115
|
+
/** The number of replies to the tweet. */
|
|
116
|
+
replyCount: number;
|
|
117
|
+
|
|
118
|
+
/** The number of retweets of the tweet. */
|
|
119
|
+
retweetCount: number;
|
|
120
|
+
|
|
121
|
+
/** The number of likes of the tweet. */
|
|
122
|
+
likeCount: number;
|
|
45
123
|
}
|
package/src/types/data/User.ts
CHANGED
|
@@ -1,21 +1,51 @@
|
|
|
1
|
-
// This file contains various objects for handling data related to User Account
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
2
|
+
* The details of a single user.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
5
|
*/
|
|
6
6
|
export interface User {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
/** The rest id of the user. */
|
|
8
|
+
id: string;
|
|
9
|
+
|
|
10
|
+
/** The username/screenname of the user. */
|
|
11
|
+
userName: string;
|
|
12
|
+
|
|
13
|
+
/** The full name of the user. */
|
|
14
|
+
fullName: string;
|
|
15
|
+
|
|
16
|
+
/** The creation date of user's account. */
|
|
17
|
+
createdAt: string;
|
|
18
|
+
|
|
19
|
+
/** The user's description. */
|
|
20
|
+
description: string;
|
|
21
|
+
|
|
22
|
+
/** Whether the account is verified or not. */
|
|
23
|
+
isVerified: boolean;
|
|
24
|
+
|
|
25
|
+
/** The number of tweets liked by the user. */
|
|
26
|
+
favouritesCount: number;
|
|
27
|
+
|
|
28
|
+
/** The number of followers of the user. */
|
|
29
|
+
followersCount: number;
|
|
30
|
+
|
|
31
|
+
/** The number of following of the user. */
|
|
32
|
+
followingsCount: number;
|
|
33
|
+
|
|
34
|
+
/** The number of tweets made by the user.
|
|
35
|
+
*
|
|
36
|
+
* @remarks This includes original tweets along with retweets.
|
|
37
|
+
*/
|
|
38
|
+
statusesCount: number;
|
|
39
|
+
|
|
40
|
+
/** The location of user as provided by user. */
|
|
41
|
+
location: string;
|
|
42
|
+
|
|
43
|
+
/** The rest id of the tweet pinned in the user's profile. */
|
|
44
|
+
pinnedTweet: string;
|
|
45
|
+
|
|
46
|
+
/** The url of the profile banner image. */
|
|
47
|
+
profileBanner: string;
|
|
48
|
+
|
|
49
|
+
/** The url of the profile image. */
|
|
50
|
+
profileImage: string;
|
|
21
51
|
}
|