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,311 +1,86 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ArrayMaxSize,
|
|
3
|
-
IsArray,
|
|
4
|
-
IsDate,
|
|
5
|
-
IsEmpty,
|
|
6
|
-
IsNotEmpty,
|
|
7
|
-
IsNumberString,
|
|
8
|
-
IsObject,
|
|
9
|
-
IsOptional,
|
|
10
|
-
IsString,
|
|
11
|
-
Max,
|
|
12
|
-
MaxLength,
|
|
13
|
-
MinDate,
|
|
14
|
-
validateSync,
|
|
15
|
-
} from 'class-validator';
|
|
16
|
-
|
|
17
|
-
import { NewTweet, NewTweetMedia } from 'rettiwt-core';
|
|
18
|
-
|
|
19
1
|
import { EResourceType } from '../../enums/Resource';
|
|
20
|
-
import {
|
|
2
|
+
import { INewTweet, INewTweetMedia, IPostArgs, IUploadArgs } from '../../types/args/PostArgs';
|
|
21
3
|
|
|
22
4
|
/**
|
|
23
5
|
* Options specifying the data that is to be posted.
|
|
24
6
|
*
|
|
25
7
|
* @public
|
|
26
8
|
*/
|
|
27
|
-
export class PostArgs {
|
|
28
|
-
/**
|
|
29
|
-
* The id of the target resource.
|
|
30
|
-
*
|
|
31
|
-
* @remarks
|
|
32
|
-
* Required only when posting using the following resources:
|
|
33
|
-
* - {@link EResourceType.TWEET_LIKE}
|
|
34
|
-
* - {@link EResourceType.TWEET_RETWEET}
|
|
35
|
-
* - {@link EResourceType.TWEET_UNLIKE}
|
|
36
|
-
* - {@link EResourceType.TWEET_UNPOST}
|
|
37
|
-
* - {@link EResourceType.TWEET_UNRETWEET}
|
|
38
|
-
* - {@link EResourceType.USER_FOLLOW}
|
|
39
|
-
* - {@link EResourceType.USER_UNFOLLOW}
|
|
40
|
-
*/
|
|
41
|
-
@IsEmpty({
|
|
42
|
-
groups: [
|
|
43
|
-
EResourceType.MEDIA_UPLOAD_APPEND,
|
|
44
|
-
EResourceType.MEDIA_UPLOAD_FINALIZE,
|
|
45
|
-
EResourceType.MEDIA_UPLOAD_INITIALIZE,
|
|
46
|
-
EResourceType.TWEET_POST,
|
|
47
|
-
EResourceType.TWEET_SCHEDULE,
|
|
48
|
-
],
|
|
49
|
-
})
|
|
50
|
-
@IsNotEmpty({
|
|
51
|
-
groups: [
|
|
52
|
-
EResourceType.TWEET_LIKE,
|
|
53
|
-
EResourceType.TWEET_RETWEET,
|
|
54
|
-
EResourceType.TWEET_UNLIKE,
|
|
55
|
-
EResourceType.TWEET_UNPOST,
|
|
56
|
-
EResourceType.TWEET_UNRETWEET,
|
|
57
|
-
EResourceType.TWEET_UNSCHEDULE,
|
|
58
|
-
EResourceType.USER_FOLLOW,
|
|
59
|
-
EResourceType.USER_UNFOLLOW,
|
|
60
|
-
],
|
|
61
|
-
})
|
|
62
|
-
@IsNumberString(undefined, {
|
|
63
|
-
groups: [
|
|
64
|
-
EResourceType.TWEET_LIKE,
|
|
65
|
-
EResourceType.TWEET_RETWEET,
|
|
66
|
-
EResourceType.TWEET_UNLIKE,
|
|
67
|
-
EResourceType.TWEET_UNPOST,
|
|
68
|
-
EResourceType.TWEET_UNRETWEET,
|
|
69
|
-
EResourceType.TWEET_UNSCHEDULE,
|
|
70
|
-
EResourceType.USER_FOLLOW,
|
|
71
|
-
EResourceType.USER_UNFOLLOW,
|
|
72
|
-
],
|
|
73
|
-
})
|
|
9
|
+
export class PostArgs implements IPostArgs {
|
|
74
10
|
public id?: string;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* The tweet that is to be posted.
|
|
78
|
-
*
|
|
79
|
-
* @remarks
|
|
80
|
-
* Required only when posting a tweet using {@link EResourceType.TWEET_POST}
|
|
81
|
-
*/
|
|
82
|
-
@IsEmpty({
|
|
83
|
-
groups: [
|
|
84
|
-
EResourceType.MEDIA_UPLOAD_APPEND,
|
|
85
|
-
EResourceType.MEDIA_UPLOAD_FINALIZE,
|
|
86
|
-
EResourceType.MEDIA_UPLOAD_INITIALIZE,
|
|
87
|
-
EResourceType.TWEET_LIKE,
|
|
88
|
-
EResourceType.TWEET_RETWEET,
|
|
89
|
-
EResourceType.TWEET_UNLIKE,
|
|
90
|
-
EResourceType.TWEET_UNPOST,
|
|
91
|
-
EResourceType.TWEET_UNRETWEET,
|
|
92
|
-
EResourceType.TWEET_UNSCHEDULE,
|
|
93
|
-
EResourceType.USER_FOLLOW,
|
|
94
|
-
EResourceType.USER_UNFOLLOW,
|
|
95
|
-
],
|
|
96
|
-
})
|
|
97
|
-
@IsNotEmpty({ groups: [EResourceType.TWEET_POST, EResourceType.TWEET_SCHEDULE] })
|
|
98
|
-
@IsObject({ groups: [EResourceType.TWEET_POST, EResourceType.TWEET_SCHEDULE] })
|
|
99
|
-
public tweet?: TweetArgs;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The media file to be uploaded.
|
|
103
|
-
*
|
|
104
|
-
* @remarks
|
|
105
|
-
* Required only when uploading a media using the following resources:
|
|
106
|
-
* - {@link EResourceType.MEDIA_UPLOAD_APPEND}
|
|
107
|
-
* - {@link EResourceType.MEDIA_UPLOAD_FINALIZE}
|
|
108
|
-
* - {@link EResourceType.MEDIA_UPLOAD_INITIALIZE}
|
|
109
|
-
*/
|
|
110
|
-
@IsEmpty({
|
|
111
|
-
groups: [
|
|
112
|
-
EResourceType.TWEET_LIKE,
|
|
113
|
-
EResourceType.TWEET_POST,
|
|
114
|
-
EResourceType.TWEET_RETWEET,
|
|
115
|
-
EResourceType.TWEET_SCHEDULE,
|
|
116
|
-
EResourceType.TWEET_UNLIKE,
|
|
117
|
-
EResourceType.TWEET_UNPOST,
|
|
118
|
-
EResourceType.TWEET_UNRETWEET,
|
|
119
|
-
EResourceType.TWEET_UNSCHEDULE,
|
|
120
|
-
EResourceType.USER_FOLLOW,
|
|
121
|
-
EResourceType.USER_UNFOLLOW,
|
|
122
|
-
],
|
|
123
|
-
})
|
|
124
|
-
@IsNotEmpty({
|
|
125
|
-
groups: [
|
|
126
|
-
EResourceType.MEDIA_UPLOAD_INITIALIZE,
|
|
127
|
-
EResourceType.MEDIA_UPLOAD_APPEND,
|
|
128
|
-
EResourceType.MEDIA_UPLOAD_FINALIZE,
|
|
129
|
-
],
|
|
130
|
-
})
|
|
131
|
-
@IsObject({
|
|
132
|
-
groups: [
|
|
133
|
-
EResourceType.MEDIA_UPLOAD_INITIALIZE,
|
|
134
|
-
EResourceType.MEDIA_UPLOAD_APPEND,
|
|
135
|
-
EResourceType.MEDIA_UPLOAD_FINALIZE,
|
|
136
|
-
],
|
|
137
|
-
})
|
|
11
|
+
public tweet?: NewTweet;
|
|
138
12
|
public upload?: UploadArgs;
|
|
139
13
|
|
|
140
14
|
/**
|
|
141
15
|
* @param resource - The resource to be posted.
|
|
142
16
|
* @param args - Additional user-defined arguments for posting the resource.
|
|
143
17
|
*/
|
|
144
|
-
public constructor(resource: EResourceType, args:
|
|
18
|
+
public constructor(resource: EResourceType, args: IPostArgs) {
|
|
145
19
|
this.id = args.id;
|
|
146
|
-
this.tweet = args.tweet ? new
|
|
20
|
+
this.tweet = args.tweet ? new NewTweet(args.tweet) : undefined;
|
|
147
21
|
this.upload = args.upload ? new UploadArgs(resource, args.upload) : undefined;
|
|
148
|
-
|
|
149
|
-
// Validating this object
|
|
150
|
-
const validationResult = validateSync(this, { groups: [resource] });
|
|
151
|
-
|
|
152
|
-
// If valiation error occured
|
|
153
|
-
if (validationResult.length) {
|
|
154
|
-
throw new DataValidationError(validationResult);
|
|
155
|
-
}
|
|
156
22
|
}
|
|
157
23
|
}
|
|
158
24
|
|
|
159
25
|
/**
|
|
160
|
-
*
|
|
26
|
+
* Configuration for the new tweet to be posted.
|
|
161
27
|
*
|
|
162
28
|
* @public
|
|
163
29
|
*/
|
|
164
|
-
export class
|
|
165
|
-
|
|
166
|
-
* The list of media to be uploaded.
|
|
167
|
-
*
|
|
168
|
-
* @remarks
|
|
169
|
-
* Maximum number of media items that can be posted is 4.
|
|
170
|
-
*/
|
|
171
|
-
@IsOptional({ groups: [EResourceType.TWEET_POST, EResourceType.TWEET_SCHEDULE] })
|
|
172
|
-
@IsArray({ groups: [EResourceType.TWEET_POST, EResourceType.TWEET_SCHEDULE] })
|
|
173
|
-
@ArrayMaxSize(4, { groups: [EResourceType.TWEET_POST, EResourceType.TWEET_SCHEDULE] })
|
|
174
|
-
@IsObject({ each: true, groups: [EResourceType.TWEET_POST, EResourceType.TWEET_SCHEDULE] })
|
|
175
|
-
public media?: TweetMediaArgs[];
|
|
176
|
-
|
|
177
|
-
/** The id of the tweet to quote. */
|
|
178
|
-
@IsOptional({ groups: [EResourceType.TWEET_POST, EResourceType.TWEET_SCHEDULE] })
|
|
179
|
-
@IsNumberString(undefined, { groups: [EResourceType.TWEET_POST, EResourceType.TWEET_SCHEDULE] })
|
|
30
|
+
export class NewTweet implements INewTweet {
|
|
31
|
+
public media?: NewTweetMedia[];
|
|
180
32
|
public quote?: string;
|
|
181
|
-
|
|
182
|
-
/** The id of the tweet to which the given tweet must be a reply. */
|
|
183
|
-
@IsOptional({ groups: [EResourceType.TWEET_POST, EResourceType.TWEET_SCHEDULE] })
|
|
184
|
-
@IsNumberString(undefined, { groups: [EResourceType.TWEET_POST, EResourceType.TWEET_SCHEDULE] })
|
|
185
33
|
public replyTo?: string;
|
|
186
|
-
|
|
187
|
-
/** The date/time at which the tweet must be scheduled to be posted. */
|
|
188
|
-
@IsEmpty({ groups: [EResourceType.TWEET_POST] })
|
|
189
|
-
@IsNotEmpty({ groups: [EResourceType.TWEET_SCHEDULE] })
|
|
190
|
-
@IsDate({ groups: [EResourceType.TWEET_SCHEDULE] })
|
|
191
|
-
@MinDate(() => new Date(), { groups: [EResourceType.TWEET_SCHEDULE] })
|
|
192
34
|
public scheduleFor?: Date;
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* The text for the tweet to be created.
|
|
196
|
-
*
|
|
197
|
-
* @remarks
|
|
198
|
-
* Length of the tweet must be \<= 280 characters.
|
|
199
|
-
*/
|
|
200
|
-
@IsNotEmpty({ groups: [EResourceType.TWEET_POST, EResourceType.TWEET_SCHEDULE] })
|
|
201
|
-
@IsString({ groups: [EResourceType.TWEET_POST, EResourceType.TWEET_SCHEDULE] })
|
|
202
|
-
@MaxLength(280, { groups: [EResourceType.TWEET_POST, EResourceType.TWEET_SCHEDULE] })
|
|
203
35
|
public text: string;
|
|
204
36
|
|
|
205
37
|
/**
|
|
206
|
-
* @param
|
|
38
|
+
* @param newTweet - The args specifying the new tweet to be posted.
|
|
207
39
|
*/
|
|
208
|
-
public constructor(
|
|
209
|
-
|
|
210
|
-
this.
|
|
211
|
-
this.
|
|
212
|
-
this.
|
|
213
|
-
this.
|
|
214
|
-
this.text = args.text;
|
|
215
|
-
|
|
216
|
-
// Validating this object
|
|
217
|
-
const validationResult = validateSync(this, { groups: [resource] });
|
|
218
|
-
|
|
219
|
-
// If valiation error occured
|
|
220
|
-
if (validationResult.length) {
|
|
221
|
-
throw new DataValidationError(validationResult);
|
|
222
|
-
}
|
|
40
|
+
public constructor(newTweet: INewTweet) {
|
|
41
|
+
this.media = newTweet.media;
|
|
42
|
+
this.quote = newTweet.quote;
|
|
43
|
+
this.replyTo = newTweet.replyTo;
|
|
44
|
+
this.scheduleFor = newTweet.scheduleFor;
|
|
45
|
+
this.text = newTweet.text ?? '';
|
|
223
46
|
}
|
|
224
47
|
}
|
|
225
48
|
|
|
226
49
|
/**
|
|
227
|
-
*
|
|
50
|
+
* Configuration for the media to be uploaded.
|
|
228
51
|
*
|
|
229
52
|
* @public
|
|
230
53
|
*/
|
|
231
|
-
export class
|
|
232
|
-
/** The id of the media to post. */
|
|
233
|
-
@IsNotEmpty()
|
|
234
|
-
@IsNumberString()
|
|
54
|
+
export class NewTweetMedia implements INewTweetMedia {
|
|
235
55
|
public id: string;
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* The list of id of the users tagged in the media.
|
|
239
|
-
*
|
|
240
|
-
* @remarks
|
|
241
|
-
* Maximum number of users that can be tagged is 10.
|
|
242
|
-
*/
|
|
243
|
-
@IsOptional()
|
|
244
|
-
@IsArray()
|
|
245
|
-
@ArrayMaxSize(10)
|
|
246
|
-
@IsNumberString(undefined, { each: true })
|
|
247
56
|
public tags?: string[];
|
|
248
57
|
|
|
249
58
|
/**
|
|
250
|
-
* @param
|
|
59
|
+
* @param newTweetMedia - The args specifying the new media to be posted along with the tweet.
|
|
251
60
|
*/
|
|
252
|
-
public constructor(
|
|
253
|
-
|
|
254
|
-
this.
|
|
255
|
-
this.tags = args.tags ?? [];
|
|
256
|
-
|
|
257
|
-
// Validating this object
|
|
258
|
-
const validationResult = validateSync(this);
|
|
259
|
-
|
|
260
|
-
// If validation error occured
|
|
261
|
-
if (validationResult.length) {
|
|
262
|
-
throw new DataValidationError(validationResult);
|
|
263
|
-
}
|
|
61
|
+
public constructor(newTweetMedia: INewTweetMedia) {
|
|
62
|
+
this.id = newTweetMedia.id;
|
|
63
|
+
this.tags = newTweetMedia.tags;
|
|
264
64
|
}
|
|
265
65
|
}
|
|
266
66
|
|
|
267
67
|
/**
|
|
268
68
|
* Options specifying the media file to be uploaded.
|
|
269
69
|
*
|
|
270
|
-
* @
|
|
70
|
+
* @public
|
|
271
71
|
*/
|
|
272
|
-
export class UploadArgs {
|
|
273
|
-
/** The id allocated to the media file to be uploaded. */
|
|
274
|
-
@IsEmpty({ groups: [EResourceType.MEDIA_UPLOAD_INITIALIZE] })
|
|
275
|
-
@IsNotEmpty({ groups: [EResourceType.MEDIA_UPLOAD_APPEND, EResourceType.MEDIA_UPLOAD_FINALIZE] })
|
|
276
|
-
@IsNumberString(undefined, { groups: [EResourceType.MEDIA_UPLOAD_APPEND, EResourceType.MEDIA_UPLOAD_FINALIZE] })
|
|
72
|
+
export class UploadArgs implements IUploadArgs {
|
|
277
73
|
public id?: string;
|
|
278
|
-
|
|
279
|
-
/** The media file to be uploaded. */
|
|
280
|
-
@IsEmpty({ groups: [EResourceType.MEDIA_UPLOAD_FINALIZE, EResourceType.MEDIA_UPLOAD_INITIALIZE] })
|
|
281
|
-
@IsNotEmpty({ groups: [EResourceType.MEDIA_UPLOAD_APPEND] })
|
|
282
74
|
public media?: string | ArrayBuffer;
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* The size (in bytes) of the media file to be uploaded.
|
|
286
|
-
*
|
|
287
|
-
* @remarks The size must be \<= 5242880 bytes.
|
|
288
|
-
*/
|
|
289
|
-
@IsEmpty({ groups: [EResourceType.MEDIA_UPLOAD_APPEND, EResourceType.MEDIA_UPLOAD_FINALIZE] })
|
|
290
|
-
@IsNotEmpty({ groups: [EResourceType.MEDIA_UPLOAD_INITIALIZE] })
|
|
291
|
-
@Max(5242880, { groups: [EResourceType.MEDIA_UPLOAD_INITIALIZE] })
|
|
292
75
|
public size?: number;
|
|
293
76
|
|
|
294
77
|
/**
|
|
295
78
|
* @param step - The upload step.
|
|
296
79
|
* @param args - The upload arguments for uploading the media file.
|
|
297
80
|
*/
|
|
298
|
-
public constructor(step: EResourceType, args:
|
|
81
|
+
public constructor(step: EResourceType, args: IUploadArgs) {
|
|
299
82
|
this.size = args.size;
|
|
300
83
|
this.media = args.media;
|
|
301
84
|
this.id = args.id;
|
|
302
|
-
|
|
303
|
-
// Validating this object
|
|
304
|
-
const validationResult = validateSync(this, { groups: [step] });
|
|
305
|
-
|
|
306
|
-
// If validation error occured
|
|
307
|
-
if (validationResult.length) {
|
|
308
|
-
throw new DataValidationError(validationResult);
|
|
309
|
-
}
|
|
310
85
|
}
|
|
311
86
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Cookie } from 'cookiejar';
|
|
2
|
+
|
|
3
|
+
import { IAuthCookie } from '../../types/auth/AuthCookie';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The cookie containing the tokens that are used to authenticate against Twitter.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export class AuthCookie implements IAuthCookie {
|
|
11
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
12
|
+
|
|
13
|
+
public auth_token: string;
|
|
14
|
+
public ct0: string;
|
|
15
|
+
public kdt: string;
|
|
16
|
+
public twid: string;
|
|
17
|
+
|
|
18
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param cookies - The cookie list obtained from the browser.
|
|
22
|
+
*/
|
|
23
|
+
public constructor(cookies: Cookie[]) {
|
|
24
|
+
// Initializing defaults
|
|
25
|
+
this.auth_token = '';
|
|
26
|
+
this.ct0 = '';
|
|
27
|
+
this.kdt = '';
|
|
28
|
+
this.twid = '';
|
|
29
|
+
|
|
30
|
+
// Parsing the cookies
|
|
31
|
+
for (const cookie of cookies) {
|
|
32
|
+
if (cookie.name == 'kdt') {
|
|
33
|
+
this.kdt = cookie.value;
|
|
34
|
+
} else if (cookie.name == 'twid') {
|
|
35
|
+
this.twid = cookie.value;
|
|
36
|
+
} else if (cookie.name == 'ct0') {
|
|
37
|
+
this.ct0 = cookie.value;
|
|
38
|
+
} else if (cookie.name == 'auth_token') {
|
|
39
|
+
this.auth_token = cookie.value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @returns the string representation of 'this' object.
|
|
46
|
+
*/
|
|
47
|
+
public toString(): string {
|
|
48
|
+
/** The string representation of 'this' object. */
|
|
49
|
+
let outStr = '';
|
|
50
|
+
|
|
51
|
+
// Iterating through the (key, value) pairs of this cookie
|
|
52
|
+
for (const [key, value] of Object.entries(this)) {
|
|
53
|
+
outStr += `${key}=${value as string};`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return outStr;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { AxiosHeaders, AxiosRequestHeaders } from 'axios';
|
|
2
|
+
|
|
3
|
+
import { Cookie } from 'cookiejar';
|
|
4
|
+
|
|
5
|
+
import { EAuthenticationType } from '../../enums/Authentication';
|
|
6
|
+
import { IAuthCredential } from '../../types/auth/AuthCredential';
|
|
7
|
+
|
|
8
|
+
import { AuthCookie } from './AuthCookie';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The credentials for authenticating against Twitter.
|
|
12
|
+
*
|
|
13
|
+
* Depending on which tokens are present, the authentication type is determined as follows:
|
|
14
|
+
* - authToken, guestToken =\> Guest authentication.
|
|
15
|
+
* - authToken, csrfToken, cookie =\> User authentication.
|
|
16
|
+
* - authToken, guestToken, cookie =\> Guest authentication while logging in.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export class AuthCredential implements IAuthCredential {
|
|
21
|
+
public authToken?: string;
|
|
22
|
+
public authenticationType?: EAuthenticationType;
|
|
23
|
+
public cookies?: string;
|
|
24
|
+
public csrfToken?: string;
|
|
25
|
+
public guestToken?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param cookies - The list of cookies to be used for authenticating against Twitter.
|
|
29
|
+
* @param guestToken - The guest token to be used to authenticate a guest session.
|
|
30
|
+
*/
|
|
31
|
+
public constructor(cookies?: Cookie[], guestToken?: string) {
|
|
32
|
+
this.authToken =
|
|
33
|
+
'AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA';
|
|
34
|
+
// If guest credentials given
|
|
35
|
+
if (!cookies && guestToken) {
|
|
36
|
+
this.guestToken = guestToken;
|
|
37
|
+
this.authenticationType = EAuthenticationType.GUEST;
|
|
38
|
+
}
|
|
39
|
+
// If login credentials given
|
|
40
|
+
else if (cookies && guestToken) {
|
|
41
|
+
// Parsing the cookies
|
|
42
|
+
const parsedCookie: AuthCookie = new AuthCookie(cookies);
|
|
43
|
+
|
|
44
|
+
this.cookies = parsedCookie.toString();
|
|
45
|
+
this.guestToken = guestToken;
|
|
46
|
+
this.authenticationType = EAuthenticationType.LOGIN;
|
|
47
|
+
}
|
|
48
|
+
// If user credentials given
|
|
49
|
+
else if (cookies && !guestToken) {
|
|
50
|
+
// Parsing the cookies
|
|
51
|
+
const parsedCookie: AuthCookie = new AuthCookie(cookies);
|
|
52
|
+
|
|
53
|
+
this.cookies = parsedCookie.toString();
|
|
54
|
+
this.csrfToken = parsedCookie.ct0;
|
|
55
|
+
this.authenticationType = EAuthenticationType.USER;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @returns The HTTP header representation of 'this' object.
|
|
61
|
+
*/
|
|
62
|
+
public toHeader(): AxiosRequestHeaders {
|
|
63
|
+
const headers = new AxiosHeaders();
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Conditionally initializing only those data which are supplied.
|
|
67
|
+
*
|
|
68
|
+
* This is done to ensure that the data that is not supplied, is not included in output, not even undefined.
|
|
69
|
+
*/
|
|
70
|
+
if (this.authToken) {
|
|
71
|
+
headers.set('authorization', `Bearer ${this.authToken}`);
|
|
72
|
+
}
|
|
73
|
+
if (this.guestToken) {
|
|
74
|
+
headers.set('x-guest-token', this.guestToken);
|
|
75
|
+
}
|
|
76
|
+
if (this.csrfToken) {
|
|
77
|
+
headers.set('x-csrf-token', this.csrfToken);
|
|
78
|
+
}
|
|
79
|
+
if (this.cookies) {
|
|
80
|
+
headers.set('cookie', this.cookies);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return headers;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ICursor } from 'rettiwt-core';
|
|
2
|
-
|
|
3
1
|
import { EBaseType } from '../../enums/Data';
|
|
4
2
|
|
|
5
3
|
import { findByFilter } from '../../helper/JsonUtils';
|
|
6
4
|
|
|
5
|
+
import { ICursoredData } from '../../types/data/CursoredData';
|
|
6
|
+
import { ICursor as IRawCursor } from '../../types/raw/base/Cursor';
|
|
7
|
+
|
|
7
8
|
import { Notification } from './Notification';
|
|
8
9
|
import { Tweet } from './Tweet';
|
|
9
10
|
import { User } from './User';
|
|
@@ -15,44 +16,38 @@ import { User } from './User';
|
|
|
15
16
|
*
|
|
16
17
|
* @public
|
|
17
18
|
*/
|
|
18
|
-
export class CursoredData<T extends Notification | Tweet | User> {
|
|
19
|
-
|
|
20
|
-
public
|
|
21
|
-
|
|
22
|
-
/** The cursor to the next batch of data. */
|
|
23
|
-
public next: Cursor = new Cursor('');
|
|
19
|
+
export class CursoredData<T extends Notification | Tweet | User> implements ICursoredData<T> {
|
|
20
|
+
public list: T[];
|
|
21
|
+
public next: string;
|
|
24
22
|
|
|
25
23
|
/**
|
|
26
24
|
* @param response - The raw response.
|
|
27
25
|
* @param type - The base type of the data included in the batch.
|
|
28
26
|
*/
|
|
29
27
|
public constructor(response: NonNullable<unknown>, type: EBaseType) {
|
|
28
|
+
// Initializing defaults
|
|
29
|
+
this.list = [];
|
|
30
|
+
this.next = '';
|
|
31
|
+
|
|
30
32
|
if (type == EBaseType.TWEET) {
|
|
31
|
-
this.list = Tweet.
|
|
32
|
-
this.next =
|
|
33
|
+
this.list = Tweet.timeline(response) as T[];
|
|
34
|
+
this.next = findByFilter<IRawCursor>(response, 'cursorType', 'Bottom')[0]?.value ?? '';
|
|
33
35
|
} else if (type == EBaseType.USER) {
|
|
34
|
-
this.list = User.
|
|
35
|
-
this.next =
|
|
36
|
+
this.list = User.timeline(response) as T[];
|
|
37
|
+
this.next = findByFilter<IRawCursor>(response, 'cursorType', 'Bottom')[0]?.value ?? '';
|
|
36
38
|
} else if (type == EBaseType.NOTIFICATION) {
|
|
37
39
|
this.list = Notification.list(response) as T[];
|
|
38
|
-
this.next =
|
|
40
|
+
this.next = findByFilter<IRawCursor>(response, 'cursorType', 'Top')[0]?.value ?? '';
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The cursor to the batch of data to fetch.
|
|
45
|
-
*
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
export class Cursor {
|
|
49
|
-
/** The cursor string. */
|
|
50
|
-
public value: string;
|
|
51
43
|
|
|
52
44
|
/**
|
|
53
|
-
* @
|
|
45
|
+
* @returns A serializable JSON representation of `this` object.
|
|
54
46
|
*/
|
|
55
|
-
public
|
|
56
|
-
|
|
47
|
+
public toJSON(): ICursoredData<T> {
|
|
48
|
+
return {
|
|
49
|
+
list: this.list.map((item) => item.toJSON() as T),
|
|
50
|
+
next: this.next,
|
|
51
|
+
};
|
|
57
52
|
}
|
|
58
53
|
}
|
package/src/models/data/List.ts
CHANGED
|
@@ -1,30 +1,18 @@
|
|
|
1
|
-
import { IList
|
|
1
|
+
import { IList } from '../../types/data/List';
|
|
2
|
+
import { IList as IRawList } from '../../types/raw/base/List';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The details of a single Twitter List.
|
|
5
6
|
*
|
|
6
7
|
* @public
|
|
7
8
|
*/
|
|
8
|
-
export class List {
|
|
9
|
-
/** The date and time of creation of the list, int UTC string format. */
|
|
9
|
+
export class List implements IList {
|
|
10
10
|
public createdAt: string;
|
|
11
|
-
|
|
12
|
-
/** The rest id of the user who created the list. */
|
|
13
11
|
public createdBy: string;
|
|
14
|
-
|
|
15
|
-
/** The list description. */
|
|
16
12
|
public description?: string;
|
|
17
|
-
|
|
18
|
-
/** The rest id of the list. */
|
|
19
13
|
public id: string;
|
|
20
|
-
|
|
21
|
-
/** The number of memeber of the list. */
|
|
22
14
|
public memberCount: number;
|
|
23
|
-
|
|
24
|
-
/** The name of the list. */
|
|
25
15
|
public name: string;
|
|
26
|
-
|
|
27
|
-
/** The number of subscribers of the list. */
|
|
28
16
|
public subscriberCount: number;
|
|
29
17
|
|
|
30
18
|
/**
|
|
@@ -39,4 +27,19 @@ export class List {
|
|
|
39
27
|
this.subscriberCount = list.subscriber_count;
|
|
40
28
|
this.createdBy = list.user_results.result.id;
|
|
41
29
|
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @returns A serializable JSON representation of `this` object.
|
|
33
|
+
*/
|
|
34
|
+
public toJSON(): IList {
|
|
35
|
+
return {
|
|
36
|
+
createdAt: this.createdAt,
|
|
37
|
+
createdBy: this.createdBy,
|
|
38
|
+
description: this.description,
|
|
39
|
+
id: this.id,
|
|
40
|
+
memberCount: this.memberCount,
|
|
41
|
+
name: this.name,
|
|
42
|
+
subscriberCount: this.subscriberCount,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
42
45
|
}
|