rettiwt-api 5.0.1 → 6.0.0

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.
Files changed (150) hide show
  1. package/.eslintrc.js +13 -8
  2. package/README.md +8 -1
  3. package/dist/cli.js +17 -14
  4. package/dist/cli.js.map +1 -1
  5. package/dist/collections/Extractors.d.ts +1 -1
  6. package/dist/collections/Extractors.js +21 -21
  7. package/dist/collections/Extractors.js.map +1 -1
  8. package/dist/collections/Groups.d.ts +4 -4
  9. package/dist/collections/Groups.js +45 -45
  10. package/dist/collections/Groups.js.map +1 -1
  11. package/dist/collections/Requests.d.ts +3 -3
  12. package/dist/collections/Requests.js +3 -3
  13. package/dist/collections/Requests.js.map +1 -1
  14. package/dist/collections/Tweet.d.ts +4 -4
  15. package/dist/collections/Tweet.js +5 -5
  16. package/dist/collections/Tweet.js.map +1 -1
  17. package/dist/commands/Tweet.js +48 -12
  18. package/dist/commands/Tweet.js.map +1 -1
  19. package/dist/enums/Api.d.ts +1 -1
  20. package/dist/enums/Api.js +7 -7
  21. package/dist/enums/Api.js.map +1 -1
  22. package/dist/enums/Authentication.d.ts +1 -1
  23. package/dist/enums/Authentication.js +7 -7
  24. package/dist/enums/Authentication.js.map +1 -1
  25. package/dist/enums/Data.d.ts +1 -1
  26. package/dist/enums/Data.js +7 -7
  27. package/dist/enums/Data.js.map +1 -1
  28. package/dist/enums/Logging.d.ts +1 -1
  29. package/dist/enums/Logging.js +11 -11
  30. package/dist/enums/Logging.js.map +1 -1
  31. package/dist/enums/Media.d.ts +1 -1
  32. package/dist/enums/Media.js +7 -7
  33. package/dist/enums/Media.js.map +1 -1
  34. package/dist/enums/Notification.d.ts +1 -1
  35. package/dist/enums/Notification.js +9 -9
  36. package/dist/enums/Notification.js.map +1 -1
  37. package/dist/enums/Resource.d.ts +1 -1
  38. package/dist/enums/Resource.js +42 -42
  39. package/dist/enums/Resource.js.map +1 -1
  40. package/dist/enums/Tweet.d.ts +1 -1
  41. package/dist/enums/Tweet.js +7 -7
  42. package/dist/enums/Tweet.js.map +1 -1
  43. package/dist/enums/raw/Analytics.d.ts +2 -2
  44. package/dist/enums/raw/Analytics.js +21 -21
  45. package/dist/enums/raw/Analytics.js.map +1 -1
  46. package/dist/enums/raw/Media.d.ts +1 -1
  47. package/dist/enums/raw/Media.js +7 -7
  48. package/dist/enums/raw/Media.js.map +1 -1
  49. package/dist/enums/raw/Notification.d.ts +1 -1
  50. package/dist/enums/raw/Notification.js +8 -8
  51. package/dist/enums/raw/Notification.js.map +1 -1
  52. package/dist/enums/raw/Tweet.d.ts +2 -2
  53. package/dist/enums/raw/Tweet.js +12 -12
  54. package/dist/enums/raw/Tweet.js.map +1 -1
  55. package/dist/models/RettiwtConfig.d.ts +3 -2
  56. package/dist/models/RettiwtConfig.js +7 -5
  57. package/dist/models/RettiwtConfig.js.map +1 -1
  58. package/dist/models/args/FetchArgs.d.ts +7 -5
  59. package/dist/models/args/FetchArgs.js +15 -9
  60. package/dist/models/args/FetchArgs.js.map +1 -1
  61. package/dist/models/auth/AuthCredential.d.ts +2 -2
  62. package/dist/models/auth/AuthCredential.js +3 -3
  63. package/dist/models/auth/AuthCredential.js.map +1 -1
  64. package/dist/models/data/CursoredData.d.ts +2 -2
  65. package/dist/models/data/CursoredData.js +3 -3
  66. package/dist/models/data/CursoredData.js.map +1 -1
  67. package/dist/models/data/Notification.d.ts +2 -2
  68. package/dist/models/data/Notification.js +3 -3
  69. package/dist/models/data/Notification.js.map +1 -1
  70. package/dist/models/data/Tweet.d.ts +4 -4
  71. package/dist/models/data/Tweet.js +18 -18
  72. package/dist/models/data/Tweet.js.map +1 -1
  73. package/dist/models/data/User.js +9 -9
  74. package/dist/models/data/User.js.map +1 -1
  75. package/dist/requests/Tweet.d.ts +2 -2
  76. package/dist/requests/Tweet.js +2 -2
  77. package/dist/requests/Tweet.js.map +1 -1
  78. package/dist/requests/User.d.ts +2 -2
  79. package/dist/requests/User.js.map +1 -1
  80. package/dist/services/internal/AuthService.js +1 -1
  81. package/dist/services/internal/AuthService.js.map +1 -1
  82. package/dist/services/internal/ErrorService.d.ts +2 -2
  83. package/dist/services/internal/ErrorService.js +4 -4
  84. package/dist/services/internal/ErrorService.js.map +1 -1
  85. package/dist/services/internal/LogService.d.ts +2 -2
  86. package/dist/services/internal/LogService.js.map +1 -1
  87. package/dist/services/internal/TidService.d.ts +4 -4
  88. package/dist/services/internal/TidService.js +10 -10
  89. package/dist/services/internal/TidService.js.map +1 -1
  90. package/dist/services/public/FetcherService.d.ts +7 -7
  91. package/dist/services/public/FetcherService.js +79 -35
  92. package/dist/services/public/FetcherService.js.map +1 -1
  93. package/dist/services/public/ListService.js +4 -4
  94. package/dist/services/public/ListService.js.map +1 -1
  95. package/dist/services/public/TweetService.d.ts +3 -3
  96. package/dist/services/public/TweetService.js +35 -35
  97. package/dist/services/public/TweetService.js.map +1 -1
  98. package/dist/services/public/UserService.js +37 -37
  99. package/dist/services/public/UserService.js.map +1 -1
  100. package/dist/types/RettiwtConfig.d.ts +6 -0
  101. package/dist/types/args/FetchArgs.d.ts +14 -6
  102. package/dist/types/auth/AuthCredential.d.ts +2 -2
  103. package/dist/types/data/Notification.d.ts +2 -2
  104. package/dist/types/data/Tweet.d.ts +2 -2
  105. package/dist/types/raw/base/Media.d.ts +2 -2
  106. package/dist/types/raw/base/Notification.d.ts +2 -2
  107. package/package.json +18 -18
  108. package/src/cli.ts +20 -14
  109. package/src/collections/Extractors.ts +21 -21
  110. package/src/collections/Groups.ts +45 -45
  111. package/src/collections/Requests.ts +4 -4
  112. package/src/collections/Tweet.ts +6 -6
  113. package/src/commands/Tweet.ts +49 -12
  114. package/src/enums/Api.ts +1 -1
  115. package/src/enums/Authentication.ts +1 -1
  116. package/src/enums/Data.ts +1 -1
  117. package/src/enums/Logging.ts +1 -1
  118. package/src/enums/Media.ts +1 -1
  119. package/src/enums/Notification.ts +1 -1
  120. package/src/enums/Resource.ts +1 -1
  121. package/src/enums/Tweet.ts +1 -1
  122. package/src/enums/raw/Analytics.ts +2 -2
  123. package/src/enums/raw/Media.ts +1 -1
  124. package/src/enums/raw/Notification.ts +1 -1
  125. package/src/enums/raw/Tweet.ts +2 -2
  126. package/src/models/RettiwtConfig.ts +7 -5
  127. package/src/models/args/FetchArgs.ts +17 -11
  128. package/src/models/auth/AuthCredential.ts +5 -5
  129. package/src/models/data/CursoredData.ts +5 -5
  130. package/src/models/data/Notification.ts +6 -6
  131. package/src/models/data/Tweet.ts +22 -22
  132. package/src/models/data/User.ts +10 -10
  133. package/src/requests/Tweet.ts +4 -4
  134. package/src/requests/User.ts +3 -3
  135. package/src/services/internal/AuthService.ts +2 -2
  136. package/src/services/internal/ErrorService.ts +4 -4
  137. package/src/services/internal/LogService.ts +2 -2
  138. package/src/services/internal/TidService.ts +11 -11
  139. package/src/services/public/FetcherService.ts +54 -38
  140. package/src/services/public/ListService.ts +6 -6
  141. package/src/services/public/TweetService.ts +39 -39
  142. package/src/services/public/UserService.ts +40 -40
  143. package/src/types/RettiwtConfig.ts +7 -0
  144. package/src/types/args/FetchArgs.ts +18 -8
  145. package/src/types/auth/AuthCredential.ts +2 -2
  146. package/src/types/data/Notification.ts +2 -2
  147. package/src/types/data/Tweet.ts +2 -2
  148. package/src/types/raw/base/Media.ts +2 -2
  149. package/src/types/raw/base/Notification.ts +2 -2
  150. package/.tool-versions +0 -1
