rettiwt-api 1.3.1 → 2.0.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.
Files changed (233) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc.js +54 -0
  3. package/.github/workflows/documentation.yml +47 -0
  4. package/.github/workflows/{publish-to-npm.yml → publish.yml} +8 -8
  5. package/.prettierignore +3 -0
  6. package/.prettierrc +13 -0
  7. package/README.md +59 -61
  8. package/dist/Rettiwt.d.ts +19 -0
  9. package/dist/Rettiwt.js +30 -0
  10. package/dist/Rettiwt.js.map +1 -0
  11. package/dist/enums/ApiErrors.d.ts +30 -0
  12. package/dist/enums/ApiErrors.js +35 -0
  13. package/dist/enums/ApiErrors.js.map +1 -0
  14. package/dist/enums/HTTP.d.ts +11 -11
  15. package/dist/enums/HTTP.js +15 -16
  16. package/dist/enums/HTTP.js.map +1 -1
  17. package/dist/helper/JsonUtils.d.ts +26 -0
  18. package/dist/helper/JsonUtils.js +88 -0
  19. package/dist/helper/JsonUtils.js.map +1 -0
  20. package/dist/index.d.ts +10 -43
  21. package/dist/index.js +16 -55
  22. package/dist/index.js.map +1 -1
  23. package/dist/models/CursoredData.d.ts +37 -0
  24. package/dist/models/CursoredData.js +59 -0
  25. package/dist/models/CursoredData.js.map +1 -0
  26. package/dist/models/{data/Tweet.d.ts → Tweet.d.ts} +4 -4
  27. package/dist/models/{data/Tweet.js → Tweet.js} +7 -32
  28. package/dist/models/Tweet.js.map +1 -0
  29. package/dist/models/{data/User.d.ts → User.d.ts} +3 -3
  30. package/dist/models/{data/User.js → User.js} +3 -3
  31. package/dist/models/User.js.map +1 -0
  32. package/dist/services/FetcherService.d.ts +66 -0
  33. package/dist/services/FetcherService.js +207 -0
  34. package/dist/services/FetcherService.js.map +1 -0
  35. package/dist/services/TweetService.d.ts +88 -0
  36. package/dist/services/TweetService.js +244 -0
  37. package/dist/services/TweetService.js.map +1 -0
  38. package/dist/services/UserService.d.ts +60 -0
  39. package/dist/services/UserService.js +188 -0
  40. package/dist/services/UserService.js.map +1 -0
  41. package/dist/types/{Service.d.ts → CursoredData.d.ts} +3 -3
  42. package/dist/types/CursoredData.js +3 -0
  43. package/dist/types/CursoredData.js.map +1 -0
  44. package/dist/types/Tweet.js +1 -1
  45. package/dist/types/User.js +1 -1
  46. package/package.json +15 -19
  47. package/src/Rettiwt.ts +33 -0
  48. package/src/enums/ApiErrors.ts +30 -0
  49. package/src/enums/HTTP.ts +12 -12
  50. package/src/helper/JsonUtils.ts +86 -0
  51. package/src/index.ts +14 -57
  52. package/src/models/CursoredData.ts +64 -0
  53. package/src/models/Tweet.ts +116 -0
  54. package/src/models/User.ts +72 -0
  55. package/src/services/FetcherService.ts +183 -0
  56. package/src/services/TweetService.ts +153 -0
  57. package/src/services/UserService.ts +117 -0
  58. package/src/types/CursoredData.ts +24 -0
  59. package/src/types/Tweet.ts +35 -35
  60. package/src/types/User.ts +30 -30
  61. package/tsconfig.json +9 -9
  62. package/.github/workflows/build-docs.yml +0 -28
  63. package/dist/config/env.d.ts +0 -5
  64. package/dist/config/env.js +0 -9
  65. package/dist/config/env.js.map +0 -1
  66. package/dist/enums/Errors.d.ts +0 -21
  67. package/dist/enums/Errors.js +0 -29
  68. package/dist/enums/Errors.js.map +0 -1
  69. package/dist/graphql/enums/Errors.d.ts +0 -21
  70. package/dist/graphql/enums/Errors.js +0 -29
  71. package/dist/graphql/enums/Errors.js.map +0 -1
  72. package/dist/graphql/queries/RootQuery.d.ts +0 -4
  73. package/dist/graphql/queries/RootQuery.js +0 -78
  74. package/dist/graphql/queries/RootQuery.js.map +0 -1
  75. package/dist/graphql/resolvers/AccountResolver.d.ts +0 -12
  76. package/dist/graphql/resolvers/AccountResolver.js +0 -84
  77. package/dist/graphql/resolvers/AccountResolver.js.map +0 -1
  78. package/dist/graphql/resolvers/ResolverBase.d.ts +0 -16
  79. package/dist/graphql/resolvers/ResolverBase.js +0 -23
  80. package/dist/graphql/resolvers/ResolverBase.js.map +0 -1
  81. package/dist/graphql/resolvers/TweetResolver.d.ts +0 -46
  82. package/dist/graphql/resolvers/TweetResolver.js +0 -312
  83. package/dist/graphql/resolvers/TweetResolver.js.map +0 -1
  84. package/dist/graphql/resolvers/UserResolver.d.ts +0 -48
  85. package/dist/graphql/resolvers/UserResolver.js +0 -334
  86. package/dist/graphql/resolvers/UserResolver.js.map +0 -1
  87. package/dist/graphql/types/Global.d.ts +0 -4
  88. package/dist/graphql/types/Global.js +0 -13
  89. package/dist/graphql/types/Global.js.map +0 -1
  90. package/dist/graphql/types/TweetTypes.d.ts +0 -4
  91. package/dist/graphql/types/TweetTypes.js +0 -160
  92. package/dist/graphql/types/TweetTypes.js.map +0 -1
  93. package/dist/graphql/types/UserTypes.d.ts +0 -3
  94. package/dist/graphql/types/UserTypes.js +0 -137
  95. package/dist/graphql/types/UserTypes.js.map +0 -1
  96. package/dist/models/args/TweetListArgs.d.ts +0 -21
  97. package/dist/models/args/TweetListArgs.js +0 -54
  98. package/dist/models/args/TweetListArgs.js.map +0 -1
  99. package/dist/models/args/UserListArgs.d.ts +0 -21
  100. package/dist/models/args/UserListArgs.js +0 -54
  101. package/dist/models/args/UserListArgs.js.map +0 -1
  102. package/dist/models/auth/AuthCookie.d.ts +0 -21
  103. package/dist/models/auth/AuthCookie.js +0 -33
  104. package/dist/models/auth/AuthCookie.js.map +0 -1
  105. package/dist/models/data/CursoredData.d.ts +0 -34
  106. package/dist/models/data/CursoredData.js +0 -42
  107. package/dist/models/data/CursoredData.js.map +0 -1
  108. package/dist/models/data/Tweet.js.map +0 -1
  109. package/dist/models/data/User.js.map +0 -1
  110. package/dist/server.d.ts +0 -1
  111. package/dist/server.js +0 -76
  112. package/dist/server.js.map +0 -1
  113. package/dist/services/auth/AccountService.d.ts +0 -83
  114. package/dist/services/auth/AccountService.js +0 -412
  115. package/dist/services/auth/AccountService.js.map +0 -1
  116. package/dist/services/auth/AuthService.d.ts +0 -31
  117. package/dist/services/auth/AuthService.js +0 -118
  118. package/dist/services/auth/AuthService.js.map +0 -1
  119. package/dist/services/data/TweetService.d.ts +0 -60
  120. package/dist/services/data/TweetService.js +0 -251
  121. package/dist/services/data/TweetService.js.map +0 -1
  122. package/dist/services/data/UserService.d.ts +0 -71
  123. package/dist/services/data/UserService.js +0 -278
  124. package/dist/services/data/UserService.js.map +0 -1
  125. package/dist/services/helper/Headers.d.ts +0 -19
  126. package/dist/services/helper/Headers.js +0 -62
  127. package/dist/services/helper/Headers.js.map +0 -1
  128. package/dist/services/helper/Parser.d.ts +0 -22
  129. package/dist/services/helper/Parser.js +0 -84
  130. package/dist/services/helper/Parser.js.map +0 -1
  131. package/dist/services/helper/extractors/Tweets.d.ts +0 -23
  132. package/dist/services/helper/extractors/Tweets.js +0 -200
  133. package/dist/services/helper/extractors/Tweets.js.map +0 -1
  134. package/dist/services/helper/extractors/Users.d.ts +0 -17
  135. package/dist/services/helper/extractors/Users.js +0 -151
  136. package/dist/services/helper/extractors/Users.js.map +0 -1
  137. package/dist/services/helper/payloads/LoginFlows.d.ts +0 -77
  138. package/dist/services/helper/payloads/LoginFlows.js +0 -92
  139. package/dist/services/helper/payloads/LoginFlows.js.map +0 -1
  140. package/dist/services/helper/urls/Authentication.d.ts +0 -4
  141. package/dist/services/helper/urls/Authentication.js +0 -11
  142. package/dist/services/helper/urls/Authentication.js.map +0 -1
  143. package/dist/services/util/CacheService.d.ts +0 -33
  144. package/dist/services/util/CacheService.js +0 -96
  145. package/dist/services/util/CacheService.js.map +0 -1
  146. package/dist/services/util/FetcherService.d.ts +0 -65
  147. package/dist/services/util/FetcherService.js +0 -202
  148. package/dist/services/util/FetcherService.js.map +0 -1
  149. package/dist/types/Args.d.ts +0 -11
  150. package/dist/types/Args.js +0 -4
  151. package/dist/types/Args.js.map +0 -1
  152. package/dist/types/Authentication.d.ts +0 -55
  153. package/dist/types/Authentication.js +0 -6
  154. package/dist/types/Authentication.js.map +0 -1
  155. package/dist/types/Resolvers.d.ts +0 -15
  156. package/dist/types/Resolvers.js +0 -3
  157. package/dist/types/Resolvers.js.map +0 -1
  158. package/dist/types/Rettiwt.d.ts +0 -16
  159. package/dist/types/Rettiwt.js +0 -3
  160. package/dist/types/Rettiwt.js.map +0 -1
  161. package/dist/types/Service.js +0 -5
  162. package/dist/types/Service.js.map +0 -1
  163. package/docs/.nojekyll +0 -1
  164. package/docs/assets/highlight.css +0 -64
  165. package/docs/assets/main.js +0 -58
  166. package/docs/assets/search.js +0 -1
  167. package/docs/assets/style.css +0 -1280
  168. package/docs/classes/AccountService.html +0 -286
  169. package/docs/classes/AuthCookie.html +0 -146
  170. package/docs/classes/AuthService.html +0 -147
  171. package/docs/classes/CacheService.html +0 -157
  172. package/docs/classes/Cursor.html +0 -102
  173. package/docs/classes/CursoredData.html +0 -126
  174. package/docs/classes/DataValidationError.html +0 -120
  175. package/docs/classes/FetcherService.html +0 -225
  176. package/docs/classes/Tweet.html +0 -210
  177. package/docs/classes/TweetEntities.html +0 -128
  178. package/docs/classes/TweetFilter.html +0 -223
  179. package/docs/classes/TweetListArgs.html +0 -118
  180. package/docs/classes/TweetService.html +0 -319
  181. package/docs/classes/User.html +0 -230
  182. package/docs/classes/UserListArgs.html +0 -118
  183. package/docs/classes/UserService.html +0 -355
  184. package/docs/enums/HttpMethods.html +0 -74
  185. package/docs/functions/Rettiwt.html +0 -100
  186. package/docs/index.html +0 -159
  187. package/docs/interfaces/IAuthCookie.html +0 -104
  188. package/docs/interfaces/ICursor.html +0 -77
  189. package/docs/interfaces/ICursoredData.html +0 -93
  190. package/docs/interfaces/IDataContext.html +0 -91
  191. package/docs/interfaces/IDataValidationError.html +0 -109
  192. package/docs/interfaces/IListArgs.html +0 -87
  193. package/docs/interfaces/ITweet.html +0 -176
  194. package/docs/interfaces/ITweetEntities.html +0 -104
  195. package/docs/interfaces/ITweetFilter.html +0 -158
  196. package/docs/interfaces/IUser.html +0 -194
  197. package/docs/modules.html +0 -111
  198. package/environment.d.ts +0 -11
  199. package/src/config/env.ts +0 -5
  200. package/src/enums/Errors.ts +0 -22
  201. package/src/graphql/enums/Errors.ts +0 -22
  202. package/src/graphql/queries/RootQuery.ts +0 -75
  203. package/src/graphql/resolvers/AccountResolver.ts +0 -22
  204. package/src/graphql/resolvers/ResolverBase.ts +0 -26
  205. package/src/graphql/resolvers/TweetResolver.ts +0 -237
  206. package/src/graphql/resolvers/UserResolver.ts +0 -257
  207. package/src/graphql/types/Global.ts +0 -10
  208. package/src/graphql/types/TweetTypes.ts +0 -158
  209. package/src/graphql/types/UserTypes.ts +0 -135
  210. package/src/models/args/TweetListArgs.ts +0 -47
  211. package/src/models/args/UserListArgs.ts +0 -47
  212. package/src/models/auth/AuthCookie.ts +0 -43
  213. package/src/models/data/CursoredData.ts +0 -45
  214. package/src/models/data/Tweet.ts +0 -118
  215. package/src/models/data/User.ts +0 -72
  216. package/src/server.ts +0 -37
  217. package/src/services/auth/AccountService.ts +0 -283
  218. package/src/services/auth/AuthService.ts +0 -81
  219. package/src/services/data/TweetService.ts +0 -198
  220. package/src/services/data/UserService.ts +0 -221
  221. package/src/services/helper/Headers.ts +0 -60
  222. package/src/services/helper/Parser.ts +0 -89
  223. package/src/services/helper/extractors/Tweets.ts +0 -190
  224. package/src/services/helper/extractors/Users.ts +0 -141
  225. package/src/services/helper/payloads/LoginFlows.ts +0 -90
  226. package/src/services/helper/urls/Authentication.ts +0 -6
  227. package/src/services/util/CacheService.ts +0 -76
  228. package/src/services/util/FetcherService.ts +0 -143
  229. package/src/types/Args.ts +0 -12
  230. package/src/types/Authentication.ts +0 -63
  231. package/src/types/Resolvers.ts +0 -18
  232. package/src/types/Rettiwt.ts +0 -20
  233. package/src/types/Service.ts +0 -24
