rettiwt-api 2.4.1 → 2.5.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 (133) hide show
  1. package/.eslintrc.js +5 -0
  2. package/.github/workflows/documentation.yml +1 -1
  3. package/.github/workflows/publish.yml +1 -1
  4. package/.prettierrc +1 -1
  5. package/README.md +118 -60
  6. package/dist/Rettiwt.d.ts +7 -4
  7. package/dist/Rettiwt.js +4 -2
  8. package/dist/Rettiwt.js.map +1 -1
  9. package/dist/cli.js +1 -1
  10. package/dist/cli.js.map +1 -1
  11. package/dist/commands/Auth.d.ts +2 -1
  12. package/dist/commands/Auth.js +10 -17
  13. package/dist/commands/Auth.js.map +1 -1
  14. package/dist/commands/Tweet.js +36 -3
  15. package/dist/commands/Tweet.js.map +1 -1
  16. package/dist/enums/{ApiErrors.js → Api.js} +1 -1
  17. package/dist/enums/Api.js.map +1 -0
  18. package/dist/enums/Http.d.ts +68 -0
  19. package/dist/enums/Http.js +73 -0
  20. package/dist/enums/Http.js.map +1 -0
  21. package/dist/enums/Logging.d.ts +1 -0
  22. package/dist/enums/Logging.js +1 -0
  23. package/dist/enums/Logging.js.map +1 -1
  24. package/dist/index.d.ts +15 -14
  25. package/dist/index.js +21 -17
  26. package/dist/index.js.map +1 -1
  27. package/dist/models/{public → data}/CursoredData.d.ts +5 -3
  28. package/dist/models/{public → data}/CursoredData.js +1 -0
  29. package/dist/models/data/CursoredData.js.map +1 -0
  30. package/dist/{types/public → models/data}/List.d.ts +8 -1
  31. package/dist/models/data/List.js.map +1 -0
  32. package/dist/models/data/Media.d.ts +14 -0
  33. package/dist/models/data/Media.js +19 -0
  34. package/dist/models/data/Media.js.map +1 -0
  35. package/dist/{types/public → models/data}/Tweet.d.ts +26 -8
  36. package/dist/models/{public → data}/Tweet.js +4 -0
  37. package/dist/models/data/Tweet.js.map +1 -0
  38. package/dist/{types/public → models/data}/User.d.ts +8 -1
  39. package/dist/models/data/User.js.map +1 -0
  40. package/dist/models/errors/ApiError.d.ts +17 -0
  41. package/dist/models/errors/ApiError.js +42 -0
  42. package/dist/models/errors/ApiError.js.map +1 -0
  43. package/dist/models/errors/HttpError.d.ts +17 -0
  44. package/dist/models/errors/HttpError.js +42 -0
  45. package/dist/models/errors/HttpError.js.map +1 -0
  46. package/dist/models/errors/RettiwtError.d.ts +8 -0
  47. package/dist/models/errors/RettiwtError.js +34 -0
  48. package/dist/models/errors/RettiwtError.js.map +1 -0
  49. package/dist/models/errors/TimeoutError.d.ts +14 -0
  50. package/dist/models/errors/TimeoutError.js +39 -0
  51. package/dist/models/errors/TimeoutError.js.map +1 -0
  52. package/dist/services/internal/ErrorService.d.ts +85 -0
  53. package/dist/services/internal/ErrorService.js +144 -0
  54. package/dist/services/internal/ErrorService.js.map +1 -0
  55. package/dist/services/internal/FetcherService.d.ts +22 -24
  56. package/dist/services/internal/FetcherService.js +79 -59
  57. package/dist/services/internal/FetcherService.js.map +1 -1
  58. package/dist/services/public/AuthService.d.ts +66 -0
  59. package/dist/services/public/AuthService.js +160 -0
  60. package/dist/services/public/AuthService.js.map +1 -0
  61. package/dist/services/public/TweetService.d.ts +27 -8
  62. package/dist/services/public/TweetService.js +40 -5
  63. package/dist/services/public/TweetService.js.map +1 -1
  64. package/dist/services/public/UserService.d.ts +5 -5
  65. package/dist/services/public/UserService.js.map +1 -1
  66. package/dist/types/ErrorHandler.d.ts +13 -0
  67. package/dist/types/{public/User.js → ErrorHandler.js} +1 -1
  68. package/dist/types/ErrorHandler.js.map +1 -0
  69. package/dist/types/RettiwtConfig.d.ts +32 -0
  70. package/dist/types/RettiwtConfig.js.map +1 -0
  71. package/dist/types/args/TweetMediaArgs.d.ts +15 -0
  72. package/dist/types/{public/CursoredData.js → args/TweetMediaArgs.js} +1 -1
  73. package/dist/types/args/TweetMediaArgs.js.map +1 -0
  74. package/package.json +5 -5
  75. package/src/Rettiwt.ts +10 -5
  76. package/src/cli.ts +1 -1
  77. package/src/commands/Auth.ts +5 -16
  78. package/src/commands/Tweet.ts +56 -3
  79. package/src/enums/Http.ts +68 -0
  80. package/src/enums/Logging.ts +1 -0
  81. package/src/index.ts +23 -18
  82. package/src/models/{public → data}/CursoredData.ts +6 -5
  83. package/src/models/{public → data}/List.ts +14 -4
  84. package/src/models/data/Media.ts +19 -0
  85. package/src/models/{public → data}/Tweet.ts +39 -5
  86. package/src/models/{public → data}/User.ts +28 -4
  87. package/src/models/errors/ApiError.ts +24 -0
  88. package/src/models/errors/HttpError.ts +24 -0
  89. package/src/models/errors/RettiwtError.ts +12 -0
  90. package/src/models/errors/TimeoutError.ts +18 -0
  91. package/src/services/internal/ErrorService.ts +158 -0
  92. package/src/services/internal/FetcherService.ts +94 -80
  93. package/src/services/public/AuthService.ts +97 -0
  94. package/src/services/public/TweetService.ts +45 -10
  95. package/src/services/public/UserService.ts +7 -5
  96. package/src/types/ErrorHandler.ts +13 -0
  97. package/src/types/RettiwtConfig.ts +40 -0
  98. package/src/types/args/TweetMediaArgs.ts +16 -0
  99. package/dist/enums/ApiErrors.js.map +0 -1
  100. package/dist/enums/HTTP.d.ts +0 -17
  101. package/dist/enums/HTTP.js +0 -22
  102. package/dist/enums/HTTP.js.map +0 -1
  103. package/dist/models/internal/RettiwtConfig.d.ts +0 -18
  104. package/dist/models/internal/RettiwtConfig.js +0 -24
  105. package/dist/models/internal/RettiwtConfig.js.map +0 -1
  106. package/dist/models/public/CursoredData.js.map +0 -1
  107. package/dist/models/public/List.d.ts +0 -22
  108. package/dist/models/public/List.js.map +0 -1
  109. package/dist/models/public/Tweet.d.ts +0 -62
  110. package/dist/models/public/Tweet.js.map +0 -1
  111. package/dist/models/public/User.d.ts +0 -29
  112. package/dist/models/public/User.js.map +0 -1
  113. package/dist/types/internal/RettiwtConfig.d.ts +0 -15
  114. package/dist/types/internal/RettiwtConfig.js.map +0 -1
  115. package/dist/types/public/CursoredData.d.ts +0 -22
  116. package/dist/types/public/CursoredData.js.map +0 -1
  117. package/dist/types/public/List.js +0 -3
  118. package/dist/types/public/List.js.map +0 -1
  119. package/dist/types/public/Tweet.js +0 -3
  120. package/dist/types/public/Tweet.js.map +0 -1
  121. package/dist/types/public/User.js.map +0 -1
  122. package/src/enums/HTTP.ts +0 -17
  123. package/src/models/internal/RettiwtConfig.ts +0 -26
  124. package/src/types/internal/RettiwtConfig.ts +0 -18
  125. package/src/types/public/CursoredData.ts +0 -24
  126. package/src/types/public/List.ts +0 -27
  127. package/src/types/public/Tweet.ts +0 -86
  128. package/src/types/public/User.ts +0 -48
  129. /package/dist/enums/{ApiErrors.d.ts → Api.d.ts} +0 -0
  130. /package/dist/models/{public → data}/List.js +0 -0
  131. /package/dist/models/{public → data}/User.js +0 -0
  132. /package/dist/types/{internal/RettiwtConfig.js → RettiwtConfig.js} +0 -0
  133. /package/src/enums/{ApiErrors.ts → Api.ts} +0 -0
