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
@@ -0,0 +1,50 @@
1
+ import { TweetFilterInterface } from '../../data/Tweet';
2
+ export declare class TweetQueryDto implements TweetFilterInterface {
3
+ /** The list of words to search. */
4
+ words?: string[];
5
+ /** The list of hashtags to search.
6
+ *
7
+ * @remarks
8
+ * '#' must be excluded from the hashtag!
9
+ */
10
+ hashtags?: string[];
11
+ /** The list of usernames whose tweets are to be searched.
12
+ *
13
+ * @remarks
14
+ * '@' must be excluded from the username!
15
+ */
16
+ fromUsers?: string[];
17
+ /** The list of username to whom the tweets to be searched, are adressed.
18
+ *
19
+ * @remarks
20
+ * '@' must be excluded from the username!
21
+ */
22
+ toUsers?: string[];
23
+ /** The list of username mentioned in the tweets to search.
24
+ *
25
+ * @remarks
26
+ * '@' must be excluded from the username!
27
+ */
28
+ mentions?: string[];
29
+ /** The date starting from which tweets are to be searched.
30
+ *
31
+ * @remarks
32
+ * Must be in the format YYYY-MM-DD.
33
+ */
34
+ startDate?: string;
35
+ /** The date upto which tweets are to be searched.
36
+ *
37
+ * @remarks
38
+ * Must be in the format YYYY-MM-DD.
39
+ */
40
+ endDate?: string;
41
+ /** The id of the tweet, after which the tweets are to be searched. */
42
+ sinceId?: string;
43
+ /** The id of the tweet which is quoted in the tweets to search. */
44
+ quoted?: string;
45
+ /** Whether to fetch tweets that are links or not.
46
+ *
47
+ * @defaultValue false
48
+ */
49
+ links?: boolean;
50
+ }
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ exports.__esModule = true;
12
+ exports.TweetQueryDto = void 0;
13
+ // PACKAGE
14
+ var class_validator_1 = require("class-validator");
15
+ var TweetQueryDto = /** @class */ (function () {
16
+ function TweetQueryDto() {
17
+ }
18
+ __decorate([
19
+ (0, class_validator_1.IsArray)(),
20
+ (0, class_validator_1.IsString)({ each: true }),
21
+ (0, class_validator_1.IsOptional)(),
22
+ __metadata("design:type", Array)
23
+ ], TweetQueryDto.prototype, "words");
24
+ __decorate([
25
+ (0, class_validator_1.IsArray)(),
26
+ (0, class_validator_1.IsString)({ each: true }),
27
+ (0, class_validator_1.IsOptional)(),
28
+ __metadata("design:type", Array)
29
+ ], TweetQueryDto.prototype, "hashtags");
30
+ __decorate([
31
+ (0, class_validator_1.IsArray)(),
32
+ (0, class_validator_1.IsString)({ each: true }),
33
+ (0, class_validator_1.IsOptional)(),
34
+ __metadata("design:type", Array)
35
+ ], TweetQueryDto.prototype, "fromUsers");
36
+ __decorate([
37
+ (0, class_validator_1.IsArray)(),
38
+ (0, class_validator_1.IsString)({ each: true }),
39
+ (0, class_validator_1.IsOptional)(),
40
+ __metadata("design:type", Array)
41
+ ], TweetQueryDto.prototype, "toUsers");
42
+ __decorate([
43
+ (0, class_validator_1.IsArray)(),
44
+ (0, class_validator_1.IsString)({ each: true }),
45
+ (0, class_validator_1.IsOptional)(),
46
+ __metadata("design:type", Array)
47
+ ], TweetQueryDto.prototype, "mentions");
48
+ __decorate([
49
+ (0, class_validator_1.IsOptional)(),
50
+ (0, class_validator_1.IsDateString)(),
51
+ __metadata("design:type", String)
52
+ ], TweetQueryDto.prototype, "startDate");
53
+ __decorate([
54
+ (0, class_validator_1.IsOptional)(),
55
+ (0, class_validator_1.IsDateString)(),
56
+ __metadata("design:type", String)
57
+ ], TweetQueryDto.prototype, "endDate");
58
+ __decorate([
59
+ (0, class_validator_1.IsNumberString)(),
60
+ (0, class_validator_1.IsOptional)(),
61
+ __metadata("design:type", String)
62
+ ], TweetQueryDto.prototype, "sinceId");
63
+ __decorate([
64
+ (0, class_validator_1.IsNumberString)(),
65
+ (0, class_validator_1.IsOptional)(),
66
+ __metadata("design:type", String)
67
+ ], TweetQueryDto.prototype, "quoted");
68
+ __decorate([
69
+ (0, class_validator_1.IsBoolean)(),
70
+ (0, class_validator_1.IsOptional)(),
71
+ __metadata("design:type", Boolean)
72
+ ], TweetQueryDto.prototype, "links");
73
+ return TweetQueryDto;
74
+ }());
75
+ exports.TweetQueryDto = TweetQueryDto;
76
+ //# sourceMappingURL=TweetFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TweetFilter.js","sourceRoot":"","sources":["../../../../src/types/services/args/TweetFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,UAAU;AACV,mDAAyG;AAKzG;IAAA;IAkFA,CAAC;IA7EG;QAHC,IAAA,yBAAO,GAAE;QACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACxB,IAAA,4BAAU,GAAE;;wCACI;IAUjB;QAHC,IAAA,yBAAO,GAAE;QACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACxB,IAAA,4BAAU,GAAE;;2CACO;IAUpB;QAHC,IAAA,yBAAO,GAAE;QACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACxB,IAAA,4BAAU,GAAE;;4CACQ;IAUrB;QAHC,IAAA,yBAAO,GAAE;QACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACxB,IAAA,4BAAU,GAAE;;0CACM;IAUnB;QAHC,IAAA,yBAAO,GAAE;QACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACxB,IAAA,4BAAU,GAAE;;2CACO;IASpB;QAFC,IAAA,4BAAU,GAAE;QACZ,IAAA,8BAAY,GAAE;;4CACI;IASnB;QAFC,IAAA,4BAAU,GAAE;QACZ,IAAA,8BAAY,GAAE;;0CACE;IAKjB;QAFC,IAAA,gCAAc,GAAE;QAChB,IAAA,4BAAU,GAAE;;0CACI;IAKjB;QAFC,IAAA,gCAAc,GAAE;QAChB,IAAA,4BAAU,GAAE;;yCACG;IAQhB;QAFC,IAAA,2BAAS,GAAE;QACX,IAAA,4BAAU,GAAE;;wCACG;IACpB,oBAAC;CAAA,AAlFD,IAkFC;AAlFY,sCAAa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rettiwt-api",
3
- "version": "1.1.2",
3
+ "version": "1.1.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "An API for fetching data from TwitterAPI, without any rate limits!",
@@ -24,12 +24,15 @@
24
24
  "homepage": "https://rishikant181.github.io/Rettiwt-API/",
