rettiwt-api 5.1.0-alpha.0 → 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 +32 -4
  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 +3 -3
  59. package/dist/models/args/FetchArgs.js +3 -3
  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 +2 -2
  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 +33 -4
  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 +5 -5
  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 +2 -2
  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,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
  }
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.
@@ -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 dateToTwitterString(date: Date): string {
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.dateToTwitterString(this.startDate)}` : '',
139
- this.endDate ? `until:${TweetFilter.dateToTwitterString(this.endDate)}` : '',
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 { EAuthenticationType } from '../../enums/Authentication';
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?: EAuthenticationType;
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 = EAuthenticationType.GUEST;
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 = EAuthenticationType.LOGIN;
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 = EAuthenticationType.USER;
55
+ this.authenticationType = AuthenticationType.USER;
56
56
  }
57
57
  }
58
58
 
@@ -1,4 +1,4 @@
1
- import { EBaseType } from '../../enums/Data';
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: EBaseType) {
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 == EBaseType.TWEET) {
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 == EBaseType.USER) {
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 == EBaseType.NOTIFICATION) {
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
  }
@@ -1,5 +1,5 @@
1
- import { ENotificationType } from '../../enums/Notification';
2
- import { ERawNotificationType } from '../../enums/raw/Notification';
1
+ import { NotificationType } from '../../enums/Notification';
2
+ import { RawNotificationType } from '../../enums/raw/Notification';
3
3
  import { findKeyByValue } from '../../helper/JsonUtils';
4
4
  import { INotification } from '../../types/data/Notification';
5
5
  import { INotification as IRawNotification } from '../../types/raw/base/Notification';
@@ -19,7 +19,7 @@ export class Notification implements INotification {
19
19
  public message: string;
20
20
  public receivedAt: string;
21
21
  public target: string[];
22
- public type?: ENotificationType;
22
+ public type?: NotificationType;
23
23
 
24
24
  /**
25
25
  * @param notification - The raw notification details.
@@ -28,7 +28,7 @@ export class Notification implements INotification {
28
28
  this._raw = { ...notification };
29
29
 
30
30
  // Getting the original notification type
31
- const notificationType: string | undefined = findKeyByValue(ERawNotificationType, notification.icon.id);
31
+ const notificationType: string | undefined = findKeyByValue(RawNotificationType, notification.icon.id);
32
32
 
33
33
  this.from = notification.template?.aggregateUserActionsV1?.fromUsers
34
34
  ? notification.template.aggregateUserActionsV1.fromUsers.map((item) => item.user.id)
@@ -40,8 +40,8 @@ export class Notification implements INotification {
40
40
  ? notification.template.aggregateUserActionsV1.targetObjects.map((item) => item.tweet.id)
41
41
  : [];
42
42
  this.type = notificationType
43
- ? ENotificationType[notificationType as keyof typeof ENotificationType]
44
- : ENotificationType.UNDEFINED;
43
+ ? NotificationType[notificationType as keyof typeof NotificationType]
44
+ : NotificationType.UNDEFINED;
45
45
  }
46
46
 
47
47
  /** The raw notification details. */