rettiwt-api 1.1.2 → 1.1.7

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.
Files changed (301) hide show
  1. package/README.md +32 -7
  2. package/dist/endpoints/Endpoints.d.ts +14 -0
  3. package/dist/endpoints/Endpoints.js +20 -0
  4. package/dist/endpoints/Endpoints.js.map +1 -0
  5. package/dist/endpoints/Url.d.ts +5 -0
  6. package/dist/endpoints/Url.js +12 -0
  7. package/dist/endpoints/Url.js.map +1 -0
  8. package/dist/enums/Endpoints.d.ts +25 -0
  9. package/dist/enums/Endpoints.js +31 -0
  10. package/dist/enums/Endpoints.js.map +1 -0
  11. package/dist/enums/Errors.d.ts +20 -0
  12. package/dist/enums/Errors.js +28 -0
  13. package/dist/enums/Errors.js.map +1 -0
  14. package/dist/enums/HTTP.d.ts +17 -0
  15. package/dist/enums/HTTP.js +23 -0
  16. package/dist/enums/HTTP.js.map +1 -0
  17. package/dist/graphql/enums/Errors.d.ts +21 -0
  18. package/dist/graphql/enums/Errors.js +29 -0
  19. package/dist/graphql/enums/Errors.js.map +1 -0
  20. package/dist/graphql/queries/RootQuery.js +10 -3
  21. package/dist/graphql/queries/RootQuery.js.map +1 -1
  22. package/dist/graphql/resolvers/AccountResolver.d.ts +3 -3
  23. package/dist/graphql/resolvers/AccountResolver.js.map +1 -1
  24. package/dist/graphql/resolvers/ResolverBase.d.ts +14 -3
  25. package/dist/graphql/resolvers/ResolverBase.js +13 -1
  26. package/dist/graphql/resolvers/ResolverBase.js.map +1 -1
  27. package/dist/graphql/resolvers/TweetResolver.d.ts +3 -3
  28. package/dist/graphql/resolvers/TweetResolver.js +30 -18
  29. package/dist/graphql/resolvers/TweetResolver.js.map +1 -1
  30. package/dist/graphql/resolvers/UserResolver.d.ts +13 -4
  31. package/dist/graphql/resolvers/UserResolver.js +83 -18
  32. package/dist/graphql/resolvers/UserResolver.js.map +1 -1
  33. package/dist/graphql/types/Errors.d.ts +20 -0
  34. package/dist/graphql/types/Errors.js +28 -0
  35. package/dist/graphql/types/Errors.js.map +1 -0
  36. package/dist/graphql/types/TweetTypes.js +2 -2
  37. package/dist/graphql/types/TweetTypes.js.map +1 -1
  38. package/dist/graphql/types/UserTypes.js +1 -1
  39. package/dist/graphql/types/UserTypes.js.map +1 -1
  40. package/dist/index.d.ts +31 -15
  41. package/dist/index.js +32 -17
  42. package/dist/index.js.map +1 -1
  43. package/dist/middlewares/Authentication.d.ts +0 -0
  44. package/dist/middlewares/Authentication.js +2 -0
  45. package/dist/middlewares/Authentication.js.map +1 -0
  46. package/dist/models/args/TweetFilter.d.ts +59 -0
  47. package/dist/models/args/TweetFilter.js +101 -0
  48. package/dist/models/args/TweetFilter.js.map +1 -0
  49. package/dist/models/args/TweetListArgs.d.ts +21 -0
  50. package/dist/models/args/TweetListArgs.js +54 -0
  51. package/dist/models/args/TweetListArgs.js.map +1 -0
  52. package/dist/models/args/UserListArgs.d.ts +21 -0
  53. package/dist/models/args/UserListArgs.js +54 -0
  54. package/dist/models/args/UserListArgs.js.map +1 -0
  55. package/dist/models/auth/AuthCookie.d.ts +21 -0
  56. package/dist/models/auth/AuthCookie.js +33 -0
  57. package/dist/models/auth/AuthCookie.js.map +1 -0
  58. package/dist/models/data/CursoredData.d.ts +34 -0
  59. package/dist/models/data/CursoredData.js +42 -0
  60. package/dist/models/data/CursoredData.js.map +1 -0
  61. package/dist/models/data/DataValidationError.d.ts +18 -0
  62. package/dist/models/data/DataValidationError.js +21 -0
  63. package/dist/models/data/DataValidationError.js.map +1 -0
  64. package/dist/models/data/Errors.d.ts +18 -0
  65. package/dist/models/data/Errors.js +21 -0
  66. package/dist/models/data/Errors.js.map +1 -0
  67. package/dist/models/data/Service.d.ts +33 -0
  68. package/dist/models/data/Service.js +41 -0
  69. package/dist/models/data/Service.js.map +1 -0
  70. package/dist/models/data/Tweet.d.ts +53 -0
  71. package/dist/models/data/Tweet.js +104 -0
  72. package/dist/models/data/Tweet.js.map +1 -0
  73. package/dist/models/data/User.d.ts +41 -0
  74. package/dist/models/data/User.js +32 -0
  75. package/dist/models/data/User.js.map +1 -0
  76. package/dist/models/errors/DataValidationError.d.ts +20 -0
  77. package/dist/models/errors/DataValidationError.js +23 -0
  78. package/dist/models/errors/DataValidationError.js.map +1 -0
  79. package/dist/models/query/Variables.d.ts +2 -0
  80. package/dist/models/query/Variables.js +10 -0
  81. package/dist/models/query/Variables.js.map +1 -0
  82. package/dist/requests/Url.d.ts +5 -0
  83. package/dist/requests/Url.js +12 -0
  84. package/dist/requests/Url.js.map +1 -0
  85. package/dist/requests/payloads/Variables.d.ts +23 -0
  86. package/dist/requests/payloads/Variables.js +24 -0
  87. package/dist/requests/payloads/Variables.js.map +1 -0
  88. package/dist/server.d.ts +1 -1
  89. package/dist/server.js +9 -10
  90. package/dist/server.js.map +1 -1
  91. package/dist/services/accounts/AccountService.d.ts +6 -0
  92. package/dist/services/accounts/AccountService.js +6 -0
  93. package/dist/services/accounts/AccountService.js.map +1 -1
  94. package/dist/services/auth/AccountService.d.ts +88 -0
  95. package/dist/services/auth/AccountService.js +392 -0
  96. package/dist/services/auth/AccountService.js.map +1 -0
  97. package/dist/services/auth/AuthService.d.ts +31 -0
  98. package/dist/services/auth/AuthService.js +118 -0
  99. package/dist/services/auth/AuthService.js.map +1 -0
  100. package/dist/services/auth/LoginFlows.d.ts +77 -0
  101. package/dist/services/auth/LoginFlows.js +92 -0
  102. package/dist/services/auth/LoginFlows.js.map +1 -0
  103. package/dist/services/data/TweetService.d.ts +46 -16
  104. package/dist/services/data/TweetService.js +71 -54
  105. package/dist/services/data/TweetService.js.map +1 -1
  106. package/dist/services/data/UserService.d.ts +58 -19
  107. package/dist/services/data/UserService.js +104 -68
  108. package/dist/services/data/UserService.js.map +1 -1
  109. package/dist/services/helper/Headers.d.ts +4 -4
  110. package/dist/services/helper/Headers.js.map +1 -1
  111. package/dist/services/helper/Parser.d.ts +2 -2
  112. package/dist/services/helper/Parser.js.map +1 -1
  113. package/dist/services/helper/extractors/Tweets.d.ts +6 -6
  114. package/dist/services/helper/extractors/Tweets.js +1 -1
  115. package/dist/services/helper/extractors/Tweets.js.map +1 -1
  116. package/dist/services/helper/extractors/Users.d.ts +10 -4
  117. package/dist/services/helper/extractors/Users.js +54 -2
  118. package/dist/services/helper/extractors/Users.js.map +1 -1
  119. package/dist/services/helper/payloads/LoginFlows.d.ts +77 -0
  120. package/dist/services/helper/payloads/LoginFlows.js +92 -0
  121. package/dist/services/helper/payloads/LoginFlows.js.map +1 -0
  122. package/dist/services/helper/urls/Users.d.ts +8 -1
  123. package/dist/services/helper/urls/Users.js +12 -2
  124. package/dist/services/helper/urls/Users.js.map +1 -1
  125. package/dist/services/util/CacheService.d.ts +33 -0
  126. package/dist/services/util/CacheService.js +96 -0
  127. package/dist/services/util/CacheService.js.map +1 -0
  128. package/dist/services/util/FetcherService.d.ts +65 -0
  129. package/dist/services/util/FetcherService.js +214 -0
  130. package/dist/services/util/FetcherService.js.map +1 -0
  131. package/dist/types/Args.d.ts +38 -0
  132. package/dist/types/Args.js +5 -0
  133. package/dist/types/Args.js.map +1 -0
  134. package/dist/types/Authentication.d.ts +17 -2
  135. package/dist/types/Authentication.js +1 -0
  136. package/dist/types/Authentication.js.map +1 -1
  137. package/dist/types/Query.d.ts +80 -0
  138. package/dist/types/Query.js +3 -0
  139. package/dist/types/Query.js.map +1 -0
  140. package/dist/types/Resolvers.d.ts +5 -4
  141. package/dist/types/Rettiwt.d.ts +16 -0
  142. package/dist/types/Rettiwt.js +3 -0
  143. package/dist/types/Rettiwt.js.map +1 -0
  144. package/dist/types/Service.d.ts +15 -23
  145. package/dist/types/Service.js +2 -16
  146. package/dist/types/Service.js.map +1 -1
  147. package/dist/types/Tweet.d.ts +25 -19
  148. package/dist/types/Tweet.js +0 -2
  149. package/dist/types/Tweet.js.map +1 -1
  150. package/dist/types/User.d.ts +35 -0
  151. package/dist/types/User.js +3 -0
  152. package/dist/types/User.js.map +1 -0
  153. package/dist/types/args/TweetFilter.d.ts +54 -0
  154. package/dist/types/args/TweetFilter.js +96 -0
  155. package/dist/types/args/TweetFilter.js.map +1 -0
  156. package/dist/types/args/TweetListArg.d.ts +10 -0
  157. package/dist/types/args/TweetListArg.js +42 -0
  158. package/dist/types/args/TweetListArg.js.map +1 -0
  159. package/dist/types/args/TweetListArgs.d.ts +20 -0
  160. package/dist/types/args/TweetListArgs.js +52 -0
  161. package/dist/types/args/TweetListArgs.js.map +1 -0
  162. package/dist/types/args/UserListArgs.d.ts +16 -0
  163. package/dist/types/args/UserListArgs.js +48 -0
  164. package/dist/types/args/UserListArgs.js.map +1 -0
  165. package/dist/types/data/TweetFilter.d.ts +49 -0
  166. package/dist/types/data/TweetFilter.js +63 -0
  167. package/dist/types/data/TweetFilter.js.map +1 -0
  168. package/dist/types/interfaces/Args.d.ts +38 -0
  169. package/dist/types/interfaces/Args.js +5 -0
  170. package/dist/types/interfaces/Args.js.map +1 -0
  171. package/dist/types/interfaces/Authentication.d.ts +40 -0
  172. package/dist/types/interfaces/Authentication.js +5 -0
  173. package/dist/types/interfaces/Authentication.js.map +1 -0
  174. package/dist/types/interfaces/Resolvers.d.ts +14 -0
  175. package/dist/types/interfaces/Resolvers.js +3 -0
  176. package/dist/types/interfaces/Resolvers.js.map +1 -0
  177. package/dist/types/interfaces/Rettiwt.d.ts +16 -0
  178. package/dist/types/interfaces/Rettiwt.js +3 -0
  179. package/dist/types/interfaces/Rettiwt.js.map +1 -0
  180. package/dist/types/interfaces/Service.d.ts +13 -0
  181. package/dist/types/interfaces/Service.js +3 -0
  182. package/dist/types/interfaces/Service.js.map +1 -0
  183. package/dist/types/interfaces/Services.d.ts +13 -0
  184. package/dist/types/interfaces/Services.js +3 -0
  185. package/dist/types/interfaces/Services.js.map +1 -0
  186. package/dist/types/interfaces/Tweet.d.ts +46 -0
  187. package/dist/types/interfaces/Tweet.js +3 -0
  188. package/dist/types/interfaces/Tweet.js.map +1 -0
  189. package/dist/types/interfaces/TweetFilter.d.ts +0 -0
  190. package/dist/types/interfaces/TweetFilter.js +2 -0
  191. package/dist/types/interfaces/TweetFilter.js.map +1 -0
  192. package/{src/types/data/User.ts → dist/types/interfaces/User.d.ts} +35 -51
  193. package/dist/types/interfaces/User.js +3 -0
  194. package/dist/types/interfaces/User.js.map +1 -0
  195. package/dist/types/raw/data/tweet/Favouriters.d.ts +164 -0
  196. package/dist/types/raw/data/tweet/Favouriters.js +3 -0
  197. package/dist/types/raw/data/tweet/Favouriters.js.map +1 -0
  198. package/dist/types/raw/data/tweet/Retweeters.d.ts +171 -0
  199. package/dist/types/raw/data/tweet/Retweeters.js +3 -0
  200. package/dist/types/raw/data/tweet/Retweeters.js.map +1 -0
  201. package/dist/types/raw/data/tweet/Tweet.d.ts +746 -0
  202. package/dist/types/raw/data/tweet/Tweet.js +3 -0
  203. package/dist/types/raw/data/tweet/Tweet.js.map +1 -0
  204. package/dist/types/raw/data/tweet/Tweets.d.ts +386 -0
  205. package/dist/types/raw/data/tweet/Tweets.js +3 -0
  206. package/dist/types/raw/data/tweet/Tweets.js.map +1 -0
  207. package/dist/types/raw/data/user/Followers.d.ts +176 -0
  208. package/dist/types/raw/data/user/Followers.js +3 -0
  209. package/dist/types/raw/data/user/Followers.js.map +1 -0
  210. package/dist/types/raw/data/user/Following.d.ts +176 -0
  211. package/dist/types/raw/data/user/Following.js +3 -0
  212. package/dist/types/raw/data/user/Following.js.map +1 -0
  213. package/dist/types/raw/data/user/Likes.d.ts +1059 -0
  214. package/dist/types/raw/data/user/Likes.js +3 -0
  215. package/dist/types/raw/data/user/Likes.js.map +1 -0
  216. package/dist/types/raw/data/user/User.d.ts +117 -0
  217. package/dist/types/raw/data/user/User.js +3 -0
  218. package/dist/types/raw/data/user/User.js.map +1 -0
  219. package/dist/types/raw/query/tweet/Details.d.ts +80 -0
  220. package/dist/types/raw/query/tweet/Details.js +5 -0
  221. package/dist/types/raw/query/tweet/Details.js.map +1 -0
  222. package/dist/types/raw/query/tweet/Engagements.d.ts +29 -0
  223. package/dist/types/raw/query/tweet/Engagements.js +3 -0
  224. package/dist/types/raw/query/tweet/Engagements.js.map +1 -0
  225. package/dist/types/raw/query/tweet/Likes.d.ts +29 -0
  226. package/dist/types/raw/query/tweet/Likes.js +3 -0
  227. package/dist/types/raw/query/tweet/Likes.js.map +1 -0
  228. package/dist/types/raw/query/tweet/Retweets.d.ts +29 -0
  229. package/dist/types/raw/query/tweet/Retweets.js +3 -0
  230. package/dist/types/raw/query/tweet/Retweets.js.map +1 -0
  231. package/dist/types/raw/query/tweet/Search.d.ts +40 -0
  232. package/dist/types/raw/query/tweet/Search.js +3 -0
  233. package/dist/types/raw/query/tweet/Search.js.map +1 -0
  234. package/dist/types/raw/query/tweet/TweetDetails.d.ts +34 -0
  235. package/dist/types/raw/query/tweet/TweetDetails.js +5 -0
  236. package/dist/types/raw/query/tweet/TweetDetails.js.map +1 -0
  237. package/dist/types/raw/query/tweet/TweetLike.d.ts +29 -0
  238. package/dist/types/raw/query/tweet/TweetLike.js +3 -0
  239. package/dist/types/raw/query/tweet/TweetLike.js.map +1 -0
  240. package/dist/types/raw/query/tweet/TweetLikes.d.ts +29 -0
  241. package/dist/types/raw/query/tweet/TweetLikes.js +3 -0
  242. package/dist/types/raw/query/tweet/TweetLikes.js.map +1 -0
  243. package/dist/types/raw/query/tweet/TweetRetweets.d.ts +0 -0
  244. package/dist/types/raw/query/tweet/TweetRetweets.js +2 -0
  245. package/dist/types/raw/query/tweet/TweetRetweets.js.map +1 -0
  246. package/dist/types/raw/query/user/Details.d.ts +34 -0
  247. package/dist/types/raw/query/user/Details.js +3 -0
  248. package/dist/types/raw/query/user/Details.js.map +1 -0
  249. package/dist/types/raw/user/Tweets.d.ts +668 -1584
  250. package/dist/types/services/args/TweetFilter.d.ts +50 -0
  251. package/dist/types/services/args/TweetFilter.js +76 -0
  252. package/dist/types/services/args/TweetFilter.js.map +1 -0
  253. package/package.json +6 -3
  254. package/src/enums/Errors.ts +21 -0
  255. package/src/graphql/enums/Errors.ts +22 -0
  256. package/src/graphql/queries/RootQuery.ts +11 -4
  257. package/src/graphql/resolvers/AccountResolver.ts +3 -3
  258. package/src/graphql/resolvers/ResolverBase.ts +19 -5
  259. package/src/graphql/resolvers/TweetResolver.ts +26 -17
  260. package/src/graphql/resolvers/UserResolver.ts +75 -20
  261. package/src/graphql/types/TweetTypes.ts +2 -2
  262. package/src/graphql/types/UserTypes.ts +4 -4
  263. package/src/index.ts +39 -17
  264. package/src/models/args/TweetFilter.ts +119 -0
  265. package/src/models/args/TweetListArgs.ts +47 -0
  266. package/src/models/args/UserListArgs.ts +47 -0
  267. package/src/models/auth/AuthCookie.ts +43 -0
  268. package/src/models/data/CursoredData.ts +45 -0
  269. package/src/models/data/Tweet.ts +118 -0
  270. package/src/models/data/User.ts +72 -0
  271. package/src/models/errors/DataValidationError.ts +29 -0
  272. package/src/server.ts +9 -10
  273. package/src/services/{accounts → auth}/AccountService.ts +71 -19
  274. package/src/services/auth/AuthService.ts +81 -0
  275. package/src/services/data/TweetService.ts +81 -62
  276. package/src/services/data/UserService.ts +118 -80
  277. package/src/services/helper/Headers.ts +4 -4
  278. package/src/services/helper/Parser.ts +2 -2
  279. package/src/services/helper/extractors/Tweets.ts +7 -7
  280. package/src/services/helper/extractors/Users.ts +60 -5
  281. package/src/services/helper/urls/Users.ts +39 -23
  282. package/src/services/{CacheService.ts → util/CacheService.ts} +4 -1
  283. package/src/services/{FetcherService.ts → util/FetcherService.ts} +19 -11
  284. package/src/types/Args.ts +49 -0
  285. package/src/types/Authentication.ts +29 -7
  286. package/src/types/Resolvers.ts +5 -4
  287. package/src/types/Rettiwt.ts +20 -0
  288. package/src/types/Service.ts +24 -0
  289. package/src/types/Tweet.ts +61 -0
  290. package/src/types/User.ts +48 -0
  291. package/src/types/raw/user/Tweets.ts +1747 -0
  292. package/tsconfig.json +2 -2
  293. package/src/services/AuthService.ts +0 -68
  294. package/src/services/helper/deserializers/Tweets.ts +0 -70
  295. package/src/services/helper/deserializers/Users.ts +0 -26
  296. package/src/types/data/Errors.ts +0 -37
  297. package/src/types/data/Service.ts +0 -55
  298. package/src/types/data/Tweet.ts +0 -123
  299. package/src/types/raw/auth/Cookie.ts +0 -16
  300. /package/src/{types → enums}/HTTP.ts +0 -0
  301. /package/src/services/{accounts → helper/payloads}/LoginFlows.ts +0 -0
