rettiwt-api 5.0.0-alpha.3 → 5.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 (162) hide show
  1. package/README.md +160 -87
  2. package/dist/collections/Extractors.d.ts +6 -2
  3. package/dist/collections/Extractors.js +1 -0
  4. package/dist/collections/Extractors.js.map +1 -1
  5. package/dist/collections/Groups.js +1 -0
  6. package/dist/collections/Groups.js.map +1 -1
  7. package/dist/collections/Requests.d.ts +1 -1
  8. package/dist/collections/Requests.js +4 -2
  9. package/dist/collections/Requests.js.map +1 -1
  10. package/dist/collections/Tweet.d.ts +10 -0
  11. package/dist/collections/Tweet.js +17 -0
  12. package/dist/collections/Tweet.js.map +1 -0
  13. package/dist/commands/Tweet.js +0 -16
  14. package/dist/commands/Tweet.js.map +1 -1
  15. package/dist/commands/User.js +15 -15
  16. package/dist/commands/User.js.map +1 -1
  17. package/dist/enums/Api.d.ts +1 -51
  18. package/dist/enums/Api.js +1 -52
  19. package/dist/enums/Api.js.map +1 -1
  20. package/dist/enums/Resource.d.ts +1 -0
  21. package/dist/enums/Resource.js +1 -0
  22. package/dist/enums/Resource.js.map +1 -1
  23. package/dist/enums/Tweet.d.ts +8 -0
  24. package/dist/enums/Tweet.js +13 -0
  25. package/dist/enums/Tweet.js.map +1 -0
  26. package/dist/enums/raw/Tweet.d.ts +11 -1
  27. package/dist/enums/raw/Tweet.js +13 -2
  28. package/dist/enums/raw/Tweet.js.map +1 -1
  29. package/dist/index.d.ts +6 -6
  30. package/dist/index.js +3 -5
  31. package/dist/index.js.map +1 -1
  32. package/dist/models/RettiwtConfig.d.ts +27 -3
  33. package/dist/models/RettiwtConfig.js +37 -4
  34. package/dist/models/RettiwtConfig.js.map +1 -1
  35. package/dist/models/args/FetchArgs.d.ts +3 -3
  36. package/dist/models/args/FetchArgs.js +3 -2
  37. package/dist/models/args/FetchArgs.js.map +1 -1
  38. package/dist/models/args/PostArgs.d.ts +2 -3
  39. package/dist/models/args/PostArgs.js +3 -3
  40. package/dist/models/args/PostArgs.js.map +1 -1
  41. package/dist/models/auth/AuthCookie.d.ts +1 -1
  42. package/dist/models/auth/AuthCookie.js +1 -1
  43. package/dist/models/auth/AuthCredential.d.ts +1 -1
  44. package/dist/models/auth/AuthCredential.js +1 -1
  45. package/dist/models/data/List.d.ts +4 -0
  46. package/dist/models/data/List.js +7 -0
  47. package/dist/models/data/List.js.map +1 -1
  48. package/dist/models/data/Notification.d.ts +4 -0
  49. package/dist/models/data/Notification.js +7 -0
  50. package/dist/models/data/Notification.js.map +1 -1
  51. package/dist/models/data/Tweet.d.ts +4 -0
  52. package/dist/models/data/Tweet.js +7 -0
  53. package/dist/models/data/Tweet.js.map +1 -1
  54. package/dist/models/data/User.d.ts +4 -0
  55. package/dist/models/data/User.js +7 -0
  56. package/dist/models/data/User.js.map +1 -1
  57. package/dist/models/errors/TwitterError.d.ts +37 -0
  58. package/dist/models/errors/TwitterError.js +60 -0
  59. package/dist/models/errors/TwitterError.js.map +1 -0
  60. package/dist/requests/List.js +28 -9
  61. package/dist/requests/List.js.map +1 -1
  62. package/dist/requests/Tweet.d.ts +2 -1
  63. package/dist/requests/Tweet.js +94 -38
  64. package/dist/requests/Tweet.js.map +1 -1
  65. package/dist/requests/User.js +231 -111
  66. package/dist/requests/User.js.map +1 -1
  67. package/dist/services/internal/AuthService.d.ts +6 -6
  68. package/dist/services/internal/AuthService.js +7 -8
  69. package/dist/services/internal/AuthService.js.map +1 -1
  70. package/dist/services/internal/ErrorService.d.ts +5 -76
  71. package/dist/services/internal/ErrorService.js +13 -116
  72. package/dist/services/internal/ErrorService.js.map +1 -1
  73. package/dist/services/internal/TidService.d.ts +4 -5
  74. package/dist/services/internal/TidService.js +18 -24
  75. package/dist/services/internal/TidService.js.map +1 -1
  76. package/dist/services/public/FetcherService.d.ts +4 -3
  77. package/dist/services/public/FetcherService.js +8 -7
  78. package/dist/services/public/FetcherService.js.map +1 -1
  79. package/dist/services/public/ListService.d.ts +6 -4
  80. package/dist/services/public/ListService.js +6 -4
  81. package/dist/services/public/ListService.js.map +1 -1
  82. package/dist/services/public/TweetService.d.ts +96 -74
  83. package/dist/services/public/TweetService.js +97 -87
  84. package/dist/services/public/TweetService.js.map +1 -1
  85. package/dist/services/public/UserService.d.ts +106 -38
  86. package/dist/services/public/UserService.js +126 -43
  87. package/dist/services/public/UserService.js.map +1 -1
  88. package/dist/types/args/FetchArgs.d.ts +8 -0
  89. package/dist/types/errors/TwitterError.d.ts +30 -0
  90. package/dist/types/{raw/generic/Error.js → errors/TwitterError.js} +1 -1
  91. package/dist/types/errors/TwitterError.js.map +1 -0
  92. package/dist/types/raw/base/Error.d.ts +32 -0
  93. package/dist/types/raw/base/Error.js +4 -0
  94. package/dist/types/raw/base/Error.js.map +1 -0
  95. package/dist/types/raw/generic/Response.d.ts +0 -2
  96. package/dist/types/raw/tweet/DetailsBulk.d.ts +288 -0
  97. package/dist/types/raw/tweet/DetailsBulk.js +4 -0
  98. package/dist/types/raw/tweet/DetailsBulk.js.map +1 -0
  99. package/dist/types/raw/user/DetailsBulk.d.ts +91 -0
  100. package/dist/types/raw/user/DetailsBulk.js +4 -0
  101. package/dist/types/raw/user/DetailsBulk.js.map +1 -0
  102. package/package.json +1 -1
  103. package/src/collections/Extractors.ts +8 -2
  104. package/src/collections/Groups.ts +1 -0
  105. package/src/collections/Requests.ts +6 -2
  106. package/src/collections/Tweet.ts +17 -0
  107. package/src/commands/Tweet.ts +0 -16
  108. package/src/commands/User.ts +15 -15
  109. package/src/enums/Api.ts +0 -51
  110. package/src/enums/Resource.ts +1 -0
  111. package/src/enums/Tweet.ts +8 -0
  112. package/src/enums/raw/Tweet.ts +12 -1
  113. package/src/index.ts +6 -6
  114. package/src/models/RettiwtConfig.ts +43 -4
  115. package/src/models/args/FetchArgs.ts +4 -3
  116. package/src/models/args/PostArgs.ts +3 -4
  117. package/src/models/auth/AuthCookie.ts +1 -1
  118. package/src/models/auth/AuthCredential.ts +1 -1
  119. package/src/models/data/List.ts +9 -0
  120. package/src/models/data/Notification.ts +10 -0
  121. package/src/models/data/Tweet.ts +9 -0
  122. package/src/models/data/User.ts +9 -0
  123. package/src/models/errors/TwitterError.ts +65 -0
  124. package/src/requests/List.ts +28 -9
  125. package/src/requests/Tweet.ts +95 -39
  126. package/src/requests/User.ts +231 -111
  127. package/src/services/internal/AuthService.ts +8 -9
  128. package/src/services/internal/ErrorService.ts +14 -132
  129. package/src/services/internal/TidService.ts +21 -28
  130. package/src/services/public/FetcherService.ts +8 -7
  131. package/src/services/public/ListService.ts +6 -4
  132. package/src/services/public/TweetService.ts +104 -95
  133. package/src/services/public/UserService.ts +143 -51
  134. package/src/types/args/FetchArgs.ts +10 -0
  135. package/src/types/errors/TwitterError.ts +37 -0
  136. package/src/types/raw/base/Error.ts +37 -0
  137. package/src/types/raw/generic/Response.ts +0 -3
  138. package/src/types/raw/tweet/DetailsBulk.ts +338 -0
  139. package/src/types/raw/user/DetailsBulk.ts +104 -0
  140. package/dist/enums/Http.d.ts +0 -68
  141. package/dist/enums/Http.js +0 -73
  142. package/dist/enums/Http.js.map +0 -1
  143. package/dist/models/errors/ApiError.d.ts +0 -15
  144. package/dist/models/errors/ApiError.js +0 -23
  145. package/dist/models/errors/ApiError.js.map +0 -1
  146. package/dist/models/errors/HttpError.d.ts +0 -15
  147. package/dist/models/errors/HttpError.js +0 -23
  148. package/dist/models/errors/HttpError.js.map +0 -1
  149. package/dist/models/errors/RettiwtError.d.ts +0 -9
  150. package/dist/models/errors/RettiwtError.js +0 -17
  151. package/dist/models/errors/RettiwtError.js.map +0 -1
  152. package/dist/models/errors/TimeoutError.d.ts +0 -12
  153. package/dist/models/errors/TimeoutError.js +0 -19
  154. package/dist/models/errors/TimeoutError.js.map +0 -1
  155. package/dist/types/raw/generic/Error.d.ts +0 -30
  156. package/dist/types/raw/generic/Error.js.map +0 -1
  157. package/src/enums/Http.ts +0 -68
  158. package/src/models/errors/ApiError.ts +0 -21
  159. package/src/models/errors/HttpError.ts +0 -21
  160. package/src/models/errors/RettiwtError.ts +0 -13
  161. package/src/models/errors/TimeoutError.ts +0 -15
  162. package/src/types/raw/generic/Error.ts +0 -35