@@ -1,46 +0,0 @@
1
- import { TweetFilter } from 'rettiwt-core';
2
- import ResolverBase from './ResolverBase';
3
- import { IDataContext } from '../../types/Rettiwt';
4
- export default class TweetResolver extends ResolverBase {
5
- private batchSize;
6
- constructor(context: IDataContext);
7
- /**
8
- * @returns The details of the tweet with the given id
9
- * @param id The id of the tweet which is to be fetched
10
- */
11
- resolveTweet(id: string): Promise<any>;
12
- /**
13
- * @returns The list of tweets matching the given filter
14
- * @param filter The filter to be used for fetching matching tweets
15
- * @param count The number of tweets to fetch, must be >= 20 (when no cursor if provided)
16
- * @param cursor The cursor to the batch of tweets to fetch
17
- */
18
- resolveTweets(filter: TweetFilter, count: number, cursor: string): Promise<any>;
19
- /**
20
- * @returns The list of quotes of the given tweet
21
- * @param id The id of the tweet whose quotes are to be fetched
22
- * @param count The number of quotes to be fetched, must be >= 20 (when no cursor if provided)
23
- * @param all Whether to fetch all quotes or not
24
- * @param cursor The cursor to the batch of tweet quotes to fetch
25
- * @param quoteCount The total number of quotes of the given tweet
26
- */
27
- resolveTweetQuotes(id: string, count: number, all: boolean, cursor: string, quoteCount: number): Promise<any[]>;
28
- /**
29
- * @returns The list of likers of the given tweet
30
- * @param id The id of the tweet whose likers are to be fetched
31
- * @param count The total number of likers to fetch, must be >= 10 (when no cursor is provided)
32
- * @param all Whether to fetch all the likers of the tweet
33
- * @param cursor The cursor to the batch of likers to fetch
34
- * @param likesCount The total number of like of the tweet
35
- */
36
- resolveTweetLikers(id: string, count: number, all: boolean, cursor: string, likesCount: number): Promise<any>;
37
- /**
38
- * @returns The list of retweeters of the given tweet
39
- * @param id The id of the tweet whose retweeters are to be fetched
40
- * @param count The total number of retweeters to fetch, must be >= 10 (when no cursor is provided)
41
- * @param all Whether to fetch all retweeters
42
- * @param cursor The cursor to the batch of retweeters to fetch
43
- * @param retweetsCount The total number of retweets of the
44
- */
45
- resolveTweetRetweeters(id: string, count: number, all: boolean, cursor: string, retweetsCount: number): Promise<any>;
46
- }
@@ -1,312 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- var __importDefault = (this && this.__importDefault) || function (mod) {
54
- return (mod && mod.__esModule) ? mod : { "default": mod };
55
- };
56
- exports.__esModule = true;
57
- // RESOLVERS
58
- var ResolverBase_1 = __importDefault(require("./ResolverBase"));
59
- var CursoredData_1 = require("../../models/data/CursoredData");
60
- var Errors_1 = require("../enums/Errors");
61
- var TweetResolver = /** @class */ (function (_super) {
62
- __extends(TweetResolver, _super);
63
- // MEMBER METHODS
64
- function TweetResolver(context) {
65
- var _this = _super.call(this, context) || this;
66
- _this.batchSize = 100;
67
- return _this;
68
- }
69
- /**
70
- * @returns The details of the tweet with the given id
71
- * @param id The id of the tweet which is to be fetched
72
- */
73
- TweetResolver.prototype.resolveTweet = function (id) {
74
- return __awaiter(this, void 0, void 0, function () {
75
- var res;
76
- var _this = this;
77
- return __generator(this, function (_a) {
78
- switch (_a.label) {
79
- case 0: return [4 /*yield*/, this.context.tweets.getTweetDetails(id)["catch"](function (error) {
80
- throw _this.getGraphQLError(error);
81
- })];
82
- case 1:
83
- res = _a.sent();
84
- // Evaluating response
85
- return [2 /*return*/, res];
86
- }
87
- });
88
- });
89
- };
90
- /**
91
- * @returns The list of tweets matching the given filter
92
- * @param filter The filter to be used for fetching matching tweets
93
- * @param count The number of tweets to fetch, must be >= 20 (when no cursor if provided)
94
- * @param cursor The cursor to the batch of tweets to fetch
95
- */
96
- TweetResolver.prototype.resolveTweets = function (filter, count, cursor) {
97
- var _a;
98
- return __awaiter(this, void 0, void 0, function () {
99
- var tweets, next, total, batchSize, res;
100
- var _this = this;
101
- return __generator(this, function (_b) {
102
- switch (_b.label) {
103
- case 0:
104
- tweets = [];
105
- next = new CursoredData_1.Cursor(cursor);
106
- total = 0;
107
- batchSize = 20;
108
- // If required count less than batch size, setting batch size to required count
109
- batchSize = (count < batchSize) ? count : batchSize;
110
- _b.label = 1;
111
- case 1:
112
- // If this is the last batch, change batch size to number of remaining tweets
113
- batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
114
- return [4 /*yield*/, this.context.tweets.getTweets(filter, batchSize, next.value)["catch"](function (error) {
115
- throw _this.getGraphQLError(error);
116
- })];
117
- case 2:
118
- res = _b.sent();
119
- // If data is available
120
- if ((_a = res.list) === null || _a === void 0 ? void 0 : _a.length) {
121
- // Adding fetched tweets to list of tweets
122
- tweets = tweets.concat(res.list);
123
- // Updating total tweets fetched
124
- total = tweets.length;
125
- // Getting cursor to next batch
126
- next = res.next;
127
- }
128
- // If no more data is available
129
- else {
130
- return [3 /*break*/, 4];
131
- }
132
- _b.label = 3;
133
- case 3:
134
- if (total < count) return [3 /*break*/, 1];
135
- _b.label = 4;
136
- case 4:
137
- // If no tweets found
138
- if (!tweets.length) {
139
- return [2 /*return*/, new Error(Errors_1.DataErrors.NoTweetsFound)];
140
- }
141
- // Adding the cursor to the end of list of data
142
- tweets.push(next);
143
- return [2 /*return*/, tweets];
144
- }
145
- });
146
- });
147
- };
148
- /**
149
- * @returns The list of quotes of the given tweet
150
- * @param id The id of the tweet whose quotes are to be fetched
151
- * @param count The number of quotes to be fetched, must be >= 20 (when no cursor if provided)
152
- * @param all Whether to fetch all quotes or not
153
- * @param cursor The cursor to the batch of tweet quotes to fetch
154
- * @param quoteCount The total number of quotes of the given tweet
155
- */
156
- TweetResolver.prototype.resolveTweetQuotes = function (id, count, all, cursor, quoteCount) {
157
- return __awaiter(this, void 0, void 0, function () {
158
- var quotes, filter;
159
- var _this = this;
160
- return __generator(this, function (_a) {
161
- switch (_a.label) {
162
- case 0:
163
- quotes = [];
164
- // If all tweets are to be fetched
165
- count = all ? quoteCount : count;
166
- filter = {
167
- words: [],
168
- hashtags: [],
169
- fromUsers: [],
170
- toUsers: [],
171
- mentions: [],
172
- startDate: '',
173
- endDate: '',
174
- quoted: id
175
- };
176
- return [4 /*yield*/, this.resolveTweets(filter, count, cursor)["catch"](function (error) {
177
- throw _this.getGraphQLError(error);
178
- })];
179
- case 1:
180
- // Fetching the quotes using resolveTweets method
181
- quotes = _a.sent();
182
- return [2 /*return*/, quotes];
183
- }
184
- });
185
- });
186
- };
187
- /**
188
- * @returns The list of likers of the given tweet
189
- * @param id The id of the tweet whose likers are to be fetched
190
- * @param count The total number of likers to fetch, must be >= 10 (when no cursor is provided)
191
- * @param all Whether to fetch all the likers of the tweet
192
- * @param cursor The cursor to the batch of likers to fetch
193
- * @param likesCount The total number of like of the tweet
194
- */
195
- TweetResolver.prototype.resolveTweetLikers = function (id, count, all, cursor, likesCount) {
196
- var _a;
197
- return __awaiter(this, void 0, void 0, function () {
198
- var likers, next, total, res;
199
- var _this = this;
200
- return __generator(this, function (_b) {
201
- switch (_b.label) {
202
- case 0:
203
- likers = [];
204
- next = new CursoredData_1.Cursor(cursor);
205
- total = 0;
206
- // If all likers are to be fetched
207
- count = all ? likesCount : count;
208
- // If required count less than batch size, setting batch size to required count
209
- this.batchSize = (count < this.batchSize) ? count : this.batchSize;
210
- _b.label = 1;
211
- case 1:
212
- // If this is the last batch, change batch size to number of remaining likers
213
- this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
214
- return [4 /*yield*/, this.context.tweets.getTweetLikers(id, this.batchSize, next.value)["catch"](function (error) {
215
- throw _this.getGraphQLError(error);
216
- })];
217
- case 2:
218
- res = _b.sent();
219
- // If data is available
220
- if ((_a = res.list) === null || _a === void 0 ? void 0 : _a.length) {
221
- // Adding fetched likers to list of likers
222
- likers = likers.concat(res.list);
223
- // Updating total likers fetched
224
- total = likers.length;
225
- // Getting cursor to next batch
226
- next = res.next;
227
- }
228
- // If no more data is available
229
- else {
230
- return [3 /*break*/, 4];
231
- }
232
- _b.label = 3;
233
- case 3:
234
- if (total < count) return [3 /*break*/, 1];
235
- _b.label = 4;
236
- case 4:
237
- // If no likers found
238
- if (!likers.length) {
239
- return [2 /*return*/, new Error(Errors_1.DataErrors.NoLikersFound)];
240
- }
241
- // Adding the cursor to the end of list of data
242
- likers.push(next);
243
- return [2 /*return*/, likers];
244
- }
245
- });
246
- });
247
- };
248
- /**
249
- * @returns The list of retweeters of the given tweet
250
- * @param id The id of the tweet whose retweeters are to be fetched
251
- * @param count The total number of retweeters to fetch, must be >= 10 (when no cursor is provided)
252
- * @param all Whether to fetch all retweeters
253
- * @param cursor The cursor to the batch of retweeters to fetch
254
- * @param retweetsCount The total number of retweets of the
255
- */
256
- TweetResolver.prototype.resolveTweetRetweeters = function (id, count, all, cursor, retweetsCount) {
257
- var _a;
258
- return __awaiter(this, void 0, void 0, function () {
259
- var retweeters, next, total, res;
260
- var _this = this;
261
- return __generator(this, function (_b) {
262
- switch (_b.label) {
263
- case 0:
264
- retweeters = [];
265
- next = new CursoredData_1.Cursor(cursor);
266
- total = 0;
267
- // If all retweeters are to be fetched
268
- count = all ? retweetsCount : count;
269
- // If required count less than batch size, setting batch size to required count
270
- this.batchSize = (count < this.batchSize) ? count : this.batchSize;
271
- _b.label = 1;
272
- case 1:
273
- // If this is the last batch, change batch size to number of remaining retweeters
274
- this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
275
- return [4 /*yield*/, this.context.tweets.getTweetRetweeters(id, this.batchSize, next.value)["catch"](function (error) {
276
- throw _this.getGraphQLError(error);
277
- })];
278
- case 2:
279
- res = _b.sent();
280
- // If data is available
281
- if ((_a = res.list) === null || _a === void 0 ? void 0 : _a.length) {
282
- // Adding fetched retweeters to list of retweeters
283
- retweeters = retweeters.concat(res.list);
284
- // Updating total retweeters fetched
285
- total = retweeters.length;
286
- // Getting cursor to next batch
287
- next = res.next;
288
- }
289
- // If no more data is available
290
- else {
291
- return [3 /*break*/, 4];
292
- }
293
- _b.label = 3;
294
- case 3:
295
- if (total < count) return [3 /*break*/, 1];
296
- _b.label = 4;
297
- case 4:
298
- // If no retweeters found
299
- if (!retweeters.length) {
300
- return [2 /*return*/, new Error(Errors_1.DataErrors.NoRetweetersFound)];
301
- }
302
- // Adding the cursor to the end of list of data
303
- retweeters.push(next);
304
- return [2 /*return*/, retweeters];
305
- }
306
- });
307
- });
308
- };
309
- return TweetResolver;
310
- }(ResolverBase_1["default"]));
311
- exports["default"] = TweetResolver;
312
- //# sourceMappingURL=TweetResolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TweetResolver.js","sourceRoot":"","sources":["../../../src/graphql/resolvers/TweetResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,YAAY;AACZ,gEAA0C;AAI1C,+DAAwD;AACxD,0CAA6C;AAE7C;IAA2C,iCAAY;IAGnD,iBAAiB;IACjB,uBAAY,OAAqB;QAAjC,YACI,kBAAM,OAAO,CAAC,SAEjB;QADG,KAAI,CAAC,SAAS,GAAG,GAAG,CAAC;;IACzB,CAAC;IAED;;;OAGG;IACG,oCAAY,GAAlB,UAAmB,EAAU;;;;;;4BAEf,qBAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,OAAK,CAAA,CAAC,UAAA,KAAK;4BAC/D,MAAM,KAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;wBACtC,CAAC,CAAC,EAAA;;wBAFE,GAAG,GAAG,SAER;wBAEF,sBAAsB;wBACtB,sBAAO,GAAG,EAAC;;;;KACd;IAED;;;;;OAKG;IACG,qCAAa,GAAnB,UAAoB,MAAmB,EAAE,KAAa,EAAE,MAAc;;;;;;;;wBAC9D,MAAM,GAAU,EAAE,CAAC;wBACnB,IAAI,GAAW,IAAI,qB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AAO,IAAI,KAAK,CAAC,mBAAU,CAAC,iBAAiB,CAAC,EAAC;yBAClD;wBAED,+CAA+C;wBAC/C,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBAEtB,sBAAO,UAAU,EAAC;;;;KACrB;IACL,oBAAC;AAAD,CAAC,AAjOD,CAA2C,yBAAY,GAiOtD"}
@@ -1,48 +0,0 @@
1
- import ResolverBase from './ResolverBase';
2
- import { IDataContext } from '../../types/Rettiwt';
3
- export default class UserResolver extends ResolverBase {
4
- private batchSize;
5
- constructor(context: IDataContext);
6
- /**
7
- * @returns The details of the target twitter user
8
- * @param userName The user name of the target twitter user
9
- * @param id The id/username of the target twitter user
10
- */
11
- resolveUserDetails(id: string): Promise<any>;
12
- /**
13
- * @returns The list of tweets made by the given user
14
- * @param userName The username of the user whose tweets are to be fetched
15
- * @param count The number of tweets to fetch, must be >= 10
16
- * @param all Whether to fetch list of all tweets made by user
17
- * @param cursor The cursor to the batch of tweets to fetch
18
- * @param statusesCount The total number of tweets made by target user
19
- */
20
- resolveUserTweets(userName: string, count: number, all: boolean, cursor: string, statusesCount: number): Promise<any>;
21
- /**
22
- * @returns The list of tweets liked by the given user
23
- * @param id The id of the user whose likes are to be fetched
24
- * @param count The number of likes to fetch, must be >= 40
25
- * @param all Whether to fetch list of all tweets liked by user
26
- * @param cursor The cursor to the batch of likes to fetch
27
- * @param favouritesCount The total number of tweets liked by target user
28
- */
29
- resolveUserLikes(id: string, count: number, all: boolean, cursor: string, favouritesCount: number): Promise<any>;
30
- /**
31
- * @returns The list of followers of the given twiiter user
32
- * @param id The id of the user whose followers are to be fetched
33
- * @param count The number of followers to fetch, must be >= 40 when no cursor is provided
34
- * @param all Whether to fetch all followers list
35
- * @param cursor The cursor to the batch of followers to fetch
36
- * @param followerCount The total number of followers of the target user
37
- */
38
- resolveUserFollowers(id: string, count: number, all: boolean, cursor: string, followersCount: number): Promise<any>;
39
- /**
40
- * @returns The list of following of the given twiiter user
41
- * @param id The id of the user whose followings are to be fetched
42
- * @param count The number of following to fetch, should be >= 40 when no cursor is provided
43
- * @param all Whether to fetch list of all followings
44
- * @param cursor The cursor to the batch of followings to fetch
45
- * @param followingsCount The total number of followings of the target user
46
- */
47
- resolveUserFollowing(id: string, count: number, all: boolean, cursor: string, followingsCount: number): Promise<any>;
48
- }