rettiwt-api 5.0.0-alpha.0 → 5.0.0-alpha.2
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/.eslintrc.js +2 -3
- package/.github/workflows/documentation.yml +1 -1
- package/.github/workflows/publish-alpha.yml +1 -1
- package/.github/workflows/publish.yml +1 -1
- package/.prettierignore +1 -1
- package/.tool-versions +1 -1
- package/README.md +100 -100
- package/dist/Rettiwt.d.ts +10 -3
- package/dist/Rettiwt.js +31 -12
- package/dist/Rettiwt.js.map +1 -1
- package/dist/cli.js +8 -11
- package/dist/cli.js.map +1 -1
- package/dist/collections/Extractors.d.ts +36 -2
- package/dist/collections/Extractors.js +41 -69
- package/dist/collections/Extractors.js.map +1 -1
- package/dist/collections/Groups.js +5 -1
- package/dist/collections/Groups.js.map +1 -1
- package/dist/collections/Requests.d.ts +3 -3
- package/dist/collections/Requests.js +41 -40
- package/dist/collections/Requests.js.map +1 -1
- package/dist/commands/List.js +21 -78
- package/dist/commands/List.js.map +1 -1
- package/dist/commands/Tweet.js +214 -373
- package/dist/commands/Tweet.js.map +1 -1
- package/dist/commands/User.js +138 -305
- package/dist/commands/User.js.map +1 -1
- package/dist/enums/Authentication.d.ts +10 -0
- package/dist/enums/Authentication.js +15 -0
- package/dist/enums/Authentication.js.map +1 -0
- package/dist/enums/Data.d.ts +3 -3
- package/dist/enums/Data.js +3 -3
- package/dist/enums/Media.d.ts +10 -0
- package/dist/enums/Media.js +15 -0
- package/dist/enums/Media.js.map +1 -0
- package/dist/enums/Notification.d.ts +12 -0
- package/dist/enums/Notification.js +17 -0
- package/dist/enums/Notification.js.map +1 -0
- package/dist/enums/Resource.d.ts +4 -0
- package/dist/enums/Resource.js +4 -0
- package/dist/enums/Resource.js.map +1 -1
- package/dist/enums/raw/Analytics.d.ts +28 -0
- package/dist/enums/raw/Analytics.js +34 -0
- package/dist/enums/raw/Analytics.js.map +1 -0
- package/dist/enums/raw/Media.d.ts +10 -0
- package/dist/enums/raw/Media.js +15 -0
- package/dist/enums/raw/Media.js.map +1 -0
- package/dist/enums/raw/Notification.d.ts +11 -0
- package/dist/enums/raw/Notification.js +16 -0
- package/dist/enums/raw/Notification.js.map +1 -0
- package/dist/enums/raw/Tweet.d.ts +9 -0
- package/dist/enums/raw/Tweet.js +14 -0
- package/dist/enums/raw/Tweet.js.map +1 -0
- package/dist/helper/CliUtils.js +1 -2
- package/dist/helper/CliUtils.js.map +1 -1
- package/dist/helper/JsonUtils.js +6 -11
- package/dist/helper/JsonUtils.js.map +1 -1
- package/dist/helper/TidUtils.d.ts +2 -0
- package/dist/helper/TidUtils.js +162 -0
- package/dist/helper/TidUtils.js.map +1 -0
- package/dist/index.d.ts +75 -5
- package/dist/index.js +26 -6
- package/dist/index.js.map +1 -1
- package/dist/models/RettiwtConfig.d.ts +28 -0
- package/dist/models/RettiwtConfig.js +55 -0
- package/dist/models/RettiwtConfig.js.map +1 -0
- package/dist/models/args/FetchArgs.d.ts +16 -102
- package/dist/models/args/FetchArgs.js +105 -407
- package/dist/models/args/FetchArgs.js.map +1 -1
- package/dist/models/args/PostArgs.d.ts +16 -73
- package/dist/models/args/PostArgs.js +43 -236
- package/dist/models/args/PostArgs.js.map +1 -1
- package/dist/models/auth/AuthCookie.d.ts +21 -0
- package/dist/models/auth/AuthCookie.js +55 -0
- package/dist/models/auth/AuthCookie.js.map +1 -0
- package/dist/models/auth/AuthCredential.d.ts +30 -0
- package/dist/models/auth/AuthCredential.js +78 -0
- package/dist/models/auth/AuthCredential.js.map +1 -0
- package/dist/models/data/CursoredData.d.ts +5 -15
- package/dist/models/data/CursoredData.js +25 -32
- package/dist/models/data/CursoredData.js.map +1 -1
- package/dist/models/data/List.d.ts +7 -9
- package/dist/models/data/List.js +24 -4
- package/dist/models/data/List.js.map +1 -1
- package/dist/models/data/Notification.d.ts +10 -24
- package/dist/models/data/Notification.js +38 -36
- package/dist/models/data/Notification.js.map +1 -1
- package/dist/models/data/Tweet.d.ts +34 -31
- package/dist/models/data/Tweet.js +186 -112
- package/dist/models/data/Tweet.js.map +1 -1
- package/dist/models/data/User.d.ts +19 -23
- package/dist/models/data/User.js +92 -32
- package/dist/models/data/User.js.map +1 -1
- package/dist/models/errors/ApiError.js +8 -24
- package/dist/models/errors/ApiError.js.map +1 -1
- package/dist/models/errors/HttpError.js +8 -24
- package/dist/models/errors/HttpError.js.map +1 -1
- package/dist/models/errors/RettiwtError.d.ts +3 -2
- package/dist/models/errors/RettiwtError.js +8 -25
- package/dist/models/errors/RettiwtError.js.map +1 -1
- package/dist/models/errors/TimeoutError.js +5 -22
- package/dist/models/errors/TimeoutError.js.map +1 -1
- package/dist/models/params/Variables.d.ts +41 -0
- package/dist/models/params/Variables.js +61 -0
- package/dist/models/params/Variables.js.map +1 -0
- package/dist/requests/List.d.ts +24 -0
- package/dist/requests/List.js +122 -0
- package/dist/requests/List.js.map +1 -0
- package/dist/requests/Media.d.ts +21 -0
- package/dist/requests/Media.js +70 -0
- package/dist/requests/Media.js.map +1 -0
- package/dist/requests/Tweet.d.ts +75 -0
- package/dist/requests/Tweet.js +480 -0
- package/dist/requests/Tweet.js.map +1 -0
- package/dist/requests/User.d.ts +111 -0
- package/dist/requests/User.js +762 -0
- package/dist/requests/User.js.map +1 -0
- package/dist/services/internal/AuthService.d.ts +60 -0
- package/dist/services/internal/AuthService.js +106 -0
- package/dist/services/internal/AuthService.js.map +1 -0
- package/dist/services/internal/ErrorService.js +38 -40
- package/dist/services/internal/ErrorService.js.map +1 -1
- package/dist/services/internal/LogService.d.ts +0 -6
- package/dist/services/internal/LogService.js +12 -32
- package/dist/services/internal/LogService.js.map +1 -1
- package/dist/services/internal/TidService.d.ts +44 -0
- package/dist/services/internal/TidService.js +162 -0
- package/dist/services/internal/TidService.js.map +1 -0
- package/dist/services/public/FetcherService.d.ts +22 -19
- package/dist/services/public/FetcherService.js +126 -153
- package/dist/services/public/FetcherService.js.map +1 -1
- package/dist/services/public/ListService.d.ts +2 -2
- package/dist/services/public/ListService.js +31 -100
- package/dist/services/public/ListService.js.map +1 -1
- package/dist/services/public/TweetService.d.ts +63 -10
- package/dist/services/public/TweetService.js +255 -387
- package/dist/services/public/TweetService.js.map +1 -1
- package/dist/services/public/UserService.d.ts +4 -4
- package/dist/services/public/UserService.js +199 -386
- package/dist/services/public/UserService.js.map +1 -1
- package/dist/types/RettiwtConfig.d.ts +17 -10
- package/dist/types/args/FetchArgs.d.ts +123 -0
- package/dist/types/{ReturnTypes.js → args/FetchArgs.js} +1 -1
- package/dist/types/args/FetchArgs.js.map +1 -0
- package/dist/types/args/PostArgs.d.ts +100 -0
- package/dist/types/args/PostArgs.js +3 -0
- package/dist/types/args/PostArgs.js.map +1 -0
- package/dist/types/auth/AuthCookie.d.ts +15 -0
- package/dist/types/auth/AuthCookie.js +3 -0
- package/dist/types/auth/AuthCookie.js.map +1 -0
- package/dist/types/auth/AuthCredential.d.ts +23 -0
- package/dist/types/auth/AuthCredential.js +3 -0
- package/dist/types/auth/AuthCredential.js.map +1 -0
- package/dist/types/auth/TidDynamicArgs.d.ts +10 -0
- package/dist/types/auth/TidDynamicArgs.js +3 -0
- package/dist/types/auth/TidDynamicArgs.js.map +1 -0
- package/dist/types/auth/TidHeader.d.ts +8 -0
- package/dist/types/auth/TidHeader.js +3 -0
- package/dist/types/auth/TidHeader.js.map +1 -0
- package/dist/types/auth/TidParams.d.ts +27 -0
- package/dist/types/auth/TidParams.js +3 -0
- package/dist/types/auth/TidParams.js.map +1 -0
- package/dist/types/auth/TidProvider.d.ts +18 -0
- package/dist/types/auth/TidProvider.js +3 -0
- package/dist/types/auth/TidProvider.js.map +1 -0
- package/dist/types/data/CursoredData.d.ts +16 -0
- package/dist/types/data/CursoredData.js +3 -0
- package/dist/types/data/CursoredData.js.map +1 -0
- package/dist/types/data/List.d.ts +21 -0
- package/dist/types/data/List.js +3 -0
- package/dist/types/data/List.js.map +1 -0
- package/dist/types/data/Notification.d.ts +20 -0
- package/dist/types/data/Notification.js +3 -0
- package/dist/types/data/Notification.js.map +1 -0
- package/dist/types/data/Tweet.d.ts +71 -0
- package/dist/types/data/Tweet.js +3 -0
- package/dist/types/data/Tweet.js.map +1 -0
- package/dist/types/data/User.d.ts +35 -0
- package/dist/types/data/User.js +3 -0
- package/dist/types/data/User.js.map +1 -0
- package/dist/types/params/Variables.d.ts +27 -0
- package/dist/types/params/Variables.js +3 -0
- package/dist/types/params/Variables.js.map +1 -0
- package/dist/types/raw/base/Analytic.d.ts +21 -0
- package/dist/types/raw/base/Analytic.js +4 -0
- package/dist/types/raw/base/Analytic.js.map +1 -0
- package/dist/types/raw/base/Cursor.d.ts +11 -0
- package/dist/types/raw/base/Cursor.js +4 -0
- package/dist/types/raw/base/Cursor.js.map +1 -0
- package/dist/types/raw/base/LimitedVisibilityTweet.d.ts +32 -0
- package/dist/types/raw/base/LimitedVisibilityTweet.js +4 -0
- package/dist/types/raw/base/LimitedVisibilityTweet.js.map +1 -0
- package/dist/types/raw/base/List.d.ts +43 -0
- package/dist/types/raw/base/List.js +4 -0
- package/dist/types/raw/base/List.js.map +1 -0
- package/dist/types/raw/base/Media.d.ts +43 -0
- package/dist/types/raw/base/Media.js +4 -0
- package/dist/types/raw/base/Media.js.map +1 -0
- package/dist/types/raw/base/Notification.d.ts +53 -0
- package/dist/types/raw/base/Notification.js +4 -0
- package/dist/types/raw/base/Notification.js.map +1 -0
- package/dist/types/raw/base/Space.d.ts +32 -0
- package/dist/types/raw/base/Space.js +4 -0
- package/dist/types/raw/base/Space.js.map +1 -0
- package/dist/types/raw/base/Tweet.d.ts +119 -0
- package/dist/types/raw/base/Tweet.js +4 -0
- package/dist/types/raw/base/Tweet.js.map +1 -0
- package/dist/types/raw/base/User.d.ts +140 -0
- package/dist/types/raw/base/User.js +4 -0
- package/dist/types/raw/base/User.js.map +1 -0
- package/dist/types/raw/composite/DataResult.d.ts +8 -0
- package/dist/types/raw/composite/DataResult.js +3 -0
- package/dist/types/raw/composite/DataResult.js.map +1 -0
- package/dist/types/raw/composite/TimelineTweet.d.ts +11 -0
- package/dist/types/raw/composite/TimelineTweet.js +4 -0
- package/dist/types/raw/composite/TimelineTweet.js.map +1 -0
- package/dist/types/raw/composite/TimelineUser.d.ts +10 -0
- package/dist/types/raw/composite/TimelineUser.js +4 -0
- package/dist/types/raw/composite/TimelineUser.js.map +1 -0
- package/dist/types/raw/generic/Error.d.ts +30 -0
- package/dist/types/raw/generic/Error.js +3 -0
- package/dist/types/raw/generic/Error.js.map +1 -0
- package/dist/types/raw/generic/Response.d.ts +12 -0
- package/dist/types/raw/generic/Response.js +3 -0
- package/dist/types/raw/generic/Response.js.map +1 -0
- package/dist/types/raw/list/Details.d.ts +122 -0
- package/dist/types/raw/list/Details.js +4 -0
- package/dist/types/raw/list/Details.js.map +1 -0
- package/dist/types/raw/list/Members.d.ts +134 -0
- package/dist/types/raw/list/Members.js +4 -0
- package/dist/types/raw/list/Members.js.map +1 -0
- package/dist/types/raw/list/Tweets.d.ts +1968 -0
- package/dist/types/raw/list/Tweets.js +4 -0
- package/dist/types/raw/list/Tweets.js.map +1 -0
- package/dist/types/raw/media/FinalizeUpload.d.ts +18 -0
- package/dist/types/raw/media/FinalizeUpload.js +4 -0
- package/dist/types/raw/media/FinalizeUpload.js.map +1 -0
- package/dist/types/raw/media/InitalizeUpload.d.ts +10 -0
- package/dist/types/raw/media/InitalizeUpload.js +4 -0
- package/dist/types/raw/media/InitalizeUpload.js.map +1 -0
- package/dist/types/raw/media/LiveVideoStream.d.ts +19 -0
- package/dist/types/raw/media/LiveVideoStream.js +4 -0
- package/dist/types/raw/media/LiveVideoStream.js.map +1 -0
- package/dist/types/raw/space/Details.d.ts +315 -0
- package/dist/types/raw/space/Details.js +4 -0
- package/dist/types/raw/space/Details.js.map +1 -0
- package/dist/types/raw/tweet/Details.d.ts +183 -0
- package/dist/types/raw/tweet/Details.js +4 -0
- package/dist/types/raw/tweet/Details.js.map +1 -0
- package/dist/types/raw/tweet/Like.d.ts +12 -0
- package/dist/types/raw/tweet/Like.js +4 -0
- package/dist/types/raw/tweet/Like.js.map +1 -0
- package/dist/types/raw/tweet/Likers.d.ts +170 -0
- package/dist/types/raw/tweet/Likers.js +4 -0
- package/dist/types/raw/tweet/Likers.js.map +1 -0
- package/dist/types/raw/tweet/Post.d.ts +133 -0
- package/dist/types/raw/tweet/Post.js +4 -0
- package/dist/types/raw/tweet/Post.js.map +1 -0
- package/dist/types/raw/tweet/Replies.d.ts +465 -0
- package/dist/types/raw/tweet/Replies.js +4 -0
- package/dist/types/raw/tweet/Replies.js.map +1 -0
- package/dist/types/raw/tweet/Retweet.d.ts +25 -0
- package/dist/types/raw/tweet/Retweet.js +4 -0
- package/dist/types/raw/tweet/Retweet.js.map +1 -0
- package/dist/types/raw/tweet/Retweeters.d.ts +177 -0
- package/dist/types/raw/tweet/Retweeters.js +4 -0
- package/dist/types/raw/tweet/Retweeters.js.map +1 -0
- package/dist/types/raw/tweet/Schedule.d.ts +15 -0
- package/dist/types/raw/tweet/Schedule.js +4 -0
- package/dist/types/raw/tweet/Schedule.js.map +1 -0
- package/dist/types/raw/tweet/Search.d.ts +518 -0
- package/dist/types/raw/tweet/Search.js +4 -0
- package/dist/types/raw/tweet/Search.js.map +1 -0
- package/dist/types/raw/tweet/Unlike.d.ts +12 -0
- package/dist/types/raw/tweet/Unlike.js +4 -0
- package/dist/types/raw/tweet/Unlike.js.map +1 -0
- package/dist/types/raw/tweet/Unpost.d.ts +17 -0
- package/dist/types/raw/tweet/Unpost.js +4 -0
- package/dist/types/raw/tweet/Unpost.js.map +1 -0
- package/dist/types/raw/tweet/Unretweet.d.ts +25 -0
- package/dist/types/raw/tweet/Unretweet.js +4 -0
- package/dist/types/raw/tweet/Unretweet.js.map +1 -0
- package/dist/types/raw/tweet/Unschedule.d.ts +12 -0
- package/dist/types/raw/tweet/Unschedule.js +4 -0
- package/dist/types/raw/tweet/Unschedule.js.map +1 -0
- package/dist/types/raw/user/Affiliates.d.ts +154 -0
- package/dist/types/raw/user/Affiliates.js +4 -0
- package/dist/types/raw/user/Affiliates.js.map +1 -0
- package/dist/types/raw/user/Analytics.d.ts +32 -0
- package/dist/types/raw/user/Analytics.js +4 -0
- package/dist/types/raw/user/Analytics.js.map +1 -0
- package/dist/types/raw/user/Bookmarks.d.ts +550 -0
- package/dist/types/raw/user/Bookmarks.js +4 -0
- package/dist/types/raw/user/Bookmarks.js.map +1 -0
- package/dist/types/raw/user/Details.d.ts +157 -0
- package/dist/types/raw/user/Details.js +4 -0
- package/dist/types/raw/user/Details.js.map +1 -0
- package/dist/types/raw/user/Follow.d.ts +248 -0
- package/dist/types/raw/user/Follow.js +4 -0
- package/dist/types/raw/user/Follow.js.map +1 -0
- package/dist/types/raw/user/Followed.d.ts +1666 -0
- package/dist/types/raw/user/Followed.js +4 -0
- package/dist/types/raw/user/Followed.js.map +1 -0
- package/dist/types/raw/user/Followers.d.ts +182 -0
- package/dist/types/raw/user/Followers.js +4 -0
- package/dist/types/raw/user/Followers.js.map +1 -0
- package/dist/types/raw/user/Following.d.ts +182 -0
- package/dist/types/raw/user/Following.js +4 -0
- package/dist/types/raw/user/Following.js.map +1 -0
- package/dist/types/raw/user/Highlights.d.ts +1106 -0
- package/dist/types/raw/user/Highlights.js +4 -0
- package/dist/types/raw/user/Highlights.js.map +1 -0
- package/dist/types/raw/user/Likes.d.ts +1065 -0
- package/dist/types/raw/user/Likes.js +4 -0
- package/dist/types/raw/user/Likes.js.map +1 -0
- package/dist/types/raw/user/Media.d.ts +1492 -0
- package/dist/types/raw/user/Media.js +4 -0
- package/dist/types/raw/user/Media.js.map +1 -0
- package/dist/types/raw/user/Notifications.d.ts +142 -0
- package/dist/types/raw/user/Notifications.js +4 -0
- package/dist/types/raw/user/Notifications.js.map +1 -0
- package/dist/types/raw/user/Recommended.d.ts +1991 -0
- package/dist/types/raw/user/Recommended.js +4 -0
- package/dist/types/raw/user/Recommended.js.map +1 -0
- package/dist/types/raw/user/Scheduled.d.ts +31 -0
- package/dist/types/raw/user/Scheduled.js +4 -0
- package/dist/types/raw/user/Scheduled.js.map +1 -0
- package/dist/types/raw/user/Subscriptions.d.ts +151 -0
- package/dist/types/raw/user/Subscriptions.js +4 -0
- package/dist/types/raw/user/Subscriptions.js.map +1 -0
- package/dist/types/raw/user/Tweets.d.ts +1065 -0
- package/dist/types/raw/user/Tweets.js +4 -0
- package/dist/types/raw/user/Tweets.js.map +1 -0
- package/dist/types/raw/user/TweetsAndReplies.d.ts +1065 -0
- package/dist/types/raw/user/TweetsAndReplies.js +4 -0
- package/dist/types/raw/user/TweetsAndReplies.js.map +1 -0
- package/dist/types/raw/user/Unfollow.d.ts +248 -0
- package/dist/types/raw/user/Unfollow.js +4 -0
- package/dist/types/raw/user/Unfollow.js.map +1 -0
- package/eslint.config.mjs +17 -0
- package/package.json +22 -19
- package/src/Rettiwt.ts +22 -7
- package/src/cli.ts +0 -2
- package/src/collections/Extractors.ts +40 -34
- package/src/collections/Groups.ts +4 -0
- package/src/collections/Requests.ts +46 -44
- package/src/commands/Tweet.ts +35 -7
- package/src/commands/User.ts +13 -2
- package/src/enums/Authentication.ts +10 -0
- package/src/enums/Data.ts +3 -3
- package/src/enums/Media.ts +10 -0
- package/src/enums/Notification.ts +12 -0
- package/src/enums/Resource.ts +4 -0
- package/src/enums/raw/Analytics.ts +29 -0
- package/src/enums/raw/Media.ts +10 -0
- package/src/enums/raw/Notification.ts +11 -0
- package/src/enums/raw/Tweet.ts +9 -0
- package/src/helper/JsonUtils.ts +1 -1
- package/src/helper/TidUtils.ts +189 -0
- package/src/index.ts +78 -44
- package/src/models/RettiwtConfig.ts +64 -0
- package/src/models/args/FetchArgs.ts +86 -436
- package/src/models/args/PostArgs.ts +24 -249
- package/src/models/auth/AuthCookie.ts +58 -0
- package/src/models/auth/AuthCredential.ts +85 -0
- package/src/models/data/CursoredData.ts +21 -26
- package/src/models/data/List.ts +18 -15
- package/src/models/data/Notification.ts +25 -38
- package/src/models/data/Tweet.ts +143 -104
- package/src/models/data/User.ts +74 -44
- package/src/models/errors/RettiwtError.ts +3 -2
- package/src/models/params/Variables.ts +62 -0
- package/src/requests/List.ts +121 -0
- package/src/requests/Media.ts +67 -0
- package/src/requests/Tweet.ts +496 -0
- package/src/requests/User.ts +783 -0
- package/src/services/{public → internal}/AuthService.ts +28 -60
- package/src/services/internal/LogService.ts +4 -19
- package/src/services/internal/TidService.ts +147 -0
- package/src/services/public/FetcherService.ts +89 -59
- package/src/services/public/ListService.ts +4 -4
- package/src/services/public/TweetService.ts +129 -42
- package/src/services/public/UserService.ts +49 -37
- package/src/types/RettiwtConfig.ts +18 -12
- package/src/types/args/FetchArgs.ts +148 -0
- package/src/types/args/PostArgs.ts +112 -0
- package/src/types/auth/AuthCookie.ts +22 -0
- package/src/types/auth/AuthCredential.ts +28 -0
- package/src/types/auth/TidDynamicArgs.ts +10 -0
- package/src/types/auth/TidHeader.ts +12 -0
- package/src/types/auth/TidParams.ts +36 -0
- package/src/types/auth/TidProvider.ts +19 -0
- package/src/types/data/CursoredData.ts +18 -0
- package/src/types/data/List.ts +27 -0
- package/src/types/data/Notification.ts +26 -0
- package/src/types/data/Tweet.ts +96 -0
- package/src/types/data/User.ts +48 -0
- package/src/types/params/Variables.ts +41 -0
- package/src/types/raw/base/Analytic.ts +26 -0
- package/src/types/raw/base/Cursor.ts +13 -0
- package/src/types/raw/base/LimitedVisibilityTweet.ts +40 -0
- package/src/types/raw/base/List.ts +50 -0
- package/src/types/raw/base/Media.ts +53 -0
- package/src/types/raw/base/Notification.ts +67 -0
- package/src/types/raw/base/Space.ts +35 -0
- package/src/types/raw/base/Tweet.ts +139 -0
- package/src/types/raw/base/User.ts +164 -0
- package/src/types/raw/composite/DataResult.ts +8 -0
- package/src/types/raw/composite/TimelineTweet.ts +14 -0
- package/src/types/raw/composite/TimelineUser.ts +13 -0
- package/src/types/raw/generic/Error.ts +35 -0
- package/src/types/raw/generic/Response.ts +13 -0
- package/src/types/raw/list/Details.ts +137 -0
- package/src/types/raw/list/Members.ts +154 -0
- package/src/types/raw/list/Tweets.ts +2296 -0
- package/src/types/raw/media/FinalizeUpload.ts +20 -0
- package/src/types/raw/media/InitalizeUpload.ts +12 -0
- package/src/types/raw/media/LiveVideoStream.ts +21 -0
- package/src/types/raw/space/Details.ts +359 -0
- package/src/types/raw/tweet/Details.ts +210 -0
- package/src/types/raw/tweet/Like.ts +14 -0
- package/src/types/raw/tweet/Likers.ts +200 -0
- package/src/types/raw/tweet/Post.ts +150 -0
- package/src/types/raw/tweet/Replies.ts +539 -0
- package/src/types/raw/tweet/Retweet.ts +31 -0
- package/src/types/raw/tweet/Retweeters.ts +208 -0
- package/src/types/raw/tweet/Schedule.ts +18 -0
- package/src/types/raw/tweet/Search.ts +597 -0
- package/src/types/raw/tweet/Unlike.ts +14 -0
- package/src/types/raw/tweet/Unpost.ts +20 -0
- package/src/types/raw/tweet/Unretweet.ts +31 -0
- package/src/types/raw/tweet/Unschedule.ts +14 -0
- package/src/types/raw/user/Affiliates.ts +179 -0
- package/src/types/raw/user/Analytics.ts +39 -0
- package/src/types/raw/user/Bookmarks.ts +637 -0
- package/src/types/raw/user/Details.ts +185 -0
- package/src/types/raw/user/Follow.ts +280 -0
- package/src/types/raw/user/Followed.ts +1942 -0
- package/src/types/raw/user/Followers.ts +215 -0
- package/src/types/raw/user/Following.ts +215 -0
- package/src/types/raw/user/Highlights.ts +1287 -0
- package/src/types/raw/user/Likes.ts +1254 -0
- package/src/types/raw/user/Media.ts +1738 -0
- package/src/types/raw/user/Notifications.ts +175 -0
- package/src/types/raw/user/Recommended.ts +2319 -0
- package/src/types/raw/user/Scheduled.ts +37 -0
- package/src/types/raw/user/Subscriptions.ts +176 -0
- package/src/types/raw/user/Tweets.ts +1254 -0
- package/src/types/raw/user/TweetsAndReplies.ts +1254 -0
- package/src/types/raw/user/Unfollow.ts +280 -0
- package/tsconfig.json +7 -5
- package/.eslintignore +0 -3
- package/dist/commands/Auth.d.ts +0 -10
- package/dist/commands/Auth.js +0 -101
- package/dist/commands/Auth.js.map +0 -1
- package/dist/models/errors/DataValidationError.d.ts +0 -30
- package/dist/models/errors/DataValidationError.js +0 -34
- package/dist/models/errors/DataValidationError.js.map +0 -1
- package/dist/services/public/AuthService.d.ts +0 -91
- package/dist/services/public/AuthService.js +0 -205
- package/dist/services/public/AuthService.js.map +0 -1
- package/dist/types/ReturnTypes.d.ts +0 -21
- package/dist/types/ReturnTypes.js.map +0 -1
- package/src/commands/Auth.ts +0 -46
- package/src/models/errors/DataValidationError.ts +0 -44
- package/src/types/ReturnTypes.ts +0 -24
|
@@ -1,61 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
INotification,
|
|
4
|
-
IUserNotificationsResponse,
|
|
5
|
-
} from 'rettiwt-core';
|
|
6
|
-
|
|
1
|
+
import { ENotificationType } from '../../enums/Notification';
|
|
2
|
+
import { ERawNotificationType } from '../../enums/raw/Notification';
|
|
7
3
|
import { findKeyByValue } from '../../helper/JsonUtils';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export enum ENotificationType {
|
|
15
|
-
RECOMMENDATION = 'RECOMMENDATION',
|
|
16
|
-
INFORMATION = 'INFORMATION',
|
|
17
|
-
LIVE = 'LIVE',
|
|
18
|
-
ALERT = 'ALERT',
|
|
19
|
-
UNDEFINED = 'UNDEFINED',
|
|
20
|
-
}
|
|
4
|
+
import { INotification } from '../../types/data/Notification';
|
|
5
|
+
import { INotification as IRawNotification } from '../../types/raw/base/Notification';
|
|
6
|
+
import { IUserNotificationsResponse } from '../../types/raw/user/Notifications';
|
|
21
7
|
|
|
22
8
|
/**
|
|
23
9
|
* The details of a single notification.
|
|
24
10
|
*
|
|
25
11
|
* @public
|
|
26
12
|
*/
|
|
27
|
-
export class Notification {
|
|
28
|
-
/** The list of id of the users from whom the notification was received. */
|
|
13
|
+
export class Notification implements INotification {
|
|
29
14
|
public from: string[];
|
|
30
|
-
|
|
31
|
-
/** The id of the notification. */
|
|
32
15
|
public id: string;
|
|
33
|
-
|
|
34
|
-
/** The text contents of the notification. */
|
|
35
16
|
public message: string;
|
|
36
|
-
|
|
37
|
-
/** The date/time at which the notification was received. */
|
|
38
|
-
public receivedAt: Date;
|
|
39
|
-
|
|
40
|
-
/** The list of id of the target tweet(s) of the notification. */
|
|
17
|
+
public receivedAt: string;
|
|
41
18
|
public target: string[];
|
|
42
|
-
|
|
43
|
-
/** The type of notification. */
|
|
44
19
|
public type?: ENotificationType;
|
|
45
20
|
|
|
46
21
|
/**
|
|
47
22
|
* @param notification - The raw notification details.
|
|
48
23
|
*/
|
|
49
|
-
public constructor(notification:
|
|
24
|
+
public constructor(notification: IRawNotification) {
|
|
50
25
|
// Getting the original notification type
|
|
51
|
-
const notificationType: string | undefined = findKeyByValue(
|
|
26
|
+
const notificationType: string | undefined = findKeyByValue(ERawNotificationType, notification.icon.id);
|
|
52
27
|
|
|
53
28
|
this.from = notification.template?.aggregateUserActionsV1?.fromUsers
|
|
54
29
|
? notification.template.aggregateUserActionsV1.fromUsers.map((item) => item.user.id)
|
|
55
30
|
: [];
|
|
56
31
|
this.id = notification.id;
|
|
57
32
|
this.message = notification.message.text;
|
|
58
|
-
this.receivedAt = new Date(Number(notification.timestampMs));
|
|
33
|
+
this.receivedAt = new Date(Number(notification.timestampMs)).toISOString();
|
|
59
34
|
this.target = notification.template?.aggregateUserActionsV1?.targetObjects
|
|
60
35
|
? notification.template.aggregateUserActionsV1.targetObjects.map((item) => item.tweet.id)
|
|
61
36
|
: [];
|
|
@@ -70,8 +45,6 @@ export class Notification {
|
|
|
70
45
|
* @param response - The raw response data.
|
|
71
46
|
*
|
|
72
47
|
* @returns The deserialized list of notifications.
|
|
73
|
-
*
|
|
74
|
-
* @internal
|
|
75
48
|
*/
|
|
76
49
|
public static list(response: NonNullable<unknown>): Notification[] {
|
|
77
50
|
const notifications: Notification[] = [];
|
|
@@ -82,10 +55,24 @@ export class Notification {
|
|
|
82
55
|
for (const [, value] of Object.entries(
|
|
83
56
|
(response as IUserNotificationsResponse).globalObjects.notifications,
|
|
84
57
|
)) {
|
|
85
|
-
notifications.push(new Notification(value as
|
|
58
|
+
notifications.push(new Notification(value as IRawNotification));
|
|
86
59
|
}
|
|
87
60
|
}
|
|
88
61
|
|
|
89
62
|
return notifications;
|
|
90
63
|
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @returns A serializable JSON representation of `this` object.
|
|
67
|
+
*/
|
|
68
|
+
public toJSON(): INotification {
|
|
69
|
+
return {
|
|
70
|
+
from: this.from,
|
|
71
|
+
id: this.id,
|
|
72
|
+
message: this.message,
|
|
73
|
+
receivedAt: this.receivedAt,
|
|
74
|
+
target: this.target,
|
|
75
|
+
type: this.type,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
91
78
|
}
|
package/src/models/data/Tweet.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EMediaType,
|
|
3
|
-
ILimitedVisibilityTweet,
|
|
4
|
-
IExtendedMedia as IRawExtendedMedia,
|
|
5
|
-
ITweet as IRawTweet,
|
|
6
|
-
IEntities as IRawTweetEntities,
|
|
7
|
-
ITimelineTweet,
|
|
8
|
-
ITweet,
|
|
9
|
-
} from 'rettiwt-core';
|
|
10
|
-
|
|
11
1
|
import { ELogActions } from '../../enums/Logging';
|
|
2
|
+
import { EMediaType } from '../../enums/Media';
|
|
3
|
+
import { ERawMediaType } from '../../enums/raw/Media';
|
|
12
4
|
import { findByFilter } from '../../helper/JsonUtils';
|
|
13
5
|
|
|
14
6
|
import { LogService } from '../../services/internal/LogService';
|
|
15
7
|
|
|
8
|
+
import { ITweet, ITweetEntities, ITweetMedia } from '../../types/data/Tweet';
|
|
9
|
+
import { ILimitedVisibilityTweet } from '../../types/raw/base/LimitedVisibilityTweet';
|
|
10
|
+
import { IExtendedMedia as IRawExtendedMedia } from '../../types/raw/base/Media';
|
|
11
|
+
import { ITweet as IRawTweet, IEntities as IRawTweetEntities } from '../../types/raw/base/Tweet';
|
|
12
|
+
import { ITimelineTweet } from '../../types/raw/composite/TimelineTweet';
|
|
13
|
+
|
|
16
14
|
import { User } from './User';
|
|
17
15
|
|
|
18
16
|
/**
|
|
@@ -20,68 +18,39 @@ import { User } from './User';
|
|
|
20
18
|
*
|
|
21
19
|
* @public
|
|
22
20
|
*/
|
|
23
|
-
export class Tweet {
|
|
24
|
-
/** The number of bookmarks of a tweet. */
|
|
21
|
+
export class Tweet implements ITweet {
|
|
25
22
|
public bookmarkCount: number;
|
|
26
|
-
|
|
27
|
-
/** The date and time of creation of the tweet, in UTC string format. */
|
|
23
|
+
public conversationId: string;
|
|
28
24
|
public createdAt: string;
|
|
29
|
-
|
|
30
|
-
/** Additional tweet entities like urls, mentions, etc. */
|
|
31
25
|
public entities: TweetEntities;
|
|
32
|
-
|
|
33
|
-
/** The full text content of the tweet. */
|
|
34
26
|
public fullText: string;
|
|
35
|
-
|
|
36
|
-
/** The rest id of the tweet. */
|
|
37
27
|
public id: string;
|
|
38
|
-
|
|
39
|
-
/** The language in which the tweet is written. */
|
|
40
28
|
public lang: string;
|
|
41
|
-
|
|
42
|
-
/** The number of likes of the tweet. */
|
|
43
29
|
public likeCount: number;
|
|
44
|
-
|
|
45
|
-
/** The urls of the media contents of the tweet (if any). */
|
|
46
30
|
public media?: TweetMedia[];
|
|
47
|
-
|
|
48
|
-
/** The number of quotes of the tweet. */
|
|
49
31
|
public quoteCount: number;
|
|
50
|
-
|
|
51
|
-
/** The tweet which is quoted in the tweet. */
|
|
52
32
|
public quoted?: Tweet;
|
|
53
|
-
|
|
54
|
-
/** The number of replies to the tweet. */
|
|
55
33
|
public replyCount: number;
|
|
56
|
-
|
|
57
|
-
/** The rest id of the tweet to which the tweet is a reply. */
|
|
58
|
-
public replyTo?: Tweet;
|
|
59
|
-
|
|
60
|
-
/** The number of retweets of the tweet. */
|
|
34
|
+
public replyTo?: string;
|
|
61
35
|
public retweetCount: number;
|
|
62
|
-
|
|
63
|
-
/** The tweet which is retweeted in this tweet (if any). */
|
|
64
36
|
public retweetedTweet?: Tweet;
|
|
65
|
-
|
|
66
|
-
/** The details of the user who made the tweet. */
|
|
67
37
|
public tweetBy: User;
|
|
68
|
-
|
|
69
|
-
/** The number of views of a tweet. */
|
|
38
|
+
public url: string;
|
|
70
39
|
public viewCount: number;
|
|
71
40
|
|
|
72
41
|
/**
|
|
73
42
|
* @param tweet - The raw tweet details.
|
|
74
|
-
* @param response - The raw response
|
|
75
43
|
*/
|
|
76
|
-
public constructor(tweet: IRawTweet
|
|
44
|
+
public constructor(tweet: IRawTweet) {
|
|
77
45
|
this.id = tweet.rest_id;
|
|
78
|
-
this.
|
|
46
|
+
this.conversationId = tweet.legacy.conversation_id_str;
|
|
47
|
+
this.createdAt = new Date(tweet.legacy.created_at).toISOString();
|
|
79
48
|
this.tweetBy = new User(tweet.core.user_results.result);
|
|
80
49
|
this.entities = new TweetEntities(tweet.legacy.entities);
|
|
81
50
|
this.media = tweet.legacy.extended_entities?.media?.map((media) => new TweetMedia(media));
|
|
82
|
-
this.quoted = this.getQuotedTweet(tweet
|
|
51
|
+
this.quoted = this.getQuotedTweet(tweet);
|
|
83
52
|
this.fullText = tweet.note_tweet ? tweet.note_tweet.note_tweet_results.result.text : tweet.legacy.full_text;
|
|
84
|
-
this.replyTo =
|
|
53
|
+
this.replyTo = tweet.legacy.in_reply_to_status_id_str;
|
|
85
54
|
this.lang = tweet.legacy.lang;
|
|
86
55
|
this.quoteCount = tweet.legacy.quote_count;
|
|
87
56
|
this.replyCount = tweet.legacy.reply_count;
|
|
@@ -89,42 +58,29 @@ export class Tweet {
|
|
|
89
58
|
this.likeCount = tweet.legacy.favorite_count;
|
|
90
59
|
this.viewCount = tweet.views.count ? parseInt(tweet.views.count) : 0;
|
|
91
60
|
this.bookmarkCount = tweet.legacy.bookmark_count;
|
|
92
|
-
this.retweetedTweet = this.getRetweetedTweet(tweet
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
private getParentTweet(tweet: IRawTweet, response: NonNullable<unknown>): Tweet | undefined {
|
|
96
|
-
// Getting parent tweet ID, if any
|
|
97
|
-
const parentTweetId: string = tweet.legacy?.in_reply_to_status_id_str ?? '';
|
|
98
|
-
|
|
99
|
-
// If no parent tweet
|
|
100
|
-
if (parentTweetId.length == 0) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Getting the details of parent tweet
|
|
105
|
-
return Tweet.single(response, parentTweetId);
|
|
61
|
+
this.retweetedTweet = this.getRetweetedTweet(tweet);
|
|
62
|
+
this.url = `https://x.com/${this.tweetBy.userName}/status/${this.id}`;
|
|
106
63
|
}
|
|
107
64
|
|
|
108
65
|
/**
|
|
109
66
|
* Extract and deserialize the original quoted tweet from the given raw tweet.
|
|
110
67
|
*
|
|
111
68
|
* @param tweet - The raw tweet.
|
|
112
|
-
* @param response - The raw response
|
|
113
69
|
*
|
|
114
70
|
* @returns - The deserialized original quoted tweet.
|
|
115
71
|
*/
|
|
116
|
-
private getQuotedTweet(tweet: IRawTweet
|
|
72
|
+
private getQuotedTweet(tweet: IRawTweet): Tweet | undefined {
|
|
117
73
|
// If tweet with limited visibility
|
|
118
74
|
if (
|
|
119
75
|
tweet.quoted_status_result &&
|
|
120
76
|
tweet.quoted_status_result?.result?.__typename == 'TweetWithVisibilityResults' &&
|
|
121
77
|
(tweet.quoted_status_result.result as ILimitedVisibilityTweet)?.tweet?.legacy
|
|
122
78
|
) {
|
|
123
|
-
return new Tweet((tweet.quoted_status_result.result as ILimitedVisibilityTweet).tweet
|
|
79
|
+
return new Tweet((tweet.quoted_status_result.result as ILimitedVisibilityTweet).tweet);
|
|
124
80
|
}
|
|
125
81
|
// If normal tweet
|
|
126
|
-
else if ((tweet.quoted_status_result?.result as
|
|
127
|
-
return new Tweet(tweet.quoted_status_result.result as
|
|
82
|
+
else if ((tweet.quoted_status_result?.result as IRawTweet)?.rest_id) {
|
|
83
|
+
return new Tweet(tweet.quoted_status_result.result as IRawTweet);
|
|
128
84
|
}
|
|
129
85
|
// Else, skip
|
|
130
86
|
else {
|
|
@@ -136,22 +92,21 @@ export class Tweet {
|
|
|
136
92
|
* Extract and deserialize the original retweeted tweet from the given raw tweet.
|
|
137
93
|
*
|
|
138
94
|
* @param tweet - The raw tweet.
|
|
139
|
-
* @param response - The raw response
|
|
140
95
|
*
|
|
141
96
|
* @returns - The deserialized original retweeted tweet.
|
|
142
97
|
*/
|
|
143
|
-
private getRetweetedTweet(tweet: IRawTweet
|
|
98
|
+
private getRetweetedTweet(tweet: IRawTweet): Tweet | undefined {
|
|
144
99
|
// If retweet with limited visibility
|
|
145
100
|
if (
|
|
146
101
|
tweet.legacy?.retweeted_status_result &&
|
|
147
102
|
tweet.legacy?.retweeted_status_result?.result?.__typename == 'TweetWithVisibilityResults' &&
|
|
148
103
|
(tweet.legacy?.retweeted_status_result?.result as ILimitedVisibilityTweet)?.tweet?.legacy
|
|
149
104
|
) {
|
|
150
|
-
return new Tweet((tweet.legacy.retweeted_status_result.result as ILimitedVisibilityTweet).tweet
|
|
105
|
+
return new Tweet((tweet.legacy.retweeted_status_result.result as ILimitedVisibilityTweet).tweet);
|
|
151
106
|
}
|
|
152
107
|
// If normal tweet
|
|
153
|
-
else if ((tweet.legacy?.retweeted_status_result?.result as
|
|
154
|
-
return new Tweet(tweet.legacy.retweeted_status_result.result as
|
|
108
|
+
else if ((tweet.legacy?.retweeted_status_result?.result as IRawTweet)?.rest_id) {
|
|
109
|
+
return new Tweet(tweet.legacy.retweeted_status_result.result as IRawTweet);
|
|
155
110
|
}
|
|
156
111
|
// Else, skip
|
|
157
112
|
else {
|
|
@@ -160,39 +115,27 @@ export class Tweet {
|
|
|
160
115
|
}
|
|
161
116
|
|
|
162
117
|
/**
|
|
163
|
-
* Extracts and deserializes
|
|
118
|
+
* Extracts and deserializes multiple target tweets from the given raw response data.
|
|
164
119
|
*
|
|
165
120
|
* @param response - The raw response data.
|
|
121
|
+
* @param ids - The ids of the target tweets.
|
|
166
122
|
*
|
|
167
|
-
* @returns The deserialized
|
|
168
|
-
*
|
|
169
|
-
* @internal
|
|
123
|
+
* @returns The target deserialized tweets.
|
|
170
124
|
*/
|
|
171
|
-
public static
|
|
172
|
-
|
|
125
|
+
public static multiple(response: NonNullable<unknown>, ids: string[]): Tweet[] {
|
|
126
|
+
let tweets: Tweet[] = [];
|
|
173
127
|
|
|
174
128
|
// Extracting the matching data
|
|
175
|
-
const extract = findByFilter<
|
|
129
|
+
const extract = findByFilter<IRawTweet>(response, '__typename', 'Tweet');
|
|
176
130
|
|
|
177
131
|
// Deserializing valid data
|
|
178
132
|
for (const item of extract) {
|
|
179
|
-
|
|
180
|
-
if (
|
|
181
|
-
item.tweet_results?.result &&
|
|
182
|
-
item.tweet_results?.result?.__typename == 'TweetWithVisibilityResults' &&
|
|
183
|
-
(item.tweet_results?.result as ILimitedVisibilityTweet)?.tweet?.legacy
|
|
184
|
-
) {
|
|
185
|
-
tweets.push(new Tweet((item.tweet_results.result as ILimitedVisibilityTweet).tweet, response));
|
|
186
|
-
}
|
|
187
|
-
// If normal tweet
|
|
188
|
-
else if ((item.tweet_results?.result as ITweet)?.legacy) {
|
|
133
|
+
if (item.legacy) {
|
|
189
134
|
// Logging
|
|
190
|
-
LogService.log(ELogActions.DESERIALIZE, { id:
|
|
135
|
+
LogService.log(ELogActions.DESERIALIZE, { id: item.rest_id });
|
|
191
136
|
|
|
192
|
-
tweets.push(new Tweet(item
|
|
193
|
-
}
|
|
194
|
-
// If invalid/unrecognized tweet
|
|
195
|
-
else {
|
|
137
|
+
tweets.push(new Tweet(item));
|
|
138
|
+
} else {
|
|
196
139
|
// Logging
|
|
197
140
|
LogService.log(ELogActions.WARNING, {
|
|
198
141
|
action: ELogActions.DESERIALIZE,
|
|
@@ -201,6 +144,11 @@ export class Tweet {
|
|
|
201
144
|
}
|
|
202
145
|
}
|
|
203
146
|
|
|
147
|
+
// Filtering only required tweets, if required
|
|
148
|
+
if (ids && ids.length) {
|
|
149
|
+
tweets = tweets.filter((tweet) => ids.includes(tweet.id));
|
|
150
|
+
}
|
|
151
|
+
|
|
204
152
|
return tweets;
|
|
205
153
|
}
|
|
206
154
|
|
|
@@ -211,14 +159,12 @@ export class Tweet {
|
|
|
211
159
|
* @param id - The id of the target tweet.
|
|
212
160
|
*
|
|
213
161
|
* @returns The target deserialized tweet.
|
|
214
|
-
*
|
|
215
|
-
* @internal
|
|
216
162
|
*/
|
|
217
163
|
public static single(response: NonNullable<unknown>, id: string): Tweet | undefined {
|
|
218
164
|
const tweets: Tweet[] = [];
|
|
219
165
|
|
|
220
166
|
// Extracting the matching data
|
|
221
|
-
const extract = findByFilter<
|
|
167
|
+
const extract = findByFilter<IRawTweet>(response, 'rest_id', id);
|
|
222
168
|
|
|
223
169
|
// Deserializing valid data
|
|
224
170
|
for (const item of extract) {
|
|
@@ -226,7 +172,7 @@ export class Tweet {
|
|
|
226
172
|
// Logging
|
|
227
173
|
LogService.log(ELogActions.DESERIALIZE, { id: item.rest_id });
|
|
228
174
|
|
|
229
|
-
tweets.push(new Tweet(item
|
|
175
|
+
tweets.push(new Tweet(item));
|
|
230
176
|
} else {
|
|
231
177
|
// Logging
|
|
232
178
|
LogService.log(ELogActions.WARNING, {
|
|
@@ -238,6 +184,76 @@ export class Tweet {
|
|
|
238
184
|
|
|
239
185
|
return tweets.length ? tweets[0] : undefined;
|
|
240
186
|
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Extracts and deserializes the timeline of tweets from the given raw response data.
|
|
190
|
+
*
|
|
191
|
+
* @param response - The raw response data.
|
|
192
|
+
* @param ids - The IDs of specific tweets that need to be extracted.
|
|
193
|
+
*
|
|
194
|
+
* @returns The deserialized timeline of tweets.
|
|
195
|
+
*/
|
|
196
|
+
public static timeline(response: NonNullable<unknown>): Tweet[] {
|
|
197
|
+
const tweets: Tweet[] = [];
|
|
198
|
+
|
|
199
|
+
// Extracting the matching data
|
|
200
|
+
const extract = findByFilter<ITimelineTweet>(response, '__typename', 'TimelineTweet');
|
|
201
|
+
|
|
202
|
+
// Deserializing valid data
|
|
203
|
+
for (const item of extract) {
|
|
204
|
+
// If tweet with limited visibility
|
|
205
|
+
if (
|
|
206
|
+
item.tweet_results?.result &&
|
|
207
|
+
item.tweet_results?.result?.__typename == 'TweetWithVisibilityResults' &&
|
|
208
|
+
(item.tweet_results?.result as ILimitedVisibilityTweet)?.tweet?.legacy
|
|
209
|
+
) {
|
|
210
|
+
tweets.push(new Tweet((item.tweet_results.result as ILimitedVisibilityTweet).tweet));
|
|
211
|
+
}
|
|
212
|
+
// If normal tweet
|
|
213
|
+
else if ((item.tweet_results?.result as IRawTweet)?.legacy) {
|
|
214
|
+
// Logging
|
|
215
|
+
LogService.log(ELogActions.DESERIALIZE, { id: (item.tweet_results.result as IRawTweet).rest_id });
|
|
216
|
+
|
|
217
|
+
tweets.push(new Tweet(item.tweet_results.result as IRawTweet));
|
|
218
|
+
}
|
|
219
|
+
// If invalid/unrecognized tweet
|
|
220
|
+
else {
|
|
221
|
+
// Logging
|
|
222
|
+
LogService.log(ELogActions.WARNING, {
|
|
223
|
+
action: ELogActions.DESERIALIZE,
|
|
224
|
+
message: `Tweet not found, skipping`,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return tweets;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* @returns A serializable JSON representation of `this` object.
|
|
234
|
+
*/
|
|
235
|
+
public toJSON(): ITweet {
|
|
236
|
+
return {
|
|
237
|
+
bookmarkCount: this.bookmarkCount,
|
|
238
|
+
conversationId: this.conversationId,
|
|
239
|
+
createdAt: this.createdAt,
|
|
240
|
+
entities: this.entities.toJSON(),
|
|
241
|
+
fullText: this.fullText,
|
|
242
|
+
id: this.id,
|
|
243
|
+
lang: this.lang,
|
|
244
|
+
likeCount: this.likeCount,
|
|
245
|
+
media: this.media?.map((item) => item.toJSON()),
|
|
246
|
+
quoteCount: this.quoteCount,
|
|
247
|
+
quoted: this.quoted?.toJSON(),
|
|
248
|
+
replyCount: this.replyCount,
|
|
249
|
+
replyTo: this.replyTo,
|
|
250
|
+
retweetCount: this.retweetCount,
|
|
251
|
+
retweetedTweet: this.retweetedTweet?.toJSON(),
|
|
252
|
+
tweetBy: this.tweetBy.toJSON(),
|
|
253
|
+
url: this.url,
|
|
254
|
+
viewCount: this.viewCount,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
241
257
|
}
|
|
242
258
|
|
|
243
259
|
/**
|
|
@@ -280,6 +296,17 @@ export class TweetEntities {
|
|
|
280
296
|
}
|
|
281
297
|
}
|
|
282
298
|
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* @returns A serializable JSON representation of `this` object.
|
|
302
|
+
*/
|
|
303
|
+
public toJSON(): ITweetEntities {
|
|
304
|
+
return {
|
|
305
|
+
hashtags: this.hashtags,
|
|
306
|
+
mentionedUsers: this.mentionedUsers,
|
|
307
|
+
urls: this.urls,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
283
310
|
}
|
|
284
311
|
|
|
285
312
|
/**
|
|
@@ -295,28 +322,29 @@ export class TweetMedia {
|
|
|
295
322
|
public type: EMediaType;
|
|
296
323
|
|
|
297
324
|
/** The direct URL to the media. */
|
|
298
|
-
public url
|
|
325
|
+
public url = '';
|
|
299
326
|
|
|
300
327
|
/**
|
|
301
328
|
* @param media - The raw media details.
|
|
302
329
|
*/
|
|
303
330
|
public constructor(media: IRawExtendedMedia) {
|
|
304
|
-
this.type = media.type;
|
|
305
|
-
|
|
306
331
|
// If the media is a photo
|
|
307
|
-
if (media.type ==
|
|
332
|
+
if (media.type == ERawMediaType.PHOTO) {
|
|
333
|
+
this.type = EMediaType.PHOTO;
|
|
308
334
|
this.url = media.media_url_https;
|
|
309
335
|
}
|
|
310
336
|
// If the media is a gif
|
|
311
|
-
else if (media.type ==
|
|
337
|
+
else if (media.type == ERawMediaType.GIF) {
|
|
338
|
+
this.type = EMediaType.GIF;
|
|
312
339
|
this.url = media.video_info?.variants[0].url as string;
|
|
313
340
|
}
|
|
314
341
|
// If the media is a video
|
|
315
342
|
else {
|
|
343
|
+
this.type = EMediaType.VIDEO;
|
|
316
344
|
this.thumbnailUrl = media.media_url_https;
|
|
317
345
|
|
|
318
346
|
/** The highest bitrate of all variants. */
|
|
319
|
-
let highestRate
|
|
347
|
+
let highestRate = 0;
|
|
320
348
|
|
|
321
349
|
/**
|
|
322
350
|
* Selecting the URL of the video variant with the highest bitrate.
|
|
@@ -329,4 +357,15 @@ export class TweetMedia {
|
|
|
329
357
|
});
|
|
330
358
|
}
|
|
331
359
|
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @returns A serializable JSON representation of `this` object.
|
|
363
|
+
*/
|
|
364
|
+
public toJSON(): ITweetMedia {
|
|
365
|
+
return {
|
|
366
|
+
thumbnailUrl: this.thumbnailUrl,
|
|
367
|
+
type: this.type,
|
|
368
|
+
url: this.url,
|
|
369
|
+
};
|
|
370
|
+
}
|
|
332
371
|
}
|