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,31 +1,30 @@
|
|
|
1
1
|
import { statSync } from 'fs';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
ESearchResultType,
|
|
5
|
-
IInitializeMediaUploadResponse,
|
|
6
|
-
IListTweetsResponse,
|
|
7
|
-
ITweetDetailsResponse,
|
|
8
|
-
ITweetLikeResponse,
|
|
9
|
-
ITweetPostResponse,
|
|
10
|
-
ITweetRepliesResponse,
|
|
11
|
-
ITweetRetweetersResponse,
|
|
12
|
-
ITweetRetweetResponse,
|
|
13
|
-
ITweetScheduleResponse,
|
|
14
|
-
ITweetSearchResponse,
|
|
15
|
-
ITweetUnlikeResponse,
|
|
16
|
-
ITweetUnpostResponse,
|
|
17
|
-
ITweetUnretweetResponse,
|
|
18
|
-
ITweetUnscheduleResponse,
|
|
19
|
-
TweetFilter,
|
|
20
|
-
} from 'rettiwt-core';
|
|
21
|
-
|
|
22
3
|
import { extractors } from '../../collections/Extractors';
|
|
23
4
|
import { EResourceType } from '../../enums/Resource';
|
|
24
|
-
import { TweetArgs } from '../../models/args/PostArgs';
|
|
25
5
|
import { CursoredData } from '../../models/data/CursoredData';
|
|
26
6
|
import { Tweet } from '../../models/data/Tweet';
|
|
27
7
|
import { User } from '../../models/data/User';
|
|
28
|
-
|
|
8
|
+
|
|
9
|
+
import { RettiwtConfig } from '../../models/RettiwtConfig';
|
|
10
|
+
import { ITweetFilter } from '../../types/args/FetchArgs';
|
|
11
|
+
import { INewTweet } from '../../types/args/PostArgs';
|
|
12
|
+
import { IListTweetsResponse } from '../../types/raw/list/Tweets';
|
|
13
|
+
import { IMediaInitializeUploadResponse } from '../../types/raw/media/InitalizeUpload';
|
|
14
|
+
import { ITweetDetailsResponse } from '../../types/raw/tweet/Details';
|
|
15
|
+
|
|
16
|
+
import { ITweetLikeResponse } from '../../types/raw/tweet/Like';
|
|
17
|
+
import { ITweetLikersResponse } from '../../types/raw/tweet/Likers';
|
|
18
|
+
import { ITweetPostResponse } from '../../types/raw/tweet/Post';
|
|
19
|
+
import { ITweetRepliesResponse } from '../../types/raw/tweet/Replies';
|
|
20
|
+
import { ITweetRetweetResponse } from '../../types/raw/tweet/Retweet';
|
|
21
|
+
import { ITweetRetweetersResponse } from '../../types/raw/tweet/Retweeters';
|
|
22
|
+
import { ITweetScheduleResponse } from '../../types/raw/tweet/Schedule';
|
|
23
|
+
import { ITweetSearchResponse } from '../../types/raw/tweet/Search';
|
|
24
|
+
import { ITweetUnlikeResponse } from '../../types/raw/tweet/Unlike';
|
|
25
|
+
import { ITweetUnpostResponse } from '../../types/raw/tweet/Unpost';
|
|
26
|
+
import { ITweetUnretweetResponse } from '../../types/raw/tweet/Unretweet';
|
|
27
|
+
import { ITweetUnscheduleResponse } from '../../types/raw/tweet/Unschedule';
|
|
29
28
|
|
|
30
29
|
import { FetcherService } from './FetcherService';
|
|
31
30
|
|
|
@@ -40,14 +39,14 @@ export class TweetService extends FetcherService {
|
|
|
40
39
|
*
|
|
41
40
|
* @internal
|
|
42
41
|
*/
|
|
43
|
-
public constructor(config
|
|
42
|
+
public constructor(config: RettiwtConfig) {
|
|
44
43
|
super(config);
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
/**
|
|
48
47
|
* Get the details of a tweet.
|
|
49
48
|
*
|
|
50
|
-
* @param id - The id of the target tweet.
|
|
49
|
+
* @param id - The id(s) of the target tweet/tweets.
|
|
51
50
|
*
|
|
52
51
|
* @returns
|
|
53
52
|
* The details of the tweet with the given id.
|
|
@@ -70,11 +69,11 @@ export class TweetService extends FetcherService {
|
|
|
70
69
|
* });
|
|
71
70
|
* ```
|
|
72
71
|
*/
|
|
73
|
-
public async details(id:
|
|
72
|
+
public async details<T extends string | string[]>(id: T): Promise<T extends string ? Tweet | undefined : Tweet[]> {
|
|
74
73
|
let resource: EResourceType;
|
|
75
74
|
|
|
76
|
-
// If user is authenticated
|
|
77
|
-
if (this.userId != undefined) {
|
|
75
|
+
// If user is authenticated and details of single tweet required
|
|
76
|
+
if (this.config.userId != undefined && typeof id == 'string') {
|
|
78
77
|
resource = EResourceType.TWEET_DETAILS_ALT;
|
|
79
78
|
|
|
80
79
|
// Fetching raw tweet details
|
|
@@ -83,19 +82,31 @@ export class TweetService extends FetcherService {
|
|
|
83
82
|
// Deserializing response
|
|
84
83
|
const data = extractors[resource](response, id);
|
|
85
84
|
|
|
86
|
-
return data;
|
|
85
|
+
return data as T extends string ? Tweet | undefined : Tweet[];
|
|
86
|
+
}
|
|
87
|
+
// If user is authenticated and details of multiple tweets required
|
|
88
|
+
else if (this.config.userId != undefined && Array.isArray(id)) {
|
|
89
|
+
resource = EResourceType.TWEET_DETAILS_BULK;
|
|
90
|
+
|
|
91
|
+
// Fetching raw tweet details
|
|
92
|
+
const response = await this.request<ITweetRepliesResponse>(resource, { ids: id });
|
|
93
|
+
|
|
94
|
+
// Deserializing response
|
|
95
|
+
const data = extractors[resource](response, id);
|
|
96
|
+
|
|
97
|
+
return data as T extends string ? Tweet | undefined : Tweet[];
|
|
87
98
|
}
|
|
88
99
|
// If user is not authenticated
|
|
89
100
|
else {
|
|
90
101
|
resource = EResourceType.TWEET_DETAILS;
|
|
91
102
|
|
|
92
103
|
// Fetching raw tweet details
|
|
93
|
-
const response = await this.request<ITweetDetailsResponse>(resource, { id: id });
|
|
104
|
+
const response = await this.request<ITweetDetailsResponse>(resource, { id: String(id) });
|
|
94
105
|
|
|
95
106
|
// Deserializing response
|
|
96
|
-
const data = extractors[resource](response, id);
|
|
107
|
+
const data = extractors[resource](response, String(id));
|
|
97
108
|
|
|
98
|
-
return data;
|
|
109
|
+
return data as T extends string ? Tweet | undefined : Tweet[];
|
|
99
110
|
}
|
|
100
111
|
}
|
|
101
112
|
|
|
@@ -137,6 +148,48 @@ export class TweetService extends FetcherService {
|
|
|
137
148
|
return data;
|
|
138
149
|
}
|
|
139
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Get the list of users who liked a tweet. Only works for your own tweets.
|
|
153
|
+
*
|
|
154
|
+
* @param id - The id of the target tweet.
|
|
155
|
+
* @param count - The number of likers to fetch, must be \<= 100.
|
|
156
|
+
* @param cursor - The cursor to the batch of likers to fetch.
|
|
157
|
+
*
|
|
158
|
+
* @returns The list of users who liked the given tweet.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```
|
|
162
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
163
|
+
*
|
|
164
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
165
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
166
|
+
*
|
|
167
|
+
* // Fetching the most recent 100 likers of the Tweet with id '1234567890'
|
|
168
|
+
* rettiwt.tweet.likers('1234567890')
|
|
169
|
+
* .then(res => {
|
|
170
|
+
* console.log(res);
|
|
171
|
+
* })
|
|
172
|
+
* .catch(err => {
|
|
173
|
+
* console.log(err);
|
|
174
|
+
* });
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
public async likers(id: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
178
|
+
const resource = EResourceType.TWEET_LIKERS;
|
|
179
|
+
|
|
180
|
+
// Fetching raw likers
|
|
181
|
+
const response = await this.request<ITweetLikersResponse>(resource, {
|
|
182
|
+
id: id,
|
|
183
|
+
count: count,
|
|
184
|
+
cursor: cursor,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Deserializing response
|
|
188
|
+
const data = extractors[resource](response);
|
|
189
|
+
|
|
190
|
+
return data;
|
|
191
|
+
}
|
|
192
|
+
|
|
140
193
|
/**
|
|
141
194
|
* Get the list of tweets from a tweet list.
|
|
142
195
|
*
|
|
@@ -263,7 +316,7 @@ export class TweetService extends FetcherService {
|
|
|
263
316
|
* });
|
|
264
317
|
* ```
|
|
265
318
|
*/
|
|
266
|
-
public async post(options:
|
|
319
|
+
public async post(options: INewTweet): Promise<string | undefined> {
|
|
267
320
|
const resource = EResourceType.TWEET_POST;
|
|
268
321
|
|
|
269
322
|
// Posting the tweet
|
|
@@ -275,6 +328,46 @@ export class TweetService extends FetcherService {
|
|
|
275
328
|
return data;
|
|
276
329
|
}
|
|
277
330
|
|
|
331
|
+
/**
|
|
332
|
+
* Get the list of replies to a tweet.
|
|
333
|
+
*
|
|
334
|
+
* @param id - The id of the target tweet.
|
|
335
|
+
* @param cursor - The cursor to the batch of replies to fetch.
|
|
336
|
+
*
|
|
337
|
+
* @returns The list of replies to the given tweet.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```
|
|
341
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
342
|
+
*
|
|
343
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
344
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
345
|
+
*
|
|
346
|
+
* // Fetching the first 100 replies to the Tweet with id '1234567890'
|
|
347
|
+
* rettiwt.tweet.replies('1234567890')
|
|
348
|
+
* .then(res => {
|
|
349
|
+
* console.log(res);
|
|
350
|
+
* })
|
|
351
|
+
* .catch(err => {
|
|
352
|
+
* console.log(err);
|
|
353
|
+
* });
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
356
|
+
public async replies(id: string, cursor?: string): Promise<CursoredData<Tweet>> {
|
|
357
|
+
const resource = EResourceType.TWEET_REPLIES;
|
|
358
|
+
|
|
359
|
+
// Fetching raw list of replies
|
|
360
|
+
const response = await this.request<ITweetDetailsResponse>(resource, {
|
|
361
|
+
id: id,
|
|
362
|
+
cursor: cursor,
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
// Deserializing response
|
|
366
|
+
const data = extractors[resource](response);
|
|
367
|
+
|
|
368
|
+
return data;
|
|
369
|
+
}
|
|
370
|
+
|
|
278
371
|
/**
|
|
279
372
|
* Retweet a tweet.
|
|
280
373
|
*
|
|
@@ -381,7 +474,7 @@ export class TweetService extends FetcherService {
|
|
|
381
474
|
* @remarks
|
|
382
475
|
* Scheduling a tweet is similar to {@link post}ing, except that an extra parameter called `scheduleFor` is used.
|
|
383
476
|
*/
|
|
384
|
-
public async schedule(options:
|
|
477
|
+
public async schedule(options: INewTweet): Promise<string | undefined> {
|
|
385
478
|
const resource = EResourceType.TWEET_SCHEDULE;
|
|
386
479
|
|
|
387
480
|
// Scheduling the tweet
|
|
@@ -422,12 +515,7 @@ export class TweetService extends FetcherService {
|
|
|
422
515
|
*
|
|
423
516
|
* @remarks For details about available filters, refer to {@link TweetFilter}
|
|
424
517
|
*/
|
|
425
|
-
public async search(
|
|
426
|
-
filter: TweetFilter,
|
|
427
|
-
count?: number,
|
|
428
|
-
cursor?: string,
|
|
429
|
-
results?: ESearchResultType,
|
|
430
|
-
): Promise<CursoredData<Tweet>> {
|
|
518
|
+
public async search(filter: ITweetFilter, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
|
|
431
519
|
const resource = EResourceType.TWEET_SEARCH;
|
|
432
520
|
|
|
433
521
|
// Fetching raw list of filtered tweets
|
|
@@ -435,7 +523,6 @@ export class TweetService extends FetcherService {
|
|
|
435
523
|
filter: filter,
|
|
436
524
|
count: count,
|
|
437
525
|
cursor: cursor,
|
|
438
|
-
results: results,
|
|
439
526
|
});
|
|
440
527
|
|
|
441
528
|
// Deserializing response
|
|
@@ -479,7 +566,7 @@ export class TweetService extends FetcherService {
|
|
|
479
566
|
* streamTweets();
|
|
480
567
|
* ```
|
|
481
568
|
*/
|
|
482
|
-
public async *stream(filter:
|
|
569
|
+
public async *stream(filter: ITweetFilter, pollingInterval = 60000): AsyncGenerator<Tweet> {
|
|
483
570
|
const startDate = new Date();
|
|
484
571
|
|
|
485
572
|
let cursor: string | undefined = undefined;
|
|
@@ -505,7 +592,7 @@ export class TweetService extends FetcherService {
|
|
|
505
592
|
|
|
506
593
|
// If there are more tweets to fetch, adjust the cursor value
|
|
507
594
|
if (tweets.list.length > 0 && tweets.next) {
|
|
508
|
-
cursor = tweets.next
|
|
595
|
+
cursor = tweets.next;
|
|
509
596
|
}
|
|
510
597
|
// Else, start the next iteration from this batch's most recent tweet
|
|
511
598
|
else {
|
|
@@ -692,7 +779,7 @@ export class TweetService extends FetcherService {
|
|
|
692
779
|
// INITIALIZE
|
|
693
780
|
const size = typeof media == 'string' ? statSync(media).size : media.byteLength;
|
|
694
781
|
const id: string = (
|
|
695
|
-
await this.request<
|
|
782
|
+
await this.request<IMediaInitializeUploadResponse>(EResourceType.MEDIA_UPLOAD_INITIALIZE, {
|
|
696
783
|
upload: { size: size },
|
|
697
784
|
})
|
|
698
785
|
).media_id_string;
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IUserBookmarksResponse,
|
|
3
|
-
IUserDetailsResponse,
|
|
4
|
-
IUserFollowedResponse,
|
|
5
|
-
IUserFollowersResponse,
|
|
6
|
-
IUserFollowingResponse,
|
|
7
|
-
IUserFollowResponse,
|
|
8
|
-
IUserHighlightsResponse,
|
|
9
|
-
IUserLikesResponse,
|
|
10
|
-
IUserMediaResponse,
|
|
11
|
-
IUserNotificationsResponse,
|
|
12
|
-
IUserRecommendedResponse,
|
|
13
|
-
IUserSubscriptionsResponse,
|
|
14
|
-
IUserTweetsAndRepliesResponse,
|
|
15
|
-
IUserTweetsResponse,
|
|
16
|
-
IUserUnfollowResponse,
|
|
17
|
-
} from 'rettiwt-core';
|
|
18
|
-
|
|
19
1
|
import { extractors } from '../../collections/Extractors';
|
|
20
2
|
import { EResourceType } from '../../enums/Resource';
|
|
21
3
|
import { CursoredData } from '../../models/data/CursoredData';
|
|
22
4
|
import { Notification } from '../../models/data/Notification';
|
|
23
5
|
import { Tweet } from '../../models/data/Tweet';
|
|
24
6
|
import { User } from '../../models/data/User';
|
|
25
|
-
import {
|
|
7
|
+
import { RettiwtConfig } from '../../models/RettiwtConfig';
|
|
8
|
+
import { IUserBookmarksResponse } from '../../types/raw/user/Bookmarks';
|
|
9
|
+
import { IUserDetailsResponse } from '../../types/raw/user/Details';
|
|
10
|
+
import { IUserFollowResponse } from '../../types/raw/user/Follow';
|
|
11
|
+
import { IUserFollowedResponse } from '../../types/raw/user/Followed';
|
|
12
|
+
import { IUserFollowersResponse } from '../../types/raw/user/Followers';
|
|
13
|
+
import { IUserFollowingResponse } from '../../types/raw/user/Following';
|
|
14
|
+
import { IUserHighlightsResponse } from '../../types/raw/user/Highlights';
|
|
15
|
+
import { IUserLikesResponse } from '../../types/raw/user/Likes';
|
|
16
|
+
import { IUserMediaResponse } from '../../types/raw/user/Media';
|
|
17
|
+
import { IUserNotificationsResponse } from '../../types/raw/user/Notifications';
|
|
18
|
+
import { IUserRecommendedResponse } from '../../types/raw/user/Recommended';
|
|
19
|
+
import { IUserSubscriptionsResponse } from '../../types/raw/user/Subscriptions';
|
|
20
|
+
import { IUserTweetsResponse } from '../../types/raw/user/Tweets';
|
|
21
|
+
import { IUserTweetsAndRepliesResponse } from '../../types/raw/user/TweetsAndReplies';
|
|
22
|
+
import { IUserUnfollowResponse } from '../../types/raw/user/Unfollow';
|
|
26
23
|
|
|
27
24
|
import { FetcherService } from './FetcherService';
|
|
28
25
|
|
|
@@ -37,7 +34,7 @@ export class UserService extends FetcherService {
|
|
|
37
34
|
*
|
|
38
35
|
* @internal
|
|
39
36
|
*/
|
|
40
|
-
public constructor(config
|
|
37
|
+
public constructor(config: RettiwtConfig) {
|
|
41
38
|
super(config);
|
|
42
39
|
}
|
|
43
40
|
|
|
@@ -84,7 +81,7 @@ export class UserService extends FetcherService {
|
|
|
84
81
|
/**
|
|
85
82
|
* Get the details of a user.
|
|
86
83
|
*
|
|
87
|
-
* @param id - The username/id of the target user.
|
|
84
|
+
* @param id - The username/id(s) of the target user/users.
|
|
88
85
|
*
|
|
89
86
|
* @returns
|
|
90
87
|
* The details of the given user.
|
|
@@ -126,25 +123,40 @@ export class UserService extends FetcherService {
|
|
|
126
123
|
* });
|
|
127
124
|
* ```
|
|
128
125
|
*/
|
|
129
|
-
public async details(id:
|
|
126
|
+
public async details<T extends string | string[]>(id: T): Promise<T extends string ? User | undefined : User[]> {
|
|
130
127
|
let resource: EResourceType;
|
|
131
128
|
|
|
132
|
-
// If
|
|
133
|
-
if (
|
|
134
|
-
resource = EResourceType.
|
|
129
|
+
// If details of multiple users required
|
|
130
|
+
if (Array.isArray(id)) {
|
|
131
|
+
resource = EResourceType.USER_DETAILS_BY_IDS_BULK;
|
|
132
|
+
|
|
133
|
+
// Fetching raw details
|
|
134
|
+
const response = await this.request<IUserDetailsResponse>(resource, { ids: id });
|
|
135
|
+
|
|
136
|
+
// Deserializing response
|
|
137
|
+
const data = extractors[resource](response, id);
|
|
138
|
+
|
|
139
|
+
return data as T extends string ? User | undefined : User[];
|
|
135
140
|
}
|
|
136
|
-
// If
|
|
141
|
+
// If details of single user required
|
|
137
142
|
else {
|
|
138
|
-
|
|
139
|
-
|
|
143
|
+
// If username is given
|
|
144
|
+
if (isNaN(Number(id))) {
|
|
145
|
+
resource = EResourceType.USER_DETAILS_BY_USERNAME;
|
|
146
|
+
}
|
|
147
|
+
// If id is given
|
|
148
|
+
else {
|
|
149
|
+
resource = EResourceType.USER_DETAILS_BY_ID;
|
|
150
|
+
}
|
|
140
151
|
|
|
141
|
-
|
|
142
|
-
|
|
152
|
+
// Fetching raw details
|
|
153
|
+
const response = await this.request<IUserDetailsResponse>(resource, { id: id });
|
|
143
154
|
|
|
144
|
-
|
|
145
|
-
|
|
155
|
+
// Deserializing response
|
|
156
|
+
const data = extractors[resource](response);
|
|
146
157
|
|
|
147
|
-
|
|
158
|
+
return data as T extends string ? User | undefined : User[];
|
|
159
|
+
}
|
|
148
160
|
}
|
|
149
161
|
|
|
150
162
|
/**
|
|
@@ -381,7 +393,7 @@ export class UserService extends FetcherService {
|
|
|
381
393
|
|
|
382
394
|
// Fetching raw list of likes
|
|
383
395
|
const response = await this.request<IUserLikesResponse>(resource, {
|
|
384
|
-
id: this.userId,
|
|
396
|
+
id: this.config.userId,
|
|
385
397
|
count: count,
|
|
386
398
|
cursor: cursor,
|
|
387
399
|
});
|
|
@@ -465,11 +477,11 @@ export class UserService extends FetcherService {
|
|
|
465
477
|
* streamNotifications();
|
|
466
478
|
* ```
|
|
467
479
|
*/
|
|
468
|
-
public async *notifications(pollingInterval
|
|
480
|
+
public async *notifications(pollingInterval = 60000): AsyncGenerator<Notification> {
|
|
469
481
|
const resource = EResourceType.USER_NOTIFICATIONS;
|
|
470
482
|
|
|
471
483
|
/** Whether it's the first batch of notifications or not. */
|
|
472
|
-
let first
|
|
484
|
+
let first = true;
|
|
473
485
|
|
|
474
486
|
/** The cursor to the last notification received. */
|
|
475
487
|
let cursor: string | undefined = undefined;
|
|
@@ -502,7 +514,7 @@ export class UserService extends FetcherService {
|
|
|
502
514
|
first = false;
|
|
503
515
|
}
|
|
504
516
|
|
|
505
|
-
cursor = notifications.next
|
|
517
|
+
cursor = notifications.next;
|
|
506
518
|
}
|
|
507
519
|
}
|
|
508
520
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ITidProvider } from './auth/TidProvider';
|
|
1
2
|
import { IErrorHandler } from './ErrorHandler';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -9,9 +10,6 @@ export interface IRettiwtConfig {
|
|
|
9
10
|
/** The apiKey (cookie) to use for authenticating Rettiwt against Twitter API. */
|
|
10
11
|
apiKey?: string;
|
|
11
12
|
|
|
12
|
-
/** The guestKey (guest token) to use for guest access to Twitter API. */
|
|
13
|
-
guestKey?: string;
|
|
14
|
-
|
|
15
13
|
/**
|
|
16
14
|
* Optional URL to proxy server to use for requests to Twitter API.
|
|
17
15
|
*
|
|
@@ -19,15 +17,6 @@ export interface IRettiwtConfig {
|
|
|
19
17
|
*/
|
|
20
18
|
proxyUrl?: URL;
|
|
21
19
|
|
|
22
|
-
/**
|
|
23
|
-
* Optional URL to proxy server to use for authentication against Twitter API.
|
|
24
|
-
*
|
|
25
|
-
* @remarks Required when deploying to cloud platforms to bypass Error 429.
|
|
26
|
-
*
|
|
27
|
-
* @defaultValue Same as {@link IRettiwtConfig.proxyUrl}
|
|
28
|
-
*/
|
|
29
|
-
authProxyUrl?: URL;
|
|
30
|
-
|
|
31
20
|
/** The max wait time (in milli-seconds) for a response; if not set, Twitter server timeout is used. */
|
|
32
21
|
timeout?: number;
|
|
33
22
|
|
|
@@ -36,4 +25,21 @@ export interface IRettiwtConfig {
|
|
|
36
25
|
|
|
37
26
|
/** Optional custom error handler to define error conditions and process API/HTTP errors in responses. */
|
|
38
27
|
errorHandler?: IErrorHandler;
|
|
28
|
+
|
|
29
|
+
/** Optional custom `x-client-transaction-id` header provider. */
|
|
30
|
+
tidProvider?: ITidProvider;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Optional custom HTTP headers to add to all requests to Twitter API.
|
|
34
|
+
*
|
|
35
|
+
* @remarks Custom headers can be useful for proxies, avoiding rate limits, etc.
|
|
36
|
+
*/
|
|
37
|
+
headers?: { [key: string]: string };
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The delay (in ms) to use between concurrent request.
|
|
41
|
+
*
|
|
42
|
+
* Can either be a number or a function that returns a number synchronously or asynchronously.
|
|
43
|
+
*/
|
|
44
|
+
delay?: number | (() => number | Promise<number>);
|
|
39
45
|
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options specifying the data that is to be fetched.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface IFetchArgs {
|
|
7
|
+
/**
|
|
8
|
+
* The number of data items to fetch.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* - Works only for cursored resources.
|
|
12
|
+
* - Does not work for {@link EResourceType.TWEET_REPLIES}.
|
|
13
|
+
* - Must be \<= 20 for:
|
|
14
|
+
* - {@link EResourceType.USER_TIMELINE}
|
|
15
|
+
* - {@link EResourceType.USER_TIMELINE}
|
|
16
|
+
* - {@link EResourceType.USER_TIMELINE_AND_REPLIES}
|
|
17
|
+
* - Must be \<= 100 for all other cursored resources.
|
|
18
|
+
* - Due a bug on Twitter's end, count does not work for {@link EResourceType.USER_FOLLOWERS} and {@link EResourceType.USER_FOLLOWING}.
|
|
19
|
+
* - Has not effect for:
|
|
20
|
+
* - {@link EResourceType.USER_FEED_FOLLOWED}
|
|
21
|
+
* - {@link EResourceType.USER_FEED_RECOMMENDED}
|
|
22
|
+
*/
|
|
23
|
+
count?: number;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The cursor to the batch of data to fetch.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* - May be used for cursored resources.
|
|
30
|
+
* - Has no effect for other resources.
|
|
31
|
+
*/
|
|
32
|
+
cursor?: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The filter for searching tweets.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* Required when searching for tweets using {@link EResourceType.TWEET_SEARCH}.
|
|
39
|
+
*/
|
|
40
|
+
filter?: ITweetFilter;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The id of the target resource.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* - Required for all resources except {@link EResourceType.TWEET_SEARCH} and {@link EResourceType.USER_TIMELINE_RECOMMENDED}.
|
|
47
|
+
* - For {@link EResourceType.USER_DETAILS_BY_USERNAME}, can be alphanumeric, while for others, is strictly numeric.
|
|
48
|
+
*/
|
|
49
|
+
id?: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The IDs of the target resources.
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* - Required only for {@link EResourceType.TWEET_DETAILS_BULK} and {@link EResourceType.USER_DETAILS_BY_IDS_BULK}.
|
|
56
|
+
*/
|
|
57
|
+
ids?: string[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The filter to be used for searching tweets.
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export interface ITweetFilter {
|
|
66
|
+
/** The date upto which tweets are to be searched. */
|
|
67
|
+
endDate?: Date;
|
|
68
|
+
|
|
69
|
+
/** The list of words to exclude from search. */
|
|
70
|
+
excludeWords?: string[];
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The list of usernames whose tweets are to be searched.
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* '\@' must be excluded from the username!
|
|
77
|
+
*/
|
|
78
|
+
fromUsers?: string[];
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The list of hashtags to search.
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* '#' must be excluded from the hashtag!
|
|
85
|
+
*/
|
|
86
|
+
hashtags?: string[];
|
|
87
|
+
|
|
88
|
+
/** The exact phrase to search. */
|
|
89
|
+
includePhrase?: string;
|
|
90
|
+
|
|
91
|
+
/** The list of words to search. */
|
|
92
|
+
includeWords?: string[];
|
|
93
|
+
|
|
94
|
+
/** The language of the tweets to search. */
|
|
95
|
+
language?: string;
|
|
96
|
+
|
|
97
|
+
/** Whether to fetch tweets that are links or not. */
|
|
98
|
+
links?: boolean;
|
|
99
|
+
|
|
100
|
+
/** The list from which tweets are to be searched. */
|
|
101
|
+
list?: string;
|
|
102
|
+
|
|
103
|
+
/** The id of the tweet, before which the tweets are to be searched. */
|
|
104
|
+
maxId?: string;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The list of username mentioned in the tweets to search.
|
|
108
|
+
*
|
|
109
|
+
* @remarks
|
|
110
|
+
* '\@' must be excluded from the username!
|
|
111
|
+
*/
|
|
112
|
+
mentions?: string[];
|
|
113
|
+
|
|
114
|
+
/** The minimun number of likes to search by. */
|
|
115
|
+
minLikes?: number;
|
|
116
|
+
|
|
117
|
+
/** The minimum number of replies to search by. */
|
|
118
|
+
minReplies?: number;
|
|
119
|
+
|
|
120
|
+
/** The minimum number of retweets to search by. */
|
|
121
|
+
minRetweets?: number;
|
|
122
|
+
|
|
123
|
+
/** The optional words to search. */
|
|
124
|
+
optionalWords?: string[];
|
|
125
|
+
|
|
126
|
+
/** The id of the tweet which is quoted in the tweets to search. */
|
|
127
|
+
quoted?: string;
|
|
128
|
+
|
|
129
|
+
/** Whether to fetch tweets that are replies or not. */
|
|
130
|
+
replies?: boolean;
|
|
131
|
+
|
|
132
|
+
/** The id of the tweet, after which the tweets are to be searched. */
|
|
133
|
+
sinceId?: string;
|
|
134
|
+
|
|
135
|
+
/** The date starting from which tweets are to be searched. */
|
|
136
|
+
startDate?: Date;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The list of username to whom the tweets to be searched, are adressed.
|
|
140
|
+
*
|
|
141
|
+
* @remarks
|
|
142
|
+
* '\@' must be excluded from the username!
|
|
143
|
+
*/
|
|
144
|
+
toUsers?: string[];
|
|
145
|
+
|
|
146
|
+
/** Whether to fetch top tweets or not. */
|
|
147
|
+
top?: boolean;
|
|
148
|
+
}
|