package/src/index.ts CHANGED
@@ -9,11 +9,11 @@ export * from './enums/raw/Tweet';
9
9
  export * from './enums/Api';
10
10
  export * from './enums/Authentication';
11
11
  export * from './enums/Data';
12
- export * from './enums/Http';
13
12
  export * from './enums/Logging';
14
13
  export * from './enums/Media';
15
14
  export * from './enums/Notification';
16
15
  export * from './enums/Resource';
16
+ export * from './enums/Tweet';
17
17
 
18
18
  // MODELS
19
19
  export * from './models/args/FetchArgs';
@@ -23,10 +23,7 @@ export * from './models/data/List';
23
23
  export * from './models/data/Notification';
24
24
  export * from './models/data/Tweet';
25
25
  export * from './models/data/User';
26
- export * from './models/errors/ApiError';
27
- export * from './models/errors/HttpError';
28
- export * from './models/errors/RettiwtError';
29
- export * from './models/errors/TimeoutError';
26
+ export * from './models/errors/TwitterError';
30
27
 
31
28
  // REQUESTS
32
29
  export * from './requests/List';
@@ -49,9 +46,11 @@ export * from './types/data/List';
49
46
  export * from './types/data/Notification';
50
47
  export * from './types/data/Tweet';
51
48
  export * from './types/data/User';
