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,103 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
-
function step(op) {
|
|
42
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
44
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
-
switch (op[0]) {
|
|
47
|
-
case 0: case 1: t = op; break;
|
|
48
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
-
default:
|
|
52
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
-
if (t[2]) _.ops.pop();
|
|
57
|
-
_.trys.pop(); continue;
|
|
58
|
-
}
|
|
59
|
-
op = body.call(thisArg, _);
|
|
60
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
65
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
66
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
67
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
68
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
69
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
70
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
71
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
72
|
-
function fulfill(value) { resume("next", value); }
|
|
73
|
-
function reject(value) { resume("throw", value); }
|
|
74
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
75
|
-
};
|
|
76
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
3
|
exports.TweetService = void 0;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const Extractors_1 = require("../../collections/Extractors");
|
|
6
|
+
const Resource_1 = require("../../enums/Resource");
|
|
7
|
+
const FetcherService_1 = require("./FetcherService");
|
|
82
8
|
/**
|
|
83
9
|
* Handles interacting with resources related to tweets.
|
|
84
10
|
*
|
|
85
11
|
* @public
|
|
86
12
|
*/
|
|
87
|
-
|
|
88
|
-
__extends(TweetService, _super);
|
|
13
|
+
class TweetService extends FetcherService_1.FetcherService {
|
|
89
14
|
/**
|
|
90
15
|
* @param config - The config object for configuring the Rettiwt instance.
|
|
91
16
|
*
|
|
92
17
|
* @internal
|
|
93
18
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
19
|
+
constructor(config) {
|
|
20
|
+
super(config);
|
|
96
21
|
}
|
|
97
22
|
/**
|
|
98
23
|
* Get the details of a tweet.
|
|
99
24
|
*
|
|
100
|
-
* @param id - The id of the target tweet.
|
|
25
|
+
* @param id - The id(s) of the target tweet/tweets.
|
|
101
26
|
*
|
|
102
27
|
* @returns
|
|
103
28
|
* The details of the tweet with the given id.
|
|
@@ -120,30 +45,36 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
120
45
|
* });
|
|
121
46
|
* ```
|
|
122
47
|
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
48
|
+
async details(id) {
|
|
49
|
+
let resource;
|
|
50
|
+
// If user is authenticated and details of single tweet required
|
|
51
|
+
if (this.config.userId != undefined && typeof id == 'string') {
|
|
52
|
+
resource = Resource_1.EResourceType.TWEET_DETAILS_ALT;
|
|
53
|
+
// Fetching raw tweet details
|
|
54
|
+
const response = await this.request(resource, { id: id });
|
|
55
|
+
// Deserializing response
|
|
56
|
+
const data = Extractors_1.extractors[resource](response, id);
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
// If user is authenticated and details of multiple tweets required
|
|
60
|
+
else if (this.config.userId != undefined && Array.isArray(id)) {
|
|
61
|
+
resource = Resource_1.EResourceType.TWEET_DETAILS_BULK;
|
|
62
|
+
// Fetching raw tweet details
|
|
63
|
+
const response = await this.request(resource, { ids: id });
|
|
64
|
+
// Deserializing response
|
|
65
|
+
const data = Extractors_1.extractors[resource](response, id);
|
|
66
|
+
return data;
|
|
67
|
+
}
|
|
68
|
+
// If user is not authenticated
|
|
69
|
+
else {
|
|
70
|
+
resource = Resource_1.EResourceType.TWEET_DETAILS;
|
|
71
|
+
// Fetching raw tweet details
|
|
72
|
+
const response = await this.request(resource, { id: String(id) });
|
|
73
|
+
// Deserializing response
|
|
74
|
+
const data = Extractors_1.extractors[resource](response, String(id));
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
147
78
|
/**
|
|
148
79
|
* Like a tweet.
|
|
149
80
|
*
|
|
@@ -168,25 +99,54 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
168
99
|
* });
|
|
169
100
|
* ```
|
|
170
101
|
*/
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
switch (_b.label) {
|
|
177
|
-
case 0:
|
|
178
|
-
resource = Resource_1.EResourceType.TWEET_LIKE;
|
|
179
|
-
return [4 /*yield*/, this.request(resource, {
|
|
180
|
-
id: id,
|
|
181
|
-
})];
|
|
182
|
-
case 1:
|
|
183
|
-
response = _b.sent();
|
|
184
|
-
data = (_a = Extractors_1.extractors[resource](response)) !== null && _a !== void 0 ? _a : false;
|
|
185
|
-
return [2 /*return*/, data];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
102
|
+
async like(id) {
|
|
103
|
+
const resource = Resource_1.EResourceType.TWEET_LIKE;
|
|
104
|
+
// Favoriting the tweet
|
|
105
|
+
const response = await this.request(resource, {
|
|
106
|
+
id: id,
|
|
188
107
|
});
|
|
189
|
-
|
|
108
|
+
// Deserializing response
|
|
109
|
+
const data = Extractors_1.extractors[resource](response) ?? false;
|
|
110
|
+
return data;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get the list of users who liked a tweet. Only works for your own tweets.
|
|
114
|
+
*
|
|
115
|
+
* @param id - The id of the target tweet.
|
|
116
|
+
* @param count - The number of likers to fetch, must be \<= 100.
|
|
117
|
+
* @param cursor - The cursor to the batch of likers to fetch.
|
|
118
|
+
*
|
|
119
|
+
* @returns The list of users who liked the given tweet.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```
|
|
123
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
124
|
+
*
|
|
125
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
126
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
127
|
+
*
|
|
128
|
+
* // Fetching the most recent 100 likers of the Tweet with id '1234567890'
|
|
129
|
+
* rettiwt.tweet.likers('1234567890')
|
|
130
|
+
* .then(res => {
|
|
131
|
+
* console.log(res);
|
|
132
|
+
* })
|
|
133
|
+
* .catch(err => {
|
|
134
|
+
* console.log(err);
|
|
135
|
+
* });
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
async likers(id, count, cursor) {
|
|
139
|
+
const resource = Resource_1.EResourceType.TWEET_LIKERS;
|
|
140
|
+
// Fetching raw likers
|
|
141
|
+
const response = await this.request(resource, {
|
|
142
|
+
id: id,
|
|
143
|
+
count: count,
|
|
144
|
+
cursor: cursor,
|
|
145
|
+
});
|
|
146
|
+
// Deserializing response
|
|
147
|
+
const data = Extractors_1.extractors[resource](response);
|
|
148
|
+
return data;
|
|
149
|
+
}
|
|
190
150
|
/**
|
|
191
151
|
* Get the list of tweets from a tweet list.
|
|
192
152
|
*
|
|
@@ -215,28 +175,20 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
215
175
|
*
|
|
216
176
|
* @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
|
|
217
177
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return [4 /*yield*/, this.request(resource, {
|
|
226
|
-
id: id,
|
|
227
|
-
count: count,
|
|
228
|
-
cursor: cursor,
|
|
229
|
-
})];
|
|
230
|
-
case 1:
|
|
231
|
-
response = _a.sent();
|
|
232
|
-
data = Extractors_1.extractors[resource](response);
|
|
233
|
-
// Sorting the tweets by date, from recent to oldest
|
|
234
|
-
data.list.sort(function (a, b) { return new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf(); });
|
|
235
|
-
return [2 /*return*/, data];
|
|
236
|
-
}
|
|
237
|
-
});
|
|
178
|
+
async list(id, count, cursor) {
|
|
179
|
+
const resource = Resource_1.EResourceType.LIST_TWEETS;
|
|
180
|
+
// Fetching raw list tweets
|
|
181
|
+
const response = await this.request(resource, {
|
|
182
|
+
id: id,
|
|
183
|
+
count: count,
|
|
184
|
+
cursor: cursor,
|
|
238
185
|
});
|
|
239
|
-
|
|
186
|
+
// Deserializing response
|
|
187
|
+
const data = Extractors_1.extractors[resource](response);
|
|
188
|
+
// Sorting the tweets by date, from recent to oldest
|
|
189
|
+
data.list.sort((a, b) => new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf());
|
|
190
|
+
return data;
|
|
191
|
+
}
|
|
240
192
|
/**
|
|
241
193
|
* Post a tweet.
|
|
242
194
|
*
|
|
@@ -316,22 +268,50 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
316
268
|
* });
|
|
317
269
|
* ```
|
|
318
270
|
*/
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
271
|
+
async post(options) {
|
|
272
|
+
const resource = Resource_1.EResourceType.TWEET_POST;
|
|
273
|
+
// Posting the tweet
|
|
274
|
+
const response = await this.request(resource, { tweet: options });
|
|
275
|
+
// Deserializing response
|
|
276
|
+
const data = Extractors_1.extractors[resource](response);
|
|
277
|
+
return data;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Get the list of replies to a tweet.
|
|
281
|
+
*
|
|
282
|
+
* @param id - The id of the target tweet.
|
|
283
|
+
* @param cursor - The cursor to the batch of replies to fetch.
|
|
284
|
+
*
|
|
285
|
+
* @returns The list of replies to the given tweet.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```
|
|
289
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
290
|
+
*
|
|
291
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
292
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
293
|
+
*
|
|
294
|
+
* // Fetching the first 100 replies to the Tweet with id '1234567890'
|
|
295
|
+
* rettiwt.tweet.replies('1234567890')
|
|
296
|
+
* .then(res => {
|
|
297
|
+
* console.log(res);
|
|
298
|
+
* })
|
|
299
|
+
* .catch(err => {
|
|
300
|
+
* console.log(err);
|
|
301
|
+
* });
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
async replies(id, cursor) {
|
|
305
|
+
const resource = Resource_1.EResourceType.TWEET_REPLIES;
|
|
306
|
+
// Fetching raw list of replies
|
|
307
|
+
const response = await this.request(resource, {
|
|
308
|
+
id: id,
|
|
309
|
+
cursor: cursor,
|
|
333
310
|
});
|
|
334
|
-
|
|
311
|
+
// Deserializing response
|
|
312
|
+
const data = Extractors_1.extractors[resource](response);
|
|
313
|
+
return data;
|
|
314
|
+
}
|
|
335
315
|
/**
|
|
336
316
|
* Retweet a tweet.
|
|
337
317
|
*
|
|
@@ -356,23 +336,14 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
356
336
|
* });
|
|
357
337
|
* ```
|
|
358
338
|
*/
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
return [4 /*yield*/, this.request(resource, { id: id })];
|
|
368
|
-
case 1:
|
|
369
|
-
response = _b.sent();
|
|
370
|
-
data = (_a = Extractors_1.extractors[resource](response)) !== null && _a !== void 0 ? _a : false;
|
|
371
|
-
return [2 /*return*/, data];
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
};
|
|
339
|
+
async retweet(id) {
|
|
340
|
+
const resource = Resource_1.EResourceType.TWEET_RETWEET;
|
|
341
|
+
// Retweeting the tweet
|
|
342
|
+
const response = await this.request(resource, { id: id });
|
|
343
|
+
// Deserializing response
|
|
344
|
+
const data = Extractors_1.extractors[resource](response) ?? false;
|
|
345
|
+
return data;
|
|
346
|
+
}
|
|
376
347
|
/**
|
|
377
348
|
* Get the list of users who retweeted a tweet.
|
|
378
349
|
*
|
|
@@ -399,26 +370,18 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
399
370
|
* });
|
|
400
371
|
* ```
|
|
401
372
|
*/
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
return [4 /*yield*/, this.request(resource, {
|
|
410
|
-
id: id,
|
|
411
|
-
count: count,
|
|
412
|
-
cursor: cursor,
|
|
413
|
-
})];
|
|
414
|
-
case 1:
|
|
415
|
-
response = _a.sent();
|
|
416
|
-
data = Extractors_1.extractors[resource](response);
|
|
417
|
-
return [2 /*return*/, data];
|
|
418
|
-
}
|
|
419
|
-
});
|
|
373
|
+
async retweeters(id, count, cursor) {
|
|
374
|
+
const resource = Resource_1.EResourceType.TWEET_RETWEETERS;
|
|
375
|
+
// Fetching raw list of retweeters
|
|
376
|
+
const response = await this.request(resource, {
|
|
377
|
+
id: id,
|
|
378
|
+
count: count,
|
|
379
|
+
cursor: cursor,
|
|
420
380
|
});
|
|
421
|
-
|
|
381
|
+
// Deserializing response
|
|
382
|
+
const data = Extractors_1.extractors[resource](response);
|
|
383
|
+
return data;
|
|
384
|
+
}
|
|
422
385
|
/**
|
|
423
386
|
* Schedule a tweet.
|
|
424
387
|
*
|
|
@@ -447,22 +410,14 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
447
410
|
* @remarks
|
|
448
411
|
* Scheduling a tweet is similar to {@link post}ing, except that an extra parameter called `scheduleFor` is used.
|
|
449
412
|
*/
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
case 1:
|
|
459
|
-
response = _a.sent();
|
|
460
|
-
data = Extractors_1.extractors[resource](response);
|
|
461
|
-
return [2 /*return*/, data];
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
});
|
|
465
|
-
};
|
|
413
|
+
async schedule(options) {
|
|
414
|
+
const resource = Resource_1.EResourceType.TWEET_SCHEDULE;
|
|
415
|
+
// Scheduling the tweet
|
|
416
|
+
const response = await this.request(resource, { tweet: options });
|
|
417
|
+
// Deserializing response
|
|
418
|
+
const data = Extractors_1.extractors[resource](response);
|
|
419
|
+
return data;
|
|
420
|
+
}
|
|
466
421
|
/**
|
|
467
422
|
* Search for tweets using a filter.
|
|
468
423
|
*
|
|
@@ -492,29 +447,20 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
492
447
|
*
|
|
493
448
|
* @remarks For details about available filters, refer to {@link TweetFilter}
|
|
494
449
|
*/
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
return [4 /*yield*/, this.request(resource, {
|
|
503
|
-
filter: filter,
|
|
504
|
-
count: count,
|
|
505
|
-
cursor: cursor,
|
|
506
|
-
results: results,
|
|
507
|
-
})];
|
|
508
|
-
case 1:
|
|
509
|
-
response = _a.sent();
|
|
510
|
-
data = Extractors_1.extractors[resource](response);
|
|
511
|
-
// Sorting the tweets by date, from recent to oldest
|
|
512
|
-
data.list.sort(function (a, b) { return new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf(); });
|
|
513
|
-
return [2 /*return*/, data];
|
|
514
|
-
}
|
|
515
|
-
});
|
|
450
|
+
async search(filter, count, cursor) {
|
|
451
|
+
const resource = Resource_1.EResourceType.TWEET_SEARCH;
|
|
452
|
+
// Fetching raw list of filtered tweets
|
|
453
|
+
const response = await this.request(resource, {
|
|
454
|
+
filter: filter,
|
|
455
|
+
count: count,
|
|
456
|
+
cursor: cursor,
|
|
516
457
|
});
|
|
517
|
-
|
|
458
|
+
// Deserializing response
|
|
459
|
+
const data = Extractors_1.extractors[resource](response);
|
|
460
|
+
// Sorting the tweets by date, from recent to oldest
|
|
461
|
+
data.list.sort((a, b) => new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf());
|
|
462
|
+
return data;
|
|
463
|
+
}
|
|
518
464
|
/**
|
|
519
465
|
* Stream tweets in pseudo real-time using a filter.
|
|
520
466
|
*
|
|
@@ -547,61 +493,35 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
547
493
|
* streamTweets();
|
|
548
494
|
* ```
|
|
549
495
|
*/
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
case 6:
|
|
580
|
-
_b.sent();
|
|
581
|
-
_b.label = 7;
|
|
582
|
-
case 7:
|
|
583
|
-
_i++;
|
|
584
|
-
return [3 /*break*/, 4];
|
|
585
|
-
case 8:
|
|
586
|
-
// Store the most recent tweet ID from this batch
|
|
587
|
-
if (tweets.list.length > 0 && cursor === undefined) {
|
|
588
|
-
nextSinceId = tweets.list[0].id;
|
|
589
|
-
}
|
|
590
|
-
// If there are more tweets to fetch, adjust the cursor value
|
|
591
|
-
if (tweets.list.length > 0 && tweets.next) {
|
|
592
|
-
cursor = tweets.next.value;
|
|
593
|
-
}
|
|
594
|
-
// Else, start the next iteration from this batch's most recent tweet
|
|
595
|
-
else {
|
|
596
|
-
sinceId = nextSinceId;
|
|
597
|
-
cursor = undefined;
|
|
598
|
-
}
|
|
599
|
-
return [3 /*break*/, 1];
|
|
600
|
-
case 9: return [2 /*return*/];
|
|
601
|
-
}
|
|
602
|
-
});
|
|
603
|
-
});
|
|
604
|
-
};
|
|
496
|
+
async *stream(filter, pollingInterval = 60000) {
|
|
497
|
+
const startDate = new Date();
|
|
498
|
+
let cursor = undefined;
|
|
499
|
+
let sinceId = undefined;
|
|
500
|
+
let nextSinceId = undefined;
|
|
501
|
+
while (true) {
|
|
502
|
+
// Pause execution for the specified polling interval before proceeding to the next iteration
|
|
503
|
+
await new Promise((resolve) => setTimeout(resolve, pollingInterval));
|
|
504
|
+
// Search for tweets
|
|
505
|
+
const tweets = await this.search({ ...filter, startDate: startDate, sinceId: sinceId }, undefined, cursor);
|
|
506
|
+
// Yield the matching tweets
|
|
507
|
+
for (const tweet of tweets.list) {
|
|
508
|
+
yield tweet;
|
|
509
|
+
}
|
|
510
|
+
// Store the most recent tweet ID from this batch
|
|
511
|
+
if (tweets.list.length > 0 && cursor === undefined) {
|
|
512
|
+
nextSinceId = tweets.list[0].id;
|
|
513
|
+
}
|
|
514
|
+
// If there are more tweets to fetch, adjust the cursor value
|
|
515
|
+
if (tweets.list.length > 0 && tweets.next) {
|
|
516
|
+
cursor = tweets.next;
|
|
517
|
+
}
|
|
518
|
+
// Else, start the next iteration from this batch's most recent tweet
|
|
519
|
+
else {
|
|
520
|
+
sinceId = nextSinceId;
|
|
521
|
+
cursor = undefined;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
605
525
|
/**
|
|
606
526
|
* Unlike a tweet.
|
|
607
527
|
*
|
|
@@ -626,23 +546,14 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
626
546
|
* });
|
|
627
547
|
* ```
|
|
628
548
|
*/
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
return [4 /*yield*/, this.request(resource, { id: id })];
|
|
638
|
-
case 1:
|
|
639
|
-
response = _b.sent();
|
|
640
|
-
data = (_a = Extractors_1.extractors[resource](response)) !== null && _a !== void 0 ? _a : false;
|
|
641
|
-
return [2 /*return*/, data];
|
|
642
|
-
}
|
|
643
|
-
});
|
|
644
|
-
});
|
|
645
|
-
};
|
|
549
|
+
async unlike(id) {
|
|
550
|
+
const resource = Resource_1.EResourceType.TWEET_UNLIKE;
|
|
551
|
+
// Unliking the tweet
|
|
552
|
+
const response = await this.request(resource, { id: id });
|
|
553
|
+
// Deserializing the response
|
|
554
|
+
const data = Extractors_1.extractors[resource](response) ?? false;
|
|
555
|
+
return data;
|
|
556
|
+
}
|
|
646
557
|
/**
|
|
647
558
|
* Unpost a tweet.
|
|
648
559
|
*
|
|
@@ -667,23 +578,14 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
667
578
|
* });
|
|
668
579
|
* ```
|
|
669
580
|
*/
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
return [4 /*yield*/, this.request(resource, { id: id })];
|
|
679
|
-
case 1:
|
|
680
|
-
response = _b.sent();
|
|
681
|
-
data = (_a = Extractors_1.extractors[resource](response)) !== null && _a !== void 0 ? _a : false;
|
|
682
|
-
return [2 /*return*/, data];
|
|
683
|
-
}
|
|
684
|
-
});
|
|
685
|
-
});
|
|
686
|
-
};
|
|
581
|
+
async unpost(id) {
|
|
582
|
+
const resource = Resource_1.EResourceType.TWEET_UNPOST;
|
|
583
|
+
// Unposting the tweet
|
|
584
|
+
const response = await this.request(resource, { id: id });
|
|
585
|
+
// Deserializing the response
|
|
586
|
+
const data = Extractors_1.extractors[resource](response) ?? false;
|
|
587
|
+
return data;
|
|
588
|
+
}
|
|
687
589
|
/**
|
|
688
590
|
* Unretweet a tweet.
|
|
689
591
|
*
|
|
@@ -708,23 +610,14 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
708
610
|
* });
|
|
709
611
|
* ```
|
|
710
612
|
*/
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
return [4 /*yield*/, this.request(resource, { id: id })];
|
|
720
|
-
case 1:
|
|
721
|
-
response = _b.sent();
|
|
722
|
-
data = (_a = Extractors_1.extractors[resource](response)) !== null && _a !== void 0 ? _a : false;
|
|
723
|
-
return [2 /*return*/, data];
|
|
724
|
-
}
|
|
725
|
-
});
|
|
726
|
-
});
|
|
727
|
-
};
|
|
613
|
+
async unretweet(id) {
|
|
614
|
+
const resource = Resource_1.EResourceType.TWEET_UNRETWEET;
|
|
615
|
+
// Unretweeting the tweet
|
|
616
|
+
const response = await this.request(resource, { id: id });
|
|
617
|
+
// Deserializing the response
|
|
618
|
+
const data = Extractors_1.extractors[resource](response) ?? false;
|
|
619
|
+
return data;
|
|
620
|
+
}
|
|
728
621
|
/**
|
|
729
622
|
* Unschedule a tweet.
|
|
730
623
|
*
|
|
@@ -749,23 +642,14 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
749
642
|
* });
|
|
750
643
|
* ```
|
|
751
644
|
*/
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
return [4 /*yield*/, this.request(resource, { id: id })];
|
|
761
|
-
case 1:
|
|
762
|
-
response = _b.sent();
|
|
763
|
-
data = (_a = Extractors_1.extractors[resource](response)) !== null && _a !== void 0 ? _a : false;
|
|
764
|
-
return [2 /*return*/, data];
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
});
|
|
768
|
-
};
|
|
645
|
+
async unschedule(id) {
|
|
646
|
+
const resource = Resource_1.EResourceType.TWEET_UNSCHEDULE;
|
|
647
|
+
// Unscheduling the tweet
|
|
648
|
+
const response = await this.request(resource, { id: id });
|
|
649
|
+
// Deserializing the response
|
|
650
|
+
const data = Extractors_1.extractors[resource](response) ?? false;
|
|
651
|
+
return data;
|
|
652
|
+
}
|
|
769
653
|
/**
|
|
770
654
|
* Upload a media file to Twitter.
|
|
771
655
|
*
|
|
@@ -795,34 +679,18 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
795
679
|
* If not posted in a tweet within this period, the uploaded media is removed.
|
|
796
680
|
* - Instead of a path to the media, an ArrayBuffer containing the media can also be uploaded.
|
|
797
681
|
*/
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
return [4 /*yield*/, this.request(Resource_1.EResourceType.MEDIA_UPLOAD_APPEND, { upload: { id: id, media: media } })];
|
|
812
|
-
case 2:
|
|
813
|
-
// APPEND
|
|
814
|
-
_a.sent();
|
|
815
|
-
// FINALIZE
|
|
816
|
-
return [4 /*yield*/, this.request(Resource_1.EResourceType.MEDIA_UPLOAD_FINALIZE, { upload: { id: id } })];
|
|
817
|
-
case 3:
|
|
818
|
-
// FINALIZE
|
|
819
|
-
_a.sent();
|
|
820
|
-
return [2 /*return*/, id];
|
|
821
|
-
}
|
|
822
|
-
});
|
|
823
|
-
});
|
|
824
|
-
};
|
|
825
|
-
return TweetService;
|
|
826
|
-
}(FetcherService_1.FetcherService));
|
|
682
|
+
async upload(media) {
|
|
683
|
+
// INITIALIZE
|
|
684
|
+
const size = typeof media == 'string' ? (0, fs_1.statSync)(media).size : media.byteLength;
|
|
685
|
+
const id = (await this.request(Resource_1.EResourceType.MEDIA_UPLOAD_INITIALIZE, {
|
|
686
|
+
upload: { size: size },
|
|
687
|
+
})).media_id_string;
|
|
688
|
+
// APPEND
|
|
689
|
+
await this.request(Resource_1.EResourceType.MEDIA_UPLOAD_APPEND, { upload: { id: id, media: media } });
|
|
690
|
+
// FINALIZE
|
|
691
|
+
await this.request(Resource_1.EResourceType.MEDIA_UPLOAD_FINALIZE, { upload: { id: id } });
|
|
692
|
+
return id;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
827
695
|
exports.TweetService = TweetService;
|
|
828
696
|
//# sourceMappingURL=TweetService.js.map
|