package/tsconfig.json CHANGED
@@ -12,8 +12,8 @@
12
12
  // "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
13
13
  // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
14
14
  // "jsx": "preserve", /* Specify what JSX code is generated. */
15
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
16
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
15
+ "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
16
+ "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
17
17
  // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
18
18
  // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
19
19
  // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
@@ -1,68 +0,0 @@
1
- // PACKAGE
2
- import axios from 'axios';
3
-
4
- // URLS
5
- import { guestTokenUrl } from './helper/urls/Authentication';
6
-
7
- // TYPES
8
- import { GuestCredentials, AuthCredentials } from '../types/Authentication';
9
-
10
- // CONFIGS
11
- import { config } from '../config/env';
12
-
13
- /**
14
- * Handles authentication of http requests and other authentication related tasks.
15
- * @internal
16
- */
17
- export class AuthService {
18
- // MEMBER DATA
19
- /** The common bearer token for authentication. */
20
- private authToken: string;
21
-
22
- /** The current authentication credentials. */
23
- private credentials: AuthCredentials;
24
-
25
- /** Whether instance has been authenticated or not. */
26
- public isAuthenticated: boolean;
27
-
28
- // MEMBER METHODS
29
- constructor(cookie: string = '') {
30
- // Reading the auth token from the config, since it's always the same
31
- this.authToken = config.twitter_auth_token;
32
-
33
- // Setting authentication status
34
- this.isAuthenticated = cookie != '';
35
-
36
- // Setting up the authenticated credentials
37
- /**
38
- * The following regex pattern is used to extract the csrfToken from the cookie string.
39
- * This is done by matching any string between the characters 'ct0=' and nearest enclosing ';'.
40
- * (?<=pattern) starts matching after the given pattern.
41
- * (?=pattern) stops matching just before the pattern.
42
- */
43
- this.credentials = { authToken: this.authToken, csrfToken: cookie.match(/(?<=ct0=).+?(?=;)/) + '', cookie: cookie};
44
-
45
- }
46
-
47
- /**
48
- * @returns The current authentication credentials. A different credential is returned each time this is invoked
49
- */
50
- async getAuthCredentials(): Promise<AuthCredentials> {
51
- return this.credentials;
52
- }
53
-
54
- /**
55
- * @returns The guest credentials fetched from twitter.
56
- */
57
- async getGuestCredentials(): Promise<GuestCredentials> {
58
- // Getting the guest credentials from twitter
59
- return await axios.post<{ guest_token: string }>(guestTokenUrl(), null, {
60
- headers: {
61
- 'Authorization': this.authToken
62
- }
63
- }).then(res => ({
64
- authToken: this.authToken,
65
- guestToken: res.data.guest_token
66
- }));
67
- }
68
- }
@@ -1,70 +0,0 @@
1
- // TYPES
2
- import { Tweet, TweetEntities } from '../../../types/data/Tweet';
3
- import { Result as RawTweet, Entities2 as RawTweetEntities } from '../../../types/raw/tweet/Tweet';
4
-
5
- // PARSERS
6
- import * as Parsers from '../Parser';
7
-
8
- /**
9
- * @returns A TweetEntities object containing the various tweet entities
10
- * @param data The raw tweet entities data from the response received from TwitterAPI
11
- */
12
- export function toTweetEntities(data: RawTweetEntities): TweetEntities {
13
- let entities: TweetEntities = {
14
- mentionedUsers: [],
15
- urls: [],
16
- media: [],
17
- hashtags: []
18
- };
19
-
20
- // Extracting user mentions
21
- if(data.user_mentions) {
22
- for(let user of data.user_mentions) {
23
- entities.mentionedUsers.push(user.id_str);
24
- }
25
- }
26
-
27
- // Extracting urls
28
- if(data.urls) {
29
- for(let url of data.urls) {
30
- entities.urls.push(url.expanded_url);
31
- }
32
- }
33
-
34
- // Extracting hashtags
35
- if(data.hashtags) {
36
- for(let hashtag of data.hashtags) {
37
- entities.hashtags.push(hashtag.text);
38
- }
39
- }
40
-
41
- // Extracting media urls (if any)
42
- if(data.media) {
43
- for(const media of data.media) {
44
- entities.media.push(media.media_url_https);
45
- }
46
- }
47
-
48
- return entities;
49
- }
50
-
51
- /**
52
- * @returns A Tweet object containing the tweet data
53
- * @param data The raw tweet data from the response received from TwitterAPI
54
- */
55
- export function toTweet(data: RawTweet): Tweet {
56
- return {
57
- id: data.rest_id,
58
- createdAt: data.legacy.created_at,
59
- tweetBy: data.legacy.user_id_str,
60
- entities: toTweetEntities(data.legacy.entities),
61
- quoted: data.legacy.quoted_status_id_str,
62
- fullText: Parsers.normalizeText(data.legacy.full_text),
63
- replyTo: data.legacy.in_reply_to_status_id_str,
64
- lang: data.legacy.lang,
65
- quoteCount: data.legacy.quote_count,
66
- replyCount: data.legacy.reply_count,
67
- retweetCount: data.legacy.retweet_count,
68
- likeCount: data.legacy.favorite_count
69
- };
70
- }
@@ -1,26 +0,0 @@
1
- // TYPES
2
- import { User } from '../../../types/data/User';
3
- import { Result as RawUser } from '../../../types/raw/user/User';
4
-
5
- /**
6
- * @returns A User object containing the user details
7
- * @param data The raw user data from Twitter API
8
- */
9
- export function toUser(data: RawUser): User {
10
- return {
11
- id: data.rest_id,
12
- userName: data.legacy.screen_name,
13
- fullName: data.legacy.name,
14
- createdAt: data.legacy.created_at,
15
- description: data.legacy.description,
16
- isVerified: data.legacy.verified,
17
- favouritesCount: data.legacy.favourites_count,
18
- followersCount: data.legacy.followers_count,
19
- followingsCount: data.legacy.friends_count,
20
- statusesCount: data.legacy.statuses_count,
21
- location: data.legacy.location,
22
- pinnedTweet: data.legacy.pinned_tweet_ids_str[0],
23
- profileBanner: data.legacy.profile_banner_url,
24
- profileImage: data.legacy.profile_image_url_https
25
- };
26
- }
@@ -1,37 +0,0 @@
1
- /**
2
- * Different types of error messages related to authentication.
3
- *
4
- * @public
5
- */
6
- export enum AuthenticationErrors {
7
- NotAuthenticated = "Cannot fetch this data without authentication",
8
- InvalidEmail = "No Twitter account found for the given email address",
9
- InvalidUsername = "Incorrect username given for the given Twitter account",
10
- InvalidPassword = "Incorrect password given for the given Twitter account"
11
- };
12
-
13
- /**
14
- * Different types error messages for validation errors.
15
- *
16
- * @public
17
- */
18
- export enum ValidationErrors {
19
- InvalidTweetFilter = "Atleast one of fromUsers/toUsers/mentions/hashtags/words argument is required",
20
- NoUserIdentification = "Either userName or id must be given",
21
- InvalidCount = "Invalid count provided"
22
- };
23
-
24
- /**
25
- * Different type of error messages that are returned by services.
26
- *
27
- * @public
28
- */
29
- export enum DataErrors {
30
- UserNotFound = "An account with given username/id was not found",
31
- TweetNotFound = "A tweet with the given id was not found",
32
- NoTweetsFound = "No tweets matching the given criteria found",
33
- NoLikersFound = "No likers found for the tweet with the given id",
34
- NoRetweetersFound = "No retweeters found for the tweet with the given id",
35
- NoFollowsFound = "No follow details were found for the user with the given id",
36
- NoLikedTweetsFound = "No liked tweets were found for the user with the given id"
37
- };
@@ -1,55 +0,0 @@
1
- // SERVICES
2
- import { AccountService } from "../../services/accounts/AccountService";
3
- import { TweetService } from "../../services/data/TweetService";
4
- import { UserService } from "../../services/data/UserService";
5
-
6
- /**
7
- * The cursor to the batch of data to be fetched.
8
- *
9
- * @public
10
- */
11
- export class Cursor {
12
- // MEMBER DATA
13
- /** The cursor string. */
14
- value: string;
15
-
16
- // MEMBER DATA
17
- /**
18
- * Initializes a new cursor from the given cursor string.
19
- *
20
- * @param cursorStr The string representation of the cursor.
21
- */
22
- constructor(cursorStr: string) {
23
- this.value = cursorStr;
24
- }
25
- }
26
-
27
- /**
28
- * The data that us fetched batch-wise along with a cursor.
29
- *
30
- * @typeParam Type - The type of data present in the list.
31
- * @public
32
- */
33
- export interface CursoredData<Type> {
34
- /** The list of data of the given type. */
35
- list: Type[];
36
-
37
- /** The cursor to the next batch of data. */
38
- next: Cursor;
39
- }
40
-
41
- /**
42
- * The data context from where data is to be fetched.
43
- *
44
- * @public
45
- */
46
- export interface DataContext {
47
- /** Handles data related to users. */
48
- users: UserService,
49
-
50
- /** Handles data related to tweets. */
51
- tweets: TweetService,
52
-
53
- /** Handles account related operations. */
54
- account: AccountService
55
- }
@@ -1,123 +0,0 @@
1
- /**
2
- * The filter to be used for fetching tweets from Twitter.
3
- *
4
- * @public
5
- */
6
- export interface TweetFilter {
7
- /** The list of words to search. */
8
- words?: string[];
9
-
10
- /** The list of hashtags to search.
11
- *
12
- * @remarks
13
- * '#' must be excluded from the hashtag!
14
- */
15
- hashtags?: string[];
16
-
17
- /** The list of usernames whose tweets are to be searched.
18
- *
19
- * @remarks
20
- * '@' must be excluded from the username!
21
- */
22
- fromUsers?: string[];
23
-
24
- /** The list of username to whom the tweets to be searched, are adressed.
25
- *
26
- * @remarks
27
- * '@' must be excluded from the username!
28
- */
29
- toUsers?: string[];
30
-
31
- /** The list of username mentioned in the tweets to search.
32
- *
33
- * @remarks
34
- * '@' must be excluded from the username!
35
- */
36
- mentions?: string[];
37
-
38
- /** The date starting from which tweets are to be searched.
39
- *
40
- * @remarks
41
- * Must be in the format YYYY-MM-DD.
42
- */
43
- startDate?: string;
44
-
45
- /** The date upto which tweets are to be searched.
46
- *
47
- * @remarks
48
- * Must be in the format YYYY-MM-DD.
49
- */
50
- endDate?: string;
51
-
52
- /** The id of the tweet, after which the tweets are to be searched. */
53
- sinceId?: string;
54
-
55
- /** The id of the tweet which is quoted in the tweets to search. */
56
- quoted?: string;
57
-
58
- /** Whether to fetch tweets that are links or not.
59
- *
60
- * @defaultValue false
61
- */
62
- links?: boolean;
63
- };
64
-
65
- /**
66
- * The different types parsed entities like urls, media, mentions, hashtags, etc.
67
- *
68
- * @public
69
- */
70
- export interface TweetEntities {
71
- /** The list of hashtags mentioned in the tweet. */
72
- hashtags: string[];
73
-
74
- /** The list of urls mentioned in the tweet. */
75
- urls: string[];
76
-
77
- /** The list of IDs of users mentioned in the tweet. */
78
- mentionedUsers: string[];
79
-
80
- /** The list of urls to various media mentioned in the tweet. */
81
- media: string[];
82
- }
83
-
84
- /**
85
- * The details of a single Tweet.
86
- */
87
- export interface Tweet {
88
- /** The rest id of the tweet. */
89
- id: string;
90
-
91
- /** The rest id of the user who made the tweet. */
92
- tweetBy: string;
93
-
94
- /** The date and time of creation of the tweet, in UTC string format. */
95
- createdAt: string;
96
-
97
- /** Additional tweet entities like urls, mentions, etc. */
98
- entities: TweetEntities;
99
-
100
- /** The rest id of the tweet which is quoted in the tweet. */
101
- quoted: string;
102
-
103
- /** The full text content of the tweet. */
104
- fullText: string;
105
-
106
- /** The rest id of the user to which the tweet is a reply. */
107
- replyTo: string;
108
-
109
- /** The language in which the tweet is written. */
110
- lang: string;
111
-
112
- /** The number of quotes of the tweet. */
113
- quoteCount: number;
114
-
115
- /** The number of replies to the tweet. */
116
- replyCount: number;
117
-
118
- /** The number of retweets of the tweet. */
119
- retweetCount: number;
120
-
121
- /** The number of likes of the tweet. */
122
- likeCount: number;
123
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * @summary Stores a single raw cookie
3
- */
4
- export default interface Cookie {
5
- guest_id_marketing: string,
6
- guest_id_ads: string,
7
- personalization_id: string,
8
- guest_id: string,
9
- gt: string,
10
- _twitter_sess: string,
11
- kdt: string,
12
- auth_token: string,
13
- ct0: string,
14
- att: string,
15
- twid: string
16
- }
File without changes