49
+ export * from './types/errors/TwitterError';
52
50
  export * from './types/params/Variables';
53
51
  export { IAnalytics as IRawAnalytics } from './types/raw/base/Analytic';
54
52
  export { ICursor as IRawCursor } from './types/raw/base/Cursor';
53
+ export { IErrorData as IRawErrorData, IErrorDetails as IRawErrorDetails } from './types/raw/base/Error';
55
54
  export { ILimitedVisibilityTweet as IRawLimitedVisibilityTweet } from './types/raw/base/LimitedVisibilityTweet';
56
55
  export { IList as IRawList } from './types/raw/base/List';
57
56
  export { IMedia as IRawMedia } from './types/raw/base/Media';
@@ -62,7 +61,6 @@ export { IUser as IRawUser } from './types/raw/base/User';
62
61
  export { IDataResult as IRawDataResult } from './types/raw/composite/DataResult';
63
62
  export { ITimelineTweet as IRawTimelineTweet } from './types/raw/composite/TimelineTweet';
64
63
  export { ITimelineUser as IRawTimelineUser } from './types/raw/composite/TimelineUser';
65
- export { IError as IRawError } from './types/raw/generic/Error';
66
64
  export { IResponse as IRawResponse } from './types/raw/generic/Response';
67
65
  export { IListDetailsResponse as IRawListDetailsResponse } from './types/raw/list/Details';
68
66
  export { IListMembersResponse as IRawListMembersResponse } from './types/raw/list/Members';