@@ -1,4 +1,4 @@
1
- import { EBaseType } from '../enums/Data';
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 extractors = {
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, EBaseType.USER),
50
+ new CursoredData<User>(response, BaseType.USER),
51
51
  LIST_TWEETS: (response: IListTweetsResponse): CursoredData<Tweet> =>
52
- new CursoredData<Tweet>(response, EBaseType.TWEET),
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, EBaseType.USER),
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, EBaseType.TWEET),
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, EBaseType.USER),
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, EBaseType.TWEET),
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, EBaseType.USER),
82
+ new CursoredData<User>(response, BaseType.USER),
83
83
  USER_BOOKMARKS: (response: IUserBookmarksResponse): CursoredData<Tweet> =>
84
- new CursoredData<Tweet>(response, EBaseType.TWEET),
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, EBaseType.TWEET),
90
+ new CursoredData<Tweet>(response, BaseType.TWEET),
91
91
  USER_FEED_RECOMMENDED: (response: IUserRecommendedResponse): CursoredData<Tweet> =>
92
- new CursoredData<Tweet>(response, EBaseType.TWEET),
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, EBaseType.USER),
95
+ new CursoredData<User>(response, BaseType.USER),
96
96
  USER_FOLLOWERS: (response: IUserFollowersResponse): CursoredData<User> =>
