rettiwt-api 1.4.0 → 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 (232) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc.js +54 -0
  3. package/.github/workflows/documentation.yml +29 -9
  4. package/.github/workflows/publish.yml +8 -3
  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/dist/config/env.d.ts +0 -5
  63. package/dist/config/env.js +0 -9
  64. package/dist/config/env.js.map +0 -1
  65. package/dist/enums/Errors.d.ts +0 -21
  66. package/dist/enums/Errors.js +0 -29
  67. package/dist/enums/Errors.js.map +0 -1
  68. package/dist/graphql/enums/Errors.d.ts +0 -21
  69. package/dist/graphql/enums/Errors.js +0 -29
  70. package/dist/graphql/enums/Errors.js.map +0 -1
  71. package/dist/graphql/queries/RootQuery.d.ts +0 -4
  72. package/dist/graphql/queries/RootQuery.js +0 -83
  73. package/dist/graphql/queries/RootQuery.js.map +0 -1
  74. package/dist/graphql/resolvers/AccountResolver.d.ts +0 -12
  75. package/dist/graphql/resolvers/AccountResolver.js +0 -84
  76. package/dist/graphql/resolvers/AccountResolver.js.map +0 -1
  77. package/dist/graphql/resolvers/ResolverBase.d.ts +0 -16
  78. package/dist/graphql/resolvers/ResolverBase.js +0 -23
  79. package/dist/graphql/resolvers/ResolverBase.js.map +0 -1
  80. package/dist/graphql/resolvers/TweetResolver.d.ts +0 -46
  81. package/dist/graphql/resolvers/TweetResolver.js +0 -302
  82. package/dist/graphql/resolvers/TweetResolver.js.map +0 -1
  83. package/dist/graphql/resolvers/UserResolver.d.ts +0 -48
  84. package/dist/graphql/resolvers/UserResolver.js +0 -334
  85. package/dist/graphql/resolvers/UserResolver.js.map +0 -1
  86. package/dist/graphql/types/Global.d.ts +0 -4
  87. package/dist/graphql/types/Global.js +0 -13
  88. package/dist/graphql/types/Global.js.map +0 -1
  89. package/dist/graphql/types/TweetTypes.d.ts +0 -4
  90. package/dist/graphql/types/TweetTypes.js +0 -160
  91. package/dist/graphql/types/TweetTypes.js.map +0 -1
  92. package/dist/graphql/types/UserTypes.d.ts +0 -3
  93. package/dist/graphql/types/UserTypes.js +0 -137
  94. package/dist/graphql/types/UserTypes.js.map +0 -1
  95. package/dist/models/args/TweetListArgs.d.ts +0 -21
  96. package/dist/models/args/TweetListArgs.js +0 -54
  97. package/dist/models/args/TweetListArgs.js.map +0 -1
  98. package/dist/models/args/UserListArgs.d.ts +0 -21
  99. package/dist/models/args/UserListArgs.js +0 -54
  100. package/dist/models/args/UserListArgs.js.map +0 -1
  101. package/dist/models/auth/AuthCookie.d.ts +0 -21
  102. package/dist/models/auth/AuthCookie.js +0 -33
  103. package/dist/models/auth/AuthCookie.js.map +0 -1
  104. package/dist/models/data/CursoredData.d.ts +0 -34
  105. package/dist/models/data/CursoredData.js +0 -42
  106. package/dist/models/data/CursoredData.js.map +0 -1
  107. package/dist/models/data/Tweet.js.map +0 -1
  108. package/dist/models/data/User.js.map +0 -1
  109. package/dist/server.d.ts +0 -1
  110. package/dist/server.js +0 -76
  111. package/dist/server.js.map +0 -1
  112. package/dist/services/auth/AccountService.d.ts +0 -83
  113. package/dist/services/auth/AccountService.js +0 -412
  114. package/dist/services/auth/AccountService.js.map +0 -1
  115. package/dist/services/auth/AuthService.d.ts +0 -31
  116. package/dist/services/auth/AuthService.js +0 -118
  117. package/dist/services/auth/AuthService.js.map +0 -1
  118. package/dist/services/data/TweetService.d.ts +0 -60
  119. package/dist/services/data/TweetService.js +0 -250
  120. package/dist/services/data/TweetService.js.map +0 -1
  121. package/dist/services/data/UserService.d.ts +0 -71
  122. package/dist/services/data/UserService.js +0 -278
  123. package/dist/services/data/UserService.js.map +0 -1
  124. package/dist/services/helper/Headers.d.ts +0 -19
  125. package/dist/services/helper/Headers.js +0 -62
  126. package/dist/services/helper/Headers.js.map +0 -1
  127. package/dist/services/helper/Parser.d.ts +0 -22
  128. package/dist/services/helper/Parser.js +0 -84
  129. package/dist/services/helper/Parser.js.map +0 -1
  130. package/dist/services/helper/extractors/Tweets.d.ts +0 -23
  131. package/dist/services/helper/extractors/Tweets.js +0 -200
  132. package/dist/services/helper/extractors/Tweets.js.map +0 -1
  133. package/dist/services/helper/extractors/Users.d.ts +0 -17
  134. package/dist/services/helper/extractors/Users.js +0 -151
  135. package/dist/services/helper/extractors/Users.js.map +0 -1
  136. package/dist/services/helper/payloads/LoginFlows.d.ts +0 -77
  137. package/dist/services/helper/payloads/LoginFlows.js +0 -92
  138. package/dist/services/helper/payloads/LoginFlows.js.map +0 -1
  139. package/dist/services/helper/urls/Authentication.d.ts +0 -4
  140. package/dist/services/helper/urls/Authentication.js +0 -11
  141. package/dist/services/helper/urls/Authentication.js.map +0 -1
  142. package/dist/services/util/CacheService.d.ts +0 -33
  143. package/dist/services/util/CacheService.js +0 -96
  144. package/dist/services/util/CacheService.js.map +0 -1
  145. package/dist/services/util/FetcherService.d.ts +0 -65
  146. package/dist/services/util/FetcherService.js +0 -202
  147. package/dist/services/util/FetcherService.js.map +0 -1
  148. package/dist/types/Args.d.ts +0 -11
  149. package/dist/types/Args.js +0 -4
  150. package/dist/types/Args.js.map +0 -1
  151. package/dist/types/Authentication.d.ts +0 -55
  152. package/dist/types/Authentication.js +0 -6
  153. package/dist/types/Authentication.js.map +0 -1
  154. package/dist/types/Resolvers.d.ts +0 -15
  155. package/dist/types/Resolvers.js +0 -3
  156. package/dist/types/Resolvers.js.map +0 -1
  157. package/dist/types/Rettiwt.d.ts +0 -16
  158. package/dist/types/Rettiwt.js +0 -3
  159. package/dist/types/Rettiwt.js.map +0 -1
  160. package/dist/types/Service.js +0 -5
  161. package/dist/types/Service.js.map +0 -1
  162. package/docs/.nojekyll +0 -1
  163. package/docs/assets/highlight.css +0 -64
  164. package/docs/assets/main.js +0 -58
  165. package/docs/assets/search.js +0 -1
  166. package/docs/assets/style.css +0 -1280
  167. package/docs/classes/AccountService.html +0 -286
  168. package/docs/classes/AuthCookie.html +0 -146
  169. package/docs/classes/AuthService.html +0 -147
  170. package/docs/classes/CacheService.html +0 -157
  171. package/docs/classes/Cursor.html +0 -102
  172. package/docs/classes/CursoredData.html +0 -126
  173. package/docs/classes/DataValidationError.html +0 -120
  174. package/docs/classes/FetcherService.html +0 -225
  175. package/docs/classes/Tweet.html +0 -210
  176. package/docs/classes/TweetEntities.html +0 -128
  177. package/docs/classes/TweetFilter.html +0 -233
  178. package/docs/classes/TweetListArgs.html +0 -118
  179. package/docs/classes/TweetService.html +0 -319
  180. package/docs/classes/User.html +0 -230
  181. package/docs/classes/UserListArgs.html +0 -118
  182. package/docs/classes/UserService.html +0 -355
  183. package/docs/enums/HttpMethods.html +0 -74
  184. package/docs/functions/Rettiwt.html +0 -100
  185. package/docs/index.html +0 -159
  186. package/docs/interfaces/IAuthCookie.html +0 -104
  187. package/docs/interfaces/ICursor.html +0 -77
  188. package/docs/interfaces/ICursoredData.html +0 -93
  189. package/docs/interfaces/IDataContext.html +0 -91
  190. package/docs/interfaces/IDataValidationError.html +0 -109
  191. package/docs/interfaces/IListArgs.html +0 -87
  192. package/docs/interfaces/ITweet.html +0 -176
  193. package/docs/interfaces/ITweetEntities.html +0 -104
  194. package/docs/interfaces/ITweetFilter.html +0 -158
  195. package/docs/interfaces/IUser.html +0 -194
  196. package/docs/modules.html +0 -111
  197. package/environment.d.ts +0 -11
  198. package/src/config/env.ts +0 -5
  199. package/src/enums/Errors.ts +0 -22
  200. package/src/graphql/enums/Errors.ts +0 -22
  201. package/src/graphql/queries/RootQuery.ts +0 -81
  202. package/src/graphql/resolvers/AccountResolver.ts +0 -22
  203. package/src/graphql/resolvers/ResolverBase.ts +0 -26
  204. package/src/graphql/resolvers/TweetResolver.ts +0 -225
  205. package/src/graphql/resolvers/UserResolver.ts +0 -257
  206. package/src/graphql/types/Global.ts +0 -10
  207. package/src/graphql/types/TweetTypes.ts +0 -158
  208. package/src/graphql/types/UserTypes.ts +0 -134
  209. package/src/models/args/TweetListArgs.ts +0 -47
  210. package/src/models/args/UserListArgs.ts +0 -47
  211. package/src/models/auth/AuthCookie.ts +0 -43
  212. package/src/models/data/CursoredData.ts +0 -45
  213. package/src/models/data/Tweet.ts +0 -118
  214. package/src/models/data/User.ts +0 -72
  215. package/src/server.ts +0 -37
  216. package/src/services/auth/AccountService.ts +0 -283
  217. package/src/services/auth/AuthService.ts +0 -81
  218. package/src/services/data/TweetService.ts +0 -197
  219. package/src/services/data/UserService.ts +0 -221
  220. package/src/services/helper/Headers.ts +0 -60
  221. package/src/services/helper/Parser.ts +0 -89
  222. package/src/services/helper/extractors/Tweets.ts +0 -190
  223. package/src/services/helper/extractors/Users.ts +0 -141
  224. package/src/services/helper/payloads/LoginFlows.ts +0 -90
  225. package/src/services/helper/urls/Authentication.ts +0 -6
  226. package/src/services/util/CacheService.ts +0 -76
  227. package/src/services/util/FetcherService.ts +0 -143
  228. package/src/types/Args.ts +0 -12
  229. package/src/types/Authentication.ts +0 -63
  230. package/src/types/Resolvers.ts +0 -18
  231. package/src/types/Rettiwt.ts +0 -20
  232. 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,302 +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;
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
- return [4 /*yield*/, this.resolveTweets({ quoted: id }, count, cursor)["catch"](function (error) {
167
- throw _this.getGraphQLError(error);
168
- })];
169
- case 1:
170
- // Fetching the quotes using resolveTweets method
171
- quotes = _a.sent();
172
- return [2 /*return*/, quotes];
173
- }
174
- });
175
- });
176
- };
177
- /**
178
- * @returns The list of likers of the given tweet
179
- * @param id The id of the tweet whose likers are to be fetched
180
- * @param count The total number of likers to fetch, must be >= 10 (when no cursor is provided)
181
- * @param all Whether to fetch all the likers of the tweet
182
- * @param cursor The cursor to the batch of likers to fetch
183
- * @param likesCount The total number of like of the tweet
184
- */
185
- TweetResolver.prototype.resolveTweetLikers = function (id, count, all, cursor, likesCount) {
186
- var _a;
187
- return __awaiter(this, void 0, void 0, function () {
188
- var likers, next, total, res;
189
- var _this = this;
190
- return __generator(this, function (_b) {
191
- switch (_b.label) {
192
- case 0:
193
- likers = [];
194
- next = new CursoredData_1.Cursor(cursor);
195
- total = 0;
196
- // If all likers are to be fetched
197
- count = all ? likesCount : count;
198
- // If required count less than batch size, setting batch size to required count
199
- this.batchSize = (count < this.batchSize) ? count : this.batchSize;
200
- _b.label = 1;
201
- case 1:
202
- // If this is the last batch, change batch size to number of remaining likers
203
- this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
204
- return [4 /*yield*/, this.context.tweets.getTweetLikers(id, this.batchSize, next.value)["catch"](function (error) {
205
- throw _this.getGraphQLError(error);
206
- })];
207
- case 2:
208
- res = _b.sent();
209
- // If data is available
210
- if ((_a = res.list) === null || _a === void 0 ? void 0 : _a.length) {
211
- // Adding fetched likers to list of likers
212
- likers = likers.concat(res.list);
213
- // Updating total likers fetched
214
- total = likers.length;
215
- // Getting cursor to next batch
216
- next = res.next;
217
- }
218
- // If no more data is available
219
- else {
220
- return [3 /*break*/, 4];
221
- }
222
- _b.label = 3;
223
- case 3:
224
- if (total < count) return [3 /*break*/, 1];
225
- _b.label = 4;
226
- case 4:
227
- // If no likers found
228
- if (!likers.length) {
229
- return [2 /*return*/, new Error(Errors_1.DataErrors.NoLikersFound)];
230
- }
231
- // Adding the cursor to the end of list of data
232
- likers.push(next);
233
- return [2 /*return*/, likers];
234
- }
235
- });
236
- });
237
- };
238
- /**
239
- * @returns The list of retweeters of the given tweet
240
- * @param id The id of the tweet whose retweeters are to be fetched
241
- * @param count The total number of retweeters to fetch, must be >= 10 (when no cursor is provided)
242
- * @param all Whether to fetch all retweeters
243
- * @param cursor The cursor to the batch of retweeters to fetch
244
- * @param retweetsCount The total number of retweets of the
245
- */
246
- TweetResolver.prototype.resolveTweetRetweeters = function (id, count, all, cursor, retweetsCount) {
247
- var _a;
248
- return __awaiter(this, void 0, void 0, function () {
249
- var retweeters, next, total, res;
250
- var _this = this;
251
- return __generator(this, function (_b) {
252
- switch (_b.label) {
253
- case 0:
254
- retweeters = [];
255
- next = new CursoredData_1.Cursor(cursor);
256
- total = 0;
257
- // If all retweeters are to be fetched
258
- count = all ? retweetsCount : count;
259
- // If required count less than batch size, setting batch size to required count
260
- this.batchSize = (count < this.batchSize) ? count : this.batchSize;
261
- _b.label = 1;
262
- case 1:
263
- // If this is the last batch, change batch size to number of remaining retweeters
264
- this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
265
- return [4 /*yield*/, this.context.tweets.getTweetRetweeters(id, this.batchSize, next.value)["catch"](function (error) {
266
- throw _this.getGraphQLError(error);
267
- })];
268
- case 2:
269
- res = _b.sent();
270
- // If data is available
271
- if ((_a = res.list) === null || _a === void 0 ? void 0 : _a.length) {
272
- // Adding fetched retweeters to list of retweeters
273
- retweeters = retweeters.concat(res.list);
274
- // Updating total retweeters fetched
275
- total = retweeters.length;
276
- // Getting cursor to next batch
277
- next = res.next;
278
- }
279
- // If no more data is available
280
- else {
281
- return [3 /*break*/, 4];
282
- }
283
- _b.label = 3;
284
- case 3:
285
- if (total < count) return [3 /*break*/, 1];
286
- _b.label = 4;
287
- case 4:
288
- // If no retweeters found
289
- if (!retweeters.length) {
290
- return [2 /*return*/, new Error(Errors_1.DataErrors.NoRetweetersFound)];
291
- }
292
- // Adding the cursor to the end of list of data
293
- retweeters.push(next);
294
- return [2 /*return*/, retweeters];
295
- }
296
- });
297
- });
298
- };
299
- return TweetResolver;
300
- }(ResolverBase_1["default"]));
301
- exports["default"] = TweetResolver;
302
- //# 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,qBAAM,CAAC,MAAM,CAAC,CAAC;wBAClC,KAAK,GAAW,CAAC,CAAC;wBAGlB,SAAS,GAAW,EAAE,CAAC;wBAE3B,+EAA+E;wBAC/E,SAAS,GAAG,CAAC,KAAK,GAAG,SAAS,CA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,SAAS,GAAG,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;wBAG3E,qBAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,OAAK,CAAA,CAAC,UAAA,KAAK;gCAChG,MAAM,KAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;4BACtC,CAAC,CAAC,EAAA;;wBAFI,GAAG,GAAG,SAEV;wBAEF,uBAAuB;wBACvB,IAAI,MAAA,GAAG,CAAC,IAAI,0CAAE,MAAM,EAAE;4BAClB,kDAAkD;4BAClD,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;4BAEzC,oCAAoC;4BACpC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC;4BAE1B,+BAA+B;4BAC/B,IAAI,GAAG,GAAG,CAAC,IAAc,CAAC;yBAC7B;wBACD,+BAA+B;6BAC1B;4BACD,wBAAM;yBACT;;;4BACI,KAAK,GAAG,KAAK;;;wBAEtB,yBAAyB;wBACzB,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;4BACpB,sBAAO,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,AArND,CAA2C,yBAAY,GAqNtD"}
@@ -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
- }