@@ -71,6 +69,7 @@ export { IMediaFinalizeUploadResponse as IRawMediaFinalizeUploadResponse } from
71
69
  export { IMediaInitializeUploadResponse as IRawMediaInitializeUploadResponse } from './types/raw/media/InitalizeUpload';
72
70
  export { IMediaLiveVideoStreamResponse as IRawMediaLiveVideoStreamResponse } from './types/raw/media/LiveVideoStream';
73
71
  export { ITweetDetailsResponse as IRawTweetDetailsResponse } from './types/raw/tweet/Details';
72
+ export { ITweetDetailsBulkResponse as IRawTweetDetailsBulkResponse } from './types/raw/tweet/DetailsBulk';
74
73
  export { ITweetLikeResponse as IRawTweetLikeResponse } from './types/raw/tweet/Like';
75
74
  export { ITweetLikersResponse as IRawTweetLikersResponse } from './types/raw/tweet/Likers';
76
75
  export { ITweetPostResponse as IRawTweetPostResponse } from './types/raw/tweet/Post';
@@ -87,6 +86,7 @@ export { IUserAffiliatesResponse as IRawUserAffiliatesResponse } from './types/r
87
86
  export { IUserAnalyticsResponse as IRawUserAnalyticsResponse } from './types/raw/user/Analytics';
88
87
  export { IUserBookmarksResponse as IRawUserBookmarksResponse } from './types/raw/user/Bookmarks';
89
88
  export { IUserDetailsResponse as IRawUserDetailsResponse } from './types/raw/user/Details';
89
+ export { IUserDetailsBulkResponse as IRawUserDetailsBulkResponse } from './types/raw/user/DetailsBulk';
90
90
  export { IUserFollowResponse as IRawUserFollowResponse } from './types/raw/user/Follow';
91
91
  export { IUserFollowedResponse as IRawUserFollowedResponse } from './types/raw/user/Followed';
92
92
  export { IUserFollowersResponse as IRawUserFollowersResponse } from './types/raw/user/Followers';
@@ -7,9 +7,35 @@ import { ITidProvider } from '../types/auth/TidProvider';
7
7
  import { IErrorHandler } from '../types/ErrorHandler';
8
8
  import { IRettiwtConfig } from '../types/RettiwtConfig';
9
9
 
