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,8 +1,8 @@
1
1
  import { statSync } from 'fs';
2
2
 
3
- import { extractors } from '../../collections/Extractors';
4
- import { EResourceType } from '../../enums/Resource';
5
- import { ETweetRepliesSortType } from '../../enums/Tweet';
3
+ import { Extractors } from '../../collections/Extractors';
4
+ import { ResourceType } from '../../enums/Resource';
5
+ import { TweetRepliesSortType } from '../../enums/Tweet';
6
6
  import { CursoredData } from '../../models/data/CursoredData';
7
7
  import { Tweet } from '../../models/data/Tweet';
8
8
  import { User } from '../../models/data/User';
@@ -95,41 +95,41 @@ export class TweetService extends FetcherService {
95
95
  * ```
96
96
  */
97
97
  public async details<T extends string | string[]>(id: T): Promise<T extends string ? Tweet | undefined : Tweet[]> {
98
- let resource: EResourceType;
98
+ let resource: ResourceType;
99
99
 
100
100
  // If user is authenticated and details of single tweet required
101
101
  if (this.config.userId != undefined && typeof id == 'string') {
102
- resource = EResourceType.TWEET_DETAILS_ALT;
102
+ resource = ResourceType.TWEET_DETAILS_ALT;
103
103
 
104
104
  // Fetching raw tweet details
105
105
  const response = await this.request<ITweetRepliesResponse>(resource, { id: id });
106
106
 
107
107
  // Deserializing response
108
- const data = extractors[resource](response, id);
108
+ const data = Extractors[resource](response, id);
109
109
 
110
110
  return data as T extends string ? Tweet | undefined : Tweet[];
111
111
  }
112
112
  // If user is authenticated and details of multiple tweets required
113
113
  else if (this.config.userId != undefined && Array.isArray(id)) {
114
- resource = EResourceType.TWEET_DETAILS_BULK;
114
+ resource = ResourceType.TWEET_DETAILS_BULK;
115
115
 
116
116
  // Fetching raw tweet details
117
117
  const response = await this.request<ITweetDetailsBulkResponse>(resource, { ids: id });
118
118
 
119
119
  // Deserializing response
120
- const data = extractors[resource](response, id);
120
+ const data = Extractors[resource](response, id);
121
121
 
122
122
  return data as T extends string ? Tweet | undefined : Tweet[];
123
123
  }
124
124
  // If user is not authenticated
125
125
  else {
126
- resource = EResourceType.TWEET_DETAILS;
126
+ resource = ResourceType.TWEET_DETAILS;
127
127
 
128
128
  // Fetching raw tweet details
129
129
  const response = await this.request<ITweetDetailsResponse>(resource, { id: String(id) });
130
130
 
131
131
  // Deserializing response
132
- const data = extractors[resource](response, String(id));
132
+ const data = Extractors[resource](response, String(id));
133
133
 
134
134
  return data as T extends string ? Tweet | undefined : Tweet[];
135
135
  }
@@ -161,7 +161,7 @@ export class TweetService extends FetcherService {
161
161
  * ```
162
162
  */
163
163
  public async like(id: string): Promise<boolean> {
164
- const resource = EResourceType.TWEET_LIKE;
164
+ const resource = ResourceType.TWEET_LIKE;
165
165
 
166
166
  // Favoriting the tweet
167
167
  const response = await this.request<ITweetLikeResponse>(resource, {
@@ -169,7 +169,7 @@ export class TweetService extends FetcherService {
169
169
  });
170
170
 
171
171
  // Deserializing response
172
- const data = extractors[resource](response) ?? false;
172
+ const data = Extractors[resource](response) ?? false;
173
173
 
174
174
  return data;
175
175
  }
@@ -202,7 +202,7 @@ export class TweetService extends FetcherService {
202
202
  * ```
203
203
  */
204
204
  public async likers(id: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
205
- const resource = EResourceType.TWEET_LIKERS;
205
+ const resource = ResourceType.TWEET_LIKERS;
206
206
 
207
207
  // Fetching raw likers
208
208
  const response = await this.request<ITweetLikersResponse>(resource, {
@@ -212,7 +212,7 @@ export class TweetService extends FetcherService {
212
212
  });
213
213
 
214
214
  // Deserializing response
215
- const data = extractors[resource](response);
215
+ const data = Extractors[resource](response);
216
216
 
217
217
  return data;
218
218
  }
@@ -301,13 +301,13 @@ export class TweetService extends FetcherService {
301
301
  * ```
302
302
  */
303
303
  public async post(options: INewTweet): Promise<string | undefined> {
304
- const resource = EResourceType.TWEET_POST;
304
+ const resource = ResourceType.TWEET_POST;
305
305
 
306
306
  // Posting the tweet
307
307
  const response = await this.request<ITweetPostResponse>(resource, { tweet: options });
308
308
 
309
309
  // Deserializing response
310
- const data = extractors[resource](response);
310
+ const data = Extractors[resource](response);
311
311
 
312
312
  return data;
313
313
  }
@@ -317,7 +317,7 @@ export class TweetService extends FetcherService {
317
317
  *
318
318
  * @param id - The ID of the target tweet.
319
319
  * @param cursor - The cursor to the batch of replies to fetch.
320
- * @param sortBy - The sorting order of the replies to fetch. Default is {@link ETweetRepliesSortType.RECENT}.
320
+ * @param sortBy - The sorting order of the replies to fetch. Default is {@link TweetRepliesSortType.RECENT}.
321
321
  *
322
322
  * @returns The list of replies to the given tweet.
323
323
  *
@@ -346,9 +346,9 @@ export class TweetService extends FetcherService {
346
346
  public async replies(
347
347
  id: string,
348
348
  cursor?: string,
349
- sortBy: ETweetRepliesSortType = ETweetRepliesSortType.LATEST,
349
+ sortBy: TweetRepliesSortType = TweetRepliesSortType.LATEST,
350
350
  ): Promise<CursoredData<Tweet>> {
351
- const resource = EResourceType.TWEET_REPLIES;
351
+ const resource = ResourceType.TWEET_REPLIES;
352
352
 
353
353
  // Fetching raw list of replies
354
354
  const response = await this.request<ITweetDetailsResponse>(resource, {
@@ -358,7 +358,7 @@ export class TweetService extends FetcherService {
358
358
  });
359
359
 
360
360
  // Deserializing response
361
- const data = extractors[resource](response);
361
+ const data = Extractors[resource](response);
362
362
 
363
363
  return data;
364
364
  }
@@ -389,13 +389,13 @@ export class TweetService extends FetcherService {
389
389
  * ```
390
390
  */
391
391
  public async retweet(id: string): Promise<boolean> {
392
- const resource = EResourceType.TWEET_RETWEET;
392
+ const resource = ResourceType.TWEET_RETWEET;
393
393
 
394
394
  // Retweeting the tweet
395
395
  const response = await this.request<ITweetRetweetResponse>(resource, { id: id });
396
396
 
397
397
  // Deserializing response
398
- const data = extractors[resource](response) ?? false;
398
+ const data = Extractors[resource](response) ?? false;
399
399
 
400
400
  return data;
401
401
  }
@@ -428,7 +428,7 @@ export class TweetService extends FetcherService {
428
428
  * ```
429
429
  */
430
430
  public async retweeters(id: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
431
- const resource = EResourceType.TWEET_RETWEETERS;
431
+ const resource = ResourceType.TWEET_RETWEETERS;
432
432
 
433
433
  // Fetching raw list of retweeters
434
434
  const response = await this.request<ITweetRetweetersResponse>(resource, {
@@ -438,7 +438,7 @@ export class TweetService extends FetcherService {
438
438
  });
439
439
 
440
440
  // Deserializing response
441
- const data = extractors[resource](response);
441
+ const data = Extractors[resource](response);
442
442
 
443
443
  return data;
444
444
  }
@@ -474,13 +474,13 @@ export class TweetService extends FetcherService {
474
474
  * Scheduling a tweet is similar to {@link post}ing, except that an extra parameter called `scheduleFor` is used.
475
475
  */
476
476
  public async schedule(options: INewTweet): Promise<string | undefined> {
477
- const resource = EResourceType.TWEET_SCHEDULE;
477
+ const resource = ResourceType.TWEET_SCHEDULE;
478
478
 
479
479
  // Scheduling the tweet
480
480
  const response = await this.request<ITweetScheduleResponse>(resource, { tweet: options });
481
481
 
482
482
  // Deserializing response
483
- const data = extractors[resource](response);
483
+ const data = Extractors[resource](response);
484
484
 
485
485
  return data;
486
486
  }
@@ -518,7 +518,7 @@ export class TweetService extends FetcherService {
518
518
  * For details about available filters, refer to {@link TweetFilter}
519
519
  */
520
520
  public async search(filter: ITweetFilter, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
521
- const resource = EResourceType.TWEET_SEARCH;
521
+ const resource = ResourceType.TWEET_SEARCH;
522
522
 
523
523
  // Fetching raw list of filtered tweets
524
524
  const response = await this.request<ITweetSearchResponse>(resource, {
@@ -528,7 +528,7 @@ export class TweetService extends FetcherService {
528
528
  });
529
529
 
530
530
  // Deserializing response
531
- const data = extractors[resource](response);
531
+ const data = Extractors[resource](response);
532
532
 
533
533
  // Sorting the tweets by date, from recent to oldest
534
534
  data.list.sort((a, b) => new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf());
@@ -631,13 +631,13 @@ export class TweetService extends FetcherService {
631
631
  * ```
632
632
  */
633
633
  public async unlike(id: string): Promise<boolean> {
634
- const resource = EResourceType.TWEET_UNLIKE;
634
+ const resource = ResourceType.TWEET_UNLIKE;
635
635
 
636
636
  // Unliking the tweet
637
637
  const response = await this.request<ITweetUnlikeResponse>(resource, { id: id });
638
638
 
639
639
  // Deserializing the response
640
- const data = extractors[resource](response) ?? false;
640
+ const data = Extractors[resource](response) ?? false;
641
641
 
642
642
  return data;
643
643
  }
@@ -668,13 +668,13 @@ export class TweetService extends FetcherService {
668
668
  * ```
669
669
  */
670
670
  public async unpost(id: string): Promise<boolean> {
671
- const resource = EResourceType.TWEET_UNPOST;
671
+ const resource = ResourceType.TWEET_UNPOST;
672
672
 
673
673
  // Unposting the tweet
674
674
  const response = await this.request<ITweetUnpostResponse>(resource, { id: id });
675
675
 
676
676
  // Deserializing the response
677
- const data = extractors[resource](response) ?? false;
677
+ const data = Extractors[resource](response) ?? false;
678
678
 
679
679
  return data;
680
680
  }
@@ -705,13 +705,13 @@ export class TweetService extends FetcherService {
705
705
  * ```
706
706
  */
707
707
  public async unretweet(id: string): Promise<boolean> {
708
- const resource = EResourceType.TWEET_UNRETWEET;
708
+ const resource = ResourceType.TWEET_UNRETWEET;
709
709
 
710
710
  // Unretweeting the tweet
711
711
  const response = await this.request<ITweetUnretweetResponse>(resource, { id: id });
712
712
 
713
713
  // Deserializing the response
714
- const data = extractors[resource](response) ?? false;
714
+ const data = Extractors[resource](response) ?? false;
715
715
 
716
716
  return data;
717
717
  }
@@ -742,13 +742,13 @@ export class TweetService extends FetcherService {
742
742
  * ```
743
743
  */
744
744
  public async unschedule(id: string): Promise<boolean> {
745
- const resource = EResourceType.TWEET_UNSCHEDULE;
745
+ const resource = ResourceType.TWEET_UNSCHEDULE;
746
746
 
747
747
  // Unscheduling the tweet
748
748
  const response = await this.request<ITweetUnscheduleResponse>(resource, { id: id });
749
749
 
750
750
  // Deserializing the response
751
- const data = extractors[resource](response) ?? false;
751
+ const data = Extractors[resource](response) ?? false;
752
752
 
753
753
  return data;
754
754
  }
@@ -788,16 +788,16 @@ export class TweetService extends FetcherService {
788
788
  // INITIALIZE
789
789
  const size = typeof media == 'string' ? statSync(media).size : media.byteLength;
790
790
  const id: string = (
791
- await this.request<IMediaInitializeUploadResponse>(EResourceType.MEDIA_UPLOAD_INITIALIZE, {
791
+ await this.request<IMediaInitializeUploadResponse>(ResourceType.MEDIA_UPLOAD_INITIALIZE, {
792
792
  upload: { size: size },
793
793
  })
794
794
  ).media_id_string;
795
795
 
796
796
  // APPEND
797
- await this.request<unknown>(EResourceType.MEDIA_UPLOAD_APPEND, { upload: { id: id, media: media } });
797
+ await this.request<unknown>(ResourceType.MEDIA_UPLOAD_APPEND, { upload: { id: id, media: media } });
798
798
 
799
799
  // FINALIZE
800
- await this.request<unknown>(EResourceType.MEDIA_UPLOAD_FINALIZE, { upload: { id: id } });
800
+ await this.request<unknown>(ResourceType.MEDIA_UPLOAD_FINALIZE, { upload: { id: id } });
801
801
 
802
802
  return id;
803
803
  }
@@ -1,5 +1,5 @@
1
- import { extractors } from '../../collections/Extractors';
2
- import { EResourceType } from '../../enums/Resource';
1
+ import { Extractors } from '../../collections/Extractors';
2
+ import { ResourceType } from '../../enums/Resource';
3
3
  import { CursoredData } from '../../models/data/CursoredData';
4
4
  import { Notification } from '../../models/data/Notification';
5
5
  import { Tweet } from '../../models/data/Tweet';
@@ -68,7 +68,7 @@ export class UserService extends FetcherService {
68
68
  * ```
69
69
  */
70
70
  public async affiliates(id?: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
71
- const resource = EResourceType.USER_AFFILIATES;
71
+ const resource = ResourceType.USER_AFFILIATES;
72
72
 
73
73
  // Fetching raw list of affiliates
74
74
  const response = await this.request<IUserAffiliatesResponse>(resource, {
@@ -78,7 +78,7 @@ export class UserService extends FetcherService {
78
78
  });
79
79
 
80
80
  // Deserializing response
81
- const data = extractors[resource](response);
81
+ const data = Extractors[resource](response);
82
82
 
83
83
  return data;
84
84
  }
@@ -110,7 +110,7 @@ export class UserService extends FetcherService {
110
110
  * ```
111
111
  */
112
112
  public async bookmarks(count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
113
- const resource = EResourceType.USER_BOOKMARKS;
113
+ const resource = ResourceType.USER_BOOKMARKS;
114
114
 
115
115
  // Fetching raw list of likes
116
116
  const response = await this.request<IUserBookmarksResponse>(resource, {
@@ -119,7 +119,7 @@ export class UserService extends FetcherService {
119
119
  });
120
120
 
121
121
  // Deserializing response
122
- const data = extractors[resource](response);
122
+ const data = Extractors[resource](response);
123
123
 
124
124
  return data;
125
125
  }
@@ -195,17 +195,17 @@ export class UserService extends FetcherService {
195
195
  public async details<T extends string | string[] | undefined>(
196
196
  id: T,
197
197
  ): Promise<T extends string | undefined ? User | undefined : User[]> {
198
- let resource: EResourceType;
198
+ let resource: ResourceType;
199
199
 
200
200
  // If details of multiple users required
201
201
  if (Array.isArray(id)) {
202
- resource = EResourceType.USER_DETAILS_BY_IDS_BULK;
202
+ resource = ResourceType.USER_DETAILS_BY_IDS_BULK;
203
203
 
204
204
  // Fetching raw details
205
205
  const response = await this.request<IUserDetailsBulkResponse>(resource, { ids: id });
206
206
 
207
207
  // Deserializing response
208
- const data = extractors[resource](response, id);
208
+ const data = Extractors[resource](response, id);
209
209
 
210
210
  return data as T extends string | undefined ? User | undefined : User[];
211
211
  }
@@ -213,11 +213,11 @@ export class UserService extends FetcherService {
213
213
  else {
214
214
  // If username is given
215
215
  if (id && isNaN(Number(id))) {
216
- resource = EResourceType.USER_DETAILS_BY_USERNAME;
216
+ resource = ResourceType.USER_DETAILS_BY_USERNAME;
217
217
  }
218
218
  // If id is given (or not, for self details)
219
219
  else {
220
- resource = EResourceType.USER_DETAILS_BY_ID;
220
+ resource = ResourceType.USER_DETAILS_BY_ID;
221
221
  }
222
222
 
223
223
  // If no ID is given, and not authenticated, skip
@@ -229,7 +229,7 @@ export class UserService extends FetcherService {
229
229
  const response = await this.request<IUserDetailsResponse>(resource, { id: id ?? this.config.userId });
230
230
 
231
231
  // Deserializing response
232
- const data = extractors[resource](response);
232
+ const data = Extractors[resource](response);
233
233
 
234
234
  return data as T extends string | undefined ? User | undefined : User[];
235
235
  }
@@ -263,13 +263,13 @@ export class UserService extends FetcherService {
263
263
  * ```
264
264
  */
265
265
  public async follow(id: string): Promise<boolean> {
266
- const resource = EResourceType.USER_FOLLOW;
266
+ const resource = ResourceType.USER_FOLLOW;
267
267
 
268
268
  // Following the user
269
- const response = await this.request<IUserFollowResponse>(EResourceType.USER_FOLLOW, { id: id });
269
+ const response = await this.request<IUserFollowResponse>(ResourceType.USER_FOLLOW, { id: id });
270
270
 
271
271
  // Deserializing the response
272
- const data = extractors[resource](response) ?? false;
272
+ const data = Extractors[resource](response) ?? false;
273
273
 
274
274
  return data;
275
275
  }
@@ -302,7 +302,7 @@ export class UserService extends FetcherService {
302
302
  * @remarks Always returns 35 feed items, with no way to customize the count.
303
303
  */
304
304
  public async followed(cursor?: string): Promise<CursoredData<Tweet>> {
305
- const resource = EResourceType.USER_FEED_FOLLOWED;
305
+ const resource = ResourceType.USER_FEED_FOLLOWED;
306
306
 
307
307
  // Fetching raw list of tweets
308
308
  const response = await this.request<IUserFollowedResponse>(resource, {
@@ -310,7 +310,7 @@ export class UserService extends FetcherService {
310
310
  });
311
311
 
312
312
  // Deserializing response
313
- const data = extractors[resource](response);
313
+ const data = Extractors[resource](response);
314
314
 
315
315
  return data;
316
316
  }
@@ -343,7 +343,7 @@ export class UserService extends FetcherService {
343
343
  * ```
344
344
  */
345
345
  public async followers(id?: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
346
- const resource = EResourceType.USER_FOLLOWERS;
346
+ const resource = ResourceType.USER_FOLLOWERS;
347
347
 
348
348
  // Fetching raw list of followers
349
349
  const response = await this.request<IUserFollowersResponse>(resource, {
@@ -353,7 +353,7 @@ export class UserService extends FetcherService {
353
353
  });
354
354
 
355
355
  // Deserializing response
356
- const data = extractors[resource](response);
356
+ const data = Extractors[resource](response);
357
357
 
358
358
  return data;
359
359
  }
@@ -386,7 +386,7 @@ export class UserService extends FetcherService {
386
386
  * ```
387
387
  */
388
388
  public async following(id?: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
389
- const resource = EResourceType.USER_FOLLOWING;
389
+ const resource = ResourceType.USER_FOLLOWING;
390
390
 
391
391
  // Fetching raw list of following
392
392
  const response = await this.request<IUserFollowingResponse>(resource, {
@@ -396,7 +396,7 @@ export class UserService extends FetcherService {
396
396
  });
397
397
 
398
398
  // Deserializing response
399
- const data = extractors[resource](response);
399
+ const data = Extractors[resource](response);
400
400
 
401
401
  return data;
402
402
  }
@@ -429,7 +429,7 @@ export class UserService extends FetcherService {
429
429
  * ```
430
430
  */
431
431
  public async highlights(id: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
432
- const resource = EResourceType.USER_HIGHLIGHTS;
432
+ const resource = ResourceType.USER_HIGHLIGHTS;
433
433
 
434
434
  // Fetching raw list of highlights
435
435
  const response = await this.request<IUserHighlightsResponse>(resource, {
@@ -439,7 +439,7 @@ export class UserService extends FetcherService {
439
439
  });
440
440
 
441
441
  // Deserializing response
442
- const data = extractors[resource](response);
442
+ const data = Extractors[resource](response);
443
443
 
444
444
  return data;
445
445
  }
@@ -471,7 +471,7 @@ export class UserService extends FetcherService {
471
471
  * ```
472
472
  */
473
473
  public async likes(count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
474
- const resource = EResourceType.USER_LIKES;
474
+ const resource = ResourceType.USER_LIKES;
475
475
 
476
476
  // Fetching raw list of likes
477
477
  const response = await this.request<IUserLikesResponse>(resource, {
@@ -481,7 +481,7 @@ export class UserService extends FetcherService {
481
481
  });
482
482
 
483
483
  // Deserializing response
484
- const data = extractors[resource](response);
484
+ const data = Extractors[resource](response);
485
485
 
486
486
  return data;
487
487
  }
@@ -514,7 +514,7 @@ export class UserService extends FetcherService {
514
514
  * ```
515
515
  */
516
516
  public async media(id?: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
517
- const resource = EResourceType.USER_MEDIA;
517
+ const resource = ResourceType.USER_MEDIA;
518
518
 
519
519
  // Fetching raw list of media
520
520
  const response = await this.request<IUserMediaResponse>(resource, {
@@ -524,7 +524,7 @@ export class UserService extends FetcherService {
524
524
  });
525
525
 
526
526
  // Deserializing response
527
- const data = extractors[resource](response);
527
+ const data = Extractors[resource](response);
528
528
 
529
529
  return data;
530
530
  }
@@ -562,7 +562,7 @@ export class UserService extends FetcherService {
562
562
  * ```
563
563
  */
564
564
  public async *notifications(pollingInterval = 60000): AsyncGenerator<Notification> {
565
- const resource = EResourceType.USER_NOTIFICATIONS;
565
+ const resource = ResourceType.USER_NOTIFICATIONS;
566
566
 
567
567
  /** Whether it's the first batch of notifications or not. */
568
568
  let first = true;
@@ -581,7 +581,7 @@ export class UserService extends FetcherService {
581
581
  });
582
582
 
583
583
  // Deserializing response
584
- const notifications = extractors[resource](response);
584
+ const notifications = Extractors[resource](response);
585
585
 
586
586
  // Sorting the notifications by time, from oldest to recent
587
587
  notifications.list.sort((a, b) => new Date(a.receivedAt).valueOf() - new Date(b.receivedAt).valueOf());
@@ -630,7 +630,7 @@ export class UserService extends FetcherService {
630
630
  * @remarks Always returns 35 feed items, with no way to customize the count.
631
631
  */
632
632
  public async recommended(cursor?: string): Promise<CursoredData<Tweet>> {
633
- const resource = EResourceType.USER_FEED_RECOMMENDED;
633
+ const resource = ResourceType.USER_FEED_RECOMMENDED;
634
634
 
635
635
  // Fetching raw list of tweets
636
636
  const response = await this.request<IUserRecommendedResponse>(resource, {
@@ -638,7 +638,7 @@ export class UserService extends FetcherService {
638
638
  });
639
639
 
640
640
  // Deserializing response
641
- const data = extractors[resource](response);
641
+ const data = Extractors[resource](response);
642
642
 
643
643
  return data;
644
644
  }
@@ -675,7 +675,7 @@ export class UserService extends FetcherService {
675
675
  * If the target user has a pinned tweet, the returned reply timeline has one item extra and this is always the pinned tweet.
676
676
  */
677
677
  public async replies(id?: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
678
- const resource = EResourceType.USER_TIMELINE_AND_REPLIES;
678
+ const resource = ResourceType.USER_TIMELINE_AND_REPLIES;
679
679
 
680
680
  // Fetching raw list of replies
681
681
  const response = await this.request<IUserTweetsAndRepliesResponse>(resource, {
@@ -685,7 +685,7 @@ export class UserService extends FetcherService {
685
685
  });
686
686
 
687
687
  // Deserializing response
688
- const data = extractors[resource](response);
688
+ const data = Extractors[resource](response);
689
689
 
690
690
  return data;
691
691
  }
@@ -720,7 +720,7 @@ export class UserService extends FetcherService {
720
720
  * ```
721
721
  */
722
722
  public async subscriptions(id: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
723
- const resource = EResourceType.USER_SUBSCRIPTIONS;
723
+ const resource = ResourceType.USER_SUBSCRIPTIONS;
724
724
 
725
725
  // Fetching raw list of subscriptions
726
726
  const response = await this.request<IUserSubscriptionsResponse>(resource, {
@@ -730,7 +730,7 @@ export class UserService extends FetcherService {
730
730
  });
731
731
 
732
732
  // Deserializing response
733
- const data = extractors[resource](response);
733
+ const data = Extractors[resource](response);
734
734
 
735
735
  return data;
736
736
  }
@@ -768,7 +768,7 @@ export class UserService extends FetcherService {
768
768
  * - If timeline is fetched without authenticating, then the most popular tweets of the target user are returned instead.
769
769
  */
770
770
  public async timeline(id: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
771
- const resource = EResourceType.USER_TIMELINE;
771
+ const resource = ResourceType.USER_TIMELINE;
772
772
 
773
773
  // Fetching raw list of tweets
774
774
  const response = await this.request<IUserTweetsResponse>(resource, {
@@ -778,7 +778,7 @@ export class UserService extends FetcherService {
778
778
  });
779
779
 
780
780
  // Deserializing response
781
- const data = extractors[resource](response);
781
+ const data = Extractors[resource](response);
782
782
 
783
783
  return data;
784
784
  }
@@ -809,13 +809,13 @@ export class UserService extends FetcherService {
809
809
  * ```
810
810
  */
811
811
  public async unfollow(id: string): Promise<boolean> {
812
- const resource = EResourceType.USER_UNFOLLOW;
812
+ const resource = ResourceType.USER_UNFOLLOW;
813
813
 
814
814
  // Unfollowing the user
815
- const response = await this.request<IUserUnfollowResponse>(EResourceType.USER_UNFOLLOW, { id: id });
815
+ const response = await this.request<IUserUnfollowResponse>(ResourceType.USER_UNFOLLOW, { id: id });
816
816
 
817
817
  // Deserializing the response
818
- const data = extractors[resource](response) ?? false;
818
+ const data = Extractors[resource](response) ?? false;
819
819
 
820
820
  return data;
821
821
  }
@@ -42,4 +42,11 @@ export interface IRettiwtConfig {
42
42
  * Can either be a number or a function that returns a number synchronously or asynchronously.
43
43
  */
44
44
  delay?: number | (() => number | Promise<number>);
45
+
46
+ /**
47
+ * The maximum number of retries to use.
48
+ *
49
+ * @remarks Recommended to use a value of 5 combined with a `delay` of 1000 to prevent error 404.
50
+ */
51
+ maxRetries?: number;
45
52
  }
@@ -1,4 +1,4 @@
1
- import { ETweetRepliesSortType } from '../../enums/Tweet';
1
+ import { TweetRepliesSortType } from '../../enums/Tweet';
2
2
 
3
3
  /**
4
4
  * Options specifying the data that is to be fetched.
@@ -64,7 +64,7 @@ export interface IFetchArgs {
64
64
  * @remarks
65
65
  * - Only works for {@link EResourceType.TWEET_REPLIES}.
66
66
  */
67
- sortBy?: ETweetRepliesSortType;
67
+ sortBy?: TweetRepliesSortType;
68
68
  }
69
69
 
70
70
  /**
@@ -1,4 +1,4 @@
1
- import { EAuthenticationType } from '../../enums/Authentication';
1
+ import { AuthenticationType } from '../../enums/Authentication';
2
2
 
3
3
  /**
4
4
  * The credentials for authenticating against Twitter.
@@ -15,7 +15,7 @@ export interface IAuthCredential {
15
15
  authToken?: string;
16
16
 
17
17
  /** The type of authentication. */
18
- authenticationType?: EAuthenticationType;
18
+ authenticationType?: AuthenticationType;
19
19
 
20
20
  /** The cookie of the twitter account, which is used to authenticate against twitter. */
21
21
  cookies?: string;
@@ -1,4 +1,4 @@
1
- import { ENotificationType } from '../../enums/Notification';
1
+ import { NotificationType } from '../../enums/Notification';
2
2
 
3
3
  /**
4
4
  * The details of a single notification.
@@ -22,5 +22,5 @@ export interface INotification {
22
22
  target: string[];
23
23
 
24
24
  /** The type of notification. */
25
- type?: ENotificationType;
25
+ type?: NotificationType;
26
26
  }
@@ -1,4 +1,4 @@
1
- import { EMediaType } from '../../enums/Media';
1
+ import { MediaType } from '../../enums/Media';
2
2
 
3
3
  import { IUser } from './User';
4
4
 
@@ -89,7 +89,7 @@ export interface ITweetMedia {
89
89
  thumbnailUrl?: string;
90
90
 
91
91
  /** The type of media. */
92
- type: EMediaType;
92
+ type: MediaType;
93
93
 
94
94
  /** The direct URL to the media. */
95
95
  url: string;