rettiwt-api 1.1.7 → 1.2.0
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/.github/workflows/build-docs.yml +22 -21
- package/.github/workflows/publish-to-npm.yml +29 -0
- package/README.md +52 -40
- package/dist/config/env.d.ts +5 -5
- package/dist/config/env.js +8 -8
- package/dist/enums/Errors.d.ts +20 -20
- package/dist/enums/Errors.js +27 -27
- package/dist/enums/HTTP.d.ts +17 -17
- package/dist/enums/HTTP.js +22 -22
- package/dist/graphql/enums/Errors.d.ts +21 -21
- package/dist/graphql/enums/Errors.js +28 -28
- package/dist/graphql/queries/RootQuery.d.ts +4 -4
- package/dist/graphql/queries/RootQuery.js +77 -77
- package/dist/graphql/resolvers/AccountResolver.d.ts +12 -12
- package/dist/graphql/resolvers/AccountResolver.js +83 -83
- package/dist/graphql/resolvers/ResolverBase.d.ts +16 -16
- package/dist/graphql/resolvers/ResolverBase.js +22 -22
- package/dist/graphql/resolvers/TweetResolver.d.ts +46 -46
- package/dist/graphql/resolvers/TweetResolver.js +311 -311
- package/dist/graphql/resolvers/UserResolver.d.ts +48 -48
- package/dist/graphql/resolvers/UserResolver.js +333 -333
- package/dist/graphql/resolvers/UserResolver.js.map +1 -1
- package/dist/graphql/types/Global.d.ts +4 -4
- package/dist/graphql/types/Global.js +12 -12
- package/dist/graphql/types/TweetTypes.d.ts +4 -4
- package/dist/graphql/types/TweetTypes.js +159 -159
- package/dist/graphql/types/UserTypes.d.ts +3 -3
- package/dist/graphql/types/UserTypes.js +136 -136
- package/dist/graphql/types/UserTypes.js.map +1 -1
- package/dist/index.d.ts +43 -43
- package/dist/index.js +70 -70
- package/dist/models/args/TweetFilter.d.ts +65 -59
- package/dist/models/args/TweetFilter.js +120 -100
- package/dist/models/args/TweetFilter.js.map +1 -1
- package/dist/models/args/TweetListArgs.d.ts +21 -21
- package/dist/models/args/TweetListArgs.js +53 -53
- package/dist/models/args/UserListArgs.d.ts +21 -21
- package/dist/models/args/UserListArgs.js +53 -53
- package/dist/models/auth/AuthCookie.d.ts +21 -21
- package/dist/models/auth/AuthCookie.js +32 -32
- package/dist/models/data/CursoredData.d.ts +34 -34
- package/dist/models/data/CursoredData.js +41 -41
- package/dist/models/data/Tweet.d.ts +53 -53
- package/dist/models/data/Tweet.js +103 -103
- package/dist/models/data/User.d.ts +41 -41
- package/dist/models/data/User.js +31 -31
- package/dist/models/errors/DataValidationError.d.ts +20 -20
- package/dist/models/errors/DataValidationError.js +22 -22
- package/dist/server.d.ts +1 -1
- package/dist/server.js +75 -75
- package/dist/services/auth/AccountService.d.ts +83 -88
- package/dist/services/auth/AccountService.js +411 -391
- package/dist/services/auth/AccountService.js.map +1 -1
- package/dist/services/auth/AuthService.d.ts +31 -31
- package/dist/services/auth/AuthService.js +117 -117
- package/dist/services/data/TweetService.d.ts +60 -74
- package/dist/services/data/TweetService.js +251 -254
- package/dist/services/data/TweetService.js.map +1 -1
- package/dist/services/data/UserService.d.ts +71 -87
- package/dist/services/data/UserService.js +287 -296
- package/dist/services/data/UserService.js.map +1 -1
- package/dist/services/helper/Headers.d.ts +19 -19
- package/dist/services/helper/Headers.js +61 -61
- package/dist/services/helper/Parser.d.ts +22 -28
- package/dist/services/helper/Parser.js +83 -104
- package/dist/services/helper/Parser.js.map +1 -1
- package/dist/services/helper/extractors/Tweets.d.ts +32 -32
- package/dist/services/helper/extractors/Tweets.js +263 -263
- package/dist/services/helper/extractors/Users.d.ts +26 -26
- package/dist/services/helper/extractors/Users.js +202 -202
- package/dist/services/helper/payloads/LoginFlows.d.ts +77 -77
- package/dist/services/helper/payloads/LoginFlows.js +91 -91
- package/dist/services/helper/urls/Authentication.d.ts +4 -4
- package/dist/services/helper/urls/Authentication.js +10 -10
- package/dist/services/util/CacheService.d.ts +33 -33
- package/dist/services/util/CacheService.js +95 -95
- package/dist/services/util/FetcherService.d.ts +65 -65
- package/dist/services/util/FetcherService.js +213 -213
- package/dist/twitter/Url.d.ts +22 -0
- package/dist/twitter/Url.js +32 -0
- package/dist/twitter/Url.js.map +1 -0
- package/dist/twitter/enums/Resources.d.ts +15 -0
- package/dist/twitter/enums/Resources.js +21 -0
- package/dist/twitter/enums/Resources.js.map +1 -0
- package/dist/twitter/params/Query.d.ts +67 -0
- package/dist/twitter/params/Query.js +64 -0
- package/dist/twitter/params/Query.js.map +1 -0
- package/dist/twitter/payloads/Args.d.ts +16 -0
- package/dist/twitter/payloads/Args.js +16 -0
- package/dist/twitter/payloads/Args.js.map +1 -0
- package/dist/{types/raw/query/tweet/Engagements.d.ts → twitter/payloads/Features.d.ts} +28 -29
- package/dist/twitter/payloads/Features.js +37 -0
- package/dist/twitter/payloads/Features.js.map +1 -0
- package/dist/twitter/payloads/Variables.d.ts +41 -0
- package/dist/twitter/payloads/Variables.js +64 -0
- package/dist/twitter/payloads/Variables.js.map +1 -0
- package/dist/{types → twitter/types/request}/Query.d.ts +86 -80
- package/dist/{types/data/Tweet.js → twitter/types/request/Query.js} +4 -4
- package/dist/twitter/types/request/Query.js.map +1 -0
- package/dist/{types/raw/data → twitter/types}/tweet/Favouriters.d.ts +164 -164
- package/dist/twitter/types/tweet/Favouriters.js +3 -0
- package/dist/twitter/types/tweet/Favouriters.js.map +1 -0
- package/dist/{types/raw → twitter/types}/tweet/Retweeters.d.ts +171 -171
- package/dist/{types/Trends.js → twitter/types/tweet/Retweeters.js} +3 -3
- package/dist/twitter/types/tweet/Retweeters.js.map +1 -0
- package/dist/{types/raw/data → twitter/types}/tweet/Tweet.d.ts +746 -746
- package/dist/{types/data/User.js → twitter/types/tweet/Tweet.js} +3 -3
- package/dist/twitter/types/tweet/Tweet.js.map +1 -0
- package/dist/{types/raw → twitter/types}/tweet/Tweets.d.ts +386 -386
- package/dist/{types/raw/user/User.js → twitter/types/tweet/Tweets.js} +3 -3
- package/dist/twitter/types/tweet/Tweets.js.map +1 -0
- package/dist/{types/raw → twitter/types}/user/Followers.d.ts +176 -176
- package/dist/{types/interfaces/Rettiwt.js → twitter/types/user/Followers.js} +3 -3
- package/dist/twitter/types/user/Followers.js.map +1 -0
- package/dist/{types/raw → twitter/types}/user/Following.d.ts +176 -176
- package/dist/{types/Query.js → twitter/types/user/Following.js} +3 -3
- package/dist/twitter/types/user/Following.js.map +1 -0
- package/dist/{types/raw/data → twitter/types}/user/Likes.d.ts +1059 -1059
- package/dist/{types/interfaces/User.js → twitter/types/user/Likes.js} +3 -3
- package/dist/twitter/types/user/Likes.js.map +1 -0
- package/dist/{types/raw → twitter/types}/user/Tweets.d.ts +1512 -1512
- package/dist/twitter/types/user/Tweets.js +3 -0
- package/dist/twitter/types/user/Tweets.js.map +1 -0
- package/dist/{types/raw → twitter/types}/user/User.d.ts +117 -117
- package/dist/{types/raw/data → twitter/types}/user/User.js +2 -2
- package/dist/{types/data → twitter/types/user}/User.js.map +1 -1
- package/dist/types/Args.d.ts +38 -38
- package/dist/types/Args.js +4 -4
- package/dist/types/Authentication.d.ts +55 -55
- package/dist/types/Authentication.js +5 -5
- package/dist/types/Resolvers.d.ts +15 -15
- package/dist/types/Resolvers.js +2 -2
- package/dist/types/Rettiwt.d.ts +16 -16
- package/dist/types/Rettiwt.js +2 -2
- package/dist/types/Service.d.ts +22 -22
- package/dist/types/Service.js +4 -4
- package/dist/types/Tweet.d.ts +46 -46
- package/dist/types/Tweet.js +2 -2
- package/dist/types/User.d.ts +35 -35
- package/dist/types/User.js +2 -2
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +64 -0
- package/docs/assets/main.js +58 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1280 -0
- package/docs/classes/AccountService.html +286 -0
- package/docs/classes/AuthCookie.html +146 -0
- package/docs/classes/AuthService.html +147 -0
- package/docs/classes/CacheService.html +157 -0
- package/docs/classes/Cursor.html +102 -0
- package/docs/classes/CursoredData.html +126 -0
- package/docs/classes/DataValidationError.html +119 -0
- package/docs/classes/FetcherService.html +225 -0
- package/docs/classes/Tweet.html +210 -0
- package/docs/classes/TweetEntities.html +128 -0
- package/docs/classes/TweetFilter.html +221 -0
- package/docs/classes/TweetListArgs.html +118 -0
- package/docs/classes/TweetService.html +319 -0
- package/docs/classes/User.html +230 -0
- package/docs/classes/UserListArgs.html +118 -0
- package/docs/classes/UserService.html +355 -0
- package/docs/enums/HttpMethods.html +74 -0
- package/docs/functions/Rettiwt.html +99 -0
- package/docs/index.html +158 -0
- package/docs/interfaces/IAuthCookie.html +104 -0
- package/docs/interfaces/ICursor.html +77 -0
- package/docs/interfaces/ICursoredData.html +93 -0
- package/docs/interfaces/IDataContext.html +91 -0
- package/docs/interfaces/IListArgs.html +87 -0
- package/docs/interfaces/ITweet.html +176 -0
- package/docs/interfaces/ITweetEntities.html +104 -0
- package/docs/interfaces/ITweetFilter.html +158 -0
- package/docs/interfaces/IUser.html +194 -0
- package/docs/modules.html +109 -0
- package/package.json +2 -2
- package/src/graphql/resolvers/UserResolver.ts +4 -4
- package/src/graphql/types/UserTypes.ts +1 -1
- package/src/models/args/TweetFilter.ts +25 -4
- package/src/models/data/Tweet.ts +1 -1
- package/src/models/data/User.ts +1 -1
- package/src/services/auth/AccountService.ts +79 -53
- package/src/services/data/TweetService.ts +35 -65
- package/src/services/data/UserService.ts +42 -48
- package/src/services/helper/Parser.ts +3 -24
- package/src/services/helper/extractors/Tweets.ts +4 -4
- package/src/services/helper/extractors/Users.ts +5 -5
- package/src/services/util/FetcherService.ts +4 -4
- package/src/twitter/Url.ts +37 -0
- package/src/twitter/enums/Resources.ts +15 -0
- package/src/twitter/params/Query.ts +100 -0
- package/src/twitter/payloads/Args.ts +21 -0
- package/src/twitter/payloads/Features.ts +33 -0
- package/src/twitter/payloads/Variables.ts +73 -0
- package/src/twitter/types/request/Query.ts +91 -0
- package/src/{types/raw → twitter/types}/user/Tweets.ts +1747 -1747
- package/src/types/Args.ts +1 -1
- package/dist/Test.d.ts +0 -0
- package/dist/Test.js +0 -2
- package/dist/Test.js.map +0 -1
- package/dist/endpoints/Endpoints.d.ts +0 -14
- package/dist/endpoints/Endpoints.js +0 -20
- package/dist/endpoints/Endpoints.js.map +0 -1
- package/dist/endpoints/Url.d.ts +0 -5
- package/dist/endpoints/Url.js +0 -12
- package/dist/endpoints/Url.js.map +0 -1
- package/dist/enums/Endpoints.d.ts +0 -25
- package/dist/enums/Endpoints.js +0 -31
- package/dist/enums/Endpoints.js.map +0 -1
- package/dist/graphql/types/Errors.d.ts +0 -20
- package/dist/graphql/types/Errors.js +0 -28
- package/dist/graphql/types/Errors.js.map +0 -1
- package/dist/middlewares/Authentication.d.ts +0 -0
- package/dist/middlewares/Authentication.js +0 -2
- package/dist/middlewares/Authentication.js.map +0 -1
- package/dist/models/data/DataValidationError.d.ts +0 -18
- package/dist/models/data/DataValidationError.js +0 -21
- package/dist/models/data/DataValidationError.js.map +0 -1
- package/dist/models/data/Errors.d.ts +0 -18
- package/dist/models/data/Errors.js +0 -21
- package/dist/models/data/Errors.js.map +0 -1
- package/dist/models/data/Service.d.ts +0 -33
- package/dist/models/data/Service.js +0 -41
- package/dist/models/data/Service.js.map +0 -1
- package/dist/models/graphql/Global.d.ts +0 -4
- package/dist/models/graphql/Global.js +0 -13
- package/dist/models/graphql/Global.js.map +0 -1
- package/dist/models/graphql/TweetTypes.d.ts +0 -6
- package/dist/models/graphql/TweetTypes.js +0 -156
- package/dist/models/graphql/TweetTypes.js.map +0 -1
- package/dist/models/graphql/UserTypes.d.ts +0 -3
- package/dist/models/graphql/UserTypes.js +0 -139
- package/dist/models/graphql/UserTypes.js.map +0 -1
- package/dist/models/query/Variables.d.ts +0 -2
- package/dist/models/query/Variables.js +0 -10
- package/dist/models/query/Variables.js.map +0 -1
- package/dist/queries/RootQuery.d.ts +0 -4
- package/dist/queries/RootQuery.js +0 -70
- package/dist/queries/RootQuery.js.map +0 -1
- package/dist/requests/Url.d.ts +0 -5
- package/dist/requests/Url.js +0 -12
- package/dist/requests/Url.js.map +0 -1
- package/dist/requests/payloads/Variables.d.ts +0 -23
- package/dist/requests/payloads/Variables.js +0 -24
- package/dist/requests/payloads/Variables.js.map +0 -1
- package/dist/resolvers/AccountResolver.d.ts +0 -12
- package/dist/resolvers/AccountResolver.js +0 -84
- package/dist/resolvers/AccountResolver.js.map +0 -1
- package/dist/resolvers/ResolverBase.d.ts +0 -5
- package/dist/resolvers/ResolverBase.js +0 -11
- package/dist/resolvers/ResolverBase.js.map +0 -1
- package/dist/resolvers/TweetResolver.d.ts +0 -54
- package/dist/resolvers/TweetResolver.js +0 -332
- package/dist/resolvers/TweetResolver.js.map +0 -1
- package/dist/resolvers/UserResolver.d.ts +0 -38
- package/dist/resolvers/UserResolver.js +0 -253
- package/dist/resolvers/UserResolver.js.map +0 -1
- package/dist/services/AuthService.d.ts +0 -22
- package/dist/services/AuthService.js +0 -106
- package/dist/services/AuthService.js.map +0 -1
- package/dist/services/CacheService.d.ts +0 -30
- package/dist/services/CacheService.js +0 -93
- package/dist/services/CacheService.js.map +0 -1
- package/dist/services/FetcherService.d.ts +0 -61
- package/dist/services/FetcherService.js +0 -209
- package/dist/services/FetcherService.js.map +0 -1
- package/dist/services/accounts/AccountService.d.ts +0 -65
- package/dist/services/accounts/AccountService.js +0 -336
- package/dist/services/accounts/AccountService.js.map +0 -1
- package/dist/services/accounts/LoginFlows.d.ts +0 -77
- package/dist/services/accounts/LoginFlows.js +0 -92
- package/dist/services/accounts/LoginFlows.js.map +0 -1
- package/dist/services/auth/LoginFlows.d.ts +0 -77
- package/dist/services/auth/LoginFlows.js +0 -92
- package/dist/services/auth/LoginFlows.js.map +0 -1
- package/dist/services/data/TrendService.d.ts +0 -17
- package/dist/services/data/TrendService.js +0 -116
- package/dist/services/data/TrendService.js.map +0 -1
- package/dist/services/data/UserAccountService.d.ts +0 -42
- package/dist/services/data/UserAccountService.js +0 -239
- package/dist/services/data/UserAccountService.js.map +0 -1
- package/dist/services/helper/Deserializers.d.ts +0 -19
- package/dist/services/helper/Deserializers.js +0 -115
- package/dist/services/helper/Deserializers.js.map +0 -1
- package/dist/services/helper/Extractors.d.ts +0 -104
- package/dist/services/helper/Extractors.js +0 -432
- package/dist/services/helper/Extractors.js.map +0 -1
- package/dist/services/helper/Urls.d.ts +0 -85
- package/dist/services/helper/Urls.js +0 -130
- package/dist/services/helper/Urls.js.map +0 -1
- package/dist/services/helper/deserializers/Tweets.d.ts +0 -12
- package/dist/services/helper/deserializers/Tweets.js +0 -92
- package/dist/services/helper/deserializers/Tweets.js.map +0 -1
- package/dist/services/helper/deserializers/Users.d.ts +0 -7
- package/dist/services/helper/deserializers/Users.js +0 -27
- package/dist/services/helper/deserializers/Users.js.map +0 -1
- package/dist/services/helper/extractors/Trends.d.ts +0 -3
- package/dist/services/helper/extractors/Trends.js +0 -51
- package/dist/services/helper/extractors/Trends.js.map +0 -1
- package/dist/services/helper/urls/Trends.d.ts +0 -7
- package/dist/services/helper/urls/Trends.js +0 -13
- package/dist/services/helper/urls/Trends.js.map +0 -1
- package/dist/services/helper/urls/Tweets.d.ts +0 -32
- package/dist/services/helper/urls/Tweets.js +0 -51
- package/dist/services/helper/urls/Tweets.js.map +0 -1
- package/dist/services/helper/urls/Users.d.ts +0 -38
- package/dist/services/helper/urls/Users.js +0 -76
- package/dist/services/helper/urls/Users.js.map +0 -1
- package/dist/types/HTTP.d.ts +0 -17
- package/dist/types/HTTP.js +0 -23
- package/dist/types/HTTP.js.map +0 -1
- package/dist/types/Query.js.map +0 -1
- package/dist/types/Trends.d.ts +0 -50
- package/dist/types/Trends.js.map +0 -1
- package/dist/types/UserAccount.d.ts +0 -19
- package/dist/types/UserAccount.js +0 -4
- package/dist/types/UserAccount.js.map +0 -1
- package/dist/types/args/TweetFilter.d.ts +0 -54
- package/dist/types/args/TweetFilter.js +0 -96
- package/dist/types/args/TweetFilter.js.map +0 -1
- package/dist/types/args/TweetListArg.d.ts +0 -10
- package/dist/types/args/TweetListArg.js +0 -42
- package/dist/types/args/TweetListArg.js.map +0 -1
- package/dist/types/args/TweetListArgs.d.ts +0 -20
- package/dist/types/args/TweetListArgs.js +0 -52
- package/dist/types/args/TweetListArgs.js.map +0 -1
- package/dist/types/args/UserListArgs.d.ts +0 -16
- package/dist/types/args/UserListArgs.js +0 -48
- package/dist/types/args/UserListArgs.js.map +0 -1
- package/dist/types/data/Errors.d.ts +0 -35
- package/dist/types/data/Errors.js +0 -45
- package/dist/types/data/Errors.js.map +0 -1
- package/dist/types/data/Service.d.ts +0 -43
- package/dist/types/data/Service.js +0 -22
- package/dist/types/data/Service.js.map +0 -1
- package/dist/types/data/Tweet.d.ts +0 -98
- package/dist/types/data/Tweet.js.map +0 -1
- package/dist/types/data/TweetFilter.d.ts +0 -49
- package/dist/types/data/TweetFilter.js +0 -63
- package/dist/types/data/TweetFilter.js.map +0 -1
- package/dist/types/data/User.d.ts +0 -38
- package/dist/types/graphql/Errors.d.ts +0 -15
- package/dist/types/graphql/Errors.js +0 -23
- package/dist/types/graphql/Errors.js.map +0 -1
- package/dist/types/interfaces/Args.d.ts +0 -38
- package/dist/types/interfaces/Args.js +0 -5
- package/dist/types/interfaces/Args.js.map +0 -1
- package/dist/types/interfaces/Authentication.d.ts +0 -40
- package/dist/types/interfaces/Authentication.js +0 -5
- package/dist/types/interfaces/Authentication.js.map +0 -1
- package/dist/types/interfaces/Resolvers.d.ts +0 -14
- package/dist/types/interfaces/Resolvers.js +0 -3
- package/dist/types/interfaces/Resolvers.js.map +0 -1
- package/dist/types/interfaces/Rettiwt.d.ts +0 -16
- package/dist/types/interfaces/Rettiwt.js.map +0 -1
- package/dist/types/interfaces/Service.d.ts +0 -13
- package/dist/types/interfaces/Service.js +0 -3
- package/dist/types/interfaces/Service.js.map +0 -1
- package/dist/types/interfaces/Services.d.ts +0 -13
- package/dist/types/interfaces/Services.js +0 -3
- package/dist/types/interfaces/Services.js.map +0 -1
- package/dist/types/interfaces/Tweet.d.ts +0 -46
- package/dist/types/interfaces/Tweet.js +0 -3
- package/dist/types/interfaces/Tweet.js.map +0 -1
- package/dist/types/interfaces/TweetFilter.d.ts +0 -0
- package/dist/types/interfaces/TweetFilter.js +0 -2
- package/dist/types/interfaces/TweetFilter.js.map +0 -1
- package/dist/types/interfaces/User.d.ts +0 -35
- package/dist/types/interfaces/User.js.map +0 -1
- package/dist/types/raw/auth/Cookie.d.ts +0 -16
- package/dist/types/raw/auth/Cookie.js +0 -3
- package/dist/types/raw/auth/Cookie.js.map +0 -1
- package/dist/types/raw/data/tweet/Favouriters.js +0 -3
- package/dist/types/raw/data/tweet/Favouriters.js.map +0 -1
- package/dist/types/raw/data/tweet/Retweeters.d.ts +0 -171
- package/dist/types/raw/data/tweet/Retweeters.js +0 -3
- package/dist/types/raw/data/tweet/Retweeters.js.map +0 -1
- package/dist/types/raw/data/tweet/Tweet.js +0 -3
- package/dist/types/raw/data/tweet/Tweet.js.map +0 -1
- package/dist/types/raw/data/tweet/Tweets.d.ts +0 -386
- package/dist/types/raw/data/tweet/Tweets.js +0 -3
- package/dist/types/raw/data/tweet/Tweets.js.map +0 -1
- package/dist/types/raw/data/user/Followers.d.ts +0 -176
- package/dist/types/raw/data/user/Followers.js +0 -3
- package/dist/types/raw/data/user/Followers.js.map +0 -1
- package/dist/types/raw/data/user/Following.d.ts +0 -176
- package/dist/types/raw/data/user/Following.js +0 -3
- package/dist/types/raw/data/user/Following.js.map +0 -1
- package/dist/types/raw/data/user/Likes.js +0 -3
- package/dist/types/raw/data/user/Likes.js.map +0 -1
- package/dist/types/raw/data/user/User.d.ts +0 -117
- package/dist/types/raw/data/user/User.js.map +0 -1
- package/dist/types/raw/general/Trends.d.ts +0 -324
- package/dist/types/raw/general/Trends.js +0 -3
- package/dist/types/raw/general/Trends.js.map +0 -1
- package/dist/types/raw/query/tweet/Details.d.ts +0 -80
- package/dist/types/raw/query/tweet/Details.js +0 -5
- package/dist/types/raw/query/tweet/Details.js.map +0 -1
- package/dist/types/raw/query/tweet/Engagements.js +0 -3
- package/dist/types/raw/query/tweet/Engagements.js.map +0 -1
- package/dist/types/raw/query/tweet/Likes.d.ts +0 -29
- package/dist/types/raw/query/tweet/Likes.js +0 -3
- package/dist/types/raw/query/tweet/Likes.js.map +0 -1
- package/dist/types/raw/query/tweet/Retweets.d.ts +0 -29
- package/dist/types/raw/query/tweet/Retweets.js +0 -3
- package/dist/types/raw/query/tweet/Retweets.js.map +0 -1
- package/dist/types/raw/query/tweet/Search.d.ts +0 -40
- package/dist/types/raw/query/tweet/Search.js +0 -3
- package/dist/types/raw/query/tweet/Search.js.map +0 -1
- package/dist/types/raw/query/tweet/TweetDetails.d.ts +0 -34
- package/dist/types/raw/query/tweet/TweetDetails.js +0 -5
- package/dist/types/raw/query/tweet/TweetDetails.js.map +0 -1
- package/dist/types/raw/query/tweet/TweetLike.d.ts +0 -29
- package/dist/types/raw/query/tweet/TweetLike.js +0 -3
- package/dist/types/raw/query/tweet/TweetLike.js.map +0 -1
- package/dist/types/raw/query/tweet/TweetLikes.d.ts +0 -29
- package/dist/types/raw/query/tweet/TweetLikes.js +0 -3
- package/dist/types/raw/query/tweet/TweetLikes.js.map +0 -1
- package/dist/types/raw/query/tweet/TweetRetweets.d.ts +0 -0
- package/dist/types/raw/query/tweet/TweetRetweets.js +0 -2
- package/dist/types/raw/query/tweet/TweetRetweets.js.map +0 -1
- package/dist/types/raw/query/user/Details.d.ts +0 -34
- package/dist/types/raw/query/user/Details.js +0 -3
- package/dist/types/raw/query/user/Details.js.map +0 -1
- package/dist/types/raw/tweet/Favouriters.d.ts +0 -164
- package/dist/types/raw/tweet/Favouriters.js +0 -3
- package/dist/types/raw/tweet/Favouriters.js.map +0 -1
- package/dist/types/raw/tweet/Retweeters.js +0 -3
- package/dist/types/raw/tweet/Retweeters.js.map +0 -1
- package/dist/types/raw/tweet/Tweet.d.ts +0 -746
- package/dist/types/raw/tweet/Tweet.js +0 -3
- package/dist/types/raw/tweet/Tweet.js.map +0 -1
- package/dist/types/raw/tweet/Tweets.js +0 -3
- package/dist/types/raw/tweet/Tweets.js.map +0 -1
- package/dist/types/raw/user/Followers.js +0 -3
- package/dist/types/raw/user/Followers.js.map +0 -1
- package/dist/types/raw/user/Following.js +0 -3
- package/dist/types/raw/user/Following.js.map +0 -1
- package/dist/types/raw/user/Likes.d.ts +0 -1059
- package/dist/types/raw/user/Likes.js +0 -3
- package/dist/types/raw/user/Likes.js.map +0 -1
- package/dist/types/raw/user/Tweets.js +0 -3
- package/dist/types/raw/user/Tweets.js.map +0 -1
- package/dist/types/raw/user/User.js.map +0 -1
- package/dist/types/services/args/TweetFilter.d.ts +0 -50
- package/dist/types/services/args/TweetFilter.js +0 -76
- package/dist/types/services/args/TweetFilter.js.map +0 -1
- package/src/services/helper/urls/Tweets.ts +0 -46
- package/src/services/helper/urls/Users.ts +0 -78
- /package/src/{types/raw → twitter/types}/tweet/Favouriters.ts +0 -0
- /package/src/{types/raw → twitter/types}/tweet/Retweeters.ts +0 -0
- /package/src/{types/raw → twitter/types}/tweet/Tweet.ts +0 -0
- /package/src/{types/raw → twitter/types}/tweet/Tweets.ts +0 -0
- /package/src/{types/raw → twitter/types}/user/Followers.ts +0 -0
- /package/src/{types/raw → twitter/types}/user/Following.ts +0 -0
- /package/src/{types/raw → twitter/types}/user/Likes.ts +0 -0
- /package/src/{types/raw → twitter/types}/user/User.ts +0 -0
|
@@ -22,23 +22,25 @@ import { Cookie, CookieJar } from 'cookiejar';
|
|
|
22
22
|
*/
|
|
23
23
|
export class AccountService {
|
|
24
24
|
/** The AuthService instance to use for authentication. */
|
|
25
|
-
private auth: AuthService;
|
|
26
|
-
|
|
25
|
+
private auth: AuthService = new AuthService();
|
|
26
|
+
|
|
27
27
|
/** The current guest credentials to use. */
|
|
28
|
-
private guestCreds: IGuestCredentials;
|
|
28
|
+
private guestCreds: IGuestCredentials = { authToken: '', guestToken: '' };
|
|
29
|
+
|
|
30
|
+
/** The email id of Twitter account to be logged into. */
|
|
31
|
+
private email: string = '';
|
|
32
|
+
|
|
33
|
+
/** The user name of the Twitter account ot be logged into */
|
|
34
|
+
private userName: string = '';
|
|
35
|
+
|
|
36
|
+
/** The password to the Twitter account to be logged into. */
|
|
37
|
+
private password: string = '';
|
|
29
38
|
|
|
30
39
|
/** The cookies received from Twitter after logging in. */
|
|
31
|
-
private cookies: Cookie[];
|
|
40
|
+
private cookies: Cookie[] = [];
|
|
32
41
|
|
|
33
42
|
/** The flow token received after execution of current flow. */
|
|
34
|
-
private flowToken: string;
|
|
35
|
-
|
|
36
|
-
constructor() {
|
|
37
|
-
this.auth = new AuthService();
|
|
38
|
-
this.guestCreds = { authToken: '', guestToken: '' };
|
|
39
|
-
this.cookies = [];
|
|
40
|
-
this.flowToken = '';
|
|
41
|
-
}
|
|
43
|
+
private flowToken: string = '';
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
46
|
* @returns The current guest credentials to use. If if does not exists, then a new one is created
|
|
@@ -69,6 +71,9 @@ export class AccountService {
|
|
|
69
71
|
|
|
70
72
|
// Getting the flow token
|
|
71
73
|
this.flowToken = res.data['flow_token'];
|
|
74
|
+
|
|
75
|
+
// Executing next subtask
|
|
76
|
+
await this.jsInstrumentationSubtask();
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
/**
|
|
@@ -76,7 +81,7 @@ export class AccountService {
|
|
|
76
81
|
* @internal
|
|
77
82
|
*/
|
|
78
83
|
private async jsInstrumentationSubtask(): Promise<void> {
|
|
79
|
-
// Executing the
|
|
84
|
+
// Executing the subtask
|
|
80
85
|
const res: CurlyResult = await curly.post(LoginFlows.JsInstrumentationSubtask.url, {
|
|
81
86
|
httpHeader: loginHeader(await this.getGuestCredentials(), this.cookies.join(';').toString()),
|
|
82
87
|
sslVerifyPeer: false,
|
|
@@ -85,6 +90,9 @@ export class AccountService {
|
|
|
85
90
|
|
|
86
91
|
// Getting the flow token
|
|
87
92
|
this.flowToken = res.data['flow_token'];
|
|
93
|
+
|
|
94
|
+
// Executing next subtask
|
|
95
|
+
await this.enterUserIdentifier();
|
|
88
96
|
}
|
|
89
97
|
|
|
90
98
|
/**
|
|
@@ -93,12 +101,12 @@ export class AccountService {
|
|
|
93
101
|
*
|
|
94
102
|
* @throws {@link AuthenticationErrors.InvalidEmail}, if email does not exist.
|
|
95
103
|
*/
|
|
96
|
-
private async enterUserIdentifier(
|
|
97
|
-
// Executing the
|
|
104
|
+
private async enterUserIdentifier(): Promise<void> {
|
|
105
|
+
// Executing the subtask
|
|
98
106
|
const res: CurlyResult = await curly.post(LoginFlows.EnterUserIdentifier.url, {
|
|
99
107
|
httpHeader: loginHeader(await this.getGuestCredentials(), this.cookies.join(';').toString()),
|
|
100
108
|
sslVerifyPeer: false,
|
|
101
|
-
postFields: JSON.stringify(LoginFlows.EnterUserIdentifier.body(this.flowToken, email))
|
|
109
|
+
postFields: JSON.stringify(LoginFlows.EnterUserIdentifier.body(this.flowToken, this.email))
|
|
102
110
|
});
|
|
103
111
|
|
|
104
112
|
// If no account found with given email
|
|
@@ -108,6 +116,31 @@ export class AccountService {
|
|
|
108
116
|
|
|
109
117
|
// Getting the flow token
|
|
110
118
|
this.flowToken = res.data['flow_token'];
|
|
119
|
+
|
|
120
|
+
// Checking the next available subtasks
|
|
121
|
+
/**
|
|
122
|
+
* This subtask has two possible outcomes.
|
|
123
|
+
* 1. The server asks for a username next.
|
|
124
|
+
* 2. The server directly asks for password, skipping username check.
|
|
125
|
+
*
|
|
126
|
+
* So, checking which is the subtask required by server, and executing that particular subtask.
|
|
127
|
+
*/
|
|
128
|
+
for (let task of res.data.subtasks) {
|
|
129
|
+
// If next subtask is to enter username
|
|
130
|
+
if (task['subtask_id'] == 'LoginEnterAlternateIdentifierSubtask') {
|
|
131
|
+
// Executing next subtask
|
|
132
|
+
await this.enterAlternateUserIdentifier();
|
|
133
|
+
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
// If next subtask is to enter password
|
|
137
|
+
else if (task['subtask_id'] == 'LoginEnterPassword') {
|
|
138
|
+
// Executing next subtask
|
|
139
|
+
await this.enterPassword();
|
|
140
|
+
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
111
144
|
}
|
|
112
145
|
|
|
113
146
|
/**
|
|
@@ -116,12 +149,12 @@ export class AccountService {
|
|
|
116
149
|
*
|
|
117
150
|
* @throws {@link AuthenticationErrors.InvalidUsername}, if wrong username entered.
|
|
118
151
|
*/
|
|
119
|
-
private async enterAlternateUserIdentifier(
|
|
120
|
-
// Executing the
|
|
152
|
+
private async enterAlternateUserIdentifier(): Promise<void> {
|
|
153
|
+
// Executing the subtask
|
|
121
154
|
const res: CurlyResult = await curly.post(LoginFlows.EnterAlternateUserIdentifier.url, {
|
|
122
155
|
httpHeader: loginHeader(await this.getGuestCredentials(), this.cookies.join(';').toString()),
|
|
123
156
|
sslVerifyPeer: false,
|
|
124
|
-
postFields: JSON.stringify(LoginFlows.EnterAlternateUserIdentifier.body(this.flowToken, userName))
|
|
157
|
+
postFields: JSON.stringify(LoginFlows.EnterAlternateUserIdentifier.body(this.flowToken, this.userName))
|
|
125
158
|
});
|
|
126
159
|
|
|
127
160
|
// If invalid username for the given account
|
|
@@ -131,6 +164,9 @@ export class AccountService {
|
|
|
131
164
|
|
|
132
165
|
// Getting the flow token
|
|
133
166
|
this.flowToken = res.data['flow_token'];
|
|
167
|
+
|
|
168
|
+
// Executing next subtask
|
|
169
|
+
await this.enterPassword();
|
|
134
170
|
}
|
|
135
171
|
|
|
136
172
|
/**
|
|
@@ -139,12 +175,12 @@ export class AccountService {
|
|
|
139
175
|
*
|
|
140
176
|
* @throws {@link AuthenticationErrors.InvalidPassword}, incorrect password entered.
|
|
141
177
|
*/
|
|
142
|
-
private async enterPassword(
|
|
143
|
-
// Executing the
|
|
178
|
+
private async enterPassword(): Promise<void> {
|
|
179
|
+
// Executing the subtask
|
|
144
180
|
const res: CurlyResult = await curly.post(LoginFlows.EnterPassword.url, {
|
|
145
181
|
httpHeader: loginHeader(await this.getGuestCredentials(), this.cookies.join(';').toString()),
|
|
146
182
|
sslVerifyPeer: false,
|
|
147
|
-
postFields: JSON.stringify(LoginFlows.EnterPassword.body(this.flowToken, password))
|
|
183
|
+
postFields: JSON.stringify(LoginFlows.EnterPassword.body(this.flowToken, this.password))
|
|
148
184
|
});
|
|
149
185
|
|
|
150
186
|
// If invalid password for the given account
|
|
@@ -154,6 +190,9 @@ export class AccountService {
|
|
|
154
190
|
|
|
155
191
|
// Getting the flow token
|
|
156
192
|
this.flowToken = res.data['flow_token'];
|
|
193
|
+
|
|
194
|
+
// Executing next subtask
|
|
195
|
+
await this.accountDuplicationCheck();
|
|
157
196
|
}
|
|
158
197
|
|
|
159
198
|
/**
|
|
@@ -161,7 +200,7 @@ export class AccountService {
|
|
|
161
200
|
* @internal
|
|
162
201
|
*/
|
|
163
202
|
private async accountDuplicationCheck(): Promise<void> {
|
|
164
|
-
// Executing the
|
|
203
|
+
// Executing the subtask
|
|
165
204
|
const res: CurlyResult = await curly.post(LoginFlows.AccountDuplicationCheck.url, {
|
|
166
205
|
httpHeader: loginHeader(await this.getGuestCredentials(), this.cookies.join(';').toString()),
|
|
167
206
|
sslVerifyPeer: false,
|
|
@@ -175,31 +214,6 @@ export class AccountService {
|
|
|
175
214
|
this.flowToken = res.data['flow_token'];
|
|
176
215
|
}
|
|
177
216
|
|
|
178
|
-
/**
|
|
179
|
-
* Execute all the flows required to login to Twitter, using the given credentials, then set the response cookies.
|
|
180
|
-
*
|
|
181
|
-
* @internal
|
|
182
|
-
*
|
|
183
|
-
* @param email The email of the account to be logged into.
|
|
184
|
-
* @param userName The username associated with the given account.
|
|
185
|
-
* @param password The password to the account.
|
|
186
|
-
*/
|
|
187
|
-
private async executeLoginFlows(email: string, userName: string, password: string): Promise<void> {
|
|
188
|
-
/**
|
|
189
|
-
* This works by sending a chain of request that are required for login to twitter.
|
|
190
|
-
* Each method in the chain returns a flow token that must be provied as payload in the next method in the chain.
|
|
191
|
-
* Each such method is called a subtask.
|
|
192
|
-
* Each subtask sets the {@link flowToken} property of the class which is then given in the payload of the next subtask.
|
|
193
|
-
* The final subtask returns the headers which actually contains the cookie in the 'set-cookie' field.
|
|
194
|
-
*/
|
|
195
|
-
await this.initiateLogin();
|
|
196
|
-
await this.jsInstrumentationSubtask();
|
|
197
|
-
await this.enterUserIdentifier(email);
|
|
198
|
-
await this.enterAlternateUserIdentifier(userName);
|
|
199
|
-
await this.enterPassword(password);
|
|
200
|
-
await this.accountDuplicationCheck();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
217
|
/**
|
|
204
218
|
* Parse the authentication cookies recieved from Twitter into known format.
|
|
205
219
|
*
|
|
@@ -212,7 +226,7 @@ export class AccountService {
|
|
|
212
226
|
private parseCookies(cookies: Cookie[]): IAuthCookie {
|
|
213
227
|
/** The tempoorary parsed cookies. */
|
|
214
228
|
let tempCookies: any = {};
|
|
215
|
-
|
|
229
|
+
|
|
216
230
|
/**
|
|
217
231
|
* Parsing the cookies into a standard JSON format.
|
|
218
232
|
* The format is 'cookie_name': 'cookie_value'.
|
|
@@ -244,13 +258,25 @@ export class AccountService {
|
|
|
244
258
|
public async login(email: string, userName: string, password: string): Promise<IAuthCookie> {
|
|
245
259
|
/** The parsed cookies that will be returned. */
|
|
246
260
|
let parsedCookies: IAuthCookie;
|
|
247
|
-
|
|
248
|
-
//
|
|
249
|
-
|
|
261
|
+
|
|
262
|
+
// Setting user credentials
|
|
263
|
+
this.email = email;
|
|
264
|
+
this.userName = userName;
|
|
265
|
+
this.password = password;
|
|
266
|
+
|
|
267
|
+
// Initiating login
|
|
268
|
+
/**
|
|
269
|
+
* This works by sending a chain of request that are required for login to twitter.
|
|
270
|
+
* Each method in the chain returns a flow token that must be provied as payload in the next method in the chain.
|
|
271
|
+
* Each such method is called a subtask.
|
|
272
|
+
* Each subtask sets the {@link flowToken} property of the class which is used in the payload of the next subtask.
|
|
273
|
+
* The final subtask returns the headers which actually contains the cookie in the 'set-cookie' field.
|
|
274
|
+
*/
|
|
275
|
+
await this.initiateLogin();
|
|
250
276
|
|
|
251
277
|
// Parsing the cookies
|
|
252
278
|
parsedCookies = this.parseCookies(this.cookies);
|
|
253
|
-
|
|
279
|
+
|
|
254
280
|
// Returning the final parsed cookies
|
|
255
281
|
return parsedCookies;
|
|
256
282
|
}
|
|
@@ -3,6 +3,7 @@ import { FetcherService } from "../util/FetcherService";
|
|
|
3
3
|
import { AuthService } from "../auth/AuthService";
|
|
4
4
|
|
|
5
5
|
// MODELS
|
|
6
|
+
import { Url } from '../../twitter/Url';
|
|
6
7
|
import { Tweet } from "../../models/data/Tweet";
|
|
7
8
|
import { User } from "../../models/data/User";
|
|
8
9
|
import { TweetListArgs } from "../../models/args/TweetListArgs";
|
|
@@ -10,24 +11,19 @@ import { TweetFilter } from "../../models/args/TweetFilter";
|
|
|
10
11
|
import { CursoredData } from '../../models/data/CursoredData';
|
|
11
12
|
|
|
12
13
|
// TYPES
|
|
13
|
-
import RawTweet, { Result as TweetData } from '../../types/
|
|
14
|
-
import { Result as UserData } from "../../types/
|
|
15
|
-
import RawTweets from '../../types/
|
|
16
|
-
import RawLikers from '../../types/
|
|
17
|
-
import RawRetweeters from '../../types/
|
|
14
|
+
import RawTweet, { Result as TweetData } from '../../twitter/types/tweet/Tweet';
|
|
15
|
+
import { Result as UserData } from "../../twitter/types/user/User";
|
|
16
|
+
import RawTweets from '../../twitter/types/tweet/Tweets';
|
|
17
|
+
import RawLikers from '../../twitter/types/tweet/Favouriters';
|
|
18
|
+
import RawRetweeters from '../../twitter/types/tweet/Retweeters';
|
|
18
19
|
|
|
19
20
|
// ENUMS
|
|
21
|
+
import { ResourceType } from '../../twitter/enums/Resources';
|
|
20
22
|
import { AuthenticationErrors } from '../../enums/Errors';
|
|
21
23
|
|
|
22
|
-
// URLS
|
|
23
|
-
import * as TweetUrls from '../helper/urls/Tweets';
|
|
24
|
-
|
|
25
24
|
// EXTRACTORS
|
|
26
25
|
import * as TweetExtractors from "../helper/extractors/Tweets";
|
|
27
26
|
|
|
28
|
-
// PARSERS
|
|
29
|
-
import { toQueryString } from '../helper/Parser';
|
|
30
|
-
|
|
31
27
|
/**
|
|
32
28
|
* Handles fetching of data related to tweets.
|
|
33
29
|
* @public
|
|
@@ -47,19 +43,24 @@ export class TweetService extends FetcherService {
|
|
|
47
43
|
*
|
|
48
44
|
* @returns The list of tweets that match the given filter.
|
|
49
45
|
*
|
|
46
|
+
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
50
47
|
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if an invalid count has been provided.
|
|
51
|
-
*
|
|
52
|
-
* @remarks
|
|
53
|
-
*
|
|
54
|
-
* Cookies are required to use this method!
|
|
55
48
|
*/
|
|
56
49
|
async getTweets(query: TweetFilter, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
|
|
50
|
+
// If user is not authenticated, abort
|
|
51
|
+
if (!this.isAuthenticated) {
|
|
52
|
+
throw new Error(AuthenticationErrors.NotAuthenticated);
|
|
53
|
+
}
|
|
54
|
+
|
|
57
55
|
// Objectifying parameters
|
|
58
56
|
let filter: TweetFilter = new TweetFilter(query);
|
|
59
57
|
let args: TweetListArgs = new TweetListArgs(count, cursor);
|
|
60
58
|
|
|
59
|
+
// Preparing the URL
|
|
60
|
+
const url: string = new Url(ResourceType.TWEETS, { query: filter.toString(), count: args.count, cursor: args.cursor }).toString();
|
|
61
|
+
|
|
61
62
|
// Getting the raw data
|
|
62
|
-
let res = await this.request<RawTweets>(
|
|
63
|
+
let res = await this.request<RawTweets>(url).then(res => res.data);
|
|
63
64
|
|
|
64
65
|
// Extracting data
|
|
65
66
|
let data = TweetExtractors.extractTweets(res);
|
|
@@ -81,13 +82,15 @@ export class TweetService extends FetcherService {
|
|
|
81
82
|
*
|
|
82
83
|
* @returns The details of a single tweet with the given tweet id.
|
|
83
84
|
*
|
|
85
|
+
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
84
86
|
* @throws {@link Errors.DataErrors.TweetNotFound} error, if no tweet with the given id was found.
|
|
85
|
-
*
|
|
86
|
-
* @remarks
|
|
87
|
-
*
|
|
88
|
-
* No cookies are required to use this method.
|
|
89
87
|
*/
|
|
90
88
|
async getTweetDetails(id: string): Promise<Tweet> {
|
|
89
|
+
// If user is not authenticated, abort
|
|
90
|
+
if (!this.isAuthenticated) {
|
|
91
|
+
throw new Error(AuthenticationErrors.NotAuthenticated);
|
|
92
|
+
}
|
|
93
|
+
|
|
91
94
|
// Getting data from cache
|
|
92
95
|
let cachedData = await this.readData(id);
|
|
93
96
|
|
|
@@ -96,8 +99,11 @@ export class TweetService extends FetcherService {
|
|
|
96
99
|
return cachedData;
|
|
97
100
|
}
|
|
98
101
|
|
|
102
|
+
// Preparing the URL
|
|
103
|
+
const url: string = new Url(ResourceType.TWEET_DETAILS, { id: id }).toString();
|
|
104
|
+
|
|
99
105
|
// Fetching the raw data
|
|
100
|
-
let res = await this.request<RawTweet>(
|
|
106
|
+
let res = await this.request<RawTweet>(url).then(res => res.data);
|
|
101
107
|
|
|
102
108
|
// Extracting data
|
|
103
109
|
let data = TweetExtractors.extractTweet(res, id);
|
|
@@ -121,10 +127,6 @@ export class TweetService extends FetcherService {
|
|
|
121
127
|
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
122
128
|
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count is provided.
|
|
123
129
|
* @throws {@link Errors.DataErrors.TweetNotFound} error, if no tweet with the given id was found.
|
|
124
|
-
*
|
|
125
|
-
* @remarks
|
|
126
|
-
*
|
|
127
|
-
* Cookies are required to use this method!
|
|
128
130
|
*/
|
|
129
131
|
async getTweetLikers(tweetId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
130
132
|
// If user is not authenticated, abort
|
|
@@ -135,8 +137,11 @@ export class TweetService extends FetcherService {
|
|
|
135
137
|
// Objectifying parameters
|
|
136
138
|
let args: TweetListArgs = new TweetListArgs(count, cursor);
|
|
137
139
|
|
|
140
|
+
// Preparing the URL
|
|
141
|
+
const url: string = new Url(ResourceType.TWEET_LIKES, { id: tweetId, count: args.count, cursor: args.cursor }).toString();
|
|
142
|
+
|
|
138
143
|
// Fetching the raw data
|
|
139
|
-
let res = await this.request<RawLikers>(
|
|
144
|
+
let res = await this.request<RawLikers>(url).then(res => res.data);
|
|
140
145
|
|
|
141
146
|
// Extracting data
|
|
142
147
|
let data = TweetExtractors.extractTweetLikers(res);
|
|
@@ -160,10 +165,6 @@ export class TweetService extends FetcherService {
|
|
|
160
165
|
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
161
166
|
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count is provided.
|
|
162
167
|
* @throws {@link Errors.DataErrors.TweetNotFound} error, if no tweet with the given id was found.
|
|
163
|
-
*
|
|
164
|
-
* @remarks
|
|
165
|
-
*
|
|
166
|
-
* Cookies are required to use this method!
|
|
167
168
|
*/
|
|
168
169
|
async getTweetRetweeters(tweetId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
169
170
|
// If user is not authenticated, abort
|
|
@@ -174,8 +175,11 @@ export class TweetService extends FetcherService {
|
|
|
174
175
|
// Objectifying parameters
|
|
175
176
|
let args: TweetListArgs = new TweetListArgs(count, cursor);
|
|
176
177
|
|
|
178
|
+
// Preparing the URL
|
|
179
|
+
const url: string = new Url(ResourceType.TWEET_RETWEETS, { id: tweetId, count: args.count, cursor: args.cursor }).toString();
|
|
180
|
+
|
|
177
181
|
// Fetching the raw data
|
|
178
|
-
let res = await this.request<RawRetweeters>(
|
|
182
|
+
let res = await this.request<RawRetweeters>(url).then(res => res.data);
|
|
179
183
|
|
|
180
184
|
// Extracting data
|
|
181
185
|
let data = TweetExtractors.extractTweetRetweeters(res);
|
|
@@ -188,38 +192,4 @@ export class TweetService extends FetcherService {
|
|
|
188
192
|
|
|
189
193
|
return new CursoredData<User>(users, data.cursor);
|
|
190
194
|
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* THIS IS DISABLED FOR USE FOR NOW BECAUSE TWITTER DOESN'T HAVE ANY ENDPOINT FOR FETCHING REPLIES.
|
|
194
|
-
* THE DATA THIS RETURNS IS INCONSISTENT!
|
|
195
|
-
*
|
|
196
|
-
* @param tweetId The rest id of the target tweet.
|
|
197
|
-
* @param cursor The cursor to the next batch of replies. If blank, first batch is fetched.
|
|
198
|
-
* @returns The list of replies to the given tweet.
|
|
199
|
-
*/
|
|
200
|
-
/*
|
|
201
|
-
async getTweetReplies(tweetId: string, cursor: string): Promise<CursoredData<Tweet>> {
|
|
202
|
-
// If user is not authenticated, abort
|
|
203
|
-
if(!this.isAuthenticated) {
|
|
204
|
-
throw new Error(Errors.AuthenticationErrors.NotAuthenticated);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Fetching the raw data
|
|
208
|
-
let res = await this.request<RawTweet>(TweetUrls.tweetRepliesUrl(tweetId, cursor)).then(res => res.data);
|
|
209
|
-
|
|
210
|
-
// Extracting data
|
|
211
|
-
let data = TweetExtractors.extractTweetReplies(res, tweetId);
|
|
212
|
-
|
|
213
|
-
// Caching data
|
|
214
|
-
this.cacheData(data);
|
|
215
|
-
|
|
216
|
-
// Parsing data
|
|
217
|
-
let tweets = data.required.map((item: TweetData) => TweetDeserializers.toTweet(item));
|
|
218
|
-
|
|
219
|
-
return {
|
|
220
|
-
list: tweets,
|
|
221
|
-
next: { value: data.cursor }
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
*/
|
|
225
195
|
}
|
|
@@ -3,27 +3,26 @@ import { FetcherService } from '../util/FetcherService';
|
|
|
3
3
|
import { AuthService } from '../auth/AuthService';
|
|
4
4
|
|
|
5
5
|
// MODELS
|
|
6
|
+
import { Url } from '../../twitter/Url';
|
|
6
7
|
import { User } from '../../models/data/User';
|
|
7
8
|
import { UserListArgs } from '../../models/args/UserListArgs';
|
|
8
9
|
import { Tweet } from '../../models/data/Tweet';
|
|
9
10
|
|
|
10
11
|
// TYPES
|
|
11
12
|
import { CursoredData } from '../../models/data/CursoredData';
|
|
12
|
-
import { Result as TweetData } from '../../types/
|
|
13
|
-
import RawUser, { Result as UserData } from '../../types/
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import RawUserLikes from '../../types/raw/user/Likes';
|
|
13
|
+
import { Result as TweetData } from '../../twitter/types/tweet/Tweet';
|
|
14
|
+
import RawUser, { Result as UserData } from '../../twitter/types/user/User';
|
|
15
|
+
import RawUserFollowers from '../../twitter/types/user/Followers';
|
|
16
|
+
import RawUserFollowing from '../../twitter/types/user/Following';
|
|
17
|
+
import RawUserLikes from '../../twitter/types/user/Likes';
|
|
18
18
|
|
|
19
19
|
// ENUMS
|
|
20
|
+
import { ResourceType } from '../../twitter/enums/Resources';
|
|
20
21
|
import { AuthenticationErrors } from '../../enums/Errors';
|
|
21
22
|
|
|
22
|
-
// URLS
|
|
23
|
-
import * as UserUrls from '../helper/urls/Users';
|
|
24
|
-
|
|
25
23
|
// EXTRACTORS
|
|
26
24
|
import * as UserExtractors from '../helper/extractors/Users';
|
|
25
|
+
import { TweetService } from './TweetService';
|
|
27
26
|
|
|
28
27
|
/**
|
|
29
28
|
* Handles fetching of data related to user account
|
|
@@ -41,19 +40,24 @@ export class UserService extends FetcherService {
|
|
|
41
40
|
*
|
|
42
41
|
* @returns The details of the given user.
|
|
43
42
|
*
|
|
43
|
+
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
44
44
|
* @throws {@link Errors.DataErrors.UserNotFound} error, if no user with the given username was found.
|
|
45
|
-
*
|
|
46
|
-
* @remarks
|
|
47
|
-
*
|
|
48
|
-
* No cookies are required to use this method.
|
|
49
45
|
*/
|
|
50
46
|
async getUserDetails(id: string): Promise<User> {
|
|
47
|
+
// If user is not authenticated, abort
|
|
48
|
+
if (!this.isAuthenticated) {
|
|
49
|
+
throw new Error(AuthenticationErrors.NotAuthenticated);
|
|
50
|
+
}
|
|
51
|
+
|
|
51
52
|
let res: RawUser;
|
|
52
53
|
|
|
53
54
|
// If id is not a numeric string => username is supplied
|
|
54
55
|
if (isNaN(Number(id))) {
|
|
56
|
+
// Preparing the URL
|
|
57
|
+
const url: string = new Url(ResourceType.USER_DETAILS, { id: id }).toString();
|
|
58
|
+
|
|
55
59
|
// Fetching the raw data
|
|
56
|
-
res = await this.request<RawUser>(
|
|
60
|
+
res = await this.request<RawUser>(url).then(res => res.data);
|
|
57
61
|
}
|
|
58
62
|
// If id is a numeric string => id is supplied
|
|
59
63
|
else {
|
|
@@ -65,8 +69,11 @@ export class UserService extends FetcherService {
|
|
|
65
69
|
return cachedData;
|
|
66
70
|
}
|
|
67
71
|
|
|
72
|
+
// Preparing the URL
|
|
73
|
+
const url: string = new Url(ResourceType.USER_DETAILS_BY_ID, { id: id }).toString();
|
|
74
|
+
|
|
68
75
|
// Fetching the raw data
|
|
69
|
-
res = await this.request<RawUser>(
|
|
76
|
+
res = await this.request<RawUser>(url).then(res => res.data);
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
// Extracting data
|
|
@@ -88,30 +95,20 @@ export class UserService extends FetcherService {
|
|
|
88
95
|
*
|
|
89
96
|
* @returns The list of tweets nade by the target user.
|
|
90
97
|
*
|
|
98
|
+
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
91
99
|
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count has been provided.
|
|
92
100
|
* @throws {@link Errors.DataErrors.UserNotFound} error, if invalid count has been provided.
|
|
93
101
|
*
|
|
94
|
-
* @
|
|
95
|
-
*
|
|
96
|
-
* No cookies are required to use this method.
|
|
102
|
+
* @deprecated Use [this](https://rishikant181.github.io/Rettiwt-API/classes/TweetService.html#getTweets) method instead. It's better in every possible way!
|
|
97
103
|
*/
|
|
98
104
|
async getUserTweets(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// Fetching the raw data
|
|
103
|
-
let res = await this.request<RawUserTweets>(UserUrls.userTweetsUrl(userId, args.count, args.cursor), false).then(res => res.data);
|
|
105
|
+
// Getting the username of the target user
|
|
106
|
+
const userName: string = (await this.getUserDetails(userId)).userName;
|
|
104
107
|
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.cacheData(data);
|
|
110
|
-
|
|
111
|
-
// Parsing data
|
|
112
|
-
let tweets = data.required.map((item: TweetData) => new Tweet(item));
|
|
113
|
-
|
|
114
|
-
return new CursoredData<Tweet>(tweets, data.cursor);
|
|
108
|
+
// Getting the tweets of the target user
|
|
109
|
+
return new TweetService(this.auth).getTweets({
|
|
110
|
+
fromUsers: [userName]
|
|
111
|
+
}, count, cursor);
|
|
115
112
|
}
|
|
116
113
|
|
|
117
114
|
/**
|
|
@@ -124,10 +121,6 @@ export class UserService extends FetcherService {
|
|
|
124
121
|
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
125
122
|
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count has been provided.
|
|
126
123
|
* @throws {@link Errors.DataErrors.UserNotFound} error, if invalid count has been provided.
|
|
127
|
-
*
|
|
128
|
-
* @remarks
|
|
129
|
-
*
|
|
130
|
-
* Cookies are required to use this method!
|
|
131
124
|
*/
|
|
132
125
|
async getUserFollowing(userId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
133
126
|
// If user is not authenticated, abort
|
|
@@ -138,8 +131,11 @@ export class UserService extends FetcherService {
|
|
|
138
131
|
// Objectifying parameters
|
|
139
132
|
let args: UserListArgs = new UserListArgs(count, cursor);
|
|
140
133
|
|
|
134
|
+
// Preparing the URL
|
|
135
|
+
const url: string = new Url(ResourceType.USER_FOLLOWING, { id: userId, count: args.count, cursor: args.cursor }).toString();
|
|
136
|
+
|
|
141
137
|
// Fetchin the raw data
|
|
142
|
-
let res = await this.request<RawUserFollowing>(
|
|
138
|
+
let res = await this.request<RawUserFollowing>(url).then(res => res.data);
|
|
143
139
|
|
|
144
140
|
// Extracting data
|
|
145
141
|
let data = UserExtractors.extractUserFollow(res);
|
|
@@ -163,10 +159,6 @@ export class UserService extends FetcherService {
|
|
|
163
159
|
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
164
160
|
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count has been provided.
|
|
165
161
|
* @throws {@link Errors.DataErrors.UserNotFound} error, if invalid count has been provided.
|
|
166
|
-
*
|
|
167
|
-
* @remarks
|
|
168
|
-
*
|
|
169
|
-
* Cookies are required to use this method!
|
|
170
162
|
*/
|
|
171
163
|
async getUserFollowers(userId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
172
164
|
// If user is not authenticated, abort
|
|
@@ -177,8 +169,11 @@ export class UserService extends FetcherService {
|
|
|
177
169
|
// Objectifying parameters
|
|
178
170
|
let args: UserListArgs = new UserListArgs(count, cursor);
|
|
179
171
|
|
|
172
|
+
// Preparing the URL
|
|
173
|
+
const url: string = new Url(ResourceType.USER_FOLLOWERS, { id: userId, count: args.count, cursor: args.cursor }).toString();
|
|
174
|
+
|
|
180
175
|
// Fetching the raw data
|
|
181
|
-
let res = await this.request<RawUserFollowers>(
|
|
176
|
+
let res = await this.request<RawUserFollowers>(url).then(res => res.data);
|
|
182
177
|
|
|
183
178
|
// Extracting data
|
|
184
179
|
let data = UserExtractors.extractUserFollow(res);
|
|
@@ -200,10 +195,6 @@ export class UserService extends FetcherService {
|
|
|
200
195
|
* @returns The list of tweets liked by the target user.
|
|
201
196
|
*
|
|
202
197
|
* @throws {@link AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
203
|
-
*
|
|
204
|
-
* @remarks
|
|
205
|
-
*
|
|
206
|
-
* Cookies are required to use this method!
|
|
207
198
|
*/
|
|
208
199
|
async getUserLikes(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
|
|
209
200
|
// If user is not authenticated, abort
|
|
@@ -214,8 +205,11 @@ export class UserService extends FetcherService {
|
|
|
214
205
|
// Objectifying parameters
|
|
215
206
|
let args: UserListArgs = new UserListArgs(count, cursor);
|
|
216
207
|
|
|
208
|
+
// Preparing the URL
|
|
209
|
+
const url: string = new Url(ResourceType.USER_LIKES, { id: userId, count: args.count, cursor: args.cursor }).toString();
|
|
210
|
+
|
|
217
211
|
// Fetching the raw data
|
|
218
|
-
let res = await this.request<RawUserLikes>(
|
|
212
|
+
let res = await this.request<RawUserLikes>(url).then(res => res.data);
|
|
219
213
|
|
|
220
214
|
// Extracting data
|
|
221
215
|
let data = UserExtractors.extractUserLikes(res);
|
|
@@ -7,7 +7,7 @@ import { ITweetFilter } from '../../types/Args';
|
|
|
7
7
|
*/
|
|
8
8
|
export function isJSONEmpty(data: any): boolean {
|
|
9
9
|
// If the JSON has any keys, it's not empty
|
|
10
|
-
if(Object.keys(data).length == 0) {
|
|
10
|
+
if (Object.keys(data).length == 0) {
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
13
|
// Else, it's empty
|
|
@@ -78,33 +78,12 @@ export function dataToList(data: any | any[]): any[] {
|
|
|
78
78
|
*/
|
|
79
79
|
export function normalizeText(text: string): string {
|
|
80
80
|
let normalizedText: string = ''; // To store the normalized text
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
// Removing unnecessary full stops, and other characters
|
|
83
83
|
normalizedText = text.replace(/\n/g, '.').replace(/[.]+[\s+.\s+]+/g, '. ');
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
// Adding full-stop to the end if does not exist already
|
|
86
86
|
normalizedText = normalizedText.endsWith('.') ? normalizedText : (normalizedText + '.');
|
|
87
87
|
|
|
88
88
|
return normalizedText;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @param filter The tweet filter to use for getting filtered tweets
|
|
93
|
-
* @returns The same tweet filter, in a URL query format string
|
|
94
|
-
*/
|
|
95
|
-
export function toQueryString(filter: ITweetFilter): string {
|
|
96
|
-
// Concatenating the input filter arguments to a URL query formatted string
|
|
97
|
-
return [
|
|
98
|
-
filter.words ? filter.words.join(' ') : '',
|
|
99
|
-
filter.hashtags ? `(${filter.hashtags.map(hashtag => '#' + hashtag).join(' OR ')})` : '',
|
|
100
|
-
filter.fromUsers ? `(${filter.fromUsers.map(user => `from:${user}`).join(' OR ')})` : '',
|
|
101
|
-
filter.toUsers ? `(${filter.toUsers.map(user => `to:${user}`).join(' OR ')})` : '',
|
|
102
|
-
filter.mentions ? `(${filter.mentions.map(mention => '@' + mention).join(' OR ')})` : '',
|
|
103
|
-
filter.startDate ? `since:${filter.startDate}` : '',
|
|
104
|
-
filter.endDate ? `until:${filter.endDate}` : '',
|
|
105
|
-
filter.sinceId ? `since_id:${filter.sinceId}` : '',
|
|
106
|
-
filter.quoted ? `quoted_tweet_id:${filter.quoted}` : ''
|
|
107
|
-
]
|
|
108
|
-
.filter(item => item !== '()' && item !== '')
|
|
109
|
-
.join(' ') + (!filter.links ? ' -filter:links' : '');
|
|
110
89
|
}
|