10
+ /**
11
+ * The default headers.
12
+ *
13
+ * @public
14
+ */
15
+ const defaultHeaders = {
16
+ /* eslint-disable @typescript-eslint/naming-convention */
17
+
18
+ Authority: 'x.com',
19
+ 'Accept-Language': 'en-US,en;q=0.9',
20
+ 'Cache-Control': 'no-cache',
21
+ Referer: 'https://x.com',
22
+ 'User-Agent':
23
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
24
+ 'X-Twitter-Active-User': 'yes',
25
+ 'X-Twitter-Client-Language': 'en',
26
+
27
+ /* eslint-enable @typescript-eslint/naming-convention */
28
+ };
29
+
30
+ /**
31
+ * The configuration for initializing a new Rettiwt instance.
32
+ *
33
+ * @public
34
+ */
10
35
  export class RettiwtConfig implements IRettiwtConfig {
11
36
  // Parameters for internal use
12
37
  private _apiKey?: string;
38
+ private _headers: { [key: string]: string };
13
39
  private _httpsAgent: Agent;
14
40
  private _userId: string | undefined;
15
41
 
@@ -20,9 +46,6 @@ export class RettiwtConfig implements IRettiwtConfig {
20
46
  public readonly tidProvider?: ITidProvider;
21
47
  public readonly timeout?: number;
22
48
 
23
- // Parameters that can be changed on the fly
24
- public headers?: { [key: string]: string };
25
-
26
49
  /**
27
50
  * @param config - The config for Rettiwt of type {@link IRettiwtConfig}.
28
51
  */
@@ -36,13 +59,20 @@ export class RettiwtConfig implements IRettiwtConfig {
36
59
  this.tidProvider = config?.tidProvider;
37
60
  this.timeout = config?.timeout;
38
61
  this.apiKey = config?.apiKey;
39
- this.headers = config?.headers;
62
+ this._headers = {
63
+ ...defaultHeaders,
64
+ ...config?.headers,
65
+ };
40
66
  }
41
67
 
42
68
  public get apiKey(): string | undefined {
43
69
  return this._apiKey;
44
70
  }
45
71
 
72
+ public get headers(): { [key: string]: string } {
73
+ return this._headers;
74
+ }
75
+
46
76
  /** The HTTPS agent instance to use. */
47
77
  public get httpsAgent(): Agent {
48
78
  return this._httpsAgent;
@@ -58,7 +88,16 @@ export class RettiwtConfig implements IRettiwtConfig {
58
88
  this._userId = apiKey ? AuthService.getUserId(apiKey) : undefined;
59
89
  }
60
90
 
91
+ public set headers(headers: { [key: string]: string } | undefined) {
92
+ this._headers = {
93
+ ...defaultHeaders,
94
+ ...headers,
95
+ };
96
+ }
97
+
61
98
  public set proxyUrl(proxyUrl: URL | undefined) {
62
99
  this._httpsAgent = proxyUrl ? new HttpsProxyAgent(proxyUrl) : new Agent();
63
100
  }
64
101
  }
102
+
103
+ export { defaultHeaders as DefaultRettiwtHeaders };
@@ -1,4 +1,4 @@
1
- import { EResourceType } from '../../enums/Resource';
1
+ import { ETweetRepliesSortType } from '../../enums/Tweet';
2
2
  import { IFetchArgs, ITweetFilter } from '../../types/args/FetchArgs';
3
3
 
4
4
  /**
@@ -12,17 +12,18 @@ 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
16
 
16
17
  /**
17
- * @param resource - The resource to be fetched.
18
18
  * @param args - Additional user-defined arguments for fetching the resource.
19
19
  */
20
- public constructor(resource: EResourceType, args: IFetchArgs) {
20
+ public constructor(args: IFetchArgs) {
21
21
  this.id = args.id;
22
22
  this.ids = args.ids;
23
23
  this.count = args.count;
24
24
  this.cursor = args.cursor;
25
25
  this.filter = args.filter ? new TweetFilter(args.filter) : undefined;
26
+ this.sortBy = args.sortBy;
26
27
  }
27
28
  }
28
29
 
@@ -1,4 +1,3 @@
1
- import { EResourceType } from '../../enums/Resource';
2
1
  import { INewTweet, INewTweetMedia, IPostArgs, IUploadArgs } from '../../types/args/PostArgs';
3
2
 
4
3
  /**
@@ -15,10 +14,10 @@ export class PostArgs implements IPostArgs {
15
14
  * @param resource - The resource to be posted.
16
15
  * @param args - Additional user-defined arguments for posting the resource.
17
16
  */
18
- public constructor(resource: EResourceType, args: IPostArgs) {
17
+ public constructor(args: IPostArgs) {
19
18
  this.id = args.id;
20
19
  this.tweet = args.tweet ? new NewTweet(args.tweet) : undefined;
21
- this.upload = args.upload ? new UploadArgs(resource, args.upload) : undefined;
20
+ this.upload = args.upload ? new UploadArgs(args.upload) : undefined;
22
21
  }
23
22
  }
24
23
 
@@ -78,7 +77,7 @@ export class UploadArgs implements IUploadArgs {
78
77
  * @param step - The upload step.
79
78
  * @param args - The upload arguments for uploading the media file.
80
79
  */
81
- public constructor(step: EResourceType, args: IUploadArgs) {
80
+ public constructor(args: IUploadArgs) {
82
81
  this.size = args.size;
83
82
  this.media = args.media;
84
83
  this.id = args.id;
@@ -5,7 +5,7 @@ import { IAuthCookie } from '../../types/auth/AuthCookie';
5
5
  /**
6
6
  * The cookie containing the tokens that are used to authenticate against Twitter.
7
7
  *
8
- * @public
8
+ * @internal
9
9
  */
10
10
  export class AuthCookie implements IAuthCookie {
11
11
  /* eslint-disable @typescript-eslint/naming-convention */
@@ -15,7 +15,7 @@ import { AuthCookie } from './AuthCookie';
15
15
  * - authToken, csrfToken, cookie =\> User authentication.
16
16
  * - authToken, guestToken, cookie =\> Guest authentication while logging in.
17
17
  *
18
- * @public
18
+ * @internal
19
19
  */
20
20
  export class AuthCredential implements IAuthCredential {
21
21
  public authToken?: string;
@@ -7,6 +7,9 @@ import { IList as IRawList } from '../../types/raw/base/List';
7
7
  * @public
8
8
  */
9
9
  export class List implements IList {
10
+ /** The raw list details. */
11
+ private readonly _raw: IRawList;
12
+
10
13
  public createdAt: string;
11
14
  public createdBy: string;
12
15
  public description?: string;
@@ -19,6 +22,7 @@ export class List implements IList {
19
22
  * @param list - The raw list details.
20
23
  */
21
24
  public constructor(list: IRawList) {
25
+ this._raw = { ...list };
22
26
  this.id = list.id_str;
23
27
  this.name = list.name;
24
28
  this.createdAt = new Date(list.created_at).toISOString();
@@ -28,6 +32,11 @@ export class List implements IList {
28
32
  this.createdBy = list.user_results.result.id;
29
33
  }
30
34
 
35
+ /** The raw list details. */
36
+ public get raw(): IRawList {
37
+ return { ...this._raw };
38
+ }
39
+
31
40
  /**
32
41
  * @returns A serializable JSON representation of `this` object.
33
42
  */
@@ -11,6 +11,9 @@ import { IUserNotificationsResponse } from '../../types/raw/user/Notifications';
11
11
  * @public
12
12
  */
13
13
  export class Notification implements INotification {
14
+ /** The raw notification details. */
15
+ private readonly _raw: IRawNotification;
16
+
14
17
  public from: string[];
15
18
  public id: string;
16
19
  public message: string;
@@ -22,6 +25,8 @@ export class Notification implements INotification {
22
25
  * @param notification - The raw notification details.
23
26
  */
24
27
  public constructor(notification: IRawNotification) {
28
+ this._raw = { ...notification };
29
+
25
30
  // Getting the original notification type
26
31
  const notificationType: string | undefined = findKeyByValue(ERawNotificationType, notification.icon.id);
27
32
 
@@ -39,6 +44,11 @@ export class Notification implements INotification {
39
44
  : ENotificationType.UNDEFINED;
40
45
  }
41
46
 
47
+ /** The raw notification details. */
48
+ public get raw(): IRawNotification {
49
+ return { ...this._raw };
50
+ }
51
+
42
52
  /**
43
53
  * Extracts and deserializes the list of notifications from the given raw response data.
44
54
  *
@@ -19,6 +19,9 @@ import { User } from './User';
19
19
  * @public
20
20
  */
21
21
  export class Tweet implements ITweet {
22
+ /** The raw tweet details. */
23
+ private readonly _raw: IRawTweet;
24
+
22
25
  public bookmarkCount: number;
23
26
  public conversationId: string;
24
27
  public createdAt: string;
@@ -42,6 +45,7 @@ export class Tweet implements ITweet {
42
45
  * @param tweet - The raw tweet details.
43
46
  */
44
47
  public constructor(tweet: IRawTweet) {
48
+ this._raw = { ...tweet };
45
49
  this.id = tweet.rest_id;
46
50
  this.conversationId = tweet.legacy.conversation_id_str;
47
51
  this.createdAt = new Date(tweet.legacy.created_at).toISOString();
@@ -62,6 +66,11 @@ export class Tweet implements ITweet {
62
66
  this.url = `https://x.com/${this.tweetBy.userName}/status/${this.id}`;
63
67
  }
64
68
 
69
+ /** The raw tweet details. */
70
+ public get raw(): IRawTweet {
71
+ return { ...this._raw };
72
+ }
73
+
65
74
  /**
66
75
  * Extract and deserialize the original quoted tweet from the given raw tweet.
67
76
  *
@@ -11,6 +11,9 @@ import { ITimelineUser as IRawTimelineUser } from '../../types/raw/composite/Tim
11
11
  * @public
12
12
  */
13
13
  export class User implements IUser {
14
+ /** The raw user details. */
15
+ private readonly _raw: IRawUser;
16
+
14
17
  public createdAt: string;
15
18
  public description?: string;
16
19
  public followersCount: number;
@@ -30,6 +33,7 @@ export class User implements IUser {
30
33
  * @param user - The raw user details.
31
34
  */
32
35
  public constructor(user: IRawUser) {
36
+ this._raw = { ...user };
33
37
  this.id = user.rest_id;
34
38
  this.userName = user.legacy.screen_name;
35
39
  this.fullName = user.legacy.name;
@@ -46,6 +50,11 @@ export class User implements IUser {
46
50
  this.profileImage = user.legacy.profile_image_url_https;
47
51
  }
48
52
 
53
+ /** The raw user details. */
54
+ public get raw(): IRawUser {
55
+ return { ...this._raw };
56
+ }
57
+
49
58
  /**
50
59
  * Extracts and deserializes multiple target users from the given raw response data.
51
60
  *
@@ -0,0 +1,65 @@
1
+ import { AxiosError } from 'axios';
2
+
3
+ import { ITwitterError, ITwitterErrorDetails } from '../../types/errors/TwitterError';
4
+ import { IErrorData as IRawErrorData, IErrorDetails as IRawErrorDetails } from '../../types/raw/base/Error';
5
+
6
+ /**
7
+ * The error thrown by Twitter API.
8
+ *
9
+ * @public
10
+ */
11
+ export class TwitterError extends Error implements ITwitterError {
12
+ public details: ITwitterErrorDetails[];
13
+ public message: string;
14
+ public name: string;
15
+ public status: number;
16
+
17
+ /**
18
+ * @param error - The error response received from Twitter.
19
+ */
20
+ public constructor(error: AxiosError<IRawErrorData | IRawErrorDetails>) {
21
+ super(error.message);
22
+ this.details = (
23
+ (error.response?.data as IRawErrorData).errors
24
+ ? (error.response?.data as IRawErrorData).errors.map((item) => new TwitterErrorDetails(item))
25
+ : [new TwitterErrorDetails(error.response?.data as IRawErrorDetails)]
26
+ ).map((item) => item.toJSON());
27
+ this.message = error.message;
28
+ this.name = 'TWITTER_ERROR';
29
+ this.status = error.status ?? 500;
30
+ }
31
+ }
32
+
33
+ /**
34
+ * The error details.
35
+ *
36
+ * @public
37
+ */
38
+ export class TwitterErrorDetails implements ITwitterErrorDetails {
39
+ public code: number;
40
+ public message: string;
41
+ public name?: string;
42
+ public type?: string;
43
+
44
+ /**
45
+ * @param details - The details of the error.
46
+ */
47
+ public constructor(details: IRawErrorDetails) {
48
+ this.code = details.code;
49
+ this.message = details.message;
50
+ this.name = details.name;
51
+ this.type = details.kind;
52
+ }
53
+
54
+ /**
55
+ * @returns The JSON representation of `this` object.
56
+ */
57
+ public toJSON(): ITwitterErrorDetails {
58
+ return {
59
+ code: this.code,
60
+ message: this.message,
61
+ name: this.message,
62
+ type: this.type,
63
+ };
64
+ }
65
+ }
@@ -37,7 +37,7 @@ export class ListRequests {
37
37
  public static members(id: string, count?: number, cursor?: string): AxiosRequestConfig {
38
38
  return {
39
39
  method: 'get',
40
- url: 'https://x.com/i/api/graphql/dsJhIe3M0vCopjSfU6SlQw/ListMembers',
40
+ url: 'https://x.com/i/api/graphql/T7VZsrWpCoi4jWxFdwyNcg/ListMembers',
41
41
  params: {
42
42
  /* eslint-disable @typescript-eslint/naming-convention */
43
43
  variables: JSON.stringify({
@@ -46,14 +46,20 @@ export class ListRequests {
46
46
  cursor: cursor,
47
47
  }),
48
48
  features: JSON.stringify({
49
+ rweb_video_screen_enabled: false,
50
+ profile_label_improvements_pcf_label_in_post_enabled: true,
49
51
  rweb_tipjar_consumption_enabled: true,
50
- responsive_web_graphql_exclude_directive_enabled: true,
51
52
  verified_phone_label_enabled: true,
52
53
  creator_subscriptions_tweet_preview_api_enabled: true,
53
54
  responsive_web_graphql_timeline_navigation_enabled: true,
54
55
  responsive_web_graphql_skip_user_profile_image_extensions_enabled: false,
56
+ premium_content_api_read_enabled: false,
55
57
  communities_web_enable_tweet_community_results_fetch: true,
56
58
  c9s_tweet_anatomy_moderator_badge_enabled: true,
59
+ responsive_web_grok_analyze_button_fetch_trends_enabled: false,
60
+ responsive_web_grok_analyze_post_followups_enabled: true,
61
+ responsive_web_jetfuel_frame: false,
62
+ responsive_web_grok_share_attachment_enabled: true,
57
63
  articles_preview_enabled: true,
58
64
  responsive_web_edit_tweet_api_enabled: true,
59
65
  graphql_is_translatable_rweb_tweet_is_translatable_enabled: true,
@@ -61,13 +67,15 @@ export class ListRequests {
61
67
  longform_notetweets_consumption_enabled: true,
62
68
  responsive_web_twitter_article_tweet_consumption_enabled: true,
63
69
  tweet_awards_web_tipping_enabled: false,
70
+ responsive_web_grok_show_grok_translated_post: false,
71
+ responsive_web_grok_analysis_button_from_backend: true,
64
72
  creator_subscriptions_quote_tweet_preview_enabled: false,
65
73
  freedom_of_speech_not_reach_fetch_enabled: true,
66
74
  standardized_nudges_misinfo: true,
67
75
  tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled: true,
68
- rweb_video_timestamps_enabled: true,
69
76
  longform_notetweets_rich_text_read_enabled: true,
70
77
  longform_notetweets_inline_media_enabled: true,
78
+ responsive_web_grok_image_annotation_enabled: true,
71
79
  responsive_web_enhance_cards_enabled: false,
72
80
  }),
73
81
  /* eslint-enable @typescript-eslint/naming-convention */
@@ -83,7 +91,7 @@ export class ListRequests {
83
91
  public static tweets(id: string, count?: number, cursor?: string): AxiosRequestConfig {
84
92
  return {
85
93
  method: 'get',
86
- url: 'https://x.com/i/api/graphql/naCjgapXCSCsbZ7qnnItQA/ListLatestTweetsTimeline',
94
+ url: 'https://x.com/i/api/graphql/BkauSnPUDQTeeJsxq17opA/ListLatestTweetsTimeline',
87
95
  params: {
88
96
  /* eslint-disable @typescript-eslint/naming-convention */
89
97
  variables: JSON.stringify({
@@ -92,25 +100,36 @@ export class ListRequests {
92
100
  cursor: cursor,
93
101
  }),
94
102
  features: JSON.stringify({
95
- rweb_lists_timeline_redesign_enabled: true,
96
- responsive_web_graphql_exclude_directive_enabled: true,
103
+ rweb_video_screen_enabled: false,
104
+ profile_label_improvements_pcf_label_in_post_enabled: true,
105
+ rweb_tipjar_consumption_enabled: true,
97
106
  verified_phone_label_enabled: true,
98
107
  creator_subscriptions_tweet_preview_api_enabled: true,
99
108
  responsive_web_graphql_timeline_navigation_enabled: true,
100
109
  responsive_web_graphql_skip_user_profile_image_extensions_enabled: false,
101
- tweetypie_unmention_optimization_enabled: true,
110
+ premium_content_api_read_enabled: false,
111
+ communities_web_enable_tweet_community_results_fetch: true,
112
+ c9s_tweet_anatomy_moderator_badge_enabled: true,
113
+ responsive_web_grok_analyze_button_fetch_trends_enabled: false,
114
+ responsive_web_grok_analyze_post_followups_enabled: true,
115
+ responsive_web_jetfuel_frame: false,
116
+ responsive_web_grok_share_attachment_enabled: true,
117
+ articles_preview_enabled: true,
102
118
  responsive_web_edit_tweet_api_enabled: true,
103
119
  graphql_is_translatable_rweb_tweet_is_translatable_enabled: true,
104
120
  view_counts_everywhere_api_enabled: true,
105
121
  longform_notetweets_consumption_enabled: true,
106
- responsive_web_twitter_article_tweet_consumption_enabled: false,
122
+ responsive_web_twitter_article_tweet_consumption_enabled: true,
107
123
  tweet_awards_web_tipping_enabled: false,
124
+ responsive_web_grok_show_grok_translated_post: false,
125
+ responsive_web_grok_analysis_button_from_backend: true,
126
+ creator_subscriptions_quote_tweet_preview_enabled: false,
108
127
  freedom_of_speech_not_reach_fetch_enabled: true,
109
128
  standardized_nudges_misinfo: true,
110
129
  tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled: true,
111
130
  longform_notetweets_rich_text_read_enabled: true,
112
131
  longform_notetweets_inline_media_enabled: true,
113
- responsive_web_media_download_video_enabled: false,
132
+ responsive_web_grok_image_annotation_enabled: true,
114
133
  responsive_web_enhance_cards_enabled: false,
115
134
  }),
116
135
  /* eslint-enable @typescript-eslint/naming-convention */