rettiwt-api 5.1.0-alpha.0 → 6.0.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/.eslintrc.js +13 -8
- package/README.md +8 -1
- package/dist/cli.js +17 -14
- package/dist/cli.js.map +1 -1
- package/dist/collections/Extractors.d.ts +1 -1
- package/dist/collections/Extractors.js +21 -21
- package/dist/collections/Extractors.js.map +1 -1
- package/dist/collections/Groups.d.ts +4 -4
- package/dist/collections/Groups.js +45 -45
- package/dist/collections/Groups.js.map +1 -1
- package/dist/collections/Requests.d.ts +3 -3
- package/dist/collections/Requests.js +3 -3
- package/dist/collections/Requests.js.map +1 -1
- package/dist/collections/Tweet.d.ts +4 -4
- package/dist/collections/Tweet.js +5 -5
- package/dist/collections/Tweet.js.map +1 -1
- package/dist/commands/Tweet.js +32 -4
- package/dist/commands/Tweet.js.map +1 -1
- package/dist/enums/Api.d.ts +1 -1
- package/dist/enums/Api.js +7 -7
- package/dist/enums/Api.js.map +1 -1
- package/dist/enums/Authentication.d.ts +1 -1
- package/dist/enums/Authentication.js +7 -7
- package/dist/enums/Authentication.js.map +1 -1
- package/dist/enums/Data.d.ts +1 -1
- package/dist/enums/Data.js +7 -7
- package/dist/enums/Data.js.map +1 -1
- package/dist/enums/Logging.d.ts +1 -1
- package/dist/enums/Logging.js +11 -11
- package/dist/enums/Logging.js.map +1 -1
- package/dist/enums/Media.d.ts +1 -1
- package/dist/enums/Media.js +7 -7
- package/dist/enums/Media.js.map +1 -1
- package/dist/enums/Notification.d.ts +1 -1
- package/dist/enums/Notification.js +9 -9
- package/dist/enums/Notification.js.map +1 -1
- package/dist/enums/Resource.d.ts +1 -1
- package/dist/enums/Resource.js +42 -42
- package/dist/enums/Resource.js.map +1 -1
- package/dist/enums/Tweet.d.ts +1 -1
- package/dist/enums/Tweet.js +7 -7
- package/dist/enums/Tweet.js.map +1 -1
- package/dist/enums/raw/Analytics.d.ts +2 -2
- package/dist/enums/raw/Analytics.js +21 -21
- package/dist/enums/raw/Analytics.js.map +1 -1
- package/dist/enums/raw/Media.d.ts +1 -1
- package/dist/enums/raw/Media.js +7 -7
- package/dist/enums/raw/Media.js.map +1 -1
- package/dist/enums/raw/Notification.d.ts +1 -1
- package/dist/enums/raw/Notification.js +8 -8
- package/dist/enums/raw/Notification.js.map +1 -1
- package/dist/enums/raw/Tweet.d.ts +2 -2
- package/dist/enums/raw/Tweet.js +12 -12
- package/dist/enums/raw/Tweet.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/models/RettiwtConfig.d.ts +3 -4
- package/dist/models/RettiwtConfig.js +7 -7
- package/dist/models/RettiwtConfig.js.map +1 -1
- package/dist/models/args/FetchArgs.d.ts +3 -3
- package/dist/models/args/FetchArgs.js +3 -3
- package/dist/models/args/FetchArgs.js.map +1 -1
- package/dist/models/auth/AuthCredential.d.ts +2 -2
- package/dist/models/auth/AuthCredential.js +3 -3
- package/dist/models/auth/AuthCredential.js.map +1 -1
- package/dist/models/data/CursoredData.d.ts +2 -2
- package/dist/models/data/CursoredData.js +3 -3
- package/dist/models/data/CursoredData.js.map +1 -1
- package/dist/models/data/Notification.d.ts +2 -2
- package/dist/models/data/Notification.js +3 -3
- package/dist/models/data/Notification.js.map +1 -1
- package/dist/models/data/Tweet.d.ts +4 -4
- package/dist/models/data/Tweet.js +18 -18
- package/dist/models/data/Tweet.js.map +1 -1
- package/dist/models/data/User.js +9 -9
- package/dist/models/data/User.js.map +1 -1
- package/dist/requests/Tweet.d.ts +2 -2
- package/dist/requests/Tweet.js +2 -2
- package/dist/requests/Tweet.js.map +1 -1
- package/dist/requests/User.d.ts +2 -2
- package/dist/requests/User.js.map +1 -1
- package/dist/services/internal/AuthService.js +1 -1
- package/dist/services/internal/AuthService.js.map +1 -1
- package/dist/services/internal/ErrorService.d.ts +2 -2
- package/dist/services/internal/ErrorService.js +4 -4
- package/dist/services/internal/ErrorService.js.map +1 -1
- package/dist/services/internal/LogService.d.ts +2 -2
- package/dist/services/internal/LogService.js.map +1 -1
- package/dist/services/public/FetcherService.d.ts +7 -9
- package/dist/services/public/FetcherService.js +102 -51
- package/dist/services/public/FetcherService.js.map +1 -1
- package/dist/services/public/ListService.js +4 -4
- package/dist/services/public/ListService.js.map +1 -1
- package/dist/services/public/TweetService.d.ts +3 -3
- package/dist/services/public/TweetService.js +35 -35
- package/dist/services/public/TweetService.js.map +1 -1
- package/dist/services/public/UserService.js +37 -37
- package/dist/services/public/UserService.js.map +1 -1
- package/dist/types/RettiwtConfig.d.ts +6 -3
- package/dist/types/args/FetchArgs.d.ts +2 -2
- package/dist/types/auth/AuthCredential.d.ts +2 -2
- package/dist/types/auth/TransactionHeader.d.ts +6 -0
- package/dist/types/auth/TransactionHeader.js +4 -0
- package/dist/types/auth/TransactionHeader.js.map +1 -0
- package/dist/types/data/Notification.d.ts +2 -2
- package/dist/types/data/Tweet.d.ts +2 -2
- package/dist/types/raw/base/Media.d.ts +2 -2
- package/dist/types/raw/base/Notification.d.ts +2 -2
- package/package.json +19 -18
- package/src/cli.ts +20 -14
- package/src/collections/Extractors.ts +21 -21
- package/src/collections/Groups.ts +45 -45
- package/src/collections/Requests.ts +4 -4
- package/src/collections/Tweet.ts +6 -6
- package/src/commands/Tweet.ts +33 -4
- package/src/enums/Api.ts +1 -1
- package/src/enums/Authentication.ts +1 -1
- package/src/enums/Data.ts +1 -1
- package/src/enums/Logging.ts +1 -1
- package/src/enums/Media.ts +1 -1
- package/src/enums/Notification.ts +1 -1
- package/src/enums/Resource.ts +1 -1
- package/src/enums/Tweet.ts +1 -1
- package/src/enums/raw/Analytics.ts +2 -2
- package/src/enums/raw/Media.ts +1 -1
- package/src/enums/raw/Notification.ts +1 -1
- package/src/enums/raw/Tweet.ts +2 -2
- package/src/index.ts +0 -1
- package/src/models/RettiwtConfig.ts +7 -8
- package/src/models/args/FetchArgs.ts +5 -5
- package/src/models/auth/AuthCredential.ts +5 -5
- package/src/models/data/CursoredData.ts +5 -5
- package/src/models/data/Notification.ts +6 -6
- package/src/models/data/Tweet.ts +22 -22
- package/src/models/data/User.ts +10 -10
- package/src/requests/Tweet.ts +4 -4
- package/src/requests/User.ts +3 -3
- package/src/services/internal/AuthService.ts +2 -2
- package/src/services/internal/ErrorService.ts +4 -4
- package/src/services/internal/LogService.ts +2 -2
- package/src/services/public/FetcherService.ts +82 -57
- package/src/services/public/ListService.ts +6 -6
- package/src/services/public/TweetService.ts +39 -39
- package/src/services/public/UserService.ts +40 -40
- package/src/types/RettiwtConfig.ts +7 -4
- package/src/types/args/FetchArgs.ts +2 -2
- package/src/types/auth/AuthCredential.ts +2 -2
- package/src/types/auth/TransactionHeader.ts +8 -0
- package/src/types/data/Notification.ts +2 -2
- package/src/types/data/Tweet.ts +2 -2
- package/src/types/raw/base/Media.ts +2 -2
- package/src/types/raw/base/Notification.ts +2 -2
- package/.tool-versions +0 -1
- package/dist/helper/TidUtils.d.ts +0 -4
- package/dist/helper/TidUtils.js +0 -171
- package/dist/helper/TidUtils.js.map +0 -1
- package/dist/services/internal/TidService.d.ts +0 -43
- package/dist/services/internal/TidService.js +0 -156
- package/dist/services/internal/TidService.js.map +0 -1
- package/dist/types/auth/TidDynamicArgs.d.ts +0 -10
- package/dist/types/auth/TidDynamicArgs.js +0 -3
- package/dist/types/auth/TidDynamicArgs.js.map +0 -1
- package/dist/types/auth/TidHeader.d.ts +0 -8
- package/dist/types/auth/TidHeader.js +0 -3
- package/dist/types/auth/TidHeader.js.map +0 -1
- package/dist/types/auth/TidParams.d.ts +0 -27
- package/dist/types/auth/TidParams.js +0 -3
- package/dist/types/auth/TidParams.js.map +0 -1
- package/dist/types/auth/TidProvider.d.ts +0 -18
- package/dist/types/auth/TidProvider.js +0 -3
- package/dist/types/auth/TidProvider.js.map +0 -1
- package/src/helper/TidUtils.ts +0 -198
- package/src/services/internal/TidService.ts +0 -140
- package/src/types/auth/TidDynamicArgs.ts +0 -10
- package/src/types/auth/TidHeader.ts +0 -12
- package/src/types/auth/TidParams.ts +0 -36
- package/src/types/auth/TidProvider.ts +0 -19
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseType } from '../enums/Data';
|
|
2
2
|
import { CursoredData } from '../models/data/CursoredData';
|
|
3
3
|
import { Notification } from '../models/data/Notification';
|
|
4
4
|
import { Tweet } from '../models/data/Tweet';
|
|
@@ -43,13 +43,13 @@ import { IUserUnfollowResponse } from '../types/raw/user/Unfollow';
|
|
|
43
43
|
*
|
|
44
44
|
* @internal
|
|
45
45
|
*/
|
|
46
|
-
export const
|
|
46
|
+
export const Extractors = {
|
|
47
47
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
48
48
|
|
|
49
49
|
LIST_MEMBERS: (response: IListMembersResponse): CursoredData<User> =>
|
|
50
|
-
new CursoredData<User>(response,
|
|
50
|
+
new CursoredData<User>(response, BaseType.USER),
|
|
51
51
|
LIST_TWEETS: (response: IListTweetsResponse): CursoredData<Tweet> =>
|
|
52
|
-
new CursoredData<Tweet>(response,
|
|
52
|
+
new CursoredData<Tweet>(response, BaseType.TWEET),
|
|
53
53
|
|
|
54
54
|
MEDIA_UPLOAD_APPEND: (): void => undefined,
|
|
55
55
|
MEDIA_UPLOAD_FINALIZE: (): void => undefined,
|
|
@@ -61,17 +61,17 @@ export const extractors = {
|
|
|
61
61
|
TWEET_DETAILS_BULK: (response: ITweetDetailsBulkResponse, ids: string[]): Tweet[] => Tweet.multiple(response, ids),
|
|
62
62
|
TWEET_LIKE: (response: ITweetLikeResponse): boolean => (response?.data?.favorite_tweet ? true : false),
|
|
63
63
|
TWEET_LIKERS: (response: ITweetLikersResponse): CursoredData<User> =>
|
|
64
|
-
new CursoredData<User>(response,
|
|
64
|
+
new CursoredData<User>(response, BaseType.USER),
|
|
65
65
|
TWEET_POST: (response: ITweetPostResponse): string =>
|
|
66
66
|
response?.data?.create_tweet?.tweet_results?.result?.rest_id ?? undefined,
|
|
67
67
|
TWEET_REPLIES: (response: ITweetDetailsResponse): CursoredData<Tweet> =>
|
|
68
|
-
new CursoredData<Tweet>(response,
|
|
68
|
+
new CursoredData<Tweet>(response, BaseType.TWEET),
|
|
69
69
|
TWEET_RETWEET: (response: ITweetRetweetResponse): boolean => (response?.data?.create_retweet ? true : false),
|
|
70
70
|
TWEET_RETWEETERS: (response: ITweetRetweetersResponse): CursoredData<User> =>
|
|
71
|
-
new CursoredData<User>(response,
|
|
71
|
+
new CursoredData<User>(response, BaseType.USER),
|
|
72
72
|
TWEET_SCHEDULE: (response: ITweetScheduleResponse): string => response?.data?.tweet?.rest_id ?? undefined,
|
|
73
73
|
TWEET_SEARCH: (response: ITweetSearchResponse): CursoredData<Tweet> =>
|
|
74
|
-
new CursoredData<Tweet>(response,
|
|
74
|
+
new CursoredData<Tweet>(response, BaseType.TWEET),
|
|
75
75
|
TWEET_UNLIKE: (response: ITweetUnlikeResponse): boolean => (response?.data?.unfavorite_tweet ? true : false),
|
|
76
76
|
TWEET_UNPOST: (response: ITweetUnpostResponse): boolean => (response?.data?.delete_tweet ? true : false),
|
|
77
77
|
TWEET_UNRETWEET: (response: ITweetUnretweetResponse): boolean =>
|
|
@@ -79,36 +79,36 @@ export const extractors = {
|
|
|
79
79
|
TWEET_UNSCHEDULE: (response: ITweetUnscheduleResponse): boolean => response?.data?.scheduledtweet_delete == 'Done',
|
|
80
80
|
|
|
81
81
|
USER_AFFILIATES: (response: IUserAffiliatesResponse): CursoredData<User> =>
|
|
82
|
-
new CursoredData<User>(response,
|
|
82
|
+
new CursoredData<User>(response, BaseType.USER),
|
|
83
83
|
USER_BOOKMARKS: (response: IUserBookmarksResponse): CursoredData<Tweet> =>
|
|
84
|
-
new CursoredData<Tweet>(response,
|
|
84
|
+
new CursoredData<Tweet>(response, BaseType.TWEET),
|
|
85
85
|
USER_DETAILS_BY_USERNAME: (response: IUserDetailsResponse): User | undefined => User.single(response),
|
|
86
86
|
USER_DETAILS_BY_ID: (response: IUserDetailsResponse): User | undefined => User.single(response),
|
|
87
87
|
USER_DETAILS_BY_IDS_BULK: (response: IUserDetailsBulkResponse, ids: string[]): User[] =>
|
|
88
88
|
User.multiple(response, ids),
|
|
89
89
|
USER_FEED_FOLLOWED: (response: IUserFollowedResponse): CursoredData<Tweet> =>
|
|
90
|
-
new CursoredData<Tweet>(response,
|
|
90
|
+
new CursoredData<Tweet>(response, BaseType.TWEET),
|
|
91
91
|
USER_FEED_RECOMMENDED: (response: IUserRecommendedResponse): CursoredData<Tweet> =>
|
|
92
|
-
new CursoredData<Tweet>(response,
|
|
92
|
+
new CursoredData<Tweet>(response, BaseType.TWEET),
|
|
93
93
|
USER_FOLLOW: (response: IUserFollowResponse): boolean => (response?.id ? true : false),
|
|
94
94
|
USER_FOLLOWING: (response: IUserFollowingResponse): CursoredData<User> =>
|
|
95
|
-
new CursoredData<User>(response,
|
|
95
|
+
new CursoredData<User>(response, BaseType.USER),
|
|
96
96
|
USER_FOLLOWERS: (response: IUserFollowersResponse): CursoredData<User> =>
|
|
97
|
-
new CursoredData<User>(response,
|
|
97
|
+
new CursoredData<User>(response, BaseType.USER),
|
|
98
98
|
USER_HIGHLIGHTS: (response: IUserHighlightsResponse): CursoredData<Tweet> =>
|
|
99
|
-
new CursoredData<Tweet>(response,
|
|
99
|
+
new CursoredData<Tweet>(response, BaseType.TWEET),
|
|
100
100
|
USER_LIKES: (response: IUserLikesResponse): CursoredData<Tweet> =>
|
|
101
|
-
new CursoredData<Tweet>(response,
|
|
101
|
+
new CursoredData<Tweet>(response, BaseType.TWEET),
|
|
102
102
|
USER_MEDIA: (response: IUserMediaResponse): CursoredData<Tweet> =>
|
|
103
|
-
new CursoredData<Tweet>(response,
|
|
103
|
+
new CursoredData<Tweet>(response, BaseType.TWEET),
|
|
104
104
|
USER_NOTIFICATIONS: (response: IUserNotificationsResponse): CursoredData<Notification> =>
|
|
105
|
-
new CursoredData<Notification>(response,
|
|
105
|
+
new CursoredData<Notification>(response, BaseType.NOTIFICATION),
|
|
106
106
|
USER_SUBSCRIPTIONS: (response: IUserSubscriptionsResponse): CursoredData<User> =>
|
|
107
|
-
new CursoredData<User>(response,
|
|
107
|
+
new CursoredData<User>(response, BaseType.USER),
|
|
108
108
|
USER_TIMELINE: (response: IUserTweetsResponse): CursoredData<Tweet> =>
|
|
109
|
-
new CursoredData<Tweet>(response,
|
|
109
|
+
new CursoredData<Tweet>(response, BaseType.TWEET),
|
|
110
110
|
USER_TIMELINE_AND_REPLIES: (response: IUserTweetsAndRepliesResponse): CursoredData<Tweet> =>
|
|
111
|
-
new CursoredData<Tweet>(response,
|
|
111
|
+
new CursoredData<Tweet>(response, BaseType.TWEET),
|
|
112
112
|
USER_UNFOLLOW: (response: IUserUnfollowResponse): boolean => (response?.id ? true : false),
|
|
113
113
|
|
|
114
114
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResourceType } from '../enums/Resource';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Collection of resources that allow guest authentication.
|
|
5
5
|
*
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export const AllowGuestAuthenticationGroup = [
|
|
9
|
+
ResourceType.TWEET_DETAILS,
|
|
10
|
+
ResourceType.USER_DETAILS_BY_USERNAME,
|
|
11
|
+
ResourceType.USER_TIMELINE,
|
|
12
12
|
];
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -16,32 +16,32 @@ export const allowGuestAuthentication = [
|
|
|
16
16
|
*
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
|
-
export const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
19
|
+
export const FetchResourcesGroup = [
|
|
20
|
+
ResourceType.LIST_MEMBERS,
|
|
21
|
+
ResourceType.LIST_TWEETS,
|
|
22
|
+
ResourceType.TWEET_DETAILS,
|
|
23
|
+
ResourceType.TWEET_DETAILS_ALT,
|
|
24
|
+
ResourceType.TWEET_DETAILS_BULK,
|
|
25
|
+
ResourceType.TWEET_LIKERS,
|
|
26
|
+
ResourceType.TWEET_REPLIES,
|
|
27
|
+
ResourceType.TWEET_RETWEETERS,
|
|
28
|
+
ResourceType.TWEET_SEARCH,
|
|
29
|
+
ResourceType.USER_AFFILIATES,
|
|
30
|
+
ResourceType.USER_BOOKMARKS,
|
|
31
|
+
ResourceType.USER_DETAILS_BY_USERNAME,
|
|
32
|
+
ResourceType.USER_DETAILS_BY_ID,
|
|
33
|
+
ResourceType.USER_DETAILS_BY_IDS_BULK,
|
|
34
|
+
ResourceType.USER_FEED_FOLLOWED,
|
|
35
|
+
ResourceType.USER_FEED_RECOMMENDED,
|
|
36
|
+
ResourceType.USER_FOLLOWING,
|
|
37
|
+
ResourceType.USER_FOLLOWERS,
|
|
38
|
+
ResourceType.USER_HIGHLIGHTS,
|
|
39
|
+
ResourceType.USER_LIKES,
|
|
40
|
+
ResourceType.USER_MEDIA,
|
|
41
|
+
ResourceType.USER_NOTIFICATIONS,
|
|
42
|
+
ResourceType.USER_SUBSCRIPTIONS,
|
|
43
|
+
ResourceType.USER_TIMELINE,
|
|
44
|
+
ResourceType.USER_TIMELINE_AND_REPLIES,
|
|
45
45
|
];
|
|
46
46
|
|
|
47
47
|
/**
|
|
@@ -49,18 +49,18 @@ export const fetchResources = [
|
|
|
49
49
|
*
|
|
50
50
|
* @internal
|
|
51
51
|
*/
|
|
52
|
-
export const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
export const PostResourcesGroup = [
|
|
53
|
+
ResourceType.MEDIA_UPLOAD_APPEND,
|
|
54
|
+
ResourceType.MEDIA_UPLOAD_FINALIZE,
|
|
55
|
+
ResourceType.MEDIA_UPLOAD_INITIALIZE,
|
|
56
|
+
ResourceType.TWEET_LIKE,
|
|
57
|
+
ResourceType.TWEET_POST,
|
|
58
|
+
ResourceType.TWEET_RETWEET,
|
|
59
|
+
ResourceType.TWEET_SCHEDULE,
|
|
60
|
+
ResourceType.TWEET_UNLIKE,
|
|
61
|
+
ResourceType.TWEET_UNPOST,
|
|
62
|
+
ResourceType.TWEET_UNRETWEET,
|
|
63
|
+
ResourceType.TWEET_UNSCHEDULE,
|
|
64
|
+
ResourceType.USER_FOLLOW,
|
|
65
|
+
ResourceType.USER_UNFOLLOW,
|
|
66
66
|
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ResourceType } from '../enums/Resource';
|
|
4
4
|
import { ListRequests } from '../requests/List';
|
|
5
5
|
import { MediaRequests } from '../requests/Media';
|
|
6
6
|
import { TweetRequests } from '../requests/Tweet';
|
|
@@ -8,14 +8,14 @@ import { UserRequests } from '../requests/User';
|
|
|
8
8
|
import { IFetchArgs } from '../types/args/FetchArgs';
|
|
9
9
|
import { IPostArgs } from '../types/args/PostArgs';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { TweetRepliesSortTypeMap } from './Tweet';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Collection of requests to various resources.
|
|
15
15
|
*
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
|
-
export const
|
|
18
|
+
export const Requests: { [key in keyof typeof ResourceType]: (args: IFetchArgs | IPostArgs) => AxiosRequestConfig } = {
|
|
19
19
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
20
20
|
|
|
21
21
|
LIST_MEMBERS: (args: IFetchArgs) => ListRequests.members(args.id!, args.count, args.cursor),
|
|
@@ -32,7 +32,7 @@ export const requests: { [key in keyof typeof EResourceType]: (args: IFetchArgs
|
|
|
32
32
|
TWEET_LIKERS: (args: IFetchArgs) => TweetRequests.likers(args.id!, args.count, args.cursor),
|
|
33
33
|
TWEET_POST: (args: IPostArgs) => TweetRequests.post(args.tweet!),
|
|
34
34
|
TWEET_REPLIES: (args: IFetchArgs) =>
|
|
35
|
-
TweetRequests.replies(args.id!, args.cursor, args.sortBy ?
|
|
35
|
+
TweetRequests.replies(args.id!, args.cursor, args.sortBy ? TweetRepliesSortTypeMap[args.sortBy] : undefined),
|
|
36
36
|
TWEET_RETWEET: (args: IPostArgs) => TweetRequests.retweet(args.id!),
|
|
37
37
|
TWEET_RETWEETERS: (args: IFetchArgs) => TweetRequests.retweeters(args.id!, args.count, args.cursor),
|
|
38
38
|
TWEET_SCHEDULE: (args: IPostArgs) => TweetRequests.schedule(args.tweet!),
|
package/src/collections/Tweet.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { RawTweetRepliesSortType } from '../enums/raw/Tweet';
|
|
2
|
+
import { TweetRepliesSortType } from '../enums/Tweet';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Collection of mapping from parsed reply sort type to raw reply sort type.
|
|
6
6
|
*
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
|
-
export const
|
|
9
|
+
export const TweetRepliesSortTypeMap: { [key in keyof typeof TweetRepliesSortType]: RawTweetRepliesSortType } = {
|
|
10
10
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
11
11
|
|
|
12
|
-
LATEST:
|
|
13
|
-
LIKES:
|
|
14
|
-
RELEVANCE:
|
|
12
|
+
LATEST: RawTweetRepliesSortType.LATEST,
|
|
13
|
+
LIKES: RawTweetRepliesSortType.LIKES,
|
|
14
|
+
RELEVANCE: RawTweetRepliesSortType.RELEVACE,
|
|
15
15
|
|
|
16
16
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
17
17
|
};
|
package/src/commands/Tweet.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command, createCommand } from 'commander';
|
|
2
2
|
|
|
3
|
+
import { TweetRepliesSortType } from '../enums/Tweet';
|
|
3
4
|
import { output } from '../helper/CliUtils';
|
|
4
5
|
import { TweetFilter } from '../models/args/FetchArgs';
|
|
5
6
|
import { Rettiwt } from '../Rettiwt';
|
|
@@ -63,8 +64,8 @@ function createTweetCommand(rettiwt: Rettiwt): Command {
|
|
|
63
64
|
.argument('[cursor]', 'The cursor to the batch of likers to fetch')
|
|
64
65
|
.action(async (id: string, count?: string, cursor?: string) => {
|
|
65
66
|
try {
|
|
66
|
-
const
|
|
67
|
-
output(
|
|
67
|
+
const users = await rettiwt.tweet.likers(id, count ? parseInt(count) : undefined, cursor);
|
|
68
|
+
output(users);
|
|
68
69
|
} catch (error) {
|
|
69
70
|
output(error);
|
|
70
71
|
}
|
|
@@ -95,6 +96,34 @@ function createTweetCommand(rettiwt: Rettiwt): Command {
|
|
|
95
96
|
}
|
|
96
97
|
});
|
|
97
98
|
|
|
99
|
+
// Replies
|
|
100
|
+
tweet
|
|
101
|
+
.command('replies')
|
|
102
|
+
.description(
|
|
103
|
+
'Fetch the list of replies to a tweet, with the first batch containing the whole thread, if the tweet is/part of a thread',
|
|
104
|
+
)
|
|
105
|
+
.argument('<id>', 'The id of the tweet')
|
|
106
|
+
.argument('[cursor]', 'The cursor to the batch of replies to fetch')
|
|
107
|
+
.option('-s, --sort-by <string>', 'Sort the tweets by likes, latest or relevance, default is latest')
|
|
108
|
+
.action(async (id: string, cursor?: string, options?: { sortBy: string }) => {
|
|
109
|
+
try {
|
|
110
|
+
// Determining the sort type
|
|
111
|
+
let sortType: TweetRepliesSortType | undefined = undefined;
|
|
112
|
+
if (options?.sortBy === 'likes') {
|
|
113
|
+
sortType = TweetRepliesSortType.LIKES;
|
|
114
|
+
} else if (options?.sortBy === 'latest') {
|
|
115
|
+
sortType = TweetRepliesSortType.LATEST;
|
|
116
|
+
} else if (options?.sortBy === 'relevance') {
|
|
117
|
+
sortType = TweetRepliesSortType.RELEVANCE;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const tweets = await rettiwt.tweet.replies(id, cursor, sortType);
|
|
121
|
+
output(tweets);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
output(error);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
98
127
|
// Retweet
|
|
99
128
|
tweet
|
|
100
129
|
.command('retweet')
|
|
@@ -118,8 +147,8 @@ function createTweetCommand(rettiwt: Rettiwt): Command {
|
|
|
118
147
|
.argument('[cursor]', 'The cursor to the batch of retweeters to fetch')
|
|
119
148
|
.action(async (id: string, count?: string, cursor?: string) => {
|
|
120
149
|
try {
|
|
121
|
-
const
|
|
122
|
-
output(
|
|
150
|
+
const users = await rettiwt.tweet.retweeters(id, count ? parseInt(count) : undefined, cursor);
|
|
151
|
+
output(users);
|
|
123
152
|
} catch (error) {
|
|
124
153
|
output(error);
|
|
125
154
|
}
|
package/src/enums/Api.ts
CHANGED
package/src/enums/Data.ts
CHANGED
package/src/enums/Logging.ts
CHANGED
package/src/enums/Media.ts
CHANGED
package/src/enums/Resource.ts
CHANGED
package/src/enums/Tweet.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
|
-
export enum
|
|
6
|
+
export enum RawAnalyticsGranularity {
|
|
7
7
|
DAILY = 'Daily',
|
|
8
8
|
WEEKLY = 'Weekly',
|
|
9
9
|
MONTHLY = 'Monthly',
|
|
@@ -14,7 +14,7 @@ export enum ERawAnalyticsGranularity {
|
|
|
14
14
|
*
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
|
-
export enum
|
|
17
|
+
export enum RawAnalyticsMetric {
|
|
18
18
|
ENGAGEMENTS = 'Engagements',
|
|
19
19
|
IMPRESSIONS = 'Impressions',
|
|
20
20
|
PROFILE_VISITS = 'ProfileVisits',
|
package/src/enums/raw/Media.ts
CHANGED
package/src/enums/raw/Tweet.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
|
-
export enum
|
|
6
|
+
export enum RawTweetSearchResultType {
|
|
7
7
|
LATEST = 'Latest',
|
|
8
8
|
TOP = 'Top',
|
|
9
9
|
}
|
|
@@ -13,7 +13,7 @@ export enum ERawTweetSearchResultType {
|
|
|
13
13
|
*
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
|
-
export enum
|
|
16
|
+
export enum RawTweetRepliesSortType {
|
|
17
17
|
RELEVACE = 'Relevance',
|
|
18
18
|
LATEST = 'Recency',
|
|
19
19
|
LIKES = 'Likes',
|
package/src/index.ts
CHANGED
|
@@ -40,7 +40,6 @@ export * from './services/public/UserService';
|
|
|
40
40
|
// TYPES
|
|
41
41
|
export * from './types/args/FetchArgs';
|
|
42
42
|
export * from './types/args/PostArgs';
|
|
43
|
-
export * from './types/auth/TidProvider';
|
|
44
43
|
export * from './types/data/CursoredData';
|
|
45
44
|
export * from './types/data/List';
|
|
46
45
|
export * from './types/data/Notification';
|
|
@@ -3,7 +3,6 @@ import { Agent } from 'https';
|
|
|
3
3
|
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
4
4
|
|
|
5
5
|
import { AuthService } from '../services/internal/AuthService';
|
|
6
|
-
import { ITidProvider } from '../types/auth/TidProvider';
|
|
7
6
|
import { IErrorHandler } from '../types/ErrorHandler';
|
|
8
7
|
import { IRettiwtConfig } from '../types/RettiwtConfig';
|
|
9
8
|
|
|
@@ -12,7 +11,7 @@ import { IRettiwtConfig } from '../types/RettiwtConfig';
|
|
|
12
11
|
*
|
|
13
12
|
* @public
|
|
14
13
|
*/
|
|
15
|
-
const
|
|
14
|
+
const DefaultHeaders = {
|
|
16
15
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
17
16
|
|
|
18
17
|
Authority: 'x.com',
|
|
@@ -43,7 +42,7 @@ export class RettiwtConfig implements IRettiwtConfig {
|
|
|
43
42
|
public readonly delay?: number | (() => number | Promise<number>);
|
|
44
43
|
public readonly errorHandler?: IErrorHandler;
|
|
45
44
|
public readonly logging?: boolean;
|
|
46
|
-
public readonly
|
|
45
|
+
public readonly maxRetries: number;
|
|
47
46
|
public readonly timeout?: number;
|
|
48
47
|
|
|
49
48
|
/**
|
|
@@ -53,14 +52,14 @@ export class RettiwtConfig implements IRettiwtConfig {
|
|
|
53
52
|
this._apiKey = config?.apiKey;
|
|
54
53
|
this._httpsAgent = config?.proxyUrl ? new HttpsProxyAgent(config?.proxyUrl) : new Agent();
|
|
55
54
|
this._userId = config?.apiKey ? AuthService.getUserId(config?.apiKey) : undefined;
|
|
56
|
-
this.delay = config?.delay;
|
|
55
|
+
this.delay = config?.delay ?? 0;
|
|
56
|
+
this.maxRetries = config?.maxRetries ?? 0;
|
|
57
57
|
this.errorHandler = config?.errorHandler;
|
|
58
58
|
this.logging = config?.logging;
|
|
59
|
-
this.tidProvider = config?.tidProvider;
|
|
60
59
|
this.timeout = config?.timeout;
|
|
61
60
|
this.apiKey = config?.apiKey;
|
|
62
61
|
this._headers = {
|
|
63
|
-
...
|
|
62
|
+
...DefaultHeaders,
|
|
64
63
|
...config?.headers,
|
|
65
64
|
};
|
|
66
65
|
}
|
|
@@ -90,7 +89,7 @@ export class RettiwtConfig implements IRettiwtConfig {
|
|
|
90
89
|
|
|
91
90
|
public set headers(headers: { [key: string]: string } | undefined) {
|
|
92
91
|
this._headers = {
|
|
93
|
-
...
|
|
92
|
+
...DefaultHeaders,
|
|
94
93
|
...headers,
|
|
95
94
|
};
|
|
96
95
|
}
|
|
@@ -100,4 +99,4 @@ export class RettiwtConfig implements IRettiwtConfig {
|
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
|
|
103
|
-
export {
|
|
102
|
+
export { DefaultHeaders as DefaultRettiwtHeaders };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TweetRepliesSortType } from '../../enums/Tweet';
|
|
2
2
|
import { IFetchArgs, ITweetFilter } from '../../types/args/FetchArgs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -12,7 +12,7 @@ export class FetchArgs implements IFetchArgs {
|
|
|
12
12
|
public filter?: TweetFilter;
|
|
13
13
|
public id?: string;
|
|
14
14
|
public ids?: string[];
|
|
15
|
-
public sortBy?:
|
|
15
|
+
public sortBy?: TweetRepliesSortType;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @param args - Additional user-defined arguments for fetching the resource.
|
|
@@ -93,7 +93,7 @@ export class TweetFilter implements ITweetFilter {
|
|
|
93
93
|
* @param date - The date object to convert.
|
|
94
94
|
* @returns The Twitter string representation of the date.
|
|
95
95
|
*/
|
|
96
|
-
private static
|
|
96
|
+
private static _dateToTwitterString(date: Date): string {
|
|
97
97
|
// Converting localized date to UTC date
|
|
98
98
|
const utc = new Date(
|
|
99
99
|
Date.UTC(
|
|
@@ -135,8 +135,8 @@ export class TweetFilter implements ITweetFilter {
|
|
|
135
135
|
this.minLikes ? `min_faves:${this.minLikes}` : '',
|
|
136
136
|
this.minRetweets ? `min_retweets:${this.minRetweets}` : '',
|
|
137
137
|
this.language ? `lang:${this.language}` : '',
|
|
138
|
-
this.startDate ? `since:${TweetFilter.
|
|
139
|
-
this.endDate ? `until:${TweetFilter.
|
|
138
|
+
this.startDate ? `since:${TweetFilter._dateToTwitterString(this.startDate)}` : '',
|
|
139
|
+
this.endDate ? `until:${TweetFilter._dateToTwitterString(this.endDate)}` : '',
|
|
140
140
|
this.sinceId ? `since_id:${this.sinceId}` : '',
|
|
141
141
|
this.maxId ? `max_id:${this.maxId}` : '',
|
|
142
142
|
this.quoted ? `quoted_tweet_id:${this.quoted}` : '',
|
|
@@ -2,7 +2,7 @@ import { AxiosHeaders, AxiosRequestHeaders } from 'axios';
|
|
|
2
2
|
|
|
3
3
|
import { Cookie } from 'cookiejar';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { AuthenticationType } from '../../enums/Authentication';
|
|
6
6
|
import { IAuthCredential } from '../../types/auth/AuthCredential';
|
|
7
7
|
|
|
8
8
|
import { AuthCookie } from './AuthCookie';
|
|
@@ -19,7 +19,7 @@ import { AuthCookie } from './AuthCookie';
|
|
|
19
19
|
*/
|
|
20
20
|
export class AuthCredential implements IAuthCredential {
|
|
21
21
|
public authToken?: string;
|
|
22
|
-
public authenticationType?:
|
|
22
|
+
public authenticationType?: AuthenticationType;
|
|
23
23
|
public cookies?: string;
|
|
24
24
|
public csrfToken?: string;
|
|
25
25
|
public guestToken?: string;
|
|
@@ -34,7 +34,7 @@ export class AuthCredential implements IAuthCredential {
|
|
|
34
34
|
// If guest credentials given
|
|
35
35
|
if (!cookies && guestToken) {
|
|
36
36
|
this.guestToken = guestToken;
|
|
37
|
-
this.authenticationType =
|
|
37
|
+
this.authenticationType = AuthenticationType.GUEST;
|
|
38
38
|
}
|
|
39
39
|
// If login credentials given
|
|
40
40
|
else if (cookies && guestToken) {
|
|
@@ -43,7 +43,7 @@ export class AuthCredential implements IAuthCredential {
|
|
|
43
43
|
|
|
44
44
|
this.cookies = parsedCookie.toString();
|
|
45
45
|
this.guestToken = guestToken;
|
|
46
|
-
this.authenticationType =
|
|
46
|
+
this.authenticationType = AuthenticationType.LOGIN;
|
|
47
47
|
}
|
|
48
48
|
// If user credentials given
|
|
49
49
|
else if (cookies && !guestToken) {
|
|
@@ -52,7 +52,7 @@ export class AuthCredential implements IAuthCredential {
|
|
|
52
52
|
|
|
53
53
|
this.cookies = parsedCookie.toString();
|
|
54
54
|
this.csrfToken = parsedCookie.ct0;
|
|
55
|
-
this.authenticationType =
|
|
55
|
+
this.authenticationType = AuthenticationType.USER;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseType } from '../../enums/Data';
|
|
2
2
|
|
|
3
3
|
import { findByFilter } from '../../helper/JsonUtils';
|
|
4
4
|
|
|
@@ -24,18 +24,18 @@ export class CursoredData<T extends Notification | Tweet | User> implements ICur
|
|
|
24
24
|
* @param response - The raw response.
|
|
25
25
|
* @param type - The base type of the data included in the batch.
|
|
26
26
|
*/
|
|
27
|
-
public constructor(response: NonNullable<unknown>, type:
|
|
27
|
+
public constructor(response: NonNullable<unknown>, type: BaseType) {
|
|
28
28
|
// Initializing defaults
|
|
29
29
|
this.list = [];
|
|
30
30
|
this.next = '';
|
|
31
31
|
|
|
32
|
-
if (type ==
|
|
32
|
+
if (type == BaseType.TWEET) {
|
|
33
33
|
this.list = Tweet.timeline(response) as T[];
|
|
34
34
|
this.next = findByFilter<IRawCursor>(response, 'cursorType', 'Bottom')[0]?.value ?? '';
|
|
35
|
-
} else if (type ==
|
|
35
|
+
} else if (type == BaseType.USER) {
|
|
36
36
|
this.list = User.timeline(response) as T[];
|
|
37
37
|
this.next = findByFilter<IRawCursor>(response, 'cursorType', 'Bottom')[0]?.value ?? '';
|
|
38
|
-
} else if (type ==
|
|
38
|
+
} else if (type == BaseType.NOTIFICATION) {
|
|
39
39
|
this.list = Notification.list(response) as T[];
|
|
40
40
|
this.next = findByFilter<IRawCursor>(response, 'cursorType', 'Top')[0]?.value ?? '';
|
|
41
41
|
}
|