rettiwt-api 5.0.0-alpha.1 → 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/dist/Rettiwt.d.ts +10 -3
- package/dist/Rettiwt.js +19 -7
- package/dist/Rettiwt.js.map +1 -1
- package/dist/collections/Extractors.d.ts +35 -2
- package/dist/collections/Extractors.js +3 -0
- package/dist/collections/Extractors.js.map +1 -1
- package/dist/collections/Groups.js +3 -0
- package/dist/collections/Groups.js.map +1 -1
- package/dist/collections/Requests.js +41 -41
- package/dist/collections/Requests.js.map +1 -1
- package/dist/commands/Tweet.js +33 -7
- package/dist/commands/Tweet.js.map +1 -1
- package/dist/commands/User.js +12 -2
- package/dist/commands/User.js.map +1 -1
- package/dist/enums/Authentication.d.ts +2 -10
- package/dist/enums/Authentication.js +3 -12
- package/dist/enums/Authentication.js.map +1 -1
- package/dist/enums/Data.d.ts +3 -15
- package/dist/enums/Data.js +4 -17
- package/dist/enums/Data.js.map +1 -1
- 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 +3 -0
- package/dist/enums/Resource.js +3 -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/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 -4
- package/dist/index.js +26 -5
- 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 +46 -3
- package/dist/models/args/FetchArgs.js +107 -5
- package/dist/models/args/FetchArgs.js.map +1 -1
- package/dist/models/args/PostArgs.d.ts +44 -16
- package/dist/models/args/PostArgs.js +61 -22
- package/dist/models/args/PostArgs.js.map +1 -1
- package/dist/models/auth/AuthCookie.d.ts +2 -0
- package/dist/models/auth/AuthCookie.js +2 -0
- package/dist/models/auth/AuthCookie.js.map +1 -1
- package/dist/models/auth/AuthCredential.d.ts +2 -0
- package/dist/models/auth/AuthCredential.js +2 -0
- package/dist/models/auth/AuthCredential.js.map +1 -1
- package/dist/models/data/CursoredData.d.ts +4 -13
- package/dist/models/data/CursoredData.js +16 -23
- package/dist/models/data/CursoredData.js.map +1 -1
- package/dist/models/data/List.d.ts +5 -1
- package/dist/models/data/List.js +14 -0
- package/dist/models/data/List.js.map +1 -1
- package/dist/models/data/Notification.d.ts +7 -5
- package/dist/models/data/Notification.js +19 -8
- package/dist/models/data/Notification.js.map +1 -1
- package/dist/models/data/Tweet.d.ts +29 -9
- package/dist/models/data/Tweet.js +103 -25
- package/dist/models/data/Tweet.js.map +1 -1
- package/dist/models/data/User.d.ts +17 -8
- package/dist/models/data/User.js +63 -13
- package/dist/models/data/User.js.map +1 -1
- package/dist/models/errors/RettiwtError.d.ts +3 -2
- package/dist/models/errors/RettiwtError.js +3 -2
- package/dist/models/errors/RettiwtError.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 +3 -5
- package/dist/services/internal/AuthService.js +5 -8
- package/dist/services/internal/AuthService.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 +20 -19
- package/dist/services/public/FetcherService.js +67 -49
- package/dist/services/public/FetcherService.js.map +1 -1
- package/dist/services/public/ListService.d.ts +2 -2
- package/dist/services/public/ListService.js.map +1 -1
- package/dist/services/public/TweetService.d.ts +35 -7
- package/dist/services/public/TweetService.js +54 -8
- package/dist/services/public/TweetService.js.map +1 -1
- package/dist/services/public/UserService.d.ts +4 -4
- package/dist/services/public/UserService.js +25 -13
- package/dist/services/public/UserService.js.map +1 -1
- package/dist/types/RettiwtConfig.d.ts +9 -10
- package/dist/types/args/FetchArgs.d.ts +71 -7
- package/dist/types/args/PostArgs.d.ts +62 -18
- package/dist/types/auth/AuthCookie.d.ts +2 -0
- package/dist/types/auth/AuthCredential.d.ts +2 -0
- package/dist/types/auth/TidDynamicArgs.d.ts +10 -0
- package/dist/types/auth/{AccountCredential.js → TidDynamicArgs.js} +1 -1
- package/dist/types/auth/TidDynamicArgs.js.map +1 -0
- package/dist/types/auth/TidHeader.d.ts +8 -0
- package/dist/types/{ReturnTypes.js → auth/TidHeader.js} +1 -1
- 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 +1 -10
- package/dist/types/data/Notification.d.ts +2 -2
- package/dist/types/data/Tweet.d.ts +2 -2
- 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/package.json +3 -3
- package/src/Rettiwt.ts +22 -7
- package/src/collections/Extractors.ts +38 -34
- package/src/collections/Groups.ts +3 -0
- package/src/collections/Requests.ts +43 -42
- package/src/commands/Tweet.ts +35 -7
- package/src/commands/User.ts +13 -2
- package/src/enums/Authentication.ts +2 -11
- package/src/enums/Data.ts +3 -16
- package/src/enums/Media.ts +10 -0
- package/src/enums/Notification.ts +12 -0
- package/src/enums/Resource.ts +3 -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/TidUtils.ts +189 -0
- package/src/index.ts +78 -43
- package/src/models/RettiwtConfig.ts +64 -0
- package/src/models/args/FetchArgs.ts +121 -5
- package/src/models/args/PostArgs.ts +61 -21
- package/src/models/auth/AuthCookie.ts +2 -0
- package/src/models/auth/AuthCredential.ts +2 -0
- package/src/models/data/CursoredData.ts +16 -24
- package/src/models/data/List.ts +16 -2
- package/src/models/data/Notification.ts +21 -12
- package/src/models/data/Tweet.ts +120 -39
- package/src/models/data/User.ts +71 -15
- 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/internal/AuthService.ts +6 -11
- package/src/services/internal/TidService.ts +147 -0
- package/src/services/public/FetcherService.ts +78 -58
- package/src/services/public/ListService.ts +4 -4
- package/src/services/public/TweetService.ts +87 -40
- package/src/services/public/UserService.ts +47 -35
- package/src/types/RettiwtConfig.ts +11 -12
- package/src/types/args/FetchArgs.ts +92 -8
- package/src/types/args/PostArgs.ts +72 -22
- package/src/types/auth/AuthCookie.ts +2 -0
- package/src/types/auth/AuthCredential.ts +2 -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 +1 -11
- package/src/types/data/Notification.ts +2 -2
- package/src/types/data/Tweet.ts +2 -2
- 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/dist/models/auth/AccountCredential.d.ts +0 -13
- package/dist/models/auth/AccountCredential.js +0 -21
- package/dist/models/auth/AccountCredential.js.map +0 -1
- package/dist/types/ReturnTypes.d.ts +0 -21
- package/dist/types/ReturnTypes.js.map +0 -1
- package/dist/types/auth/AccountCredential.d.ts +0 -11
- package/dist/types/auth/AccountCredential.js.map +0 -1
- package/src/models/auth/AccountCredential.ts +0 -19
- package/src/types/ReturnTypes.ts +0 -24
- package/src/types/auth/AccountCredential.ts +0 -13
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { ESearchResultType, TweetFilter } from 'rettiwt-core';
|
|
2
|
-
|
|
3
1
|
import { EResourceType } from '../../enums/Resource';
|
|
4
|
-
import { IFetchArgs } from '../../types/args/FetchArgs';
|
|
2
|
+
import { IFetchArgs, ITweetFilter } from '../../types/args/FetchArgs';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* Options specifying the data that is to be fetched.
|
|
@@ -13,7 +11,7 @@ export class FetchArgs implements IFetchArgs {
|
|
|
13
11
|
public cursor?: string;
|
|
14
12
|
public filter?: TweetFilter;
|
|
15
13
|
public id?: string;
|
|
16
|
-
public
|
|
14
|
+
public ids?: string[];
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
17
|
* @param resource - The resource to be fetched.
|
|
@@ -21,9 +19,127 @@ export class FetchArgs implements IFetchArgs {
|
|
|
21
19
|
*/
|
|
22
20
|
public constructor(resource: EResourceType, args: IFetchArgs) {
|
|
23
21
|
this.id = args.id;
|
|
22
|
+
this.ids = args.ids;
|
|
24
23
|
this.count = args.count;
|
|
25
24
|
this.cursor = args.cursor;
|
|
26
25
|
this.filter = args.filter ? new TweetFilter(args.filter) : undefined;
|
|
27
|
-
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The filter to be used for searching tweets.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export class TweetFilter implements ITweetFilter {
|
|
35
|
+
public endDate?: Date;
|
|
36
|
+
public excludeWords?: string[];
|
|
37
|
+
public fromUsers?: string[];
|
|
38
|
+
public hashtags?: string[];
|
|
39
|
+
public includePhrase?: string;
|
|
40
|
+
public includeWords?: string[];
|
|
41
|
+
public language?: string;
|
|
42
|
+
public links?: boolean;
|
|
43
|
+
public list?: string;
|
|
44
|
+
public maxId?: string;
|
|
45
|
+
public mentions?: string[];
|
|
46
|
+
public minLikes?: number;
|
|
47
|
+
public minReplies?: number;
|
|
48
|
+
public minRetweets?: number;
|
|
49
|
+
public optionalWords?: string[];
|
|
50
|
+
public quoted?: string;
|
|
51
|
+
public replies?: boolean;
|
|
52
|
+
public sinceId?: string;
|
|
53
|
+
public startDate?: Date;
|
|
54
|
+
public toUsers?: string[];
|
|
55
|
+
public top?: boolean;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param filter - The filter configuration.
|
|
59
|
+
*/
|
|
60
|
+
public constructor(filter: ITweetFilter) {
|
|
61
|
+
this.endDate = filter.endDate;
|
|
62
|
+
this.excludeWords = filter.excludeWords;
|
|
63
|
+
this.fromUsers = filter.fromUsers;
|
|
64
|
+
this.hashtags = filter.hashtags;
|
|
65
|
+
this.includePhrase = filter.includePhrase;
|
|
66
|
+
this.language = filter.language;
|
|
67
|
+
this.links = filter.links;
|
|
68
|
+
this.list = filter.list;
|
|
69
|
+
this.replies = filter.replies;
|
|
70
|
+
this.mentions = filter.mentions;
|
|
71
|
+
this.quoted = filter.quoted;
|
|
72
|
+
this.sinceId = filter.sinceId;
|
|
73
|
+
this.maxId = filter.maxId;
|
|
74
|
+
this.minLikes = filter.minLikes;
|
|
75
|
+
this.minReplies = filter.minReplies;
|
|
76
|
+
this.minRetweets = filter.minRetweets;
|
|
77
|
+
this.optionalWords = filter.optionalWords;
|
|
78
|
+
this.startDate = filter.startDate;
|
|
79
|
+
this.toUsers = filter.toUsers;
|
|
80
|
+
this.top = filter.top;
|
|
81
|
+
this.includeWords = filter.includeWords;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Convert Date object to Twitter string representation.
|
|
86
|
+
* eg - 2023-06-23_11:21:06_UTC
|
|
87
|
+
*
|
|
88
|
+
* @param date - The date object to convert.
|
|
89
|
+
* @returns The Twitter string representation of the date.
|
|
90
|
+
*/
|
|
91
|
+
private static dateToTwitterString(date: Date): string {
|
|
92
|
+
// Converting localized date to UTC date
|
|
93
|
+
const utc = new Date(
|
|
94
|
+
Date.UTC(
|
|
95
|
+
date.getUTCFullYear(),
|
|
96
|
+
date.getUTCMonth(),
|
|
97
|
+
date.getUTCDate(),
|
|
98
|
+
date.getUTCHours(),
|
|
99
|
+
date.getUTCMinutes(),
|
|
100
|
+
date.getUTCSeconds(),
|
|
101
|
+
),
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* To convert ISO 8601 date string to Twitter date string:
|
|
106
|
+
*
|
|
107
|
+
* - 'T' between date and time substring is replace with '_'.
|
|
108
|
+
* - Milliseconds substring is omitted.
|
|
109
|
+
* - '_UTC' is appended as suffix.
|
|
110
|
+
*/
|
|
111
|
+
return utc.toISOString().replace(/T/, '_').replace(/\..+/, '') + '_UTC';
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @returns The string representation of 'this' filter.
|
|
116
|
+
*/
|
|
117
|
+
public toString(): string {
|
|
118
|
+
return (
|
|
119
|
+
[
|
|
120
|
+
this.includeWords ? this.includeWords.join(' ') : '',
|
|
121
|
+
this.includePhrase ? `"${this.includePhrase}"` : '',
|
|
122
|
+
this.optionalWords ? `(${this.optionalWords.join(' OR ')})` : '',
|
|
123
|
+
this.excludeWords ? `${this.excludeWords.map((word) => '-' + word).join(' ')}` : '',
|
|
124
|
+
this.hashtags ? `(${this.hashtags.map((hashtag) => '#' + hashtag).join(' OR ')})` : '',
|
|
125
|
+
this.fromUsers ? `(${this.fromUsers.map((user) => `from:${user}`).join(' OR ')})` : '',
|
|
126
|
+
this.toUsers ? `(${this.toUsers.map((user) => `to:${user}`).join(' OR ')})` : '',
|
|
127
|
+
this.list ? `list:${this.list}` : '',
|
|
128
|
+
this.mentions ? `(${this.mentions.map((mention) => '@' + mention).join(' OR ')})` : '',
|
|
129
|
+
this.minReplies ? `min_replies:${this.minReplies}` : '',
|
|
130
|
+
this.minLikes ? `min_faves:${this.minLikes}` : '',
|
|
131
|
+
this.minRetweets ? `min_retweets:${this.minRetweets}` : '',
|
|
132
|
+
this.language ? `lang:${this.language}` : '',
|
|
133
|
+
this.startDate ? `since:${TweetFilter.dateToTwitterString(this.startDate)}` : '',
|
|
134
|
+
this.endDate ? `until:${TweetFilter.dateToTwitterString(this.endDate)}` : '',
|
|
135
|
+
this.sinceId ? `since_id:${this.sinceId}` : '',
|
|
136
|
+
this.maxId ? `max_id:${this.maxId}` : '',
|
|
137
|
+
this.quoted ? `quoted_tweet_id:${this.quoted}` : '',
|
|
138
|
+
]
|
|
139
|
+
.filter((item) => item !== '()' && item !== '')
|
|
140
|
+
.join(' ') +
|
|
141
|
+
(this.links == false ? ' -filter:links' : '') +
|
|
142
|
+
(this.replies == false ? ' -filter:replies' : '')
|
|
143
|
+
);
|
|
28
144
|
}
|
|
29
145
|
}
|
|
@@ -1,46 +1,86 @@
|
|
|
1
|
-
import { NewTweet } from 'rettiwt-core';
|
|
2
|
-
|
|
3
1
|
import { EResourceType } from '../../enums/Resource';
|
|
4
|
-
import { IPostArgs, IUploadArgs } from '../../types/args/PostArgs';
|
|
2
|
+
import { INewTweet, INewTweetMedia, IPostArgs, IUploadArgs } from '../../types/args/PostArgs';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
|
-
* Options specifying the
|
|
5
|
+
* Options specifying the data that is to be posted.
|
|
8
6
|
*
|
|
9
7
|
* @public
|
|
10
8
|
*/
|
|
11
|
-
export class
|
|
9
|
+
export class PostArgs implements IPostArgs {
|
|
12
10
|
public id?: string;
|
|
13
|
-
public
|
|
14
|
-
public
|
|
11
|
+
public tweet?: NewTweet;
|
|
12
|
+
public upload?: UploadArgs;
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
|
-
* @param
|
|
18
|
-
* @param args -
|
|
15
|
+
* @param resource - The resource to be posted.
|
|
16
|
+
* @param args - Additional user-defined arguments for posting the resource.
|
|
19
17
|
*/
|
|
20
|
-
public constructor(
|
|
21
|
-
this.size = args.size;
|
|
22
|
-
this.media = args.media;
|
|
18
|
+
public constructor(resource: EResourceType, args: IPostArgs) {
|
|
23
19
|
this.id = args.id;
|
|
20
|
+
this.tweet = args.tweet ? new NewTweet(args.tweet) : undefined;
|
|
21
|
+
this.upload = args.upload ? new UploadArgs(resource, args.upload) : undefined;
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
/**
|
|
28
|
-
*
|
|
26
|
+
* Configuration for the new tweet to be posted.
|
|
29
27
|
*
|
|
30
28
|
* @public
|
|
31
29
|
*/
|
|
32
|
-
export class
|
|
30
|
+
export class NewTweet implements INewTweet {
|
|
31
|
+
public media?: NewTweetMedia[];
|
|
32
|
+
public quote?: string;
|
|
33
|
+
public replyTo?: string;
|
|
34
|
+
public scheduleFor?: Date;
|
|
35
|
+
public text: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param newTweet - The args specifying the new tweet to be posted.
|
|
39
|
+
*/
|
|
40
|
+
public constructor(newTweet: INewTweet) {
|
|
41
|
+
this.media = newTweet.media;
|
|
42
|
+
this.quote = newTweet.quote;
|
|
43
|
+
this.replyTo = newTweet.replyTo;
|
|
44
|
+
this.scheduleFor = newTweet.scheduleFor;
|
|
45
|
+
this.text = newTweet.text ?? '';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Configuration for the media to be uploaded.
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export class NewTweetMedia implements INewTweetMedia {
|
|
55
|
+
public id: string;
|
|
56
|
+
public tags?: string[];
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param newTweetMedia - The args specifying the new media to be posted along with the tweet.
|
|
60
|
+
*/
|
|
61
|
+
public constructor(newTweetMedia: INewTweetMedia) {
|
|
62
|
+
this.id = newTweetMedia.id;
|
|
63
|
+
this.tags = newTweetMedia.tags;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Options specifying the media file to be uploaded.
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export class UploadArgs implements IUploadArgs {
|
|
33
73
|
public id?: string;
|
|
34
|
-
public
|
|
35
|
-
public
|
|
74
|
+
public media?: string | ArrayBuffer;
|
|
75
|
+
public size?: number;
|
|
36
76
|
|
|
37
77
|
/**
|
|
38
|
-
* @param
|
|
39
|
-
* @param args -
|
|
78
|
+
* @param step - The upload step.
|
|
79
|
+
* @param args - The upload arguments for uploading the media file.
|
|
40
80
|
*/
|
|
41
|
-
public constructor(
|
|
81
|
+
public constructor(step: EResourceType, args: IUploadArgs) {
|
|
82
|
+
this.size = args.size;
|
|
83
|
+
this.media = args.media;
|
|
42
84
|
this.id = args.id;
|
|
43
|
-
this.tweet = args.tweet ? new NewTweet(args.tweet) : undefined;
|
|
44
|
-
this.upload = args.upload ? new UploadArgs(resource, args.upload) : undefined;
|
|
45
85
|
}
|
|
46
86
|
}
|
|
@@ -4,6 +4,8 @@ import { IAuthCookie } from '../../types/auth/AuthCookie';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The cookie containing the tokens that are used to authenticate against Twitter.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
7
9
|
*/
|
|
8
10
|
export class AuthCookie implements IAuthCookie {
|
|
9
11
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
@@ -14,6 +14,8 @@ import { AuthCookie } from './AuthCookie';
|
|
|
14
14
|
* - authToken, guestToken =\> Guest authentication.
|
|
15
15
|
* - authToken, csrfToken, cookie =\> User authentication.
|
|
16
16
|
* - authToken, guestToken, cookie =\> Guest authentication while logging in.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
17
19
|
*/
|
|
18
20
|
export class AuthCredential implements IAuthCredential {
|
|
19
21
|
public authToken?: string;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { ICursor as IRawCursor } from 'rettiwt-core';
|
|
2
|
-
|
|
3
1
|
import { EBaseType } from '../../enums/Data';
|
|
4
2
|
|
|
5
3
|
import { findByFilter } from '../../helper/JsonUtils';
|
|
6
4
|
|
|
7
|
-
import {
|
|
5
|
+
import { ICursoredData } from '../../types/data/CursoredData';
|
|
6
|
+
import { ICursor as IRawCursor } from '../../types/raw/base/Cursor';
|
|
8
7
|
|
|
9
8
|
import { Notification } from './Notification';
|
|
10
9
|
import { Tweet } from './Tweet';
|
|
@@ -18,8 +17,8 @@ import { User } from './User';
|
|
|
18
17
|
* @public
|
|
19
18
|
*/
|
|
20
19
|
export class CursoredData<T extends Notification | Tweet | User> implements ICursoredData<T> {
|
|
21
|
-
public list: T[]
|
|
22
|
-
public next:
|
|
20
|
+
public list: T[];
|
|
21
|
+
public next: string;
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
24
|
* @param response - The raw response.
|
|
@@ -28,34 +27,27 @@ export class CursoredData<T extends Notification | Tweet | User> implements ICur
|
|
|
28
27
|
public constructor(response: NonNullable<unknown>, type: EBaseType) {
|
|
29
28
|
// Initializing defaults
|
|
30
29
|
this.list = [];
|
|
31
|
-
this.next =
|
|
30
|
+
this.next = '';
|
|
32
31
|
|
|
33
32
|
if (type == EBaseType.TWEET) {
|
|
34
|
-
this.list = Tweet.
|
|
35
|
-
this.next =
|
|
33
|
+
this.list = Tweet.timeline(response) as T[];
|
|
34
|
+
this.next = findByFilter<IRawCursor>(response, 'cursorType', 'Bottom')[0]?.value ?? '';
|
|
36
35
|
} else if (type == EBaseType.USER) {
|
|
37
|
-
this.list = User.
|
|
38
|
-
this.next =
|
|
36
|
+
this.list = User.timeline(response) as T[];
|
|
37
|
+
this.next = findByFilter<IRawCursor>(response, 'cursorType', 'Bottom')[0]?.value ?? '';
|
|
39
38
|
} else if (type == EBaseType.NOTIFICATION) {
|
|
40
39
|
this.list = Notification.list(response) as T[];
|
|
41
|
-
this.next =
|
|
40
|
+
this.next = findByFilter<IRawCursor>(response, 'cursorType', 'Top')[0]?.value ?? '';
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* The cursor to the batch of data to fetch.
|
|
48
|
-
*
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
export class Cursor implements ICursor {
|
|
52
|
-
/** The cursor string. */
|
|
53
|
-
public value: string;
|
|
54
43
|
|
|
55
44
|
/**
|
|
56
|
-
* @
|
|
45
|
+
* @returns A serializable JSON representation of `this` object.
|
|
57
46
|
*/
|
|
58
|
-
public
|
|
59
|
-
|
|
47
|
+
public toJSON(): ICursoredData<T> {
|
|
48
|
+
return {
|
|
49
|
+
list: this.list.map((item) => item.toJSON() as T),
|
|
50
|
+
next: this.next,
|
|
51
|
+
};
|
|
60
52
|
}
|
|
61
53
|
}
|
package/src/models/data/List.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IList as IRawList } from 'rettiwt-core';
|
|
2
|
-
|
|
3
1
|
import { IList } from '../../types/data/List';
|
|
2
|
+
import { IList as IRawList } from '../../types/raw/base/List';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* The details of a single Twitter List.
|
|
@@ -28,4 +27,19 @@ export class List implements IList {
|
|
|
28
27
|
this.subscriberCount = list.subscriber_count;
|
|
29
28
|
this.createdBy = list.user_results.result.id;
|
|
30
29
|
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @returns A serializable JSON representation of `this` object.
|
|
33
|
+
*/
|
|
34
|
+
public toJSON(): IList {
|
|
35
|
+
return {
|
|
36
|
+
createdAt: this.createdAt,
|
|
37
|
+
createdBy: this.createdBy,
|
|
38
|
+
description: this.description,
|
|
39
|
+
id: this.id,
|
|
40
|
+
memberCount: this.memberCount,
|
|
41
|
+
name: this.name,
|
|
42
|
+
subscriberCount: this.subscriberCount,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
31
45
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
INotification as IRawNotification,
|
|
4
|
-
IUserNotificationsResponse,
|
|
5
|
-
} from 'rettiwt-core';
|
|
6
|
-
|
|
7
|
-
import { ENotificationType } from '../../enums/Data';
|
|
1
|
+
import { ENotificationType } from '../../enums/Notification';
|
|
2
|
+
import { ERawNotificationType } from '../../enums/raw/Notification';
|
|
8
3
|
import { findKeyByValue } from '../../helper/JsonUtils';
|
|
9
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';
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* The details of a single notification.
|
|
@@ -17,7 +14,7 @@ export class Notification implements INotification {
|
|
|
17
14
|
public from: string[];
|
|
18
15
|
public id: string;
|
|
19
16
|
public message: string;
|
|
20
|
-
public receivedAt:
|
|
17
|
+
public receivedAt: string;
|
|
21
18
|
public target: string[];
|
|
22
19
|
public type?: ENotificationType;
|
|
23
20
|
|
|
@@ -26,14 +23,14 @@ export class Notification implements INotification {
|
|
|
26
23
|
*/
|
|
27
24
|
public constructor(notification: IRawNotification) {
|
|
28
25
|
// Getting the original notification type
|
|
29
|
-
const notificationType: string | undefined = findKeyByValue(
|
|
26
|
+
const notificationType: string | undefined = findKeyByValue(ERawNotificationType, notification.icon.id);
|
|
30
27
|
|
|
31
28
|
this.from = notification.template?.aggregateUserActionsV1?.fromUsers
|
|
32
29
|
? notification.template.aggregateUserActionsV1.fromUsers.map((item) => item.user.id)
|
|
33
30
|
: [];
|
|
34
31
|
this.id = notification.id;
|
|
35
32
|
this.message = notification.message.text;
|
|
36
|
-
this.receivedAt = new Date(Number(notification.timestampMs));
|
|
33
|
+
this.receivedAt = new Date(Number(notification.timestampMs)).toISOString();
|
|
37
34
|
this.target = notification.template?.aggregateUserActionsV1?.targetObjects
|
|
38
35
|
? notification.template.aggregateUserActionsV1.targetObjects.map((item) => item.tweet.id)
|
|
39
36
|
: [];
|
|
@@ -48,8 +45,6 @@ export class Notification implements INotification {
|
|
|
48
45
|
* @param response - The raw response data.
|
|
49
46
|
*
|
|
50
47
|
* @returns The deserialized list of notifications.
|
|
51
|
-
*
|
|
52
|
-
* @internal
|
|
53
48
|
*/
|
|
54
49
|
public static list(response: NonNullable<unknown>): Notification[] {
|
|
55
50
|
const notifications: Notification[] = [];
|
|
@@ -66,4 +61,18 @@ export class Notification implements INotification {
|
|
|
66
61
|
|
|
67
62
|
return notifications;
|
|
68
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
|
+
}
|
|
69
78
|
}
|
package/src/models/data/Tweet.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EMediaType,
|
|
3
|
-
ILimitedVisibilityTweet,
|
|
4
|
-
IExtendedMedia as IRawExtendedMedia,
|
|
5
|
-
ITweet as IRawTweet,
|
|
6
|
-
IEntities as IRawTweetEntities,
|
|
7
|
-
ITimelineTweet,
|
|
8
|
-
} from 'rettiwt-core';
|
|
9
|
-
|
|
10
1
|
import { ELogActions } from '../../enums/Logging';
|
|
2
|
+
import { EMediaType } from '../../enums/Media';
|
|
3
|
+
import { ERawMediaType } from '../../enums/raw/Media';
|
|
11
4
|
import { findByFilter } from '../../helper/JsonUtils';
|
|
12
5
|
|
|
13
6
|
import { LogService } from '../../services/internal/LogService';
|
|
14
7
|
|
|
15
|
-
import { ITweet } from '../../types/data/Tweet';
|
|
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';
|
|
16
13
|
|
|
17
14
|
import { User } from './User';
|
|
18
15
|
|
|
@@ -47,7 +44,7 @@ export class Tweet implements ITweet {
|
|
|
47
44
|
public constructor(tweet: IRawTweet) {
|
|
48
45
|
this.id = tweet.rest_id;
|
|
49
46
|
this.conversationId = tweet.legacy.conversation_id_str;
|
|
50
|
-
this.createdAt = tweet.legacy.created_at;
|
|
47
|
+
this.createdAt = new Date(tweet.legacy.created_at).toISOString();
|
|
51
48
|
this.tweetBy = new User(tweet.core.user_results.result);
|
|
52
49
|
this.entities = new TweetEntities(tweet.legacy.entities);
|
|
53
50
|
this.media = tweet.legacy.extended_entities?.media?.map((media) => new TweetMedia(media));
|
|
@@ -118,39 +115,27 @@ export class Tweet implements ITweet {
|
|
|
118
115
|
}
|
|
119
116
|
|
|
120
117
|
/**
|
|
121
|
-
* Extracts and deserializes
|
|
118
|
+
* Extracts and deserializes multiple target tweets from the given raw response data.
|
|
122
119
|
*
|
|
123
120
|
* @param response - The raw response data.
|
|
121
|
+
* @param ids - The ids of the target tweets.
|
|
124
122
|
*
|
|
125
|
-
* @returns The deserialized
|
|
126
|
-
*
|
|
127
|
-
* @internal
|
|
123
|
+
* @returns The target deserialized tweets.
|
|
128
124
|
*/
|
|
129
|
-
public static
|
|
130
|
-
|
|
125
|
+
public static multiple(response: NonNullable<unknown>, ids: string[]): Tweet[] {
|
|
126
|
+
let tweets: Tweet[] = [];
|
|
131
127
|
|
|
132
128
|
// Extracting the matching data
|
|
133
|
-
const extract = findByFilter<
|
|
129
|
+
const extract = findByFilter<IRawTweet>(response, '__typename', 'Tweet');
|
|
134
130
|
|
|
135
131
|
// Deserializing valid data
|
|
136
132
|
for (const item of extract) {
|
|
137
|
-
|
|
138
|
-
if (
|
|
139
|
-
item.tweet_results?.result &&
|
|
140
|
-
item.tweet_results?.result?.__typename == 'TweetWithVisibilityResults' &&
|
|
141
|
-
(item.tweet_results?.result as ILimitedVisibilityTweet)?.tweet?.legacy
|
|
142
|
-
) {
|
|
143
|
-
tweets.push(new Tweet((item.tweet_results.result as ILimitedVisibilityTweet).tweet));
|
|
144
|
-
}
|
|
145
|
-
// If normal tweet
|
|
146
|
-
else if ((item.tweet_results?.result as IRawTweet)?.legacy) {
|
|
133
|
+
if (item.legacy) {
|
|
147
134
|
// Logging
|
|
148
|
-
LogService.log(ELogActions.DESERIALIZE, { id:
|
|
135
|
+
LogService.log(ELogActions.DESERIALIZE, { id: item.rest_id });
|
|
149
136
|
|
|
150
|
-
tweets.push(new Tweet(item
|
|
151
|
-
}
|
|
152
|
-
// If invalid/unrecognized tweet
|
|
153
|
-
else {
|
|
137
|
+
tweets.push(new Tweet(item));
|
|
138
|
+
} else {
|
|
154
139
|
// Logging
|
|
155
140
|
LogService.log(ELogActions.WARNING, {
|
|
156
141
|
action: ELogActions.DESERIALIZE,
|
|
@@ -159,6 +144,11 @@ export class Tweet implements ITweet {
|
|
|
159
144
|
}
|
|
160
145
|
}
|
|
161
146
|
|
|
147
|
+
// Filtering only required tweets, if required
|
|
148
|
+
if (ids && ids.length) {
|
|
149
|
+
tweets = tweets.filter((tweet) => ids.includes(tweet.id));
|
|
150
|
+
}
|
|
151
|
+
|
|
162
152
|
return tweets;
|
|
163
153
|
}
|
|
164
154
|
|
|
@@ -169,8 +159,6 @@ export class Tweet implements ITweet {
|
|
|
169
159
|
* @param id - The id of the target tweet.
|
|
170
160
|
*
|
|
171
161
|
* @returns The target deserialized tweet.
|
|
172
|
-
*
|
|
173
|
-
* @internal
|
|
174
162
|
*/
|
|
175
163
|
public static single(response: NonNullable<unknown>, id: string): Tweet | undefined {
|
|
176
164
|
const tweets: Tweet[] = [];
|
|
@@ -196,6 +184,76 @@ export class Tweet implements ITweet {
|
|
|
196
184
|
|
|
197
185
|
return tweets.length ? tweets[0] : undefined;
|
|
198
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
|
+
}
|
|
199
257
|
}
|
|
200
258
|
|
|
201
259
|
/**
|
|
@@ -238,6 +296,17 @@ export class TweetEntities {
|
|
|
238
296
|
}
|
|
239
297
|
}
|
|
240
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
|
+
}
|
|
241
310
|
}
|
|
242
311
|
|
|
243
312
|
/**
|
|
@@ -259,18 +328,19 @@ export class TweetMedia {
|
|
|
259
328
|
* @param media - The raw media details.
|
|
260
329
|
*/
|
|
261
330
|
public constructor(media: IRawExtendedMedia) {
|
|
262
|
-
this.type = media.type;
|
|
263
|
-
|
|
264
331
|
// If the media is a photo
|
|
265
|
-
if (media.type ==
|
|
332
|
+
if (media.type == ERawMediaType.PHOTO) {
|
|
333
|
+
this.type = EMediaType.PHOTO;
|
|
266
334
|
this.url = media.media_url_https;
|
|
267
335
|
}
|
|
268
336
|
// If the media is a gif
|
|
269
|
-
else if (media.type ==
|
|
337
|
+
else if (media.type == ERawMediaType.GIF) {
|
|
338
|
+
this.type = EMediaType.GIF;
|
|
270
339
|
this.url = media.video_info?.variants[0].url as string;
|
|
271
340
|
}
|
|
272
341
|
// If the media is a video
|
|
273
342
|
else {
|
|
343
|
+
this.type = EMediaType.VIDEO;
|
|
274
344
|
this.thumbnailUrl = media.media_url_https;
|
|
275
345
|
|
|
276
346
|
/** The highest bitrate of all variants. */
|
|
@@ -287,4 +357,15 @@ export class TweetMedia {
|
|
|
287
357
|
});
|
|
288
358
|
}
|
|
289
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
|
+
}
|
|
290
371
|
}
|