25
25
  "dependencies": {
26
26
  "axios": "1.3.2",
27
+ "class-transformer": "0.5.1",
28
+ "class-validator": "0.14.0",
27
29
  "cookiejar": "2.1.4",
28
30
  "express": "4.18.2",
29
31
  "express-graphql": "0.12.0",
30
32
  "graphql": "14.7.0",
31
33
  "node-cache": "5.1.2",
32
- "node-libcurl": "3.0.0"
34
+ "node-libcurl": "3.0.0",
35
+ "reflect-metadata": "0.1.13"
33
36
  },
34
37
  "devDependencies": {
35
38
  "@types/cookiejar": "2.1.2",
@@ -40,4 +43,4 @@
40
43
  "typedoc": "0.23.26",
41
44
  "typescript": "4.6.4"
42
45
  }
43
- }
46
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Different types of error messages related to authentication returned by services.
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 type of error messages related to data that are returned by services.
15
+ *
16
+ * @public
17
+ */
18
+ export enum DataErrors {
19
+ UserNotFound = "An account with given username/id was not found",
20
+ TweetNotFound = "A tweet with the given id was not found"
21
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Different types error messages for validation errors returned by GraphQL API.
3
+ *
4
+ * @public
5
+ */
6
+ export enum ValidationErrors {
7
+ NoUserIdentification = "Either userName or id must be given"
8
+ };
9
+
10
+ /**
11
+ * Different type of error messages related to data that are returned by GraphQL API.
12
+ *
13
+ * @public
14
+ */
15
+ export enum DataErrors {
16
+ NoTweetsFound = "No tweets matching the given criteria found",
17
+ NoLikersFound = "No likers found for the tweet with the given id",
18
+ NoRetweetersFound = "No retweeters found for the tweet with the given id",
19
+ NoUserTweetsFound = "No tweets were found for the user with the given id",
20
+ NoFollowsFound = "No follow details were found for the user with the given id",
21
+ NoLikedTweetsFound = "No liked tweets were found for the user with the given id"
22
+ };
@@ -4,7 +4,7 @@ import { GraphQLBoolean, GraphQLInt, GraphQLList, GraphQLObjectType, GraphQLStri
4
4
  // TYPES
5
5
  import { User } from '../types/UserTypes';
6
6
  import { Tweet, TweetList } from '../types/TweetTypes';
7
- import { TweetFilter } from '../../types/data/Tweet';
7
+ import { TweetFilter } from '../../models/args/TweetFilter';
8
8
 
9
9
  // RESOLVERS
10
10
  import UserResolver from '../resolvers/UserResolver';
@@ -22,10 +22,9 @@ export const rootQuery = new GraphQLObjectType({
22
22
  type: User,
23
23
  description: "Returns the details of the twitter user with given user name",
24
24
  args: {
25
- userName: { type: GraphQLString },
26
25
  id: { type: GraphQLString }
27
26
  },
28
- resolve: (parent, args, context) => new UserResolver(context).resolveUserDetails(args.userName, args.id)
27
+ resolve: (parent, args, context) => new UserResolver(context).resolveUserDetails(args.id)
29
28
  },
30
29
  Tweet: {
31
30
  type: Tweet,
@@ -55,7 +54,15 @@ export const rootQuery = new GraphQLObjectType({
55
54
  resolve: (parent, args, context) => new TweetResolver(context).resolveTweets(args as TweetFilter, args.count, args.cursor)
56
55
  },
57
56
  Login: {
58
- type: GraphQLString,
57
+ type: new GraphQLObjectType({
58
+ name: 'AuthCookie',
59
+ fields: {
60
+ auth_token: { type: GraphQLString },
61
+ ct0: { type: GraphQLString },
62
+ kdt: { type: GraphQLString },
63
+ twid: { type: GraphQLString },
64
+ }
65
+ }),
59
66
  description: "Returns the cookies that can be used to fetch data from twitter",
60
67
  args: {
61
68
  email: { type: GraphQLString },
@@ -2,11 +2,11 @@
2
2
  import ResolverBase from './ResolverBase';
3
3
 
4
4
  // TYPES
5
- import { DataContext } from '../../types/data/Service';
5
+ import { IDataContext } from '../../types/Rettiwt';
6
6
 
7
7
  export default class AccountResolver extends ResolverBase {
8
8
  // MEMBER METHODS
9
- constructor(context: DataContext) {
9
+ constructor(context: IDataContext) {
10
10
  super(context);
11
11
  }
12
12
 
@@ -16,7 +16,7 @@ export default class AccountResolver extends ResolverBase {
16
16
  * @param password The password to the account
17
17
  * @returns The cookie string that can be used to authenticate against twitter
18
18
  */
19
- async resolveLogin(email: string, userName: string, password: string): Promise<string> {
19
+ async resolveLogin(email: string, userName: string, password: string): Promise<any> {
20
20
  return await this.context.account.login(email, userName, password);
21
21
  }
22
22
  }
@@ -1,12 +1,26 @@
1
+ // PACKAGES
2
+ import { GraphQLError } from 'graphql'
3
+
1
4
  // TYPES
2
- import { DataContext } from '../../types/data/Service';
5
+ import { IDataContext } from '../../types/Rettiwt';
3
6
 
4
7
  export default class ResolverBase {
5
- // MEMBER DATA
6
- protected context: DataContext; // To store the data context
8
+ /** The current data context that can used for fetching data from Twitter. */
9
+ protected context: IDataContext;
7
10
 
8
- // MEMBER METHODS
9
- constructor(context: DataContext) {
11
+ /**
12
+ * @param context The data context that will be used for fetching data from Twitter.
13
+ */
14
+ constructor(context: IDataContext) {
10
15
  this.context = context;
11
16
  }
17
+
18
+ /**
19
+ * @param error The error object received from the services.
20
+ *
21
+ * @returns The GraphQL error object that can be returned to the client.
22
+ */
23
+ protected getGraphQLError(error: Error) {
24
+ return new GraphQLError(error.message, undefined, undefined, undefined, undefined, undefined, error);
25
+ }
12
26
  }
@@ -2,17 +2,18 @@
2
2
  import ResolverBase from './ResolverBase';
3
3
 
4
4
  // TYPES
5
- import { TweetFilter } from '../../types/data/Tweet';
6
- import { Cursor, DataContext } from '../../types/data/Service';
7
- import { DataErrors, ValidationErrors } from '../../types/data/Errors';
5
+ import { IDataContext } from '../../types/Rettiwt'
6
+ import { TweetFilter } from '../../models/args/TweetFilter';
7
+ import { Cursor } from '../../models/data/CursoredData';
8
+ import { DataErrors } from '../enums/Errors';
8
9
 
9
10
  export default class TweetResolver extends ResolverBase {
10
11
  // MEMBER DATA
11
12
  private batchSize: number; // To store the batch size while fetching data
12
13
  // MEMBER METHODS
13
- constructor(context: DataContext) {
14
+ constructor(context: IDataContext) {
14
15
  super(context);
15
- this.batchSize = 20;
16
+ this.batchSize = 100;
16
17
  }
17
18
 
18
19
  /**
@@ -21,7 +22,9 @@ export default class TweetResolver extends ResolverBase {
21
22
  */
22
23
  async resolveTweet(id: string): Promise<any> {
23
24
  // Getting the data
24
- let res = await this.context.tweets.getTweetById(id);
25
+ let res = await this.context.tweets.getTweetDetails(id).catch(error => {
26
+ throw this.getGraphQLError(error);
27
+ });
25
28
 
26
29
  // Evaluating response
27
30
  return res;
@@ -37,22 +40,22 @@ export default class TweetResolver extends ResolverBase {
37
40
  let tweets: any[] = []; // To store the list of tweets
38
41
  let next: Cursor = new Cursor(cursor); // To store cursor to next batch
39
42
  let total: number = 0; // To store the total number of tweets fetched
40
-
41
- // Checking if the given tweet filter is valid or not
42
- if (!(filter.fromUsers || filter.toUsers || filter.words || filter.hashtags || filter.mentions || filter.quoted)) {
43
- throw new Error(ValidationErrors.InvalidTweetFilter);
44
- }
43
+
44
+ /** The batch size while fetching tweets is lower (=20), compared to other data related to a tweet (=100). */
45
+ let batchSize: number = 20; //
45
46
 
46
47
  // If required count less than batch size, setting batch size to required count
47
- this.batchSize = (count < this.batchSize) ? count : this.batchSize;
48
+ batchSize = (count < batchSize) ? count : batchSize;
48
49
 
49
50
  // Repeatedly fetching data as long as total data fetched is less than requried
50
51
  do {
51
52
  // If this is the last batch, change batch size to number of remaining tweets
52
- this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
53
+ batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
53
54
 
54
55
  // Getting the data
55
- const res = await this.context.tweets.getTweets(filter, this.batchSize, next.value);
56
+ const res = await this.context.tweets.getTweets(filter, batchSize, next.value ).catch(error => {
57
+ throw this.getGraphQLError(error);
58
+ });
56
59
 
57
60
  // If data is available
58
61
  if (res.list?.length) {
@@ -109,7 +112,9 @@ export default class TweetResolver extends ResolverBase {
109
112
  };
110
113
 
111
114
  // Fetching the quotes using resolveTweets method
112
- quotes = await this.resolveTweets(filter, count, cursor);
115
+ quotes = await this.resolveTweets(filter, count, cursor).catch(error => {
116
+ throw this.getGraphQLError(error);
117
+ });
113
118
 
114
119
  return quotes;
115
120
  }
@@ -139,7 +144,9 @@ export default class TweetResolver extends ResolverBase {
139
144
  this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
140
145
 
141
146
  // Getting the data
142
- const res = await this.context.tweets.getTweetLikers(id, this.batchSize, next.value);
147
+ const res = await this.context.tweets.getTweetLikers(id, this.batchSize, next.value).catch(error => {
148
+ throw this.getGraphQLError(error);
149
+ });
143
150
 
144
151
  // If data is available
145
152
  if (res.list?.length) {
@@ -194,7 +201,9 @@ export default class TweetResolver extends ResolverBase {
194
201
  this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
195
202
 
196
203
  // Getting the data
197
- const res = await this.context.tweets.getTweetRetweeters(id, this.batchSize, next.value);
204
+ const res = await this.context.tweets.getTweetRetweeters(id, this.batchSize, next.value).catch(error => {
205
+ throw this.getGraphQLError(error);
206
+ });
198
207
 
199
208
  // If data is available
200
209
  if (res.list?.length) {
@@ -2,15 +2,16 @@
2
2
  import ResolverBase from './ResolverBase';
3
3
 
4
4
  // TYPES
5
- import { Cursor, DataContext } from '../../types/data/Service';
6
- import { DataErrors, ValidationErrors } from '../../types/data/Errors';
5
+ import { IDataContext } from '../../types/Rettiwt'
6
+ import { Cursor } from '../../models/data/CursoredData';
7
+ import { DataErrors } from '../enums/Errors';
7
8
 
8
9
  export default class UserResolver extends ResolverBase {
9
10
  // MEMBER DATA
10
11
  private batchSize: number; // To store the batch size when fetching data
11
-
12
+
12
13
  // MEMBER METHODS
13
- constructor(context: DataContext) {
14
+ constructor(context: IDataContext) {
14
15
  super(context);
15
16
  this.batchSize = 40;
16
17
  }
@@ -18,21 +19,69 @@ export default class UserResolver extends ResolverBase {
18
19
  /**
19
20
  * @returns The details of the target twitter user
20
21
  * @param userName The user name of the target twitter user
21
- * @param id The id of the target twitter user
22
+ * @param id The id/username of the target twitter user
22
23
  */
23
- async resolveUserDetails(userName: string, id: string): Promise<any> {
24
- // If user name is supplied
25
- if (userName) {
26
- return await this.context.users.getUserDetails(userName);
27
- }
28
- // If id is supplied
29
- else if (id) {
30
- return await this.context.users.getUserDetailsById(id);
31
- }
32
- // If neither userName nor id is supplied
33
- else {
34
- throw new Error(ValidationErrors.NoUserIdentification);
24
+ async resolveUserDetails(id: string): Promise<any> {
25
+ return await this.context.users.getUserDetails(id).catch(error => {
26
+ throw this.getGraphQLError(error);
27
+ });
28
+ }
29
+
30
+ /**
31
+ * @returns The list of tweets made by the given user
32
+ * @param id The id of the user whose tweets are to be fetched
33
+ * @param count The number of tweets to fetch, must be >= 40
34
+ * @param all Whether to fetch list of all tweets made by user
35
+ * @param cursor The cursor to the batch of tweets to fetch
36
+ * @param statusesCount The total number of tweets made by target user
37
+ */
38
+ async resolveUserTweets(id: string, count: number, all: boolean, cursor: string, statusesCount: number): Promise<any> {
39
+ let likes: any[] = []; // To store the list of tweets
40
+ let next: Cursor = new Cursor(cursor); // To store cursor to next batch
41
+ let total: number = 0; // To store the total number of tweets fetched
42
+
43
+ // If all tweets are to be fetched
44
+ count = all ? statusesCount : count;
45
+
46
+ // If required count less than batch size, setting batch size to required count
47
+ this.batchSize = (count < this.batchSize) ? count : this.batchSize;
48
+
49
+ // Repeatedly fetching data as long as total data fetched is less than requried
50
+ do {
51
+ // If this is the last batch, change batch size to number of remaining tweets
52
+ this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
53
+
54
+ // Getting the data
55
+ const res = await this.context.users.getUserTweets(id, this.batchSize, next.value).catch(error => {
56
+ throw this.getGraphQLError(error);
57
+ });
58
+
59
+ // If data is available
60
+ if (res.list?.length) {
61
+ // Adding fetched tweets to list of tweets
62
+ likes = likes.concat(res.list);
63
+
64
+ // Updating total tweets fetched
65
+ total = likes.length;
66
+
67
+ // Getting cursor to next batch
68
+ next = res.next as Cursor;
69
+ }
70
+ // If no more data is available
71
+ else {
72
+ break;
73
+ }
74
+ } while (total < count);
75
+
76
+ // If no likes found
77
+ if (!likes.length) {
78
+ return new Error(DataErrors.NoUserTweetsFound);
35
79
  }
80
+
81
+ // Adding the cursor to the end of list of data
82
+ likes.push(next);
83
+
84
+ return likes;
36
85
  }
37
86
 
38
87
  /**
@@ -60,7 +109,9 @@ export default class UserResolver extends ResolverBase {
60
109
  this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
61
110
 
62
111
  // Getting the data
63
- const res = await this.context.users.getUserLikes(id, this.batchSize, next.value);
112
+ const res = await this.context.users.getUserLikes(id, this.batchSize, next.value).catch(error => {
113
+ throw this.getGraphQLError(error);
114
+ });
64
115
 
65
116
  // If data is available
66
117
  if (res.list?.length) {
@@ -115,7 +166,9 @@ export default class UserResolver extends ResolverBase {
115
166
  this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
116
167
 
117
168
  // Getting the data
118
- const res = await this.context.users.getUserFollowers(id, this.batchSize, next.value);
169
+ const res = await this.context.users.getUserFollowers(id, this.batchSize, next.value).catch(error => {
170
+ throw this.getGraphQLError(error);
171
+ });
119
172
 
120
173
  // If data is available
121
174
  if (res.list?.length) {
@@ -170,7 +223,9 @@ export default class UserResolver extends ResolverBase {
170
223
  this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
171
224
 
172
225
  // Getting the data
173
- const res = await this.context.users.getUserFollowing(id, this.batchSize, next.value);
226
+ const res = await this.context.users.getUserFollowing(id, this.batchSize, next.value).catch(error => {
227
+ throw this.getGraphQLError(error);
228
+ });
174
229
 
175
230
  // If data is available
176
231
  if (res.list?.length) {
@@ -17,7 +17,7 @@ export const TweetTokens: GraphQLObjectType = new GraphQLObjectType({
17
17
  urls: { type: new GraphQLList(GraphQLString) },
18
18
  mentionedUsers: {
19
19
  type: UserList,
20
- resolve: (parent, args, context) => parent.mentionedUsers.map((user: string) => new UserResolver(context).resolveUserDetails('', user))
20
+ resolve: (parent, args, context) => parent.mentionedUsers.map((user: string) => new UserResolver(context).resolveUserDetails(user))
21
21
  },
22
22
  media: { type: new GraphQLList(GraphQLString) },
23
23
  })
@@ -30,7 +30,7 @@ export const Tweet: GraphQLObjectType = new GraphQLObjectType({
30
30
  id: { type: GraphQLString },
31
31
  tweetBy: {
32
32
  type: User,
33
- resolve: (parent, args, context) => new UserResolver(context).resolveUserDetails('', parent.tweetBy)
33
+ resolve: (parent, args, context) => new UserResolver(context).resolveUserDetails(parent.tweetBy)
34
34
  },
35
35
  createdAt: { type: GraphQLString },
36
36
  entities: { type: TweetTokens },
@@ -4,7 +4,7 @@ import { GraphQLBoolean, GraphQLObjectType, GraphQLString, GraphQLInt, GraphQLLi
4
4
  // TYPES
5
5
  import { Tweet, TweetList } from './TweetTypes'
6
6
  import { Cursor } from './Global';
7
- import { TweetFilter } from '../../types/data/Tweet';
7
+ import { TweetFilter } from '../../models/args/TweetFilter';
8
8
 
9
9
  // RESOLVERS
10
10
  import UserResolver from '../resolvers/UserResolver';
@@ -113,7 +113,7 @@ export const User: GraphQLObjectType = new GraphQLObjectType({
113
113
  defaultValue: ''
114
114
  }
115
115
  },
116
- resolve: (parent, args, context) => new TweetResolver(context).resolveTweets({ fromUsers: [parent.userName] } as TweetFilter, args.all ? parent.statusesCount : args.count, args.cursor)
116
+ resolve: (parent, args, context) => new UserResolver(context).resolveUserTweets(parent.id, args.count, args.all, args.cursor, parent.statusesCount)
117
117
  }
118
118
  })
119
119
  });
@@ -124,11 +124,11 @@ export const UserList: GraphQLList<GraphQLType> = new GraphQLList(new GraphQLUni
124
124
  types: [User, Cursor],
125
125
  resolveType: (data) => {
126
126
  // If it has a userName field => this is a User object
127
- if(data.userName) {
127
+ if (data.userName) {
128
128
  return User;
129
129
  }
130
130
  // If it has a value field => this is a Cursor object
131
- else if(data.value) {
131
+ else if (data.value) {
132
132
  return Cursor;
133
133
  }
134
134
  }