97
- new CursoredData<User>(response, EBaseType.USER),
97
+ new CursoredData<User>(response, BaseType.USER),
98
98
  USER_HIGHLIGHTS: (response: IUserHighlightsResponse): CursoredData<Tweet> =>
99
- new CursoredData<Tweet>(response, EBaseType.TWEET),
99
+ new CursoredData<Tweet>(response, BaseType.TWEET),
100
100
  USER_LIKES: (response: IUserLikesResponse): CursoredData<Tweet> =>
101
- new CursoredData<Tweet>(response, EBaseType.TWEET),
101
+ new CursoredData<Tweet>(response, BaseType.TWEET),
102
102
  USER_MEDIA: (response: IUserMediaResponse): CursoredData<Tweet> =>
103
- new CursoredData<Tweet>(response, EBaseType.TWEET),
103
+ new CursoredData<Tweet>(response, BaseType.TWEET),
104
104
  USER_NOTIFICATIONS: (response: IUserNotificationsResponse): CursoredData<Notification> =>
105
- new CursoredData<Notification>(response, EBaseType.NOTIFICATION),
105
+ new CursoredData<Notification>(response, BaseType.NOTIFICATION),
106
106
  USER_SUBSCRIPTIONS: (response: IUserSubscriptionsResponse): CursoredData<User> =>
107
- new CursoredData<User>(response, EBaseType.USER),
107
+ new CursoredData<User>(response, BaseType.USER),
108
108
  USER_TIMELINE: (response: IUserTweetsResponse): CursoredData<Tweet> =>
109
- new CursoredData<Tweet>(response, EBaseType.TWEET),
109
+ new CursoredData<Tweet>(response, BaseType.TWEET),
110
110
  USER_TIMELINE_AND_REPLIES: (response: IUserTweetsAndRepliesResponse): CursoredData<Tweet> =>
