rettiwt-api 5.0.0-alpha.2 → 5.0.0-alpha.4
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.
- package/dist/collections/Extractors.d.ts +6 -2
- package/dist/collections/Extractors.js +1 -0
- package/dist/collections/Extractors.js.map +1 -1
- package/dist/collections/Groups.js +1 -0
- package/dist/collections/Groups.js.map +1 -1
- package/dist/collections/Requests.js +1 -0
- package/dist/collections/Requests.js.map +1 -1
- package/dist/commands/User.js +15 -0
- package/dist/commands/User.js.map +1 -1
- package/dist/enums/Api.d.ts +1 -51
- package/dist/enums/Api.js +1 -52
- package/dist/enums/Api.js.map +1 -1
- package/dist/enums/Resource.d.ts +1 -0
- package/dist/enums/Resource.js +1 -0
- package/dist/enums/Resource.js.map +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.js +2 -5
- package/dist/index.js.map +1 -1
- package/dist/models/data/List.d.ts +4 -0
- package/dist/models/data/List.js +7 -0
- package/dist/models/data/List.js.map +1 -1
- package/dist/models/data/Notification.d.ts +4 -0
- package/dist/models/data/Notification.js +7 -0
- package/dist/models/data/Notification.js.map +1 -1
- package/dist/models/data/Tweet.d.ts +4 -0
- package/dist/models/data/Tweet.js +7 -0
- package/dist/models/data/Tweet.js.map +1 -1
- package/dist/models/data/User.d.ts +4 -0
- package/dist/models/data/User.js +7 -0
- package/dist/models/data/User.js.map +1 -1
- package/dist/models/errors/TwitterError.d.ts +37 -0
- package/dist/models/errors/TwitterError.js +60 -0
- package/dist/models/errors/TwitterError.js.map +1 -0
- package/dist/requests/List.js +28 -9
- package/dist/requests/List.js.map +1 -1
- package/dist/requests/Tweet.js +111 -34
- package/dist/requests/Tweet.js.map +1 -1
- package/dist/requests/User.js +231 -111
- package/dist/requests/User.js.map +1 -1
- package/dist/services/internal/AuthService.d.ts +5 -5
- package/dist/services/internal/AuthService.js +6 -7
- package/dist/services/internal/AuthService.js.map +1 -1
- package/dist/services/internal/ErrorService.d.ts +5 -76
- package/dist/services/internal/ErrorService.js +13 -116
- package/dist/services/internal/ErrorService.js.map +1 -1
- package/dist/services/internal/TidService.d.ts +4 -4
- package/dist/services/internal/TidService.js +8 -9
- package/dist/services/internal/TidService.js.map +1 -1
- package/dist/services/public/FetcherService.js +2 -2
- package/dist/services/public/FetcherService.js.map +1 -1
- package/dist/services/public/TweetService.js.map +1 -1
- package/dist/services/public/UserService.d.ts +29 -2
- package/dist/services/public/UserService.js +46 -4
- package/dist/services/public/UserService.js.map +1 -1
- package/dist/types/errors/TwitterError.d.ts +30 -0
- package/dist/types/{raw/generic/Error.js → errors/TwitterError.js} +1 -1
- package/dist/types/errors/TwitterError.js.map +1 -0
- package/dist/types/raw/base/Error.d.ts +32 -0
- package/dist/types/raw/base/Error.js +4 -0
- package/dist/types/raw/base/Error.js.map +1 -0
- package/dist/types/raw/generic/Response.d.ts +0 -2
- package/dist/types/raw/tweet/DetailsBulk.d.ts +288 -0
- package/dist/types/raw/tweet/DetailsBulk.js +4 -0
- package/dist/types/raw/tweet/DetailsBulk.js.map +1 -0
- package/dist/types/raw/user/DetailsBulk.d.ts +91 -0
- package/dist/types/raw/user/DetailsBulk.js +4 -0
- package/dist/types/raw/user/DetailsBulk.js.map +1 -0
- package/package.json +1 -1
- package/src/collections/Extractors.ts +8 -2
- package/src/collections/Groups.ts +1 -0
- package/src/collections/Requests.ts +1 -0
- package/src/commands/User.ts +15 -0
- package/src/enums/Api.ts +0 -51
- package/src/enums/Resource.ts +1 -0
- package/src/index.ts +5 -6
- package/src/models/data/List.ts +9 -0
- package/src/models/data/Notification.ts +10 -0
- package/src/models/data/Tweet.ts +9 -0
- package/src/models/data/User.ts +9 -0
- package/src/models/errors/TwitterError.ts +65 -0
- package/src/requests/List.ts +28 -9
- package/src/requests/Tweet.ts +111 -34
- package/src/requests/User.ts +231 -111
- package/src/services/internal/AuthService.ts +7 -8
- package/src/services/internal/ErrorService.ts +14 -132
- package/src/services/internal/TidService.ts +9 -10
- package/src/services/public/FetcherService.ts +2 -2
- package/src/services/public/TweetService.ts +3 -2
- package/src/services/public/UserService.ts +59 -8
- package/src/types/errors/TwitterError.ts +37 -0
- package/src/types/raw/base/Error.ts +37 -0
- package/src/types/raw/generic/Response.ts +0 -3
- package/src/types/raw/tweet/DetailsBulk.ts +338 -0
- package/src/types/raw/user/DetailsBulk.ts +104 -0
- package/dist/enums/Http.d.ts +0 -68
- package/dist/enums/Http.js +0 -73
- package/dist/enums/Http.js.map +0 -1
- package/dist/models/errors/ApiError.d.ts +0 -15
- package/dist/models/errors/ApiError.js +0 -23
- package/dist/models/errors/ApiError.js.map +0 -1
- package/dist/models/errors/HttpError.d.ts +0 -15
- package/dist/models/errors/HttpError.js +0 -23
- package/dist/models/errors/HttpError.js.map +0 -1
- package/dist/models/errors/RettiwtError.d.ts +0 -9
- package/dist/models/errors/RettiwtError.js +0 -17
- package/dist/models/errors/RettiwtError.js.map +0 -1
- package/dist/models/errors/TimeoutError.d.ts +0 -12
- package/dist/models/errors/TimeoutError.js +0 -19
- package/dist/models/errors/TimeoutError.js.map +0 -1
- package/dist/types/raw/generic/Error.d.ts +0 -30
- package/dist/types/raw/generic/Error.js.map +0 -1
- package/src/enums/Http.ts +0 -68
- package/src/models/errors/ApiError.ts +0 -21
- package/src/models/errors/HttpError.ts +0 -21
- package/src/models/errors/RettiwtError.ts +0 -13
- package/src/models/errors/TimeoutError.ts +0 -15
- package/src/types/raw/generic/Error.ts +0 -35
package/src/commands/User.ts
CHANGED
|
@@ -13,6 +13,21 @@ function createUserCommand(rettiwt: Rettiwt): Command {
|
|
|
13
13
|
// Creating the 'user' command
|
|
14
14
|
const user = createCommand('user').description('Access resources releated to users');
|
|
15
15
|
|
|
16
|
+
// Affiliates
|
|
17
|
+
user.command('affiliates')
|
|
18
|
+
.description('Fetch the list of users who affiliated to the given user')
|
|
19
|
+
.argument('<id>', 'The id of the user')
|
|
20
|
+
.argument('[count]', 'The number of affiliates to fetch')
|
|
21
|
+
.argument('[cursor]', 'The cursor to the batch of affiliates to fetch')
|
|
22
|
+
.action(async (id: string, count?: string, cursor?: string) => {
|
|
23
|
+
try {
|
|
24
|
+
const users = await rettiwt.user.affiliates(id, count ? parseInt(count) : undefined, cursor);
|
|
25
|
+
output(users);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
output(error);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
16
31
|
user.command('bookmarks')
|
|
17
32
|
.description('Fetch your list of bookmarks')
|
|
18
33
|
.argument('[count]', 'The number of bookmarks to fetch')
|
package/src/enums/Api.ts
CHANGED
|
@@ -5,57 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export enum EApiErrors {
|
|
7
7
|
COULD_NOT_AUTHENTICATE = 'Failed to authenticate',
|
|
8
|
-
RESOURCE_NOT_FOUND = 'Requested resource not found',
|
|
9
|
-
MISSING_PARAMETER = 'Missing named parameter',
|
|
10
|
-
USER_NOT_FOUND = 'Requested user not found',
|
|
11
|
-
USER_SUSPENDED = 'Requested user has been suspended',
|
|
12
|
-
ACCOUNT_SUSPENDED = 'Account has been suspended',
|
|
13
|
-
RATE_LIMIT_EXCEEDED = 'Rate limit exceeded',
|
|
14
|
-
INTERNAL_ERROR = 'Internal server error',
|
|
15
|
-
TIME_ERROR = 'Mismatched data/time with server',
|
|
16
|
-
ALREADY_FAVORITED = 'Tweet already favorited',
|
|
17
|
-
STATUS_NOT_FOUND = 'Requested tweeet not found',
|
|
18
|
-
NOT_AUTHORIZED = 'Not authorized to view tweet',
|
|
19
|
-
DAILY_STATUS_LIMIT_EXCEEDED = 'Exceeded daily tweet update limit',
|
|
20
|
-
TWEET_LENGTH_EXCEEDED = 'Exceeded tweet text maximum length',
|
|
21
|
-
DUPLICATE_STATUS = 'Tweet already posted',
|
|
22
8
|
BAD_AUTHENTICATION = 'Invalid authentication data',
|
|
23
9
|
RESOURCE_NOT_ALLOWED = 'Not authorized to access requested resource',
|
|
24
|
-
AUTOMATED_REQUEST_ERROR = 'Automated request detected',
|
|
25
|
-
ACCOUNT_LOCKED = 'Account has been locked',
|
|
26
|
-
ALREADY_RETWEETED = 'Tweet already retweeted',
|
|
27
|
-
TWEET_NOT_FOUND = 'Requested tweet not found',
|
|
28
|
-
TWEET_VIOLATED_RULES = 'Requestd tweet has been removed for rules violation',
|
|
29
|
-
DISABLED_TWEET_ACTIONS = 'Reqeusted action disabled on the tweet',
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The different error codes.
|
|
34
|
-
*
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
export enum EErrorCodes {
|
|
38
|
-
COULD_NOT_AUTHENTICATE = 32,
|
|
39
|
-
RESOURCE_NOT_FOUND = 34,
|
|
40
|
-
MISSING_PARAMETER = 38,
|
|
41
|
-
USER_NOT_FOUND = 50,
|
|
42
|
-
USER_SUSPENDED = 63,
|
|
43
|
-
ACCOUNT_SUSPENDED = 64,
|
|
44
|
-
RATE_LIMIT_EXCEEDED = 88,
|
|
45
|
-
INTERNAL_ERROR = 131,
|
|
46
|
-
TIME_ERROR = 135,
|
|
47
|
-
ALREADY_FAVORITED = 139,
|
|
48
|
-
STATUS_NOT_FOUND = 144,
|
|
49
|
-
NOT_AUTHORIZED = 179,
|
|
50
|
-
DAILY_STATUS_LIMIT_EXCEEDED = 185,
|
|
51
|
-
TWEET_LENGTH_EXCEEDED = 186,
|
|
52
|
-
DUPLICATE_STATUS = 187,
|
|
53
|
-
BAD_AUTHENTICATION = 215,
|
|
54
|
-
RESOURCE_NOT_ALLOWED = 220,
|
|
55
|
-
AUTOMATED_REQUEST_ERROR = 226,
|
|
56
|
-
ACCOUNT_LOCKED = 326,
|
|
57
|
-
ALREADY_RETWEETED = 327,
|
|
58
|
-
TWEET_NOT_FOUND = 421,
|
|
59
|
-
TWEET_VIOLATED_RULES = 422,
|
|
60
|
-
DISABLED_TWEET_ACTIONS = 425,
|
|
61
10
|
}
|
package/src/enums/Resource.ts
CHANGED
|
@@ -31,6 +31,7 @@ export enum EResourceType {
|
|
|
31
31
|
TWEET_UNSCHEDULE = 'TWEET_UNSCHEDULE',
|
|
32
32
|
|
|
33
33
|
// USER
|
|
34
|
+
USER_AFFILIATES = 'USER_AFFILIATES',
|
|
34
35
|
USER_BOOKMARKS = 'USER_BOOKMARKS',
|
|
35
36
|
USER_DETAILS_BY_USERNAME = 'USER_DETAILS_BY_USERNAME',
|
|
36
37
|
USER_DETAILS_BY_ID = 'USER_DETAILS_BY_ID',
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,6 @@ 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';
|
|
@@ -23,10 +22,7 @@ export * from './models/data/List';
|
|
|
23
22
|
export * from './models/data/Notification';
|
|
24
23
|
export * from './models/data/Tweet';
|
|
25
24
|
export * from './models/data/User';
|
|
26
|
-
export * from './models/errors/
|
|
27
|
-
export * from './models/errors/HttpError';
|
|
28
|
-
export * from './models/errors/RettiwtError';
|
|
29
|
-
export * from './models/errors/TimeoutError';
|
|
25
|
+
export * from './models/errors/TwitterError';
|
|
30
26
|
|
|
31
27
|
// REQUESTS
|
|
32
28
|
export * from './requests/List';
|
|
@@ -49,9 +45,11 @@ export * from './types/data/List';
|
|
|
49
45
|
export * from './types/data/Notification';
|
|
50
46
|
export * from './types/data/Tweet';
|
|
51
47
|
export * from './types/data/User';
|
|
48
|
+
export * from './types/errors/TwitterError';
|
|
52
49
|
export * from './types/params/Variables';
|
|
53
50
|
export { IAnalytics as IRawAnalytics } from './types/raw/base/Analytic';
|
|
54
51
|
export { ICursor as IRawCursor } from './types/raw/base/Cursor';
|
|
52
|
+
export { IErrorData as IRawErrorData, IErrorDetails as IRawErrorDetails } from './types/raw/base/Error';
|
|
55
53
|
export { ILimitedVisibilityTweet as IRawLimitedVisibilityTweet } from './types/raw/base/LimitedVisibilityTweet';
|
|
56
54
|
export { IList as IRawList } from './types/raw/base/List';
|
|
57
55
|
export { IMedia as IRawMedia } from './types/raw/base/Media';
|
|
@@ -62,7 +60,6 @@ export { IUser as IRawUser } from './types/raw/base/User';
|
|
|
62
60
|
export { IDataResult as IRawDataResult } from './types/raw/composite/DataResult';
|
|
63
61
|
export { ITimelineTweet as IRawTimelineTweet } from './types/raw/composite/TimelineTweet';
|
|
64
62
|
export { ITimelineUser as IRawTimelineUser } from './types/raw/composite/TimelineUser';
|
|
65
|
-
export { IError as IRawError } from './types/raw/generic/Error';
|
|
66
63
|
export { IResponse as IRawResponse } from './types/raw/generic/Response';
|
|
67
64
|
export { IListDetailsResponse as IRawListDetailsResponse } from './types/raw/list/Details';
|
|
68
65
|
export { IListMembersResponse as IRawListMembersResponse } from './types/raw/list/Members';
|
|
@@ -71,6 +68,7 @@ export { IMediaFinalizeUploadResponse as IRawMediaFinalizeUploadResponse } from
|
|
|
71
68
|
export { IMediaInitializeUploadResponse as IRawMediaInitializeUploadResponse } from './types/raw/media/InitalizeUpload';
|
|
72
69
|
export { IMediaLiveVideoStreamResponse as IRawMediaLiveVideoStreamResponse } from './types/raw/media/LiveVideoStream';
|
|
73
70
|
export { ITweetDetailsResponse as IRawTweetDetailsResponse } from './types/raw/tweet/Details';
|
|
71
|
+
export { ITweetDetailsBulkResponse as IRawTweetDetailsBulkResponse } from './types/raw/tweet/DetailsBulk';
|
|
74
72
|
export { ITweetLikeResponse as IRawTweetLikeResponse } from './types/raw/tweet/Like';
|
|
75
73
|
export { ITweetLikersResponse as IRawTweetLikersResponse } from './types/raw/tweet/Likers';
|
|
76
74
|
export { ITweetPostResponse as IRawTweetPostResponse } from './types/raw/tweet/Post';
|
|
@@ -87,6 +85,7 @@ export { IUserAffiliatesResponse as IRawUserAffiliatesResponse } from './types/r
|
|
|
87
85
|
export { IUserAnalyticsResponse as IRawUserAnalyticsResponse } from './types/raw/user/Analytics';
|
|
88
86
|
export { IUserBookmarksResponse as IRawUserBookmarksResponse } from './types/raw/user/Bookmarks';
|
|
89
87
|
export { IUserDetailsResponse as IRawUserDetailsResponse } from './types/raw/user/Details';
|
|
88
|
+
export { IUserDetailsBulkResponse as IRawUserDetailsBulkResponse } from './types/raw/user/DetailsBulk';
|
|
90
89
|
export { IUserFollowResponse as IRawUserFollowResponse } from './types/raw/user/Follow';
|
|
91
90
|
export { IUserFollowedResponse as IRawUserFollowedResponse } from './types/raw/user/Followed';
|
|
92
91
|
export { IUserFollowersResponse as IRawUserFollowersResponse } from './types/raw/user/Followers';
|
package/src/models/data/List.ts
CHANGED
|
@@ -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
|
+
/** Get 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
|
+
/** Get 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
|
*
|
package/src/models/data/Tweet.ts
CHANGED
|
@@ -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
|
+
/** Get 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
|
*
|
package/src/models/data/User.ts
CHANGED
|
@@ -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
|
+
/** Get 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
|
+
}
|
package/src/requests/List.ts
CHANGED
|
@@ -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/
|
|
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/
|
|
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
|
-
|
|
96
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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 */
|