@@ -1,11 +1,11 @@
1
1
  // PACKAGES
2
2
  import { Command, createCommand } from 'commander';
3
- import { Auth } from 'rettiwt-auth';
3
+ import { Rettiwt } from '../Rettiwt';
4
4
 
5
5
  // UTILITY
6
6
  import { output } from '../helper/CliUtils';
7
7
 
8
- function createAuthCommand(): Command {
8
+ function createAuthCommand(rettiwt: Rettiwt): Command {
9
9
  // Creating the 'auth' command
10
10
  const auth = createCommand('auth').description('Manage authentication');
11
11
 
@@ -16,26 +16,15 @@ function createAuthCommand(): Command {
16
16
  .argument('<username>', 'The username associated with the Twitter account')
17
17
  .argument('<password>', 'The password to the Twitter account')
18
18
  .action(async (email: string, username: string, password: string) => {
19
- // Logging in and getting the credentials
20
- let apiKey: string =
21
- (
22
- await new Auth().getUserCredential({ email: email, userName: username, password: password })
23
- ).toHeader().cookie ?? '';
24
-
25
- // Converting the credentials to base64 string
26
- apiKey = Buffer.from(apiKey).toString('base64');
19
+ const apiKey: string = await rettiwt.auth.login(email, username, password);
27
20
  output(apiKey);
28
21
  });
29
22
 
30
23
  // Guest
31
24
  auth.command('guest')
32
- .description('Generate a new guest API key')
25
+ .description('Generate a new guest key')
33
26
  .action(async () => {
34
- // Getting a new guest API key
35
- let guestKey: string = (await new Auth().getGuestCredential()).guestToken ?? '';
36
-
37
- // Converting the credentials to base64 string
38
- guestKey = Buffer.from(guestKey).toString('base64');
27
+ const guestKey: string = await rettiwt.auth.guest();
39
28
  output(guestKey);
40
29
  });
41
30
 
@@ -35,7 +35,26 @@ function createTweetCommand(rettiwt: Rettiwt): Command {
35
35
  .option('-f, --from <string>', "Matches the tweets made by list of given users, separated by ';'")
36
36
  .option('-t, --to <string>', "Matches the tweets made to the list of given users, separated by ';'")
37
37
  .option('-w, --words <string>', "Matches the tweets containing the given list of words, separated by ';'")
38
+ .option('-p, --phrase <string>', 'Matches the tweets containing the exact phrase')
39
+ .option(
40
+ '--optional-words <string>',
41
+ "Matches the tweets containing any of the given list of words, separated by ';'",
42
+ )
43
+ .option(
44
+ '--exclude-words <string>',
45
+ "Matches the tweets that do not contain any of the give list of words, separated by ';'",
46
+ )
38
47
  .option('-h, --hashtags <string>', "Matches the tweets containing the given list of hashtags, separated by ';'")
48
+ .option(
49
+ '-m, --mentions <string>',
50
+ "Matches the tweets that mention the give list of usernames, separated by ';'",
51
+ )
52
+ .option('-r, --min-replies <number>', 'Matches the tweets that have a minimum of given number of replies')
53
+ .option('-l, --min-likes <number>', 'Matches the tweets that have a minimum of given number of likes')
54
+ .option('-x, --min-retweets <number>', 'Matches the tweets that have a minimum of given number of retweets')
55
+ .option('-q, --quoted <string>', 'Matches the tweets that quote the tweet with the given id')
56
+ .option('--exclude-links', 'Matches tweets that do not contain links')
57
+ .option('--exclude-replies', 'Matches the tweets that are not replies')
39
58
  .option('-s, --start <string>', 'Matches the tweets made since the given date (valid date string)')
40
59
  .option('-e, --end <string>', 'Matches the tweets made upto the given date (valid date string)')
41
60
  .action(async (count?: string, cursor?: string, options?: TweetSearchOptions) => {
@@ -88,8 +107,12 @@ function createTweetCommand(rettiwt: Rettiwt): Command {
88
107
  .command('post')
89
108
  .description('Post a tweet (text only)')
90
109
  .argument('<text>', 'The text to post as a tweet')
91
- .action(async (text: string) => {
92
- const result = await rettiwt.tweet.tweet(text);
110
+ .option('-m, --media [string]', "The path to the media item(s) to be posted, separated by ';'")
111
+ .action(async (text: string, options?: { media?: string }) => {
112
+ const result = await rettiwt.tweet.tweet(
113
+ text,
114
+ options?.media ? options?.media.split(';').map((item) => ({ path: item })) : undefined,
115
+ );
93
116
  output(result);
94
117
  });
95
118
 
@@ -125,7 +148,17 @@ class TweetSearchOptions {
125
148
  public from?: string;
126
149
  public to?: string;
127
150
  public words?: string;
151
+ public phrase?: string;
152
+ public optionalWords?: string;
153
+ public excludeWords?: string;
128
154
  public hashtags?: string;
155
+ public mentions?: string;
156
+ public minReplies?: number;
157
+ public minLikes?: number;
158
+ public minRetweets?: number;
159
+ public quoted?: string;
160
+ public excludeLinks?: boolean = false;
161
+ public excludeReplies?: boolean = false;
129
162
  public start?: string;
130
163
  public end?: string;
131
164
 
@@ -138,7 +171,17 @@ class TweetSearchOptions {
138
171
  this.from = options?.from;
139
172
  this.to = options?.to;
140
173
  this.words = options?.words;
174
+ this.phrase = options?.phrase;
175
+ this.optionalWords = options?.optionalWords;
176
+ this.excludeWords = options?.excludeWords;
141
177
  this.hashtags = options?.hashtags;
178
+ this.mentions = options?.mentions;
179
+ this.minReplies = options?.minReplies;
180
+ this.minLikes = options?.minLikes;
181
+ this.minRetweets = options?.minRetweets;
182
+ this.quoted = options?.quoted;
183
+ this.excludeLinks = options?.excludeLinks;
184
+ this.excludeReplies = options?.excludeReplies;
142
185
  this.start = options?.start;
143
186
  this.end = options?.end;
144
187
  }
@@ -152,8 +195,18 @@ class TweetSearchOptions {
152
195
  return new TweetFilter({
153
196
  fromUsers: this.from ? this.from.split(';') : undefined,
154
197
  toUsers: this.to ? this.to.split(';') : undefined,
155
- words: this.words ? this.words.split(';') : undefined,
198
+ includeWords: this.words ? this.words.split(';') : undefined,
199
+ includePhrase: this.phrase,
200
+ optionalWords: this.optionalWords ? this.optionalWords.split(';') : undefined,
201
+ excludeWords: this.excludeWords ? this.excludeWords.split(';') : undefined,
156
202
  hashtags: this.hashtags ? this.hashtags.split(';') : undefined,
203
+ mentions: this.mentions ? this.mentions.split(';') : undefined,
204
+ minReplies: this.minReplies,
205
+ minLikes: this.minLikes,
206
+ minRetweets: this.minRetweets,
207
+ quoted: this.quoted,
208
+ links: !this.excludeLinks,
209
+ replies: !this.excludeReplies,
157
210
  startDate: this.start ? new Date(this.start) : undefined,
158
211
  endDate: this.end ? new Date(this.end) : undefined,
159
212
  });
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The different types of http status codes
3
+ *
4
+ * @internal
5
+ */
6
+ export enum EHttpStatus {
7
+ CONTINUE = 100,
8
+ SWITCHING_PROTOCOLS = 101,
9
+ PROCESSING = 102,
10
+ OK = 200,
11
+ CREATED = 201,
12
+ ACCEPTED = 202,
13
+ NON_AUTHORITATIVE_INFORMATION = 203,
14
+ NO_CONTENT = 204,
15
+ RESET_CONTENT = 205,
16
+ PARTIAL_CONTENT = 206,
17
+ MULTI_STATUS = 207,
18
+ ALREADY_REPORTED = 208,
19
+ IM_USED = 226,
20
+ MULTIPLE_CHOICES = 300,
21
+ MOVED_PERMANENTLY = 301,
22
+ FOUND = 302,
23
+ SEE_OTHER = 303,
24
+ NOT_MODIFIED = 304,
25
+ USE_PROXY = 305,
26
+ SWITCH_PROXY = 306,
27
+ TEMPORARY_REDIRECT = 307,
28
+ PERMANENT_REDIRECT = 308,
29
+ BAD_REQUEST = 400,
30
+ UNAUTHORIZED = 401,
31
+ PAYMENT_REQUIRED = 402,
32
+ FORBIDDEN = 403,
33
+ NOT_FOUND = 404,
34
+ METHOD_NOT_ALLOWED = 405,
35
+ NOT_ACCEPTABLE = 406,
36
+ PROXY_AUTHENTICATION_REQUIRED = 407,
37
+ REQUEST_TIMEOUT = 408,
38
+ CONFLICT = 409,
39
+ GONE = 410,
40
+ LENGTH_REQUIRED = 411,
41
+ PRECONDITION_FAILED = 412,
42
+ PAYLOAD_TOO_LARGE = 413,
43
+ URI_TOO_LONG = 414,
44
+ UNSUPPORTED_MEDIA_TYPE = 415,
45
+ RANGE_NOT_SATISFIABLE = 416,
46
+ EXPECTATION_FAILED = 417,
47
+ I_AM_A_TEAPOT = 418,
48
+ MISDIRECTED_REQUEST = 421,
49
+ UNPROCESSABLE_ENTITY = 422,
50
+ LOCKED = 423,
51
+ FAILED_DEPENDENCY = 424,
52
+ UPGRADE_REQUIRED = 426,
53
+ PRECONDITION_REQUIRED = 428,
54
+ TOO_MANY_REQUESTS = 429,
55
+ REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
56
+ UNAVAILABLE_FOR_LEGAL_REASONS = 451,
57
+ INTERNAL_SERVER_ERROR = 500,
58
+ NOT_IMPLEMENTED = 501,
59
+ BAD_GATEWAY = 502,
60
+ SERVICE_UNAVAILABLE = 503,
61
+ GATEWAY_TIMEOUT = 504,
62
+ HTTP_VERSION_NOT_SUPPORTED = 505,
63
+ VARIANT_ALSO_NEGOTIATES = 506,
64
+ INSUFFICIENT_STORAGE = 507,
65
+ LOOP_DETECTED = 508,
66
+ NOT_EXTENDED = 510,
67
+ NETWORK_AUTHENTICATION_REQUIRED = 511,
68
+ }
@@ -6,6 +6,7 @@
6
6
  export enum ELogActions {
7
7
  FETCH = 'FETCH',
8
8
  POST = 'POST',
9
+ UPLOAD = 'UPLOAD',
9
10
  EXTRACT = 'EXTRACT',
10
11
  DESERIALIZE = 'DESERIALIZE',
11
12
  AUTHORIZATION = 'AUTHORIZATION',
package/src/index.ts CHANGED
@@ -1,29 +1,34 @@
1
1
  // MAIN
2
2
  export * from './Rettiwt';
3
3
 
4
- // Exporting enums
5
- export * from './enums/ApiErrors';
6
- export * from './enums/HTTP';
4
+ // EXTERNAL
5
+ export { TweetFilter } from 'rettiwt-core';
6
+
7
+ // ENUMS
8
+ export * from './enums/Api';
9
+ export * from './enums/Http';
7
10
  export * from './enums/Logging';
8
11
 
9
- // Exporting models
10
- export * from './models/internal/RettiwtConfig';
11
- export * from './models/public/CursoredData';
12
- export * from './models/public/List';
13
- export * from './models/public/Tweet';
14
- export * from './models/public/User';
15
- export { TweetFilter } from 'rettiwt-core';
12
+ // ERROR MODELS
13
+ export * from './models/errors/ApiError';
14
+ export * from './models/errors/HttpError';
15
+ export * from './models/errors/RettiwtError';
16
+
17
+ // DATA MODELS
18
+ export * from './models/data/CursoredData';
19
+ export * from './models/data/List';
20
+ export * from './models/data/Tweet';
21
+ export * from './models/data/User';
16
22
 
17
- // Exporting services
23
+ // SERVICES
24
+ export * from './services/internal/ErrorService';
18
25
  export * from './services/internal/FetcherService';
19
26
  export * from './services/internal/LogService';
27
+ export * from './services/public/AuthService';
20
28
  export * from './services/public/TweetService';
21
29
  export * from './services/public/UserService';
22
30
 
23
- // Exporting types
24
- export * from './types/internal/RettiwtConfig';
25
- export * from './types/public/CursoredData';
26
- export * from './types/public/List';
27
- export * from './types/public/Tweet';
28
- export * from './types/public/User';
29
- export { ITweetFilter } from 'rettiwt-core';
31
+ // TYPES
32
+ export * from './types/args/TweetMediaArgs';
33
+ export * from './types/RettiwtConfig';
34
+ export * from './types/ErrorHandler';
@@ -2,9 +2,6 @@
2
2
  import { Tweet } from './Tweet';
3
3
  import { User } from './User';
4
4
 
5
- // TYPES
6
- import { ICursor, ICursoredData } from '../../types/public/CursoredData';
7
-
8
5
  /**
9
6
  * The data that us fetched batch-wise along with a cursor.
10
7
  *
@@ -12,8 +9,11 @@ import { ICursor, ICursoredData } from '../../types/public/CursoredData';
12
9
  *
13
10
  * @public
14
11
  */
15
- export class CursoredData<T extends Tweet | User> implements ICursoredData<T> {
12
+ export class CursoredData<T extends Tweet | User> {
13
+ /** The list of data of the given type. */
16
14
  public list: T[] = [];
15
+
16
+ /** The cursor to the next batch of data. */
17
17
  public next: Cursor;
18
18
 
19
19
  /**
@@ -31,7 +31,8 @@ export class CursoredData<T extends Tweet | User> implements ICursoredData<T> {
31
31
  *
32
32
  * @public
33
33
  */
34
- export class Cursor implements ICursor {
34
+ export class Cursor {
35
+ /** The cursor string. */
35
36
  public value: string;
36
37
 
37
38
  /**
@@ -1,21 +1,31 @@
1
1
  // PACKAGES
2
2
  import { IList as IRawList } from 'rettiwt-core';
3
3
 
4
- // TYPES
5
- import { IList } from '../../types/public/List';
6
-
7
4
  /**
8
5
  * The details of a single Twitter List.
9
6
  *
10
7
  * @public
11
8
  */
12
- export class List implements IList {
9
+ export class List {
10
+ /** The rest id of the list. */
13
11
  public id: string;
12
+
13
+ /** The name of the list. */
14
14
  public name: string;
15
+
16
+ /** The date and time of creation of the list, int UTC string format. */
15
17
  public createdAt: string;
18
+
19
+ /** The list description. */
16
20
  public description: string;
21
+
22
+ /** The number of memeber of the list. */
17
23
  public memberCount: number;
24
+
25
+ /** The number of subscribers of the list. */
18
26
  public subscriberCount: number;
27
+
28
+ /** The rest id of the user who created the list. */
19
29
  public createdBy: string;
20
30
 
21
31
  /**
@@ -0,0 +1,19 @@
1
+ // PACKAGES
2
+ import { IMediaUploadInitializeResponse } from 'rettiwt-core';
3
+
4
+ /**
5
+ * The details of a single media file.
6
+ *
7
+ * @public
8
+ */
9
+ export class Media {
10
+ /** The id of the media. */
11
+ public id: string;
12
+
13
+ /**
14
+ * @param media - The raw media data.
15
+ */
16
+ public constructor(media: IMediaUploadInitializeResponse) {
17
+ this.id = media.media_id_string;
18
+ }
19
+ }
@@ -6,9 +6,6 @@ import {
6
6
  EMediaType,
7
7
  } from 'rettiwt-core';
8
8
 
9
- // TYPES
10
- import { ITweet, ITweetEntities } from '../../types/public/Tweet';
11
-
12
9
  // MODELS
13
10
  import { User } from './User';
14
11
 
@@ -20,21 +17,50 @@ import { normalizeText } from '../../helper/JsonUtils';
20
17
  *
21
18
  * @public
22
19
  */
23
- export class Tweet implements ITweet {
20
+ export class Tweet {
21
+ /** The rest id of the tweet. */
24
22
  public id: string;
23
+
24
+ /** The details of the user who made the tweet. */
25
25
  public tweetBy: User;
26
+
27
+ /** The date and time of creation of the tweet, in UTC string format. */
26
28
  public createdAt: string;
29
+
30
+ /** Additional tweet entities like urls, mentions, etc. */
27
31
  public entities: TweetEntities;
32
+
33
+ /** The urls of the media contents of the tweet (if any). */
28
34
  public media: TweetMedia[];
35
+
36
+ /** The rest id of the tweet which is quoted in the tweet. */
29
37
  public quoted: string;
38
+
39
+ /** The full text content of the tweet. */
30
40
  public fullText: string;
41
+
42
+ /** The rest id of the user to which the tweet is a reply. */
31
43
  public replyTo: string;
44
+
45
+ /** The language in which the tweet is written. */
32
46
  public lang: string;
47
+
48
+ /** The number of quotes of the tweet. */
33
49
  public quoteCount: number;
50
+
51
+ /** The number of replies to the tweet. */
34
52
  public replyCount: number;
53
+
54
+ /** The number of retweets of the tweet. */
35
55
  public retweetCount: number;
56
+
57
+ /** The number of likes of the tweet. */
36
58
  public likeCount: number;
59
+
60
+ /** The number of views of a tweet. */
37
61
  public viewCount: number;
62
+
63
+ /** The number of bookmarks of a tweet. */
38
64
  public bookmarkCount: number;
39
65
 
40
66
  /**
@@ -66,9 +92,14 @@ export class Tweet implements ITweet {
66
92
  *
67
93
  * @public
68
94
  */
69
- export class TweetEntities implements ITweetEntities {
95
+ export class TweetEntities {
96
+ /** The list of hashtags mentioned in the tweet. */
70
97
  public hashtags: string[] = [];
98
+
99
+ /** The list of urls mentioned in the tweet. */
71
100
  public urls: string[] = [];
101
+
102
+ /** The list of IDs of users mentioned in the tweet. */
72
103
  public mentionedUsers: string[] = [];
73
104
 
74
105
  /**
@@ -106,7 +137,10 @@ export class TweetEntities implements ITweetEntities {
106
137
  * @public
107
138
  */
108
139
  export class TweetMedia {
140
+ /** The type of media. */
109
141
  public type: EMediaType;
142
+
143
+ /** The direct URL to the media. */
110
144
  public url: string = '';
111
145
 
112
146
  /**
@@ -1,28 +1,52 @@
1
1
  // PACKAGES
2
2
  import { IUser as IRawUser } from 'rettiwt-core';
3
3
 
4
- // TYPES
5
- import { IUser } from '../../types/public/User';
6
-
7
4
  /**
8
5
  * The details of a single user.
9
6
  *
10
7
  * @public
11
8
  */
12
- export class User implements IUser {
9
+ export class User {
10
+ /** The rest id of the user. */
13
11
  public id: string;
12
+
13
+ /** The username/screenname of the user. */
14
14
  public userName: string;
15
+
16
+ /** The full name of the user. */
15
17
  public fullName: string;
18
+
19
+ /** The creation date of user's account. */
16
20
  public createdAt: string;
21
+
22
+ /** The user's description. */
17
23
  public description: string;
24
+
25
+ /** Whether the account is verified or not. */
18
26
  public isVerified: boolean;
27
+
28
+ /** The number of tweets liked by the user. */
19
29
  public favouritesCount: number;
30
+
31
+ /** The number of followers of the user. */
20
32
  public followersCount: number;
33
+
34
+ /** The number of following of the user. */
21
35
  public followingsCount: number;
36
+
37
+ /** The number of tweets made by the user. */
22
38
  public statusesCount: number;
39
+
40
+ /** The location of user as provided by user. */
23
41
  public location: string;
42
+
43
+ /** The rest id of the tweet pinned in the user's profile. */
24
44
  public pinnedTweet: string;
45
+
46
+ /** The url of the profile banner image. */
25
47
  public profileBanner: string;
48
+
49
+ /** The url of the profile image. */
26
50
  public profileImage: string;
27
51
 
28
52
  /**
@@ -0,0 +1,24 @@
1
+ // ERRORS
2
+ import { RettiwtError } from './RettiwtError';
3
+
4
+ /**
5
+ * Represents an error that is thrown by Twitter API.
6
+ *
7
+ * @internal
8
+ */
9
+ export class ApiError extends RettiwtError {
10
+ /** The error code thrown by Twitter API. */
11
+ public code: number;
12
+
13
+ /**
14
+ * Initializes a new ApiError based on the given error details.
15
+ *
16
+ * @param errorCode - The error code thrown by Twitter API.
17
+ * @param message - Any additional error message.
18
+ */
19
+ public constructor(errorCode: number, message?: string) {
20
+ super(message);
21
+
22
+ this.code = errorCode;
23
+ }
24
+ }
@@ -0,0 +1,24 @@
1
+ // ERRORS
2
+ import { RettiwtError } from './RettiwtError';
3
+
4
+ /**
5
+ * Represents an HTTP error that occues while making a request to Twitter API.
6
+ *
7
+ * @internal
8
+ */
9
+ export class HttpError extends RettiwtError {
10
+ /** The HTTP status code. */
11
+ public status: number;
12
+
13
+ /**
14
+ * Initializes a new HttpError based on the given error details.
15
+ *
16
+ * @param httpStatus - The HTTP status code received upon making the request
17
+ * @param message - Any additional error message.
18
+ */
19
+ public constructor(httpStatus: number, message?: string) {
20
+ super(message);
21
+
22
+ this.status = httpStatus;
23
+ }
24
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Represents an error that arises inside the package.
3
+ *
4
+ * @internal
5
+ */
6
+ export class RettiwtError extends Error {
7
+ public constructor(message?: string) {
8
+ super(message);
9
+
10
+ Object.setPrototypeOf(this, RettiwtError.prototype);
11
+ }
12
+ }
@@ -0,0 +1,18 @@
1
+ // ERRORS
2
+ import { RettiwtError } from './RettiwtError';
3
+
4
+ /**
5
+ * Represents an HTTP error that occues while making a request to Twitter API.
6
+ *
7
+ * @internal
8
+ */
9
+ export class TimeoutError extends RettiwtError {
10
+ /**
11
+ * Initializes a new TimeoutError based on the given error details.
12
+ *
13
+ * @param message - Error message with the configured timeout.
14
+ */
15
+ public constructor(message?: string) {
16
+ super(message);
17
+ }
18
+ }