111
- new CursoredData<Tweet>(response, EBaseType.TWEET),
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 { EResourceType } from '../enums/Resource';
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 allowGuestAuthentication = [
9
- EResourceType.TWEET_DETAILS,
10
- EResourceType.USER_DETAILS_BY_USERNAME,
11
- EResourceType.USER_TIMELINE,
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 fetchResources = [
20
- EResourceType.LIST_MEMBERS,
21
- EResourceType.LIST_TWEETS,
22
- EResourceType.TWEET_DETAILS,
23
- EResourceType.TWEET_DETAILS_ALT,
24
- EResourceType.TWEET_DETAILS_BULK,
25
- EResourceType.TWEET_LIKERS,
26
- EResourceType.TWEET_REPLIES,
27
- EResourceType.TWEET_RETWEETERS,
28
- EResourceType.TWEET_SEARCH,
29
- EResourceType.USER_AFFILIATES,
30
- EResourceType.USER_BOOKMARKS,
31
- EResourceType.USER_DETAILS_BY_USERNAME,
32
- EResourceType.USER_DETAILS_BY_ID,
33
- EResourceType.USER_DETAILS_BY_IDS_BULK,
34
- EResourceType.USER_FEED_FOLLOWED,
35
- EResourceType.USER_FEED_RECOMMENDED,
36
- EResourceType.USER_FOLLOWING,
37
- EResourceType.USER_FOLLOWERS,
38
- EResourceType.USER_HIGHLIGHTS,
39
- EResourceType.USER_LIKES,
40
- EResourceType.USER_MEDIA,
41
- EResourceType.USER_NOTIFICATIONS,
42
- EResourceType.USER_SUBSCRIPTIONS,
43
- EResourceType.USER_TIMELINE,
44
- EResourceType.USER_TIMELINE_AND_REPLIES,
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 postResources = [
53
- EResourceType.MEDIA_UPLOAD_APPEND,
54
- EResourceType.MEDIA_UPLOAD_FINALIZE,
55
- EResourceType.MEDIA_UPLOAD_INITIALIZE,
56
- EResourceType.TWEET_LIKE,
57
- EResourceType.TWEET_POST,
58
- EResourceType.TWEET_RETWEET,
59
- EResourceType.TWEET_SCHEDULE,
60
- EResourceType.TWEET_UNLIKE,
61
- EResourceType.TWEET_UNPOST,
62
- EResourceType.TWEET_UNRETWEET,
63
- EResourceType.TWEET_UNSCHEDULE,
64
- EResourceType.USER_FOLLOW,
65
- EResourceType.USER_UNFOLLOW,
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 { EResourceType } from '../enums/Resource';
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 { rawTweetRepliesSortType } from './Tweet';
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 requests: { [key in keyof typeof EResourceType]: (args: IFetchArgs | IPostArgs) => AxiosRequestConfig } = {
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 ? rawTweetRepliesSortType[args.sortBy] : undefined),
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!),
@@ -1,17 +1,17 @@
1
- import { ERawTweetRepliesSortType } from '../enums/raw/Tweet';
2
- import { ETweetRepliesSortType } from '../enums/Tweet';
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 rawTweetRepliesSortType: { [key in keyof typeof ETweetRepliesSortType]: ERawTweetRepliesSortType } = {
9
+ export const TweetRepliesSortTypeMap: { [key in keyof typeof TweetRepliesSortType]: RawTweetRepliesSortType } = {
10
10
  /* eslint-disable @typescript-eslint/naming-convention */
11
11
 
12
- LATEST: ERawTweetRepliesSortType.LATEST,
13
- LIKES: ERawTweetRepliesSortType.LIKES,
14
- RELEVANCE: ERawTweetRepliesSortType.RELEVACE,
12
+ LATEST: RawTweetRepliesSortType.LATEST,
13
+ LIKES: RawTweetRepliesSortType.LIKES,
14
+ RELEVANCE: RawTweetRepliesSortType.RELEVACE,
15
15
 
16
16
  /* eslint-enable @typescript-eslint/naming-convention */
17
17
  };
@@ -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 tweets = await rettiwt.tweet.likers(id, count ? parseInt(count) : undefined, cursor);
67
- output(tweets);
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 tweets = await rettiwt.tweet.retweeters(id, count ? parseInt(count) : undefined, cursor);
122
- output(tweets);
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
  }
@@ -180,8 +209,10 @@ function createTweetCommand(rettiwt: Rettiwt): Command {
180
209
  .option('-l, --min-likes <number>', 'Matches the tweets that have a minimum of given number of likes')
181
210
  .option('-x, --min-retweets <number>', 'Matches the tweets that have a minimum of given number of retweets')
182
211
  .option('-q, --quoted <string>', 'Matches the tweets that quote the tweet with the given id')
183
- .option('--exclude-links', 'Matches tweets that do not contain links')
184
- .option('--exclude-replies', 'Matches the tweets that are not replies')
212
+ .option('--only-original', 'Matches tweets are original posts')
213
+ .option('--only-replies', 'Matches tweets that are replies')
214
+ .option('--only-text', 'Matches tweets that are only text')
215
+ .option('--only-links', 'Matches tweets that only contain links like media, quotes, etc')
185
216
  .option('-s, --start <string>', 'Matches the tweets made since the given date (valid date/time string)')
186
217
  .option('-e, --end <string>', 'Matches the tweets made upto the given date (valid date/time string)')
187
218
  .option('--top', 'Matches top tweets instead of latest')
@@ -292,8 +323,6 @@ function createTweetCommand(rettiwt: Rettiwt): Command {
292
323
  */
293
324
  class TweetSearchOptions {
294
325
  public end?: string;
295
- public excludeLinks?: boolean = false;
296
- public excludeReplies?: boolean = false;
297
326
  public excludeWords?: string;
298
327
  public from?: string;
299
328
  public hashtags?: string;
@@ -303,6 +332,10 @@ class TweetSearchOptions {
303
332
  public minLikes?: number;
304
333
  public minReplies?: number;
305
334
  public minRetweets?: number;
335
+ public onlyLinks?: boolean = false;
336
+ public onlyOriginal?: boolean = false;
337
+ public onlyReplies?: boolean = false;
338
+ public onlyText?: boolean = false;
306
339
  public optionalWords?: string;
307
340
  public phrase?: string;
308
341
  public quoted?: string;
@@ -330,9 +363,11 @@ class TweetSearchOptions {
330
363
  this.minReplies = options?.minReplies;
331
364
  this.minLikes = options?.minLikes;
332
365
  this.minRetweets = options?.minRetweets;
366
+ this.onlyLinks = options?.onlyLinks;
367
+ this.onlyOriginal = options?.onlyOriginal;
368
+ this.onlyReplies = options?.onlyReplies;
369
+ this.onlyText = options?.onlyText;
333
370
  this.quoted = options?.quoted;
334
- this.excludeLinks = options?.excludeLinks;
335
- this.excludeReplies = options?.excludeReplies;
336
371
  this.start = options?.start;
337
372
  this.end = options?.end;
338
373
  this.stream = options?.stream;
@@ -359,9 +394,11 @@ class TweetSearchOptions {
359
394
  minReplies: this.minReplies,
360
395
  minLikes: this.minLikes,
361
396
  minRetweets: this.minRetweets,
397
+ onlyLinks: this.onlyLinks,
398
+ onlyOriginal: this.onlyOriginal,
399
+ onlyReplies: this.onlyReplies,
400
+ onlyText: this.onlyText,
362
401
  quoted: this.quoted,
363
- links: !this.excludeLinks,
364
- replies: !this.excludeReplies,
365
402
  startDate: this.start ? new Date(this.start) : undefined,
366
403
  top: this.top,
367
404
  endDate: this.end ? new Date(this.end) : undefined,
package/src/enums/Api.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @public
5
5
  */
6
- export enum EApiErrors {
6
+ export enum ApiErrors {
7
7
  COULD_NOT_AUTHENTICATE = 'Failed to authenticate',
8
8
  BAD_AUTHENTICATION = 'Invalid authentication data',
9
9
  RESOURCE_NOT_ALLOWED = 'Not authorized to access requested resource',
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @public
5
5
  */
6
- export enum EAuthenticationType {
6
+ export enum AuthenticationType {
7
7
  GUEST = 'GUEST',
8
8
  USER = 'USER',
9
9
  LOGIN = 'LOGIN',
package/src/enums/Data.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @internal
5
5
  */
6
- export enum EBaseType {
6
+ export enum BaseType {
7
7
  NOTIFICATION = 'NOTIFICATION',
8
8
  TWEET = 'TWEET',
9
9
  USER = 'USER',
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @internal
5
5
  */
6
- export enum ELogActions {
6
+ export enum LogActions {
7
7
  AUTHORIZATION = 'AUTHORIZATION',
8
8
  DESERIALIZE = 'DESERIALIZE',
9
9
  EXTRACT = 'EXTRACT',
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @public
5
5
  */
6
- export enum EMediaType {
6
+ export enum MediaType {
7
7
  PHOTO = 'PHOTO',
8
8
  VIDEO = 'VIDEO',
9
9
  GIF = 'GIF',
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @public
5
5
  */
6
- export enum ENotificationType {
6
+ export enum NotificationType {
7
7
  RECOMMENDATION = 'RECOMMENDATION',
8
8
  INFORMATION = 'INFORMATION',
9
9
  LIVE = 'LIVE',
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @public
5
5
  */
6
- export enum EResourceType {
6
+ export enum ResourceType {
7
7
  // LIST
8
8
  LIST_MEMBERS = 'LIST_MEMBERS',
9
9
  LIST_TWEETS = 'LIST_TWEETS',
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The different types of sorting options when fetching replies to tweets.
3
3
  */
4
- export enum ETweetRepliesSortType {
4
+ export enum TweetRepliesSortType {
5
5
  LIKES = 'LIKES',
6
6
  LATEST = 'LATEST',
7
7
  RELEVANCE = 'RELEVANCE',
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @public
5
5
  */
6
- export enum ERawAnalyticsGranularity {
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 ERawAnalyticsMetric {
17
+ export enum RawAnalyticsMetric {
18
18
  ENGAGEMENTS = 'Engagements',
19
19
  IMPRESSIONS = 'Impressions',
20
20
  PROFILE_VISITS = 'ProfileVisits',
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @public
5
5
  */
6
- export enum ERawMediaType {
6
+ export enum RawMediaType {
7
7
  PHOTO = 'photo',
8
8
  VIDEO = 'video',
9
9
  GIF = 'animated_gif',
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @public
5
5
  */
6
- export enum ERawNotificationType {
6
+ export enum RawNotificationType {
7
7
  RECOMMENDATION = 'recommendation_icon',
8
8
  INFORMATION = 'bird_icon',
9
9
  LIVE = 'live_icon',
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @public
5
5
  */
6
- export enum ERawTweetSearchResultType {
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 ERawTweetRepliesSortType {
16
+ export enum RawTweetRepliesSortType {
17
17
  RELEVACE = 'Relevance',
18
18
  LATEST = 'Recency',
19
19
  LIKES = 'Likes',
@@ -12,7 +12,7 @@ import { IRettiwtConfig } from '../types/RettiwtConfig';
12
12
  *
13
13
  * @public
14
14
  */
15
- const defaultHeaders = {
15
+ const DefaultHeaders = {
16
16
  /* eslint-disable @typescript-eslint/naming-convention */
17
17
 
18
18
  Authority: 'x.com',
@@ -43,6 +43,7 @@ export class RettiwtConfig implements IRettiwtConfig {
43
43
  public readonly delay?: number | (() => number | Promise<number>);
44
44
  public readonly errorHandler?: IErrorHandler;
45
45
  public readonly logging?: boolean;
46
+ public readonly maxRetries: number;
46
47
  public readonly tidProvider?: ITidProvider;
47
48
  public readonly timeout?: number;
48
49
 
@@ -53,14 +54,15 @@ export class RettiwtConfig implements IRettiwtConfig {
53
54
  this._apiKey = config?.apiKey;
54
55
  this._httpsAgent = config?.proxyUrl ? new HttpsProxyAgent(config?.proxyUrl) : new Agent();
55
56
  this._userId = config?.apiKey ? AuthService.getUserId(config?.apiKey) : undefined;
56
- this.delay = config?.delay;
57
+ this.delay = config?.delay ?? 1000;
58
+ this.maxRetries = config?.maxRetries ?? 5;
57
59
  this.errorHandler = config?.errorHandler;
58
60
  this.logging = config?.logging;
59
61
  this.tidProvider = config?.tidProvider;
60
62
  this.timeout = config?.timeout;
61
63
  this.apiKey = config?.apiKey;
62
64
  this._headers = {
63
- ...defaultHeaders,
65
+ ...DefaultHeaders,
64
66
  ...config?.headers,
65
67
  };
66
68
  }
@@ -90,7 +92,7 @@ export class RettiwtConfig implements IRettiwtConfig {
90
92
 
91
93
  public set headers(headers: { [key: string]: string } | undefined) {
92
94
  this._headers = {
93
- ...defaultHeaders,
95
+ ...DefaultHeaders,
94
96
  ...headers,
95
97
  };
96
98
  }
@@ -100,4 +102,4 @@ export class RettiwtConfig implements IRettiwtConfig {
100
102
  }
101
103
  }
102
104
 
103
- export { defaultHeaders as DefaultRettiwtHeaders };
105
+ export { DefaultHeaders as DefaultRettiwtHeaders };
@@ -1,4 +1,4 @@
1
- import { ETweetRepliesSortType } from '../../enums/Tweet';
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?: ETweetRepliesSortType;
15
+ public sortBy?: TweetRepliesSortType;
16
16
 
17
17
  /**
18
18
  * @param args - Additional user-defined arguments for fetching the resource.
@@ -40,16 +40,18 @@ export class TweetFilter implements ITweetFilter {
40
40
  public includePhrase?: string;
41
41
  public includeWords?: string[];
42
42
  public language?: string;
43
- public links?: boolean;
44
43
  public list?: string;
45
44
  public maxId?: string;
46
45
  public mentions?: string[];
47
46
  public minLikes?: number;
48
47
  public minReplies?: number;
49
48
  public minRetweets?: number;
49
+ public onlyLinks?: boolean;
50
+ public onlyOriginal?: boolean;
51
+ public onlyReplies?: boolean;
52
+ public onlyText?: boolean;
50
53
  public optionalWords?: string[];
51
54
  public quoted?: string;
52
- public replies?: boolean;
53
55
  public sinceId?: string;
54
56
  public startDate?: Date;
55
57
  public toUsers?: string[];
@@ -65,9 +67,7 @@ export class TweetFilter implements ITweetFilter {
65
67
  this.hashtags = filter.hashtags;
66
68
  this.includePhrase = filter.includePhrase;
67
69
  this.language = filter.language;
68
- this.links = filter.links;
69
70
  this.list = filter.list;
70
- this.replies = filter.replies;
71
71
  this.mentions = filter.mentions;
72
72
  this.quoted = filter.quoted;
73
73
  this.sinceId = filter.sinceId;
@@ -75,6 +75,10 @@ export class TweetFilter implements ITweetFilter {
75
75
  this.minLikes = filter.minLikes;
76
76
  this.minReplies = filter.minReplies;
77
77
  this.minRetweets = filter.minRetweets;
78
+ this.onlyLinks = filter.onlyLinks;
79
+ this.onlyOriginal = filter.onlyOriginal;
80
+ this.onlyReplies = filter.onlyReplies;
81
+ this.onlyText = filter.onlyText;
78
82
  this.optionalWords = filter.optionalWords;
79
83
  this.startDate = filter.startDate;
80
84
  this.toUsers = filter.toUsers;
@@ -89,7 +93,7 @@ export class TweetFilter implements ITweetFilter {
89
93
  * @param date - The date object to convert.
90
94
  * @returns The Twitter string representation of the date.
91
95
  */
92
- private static dateToTwitterString(date: Date): string {
96
+ private static _dateToTwitterString(date: Date): string {
93
97
  // Converting localized date to UTC date
94
98
  const utc = new Date(
95
99
  Date.UTC(
@@ -131,16 +135,18 @@ export class TweetFilter implements ITweetFilter {
131
135
  this.minLikes ? `min_faves:${this.minLikes}` : '',
132
136
  this.minRetweets ? `min_retweets:${this.minRetweets}` : '',
133
137
  this.language ? `lang:${this.language}` : '',
134
- this.startDate ? `since:${TweetFilter.dateToTwitterString(this.startDate)}` : '',
135
- this.endDate ? `until:${TweetFilter.dateToTwitterString(this.endDate)}` : '',
138
+ this.startDate ? `since:${TweetFilter._dateToTwitterString(this.startDate)}` : '',
139
+ this.endDate ? `until:${TweetFilter._dateToTwitterString(this.endDate)}` : '',
136
140
  this.sinceId ? `since_id:${this.sinceId}` : '',
137
141
  this.maxId ? `max_id:${this.maxId}` : '',
138
142
  this.quoted ? `quoted_tweet_id:${this.quoted}` : '',
139
143
  ]
140
144
  .filter((item) => item !== '()' && item !== '')
141
145
  .join(' ') +
142
- (this.links == false ? ' -filter:links' : '') +
143
- (this.replies == false ? ' -filter:replies' : '')
146
+ (this.onlyText === true ? ' -filter:links' : '') +
147
+ (this.onlyOriginal === true ? ' -filter:replies' : '') +
148
+ (this.onlyLinks === true ? ' filter:links' : '') +
149
+ (this.onlyReplies === true ? ' filter:replies' : '')
144
150
  );
145
151
  }
146
152
  }