rettiwt-api 1.1.0 → 1.1.1

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 (125) hide show
  1. package/.github/workflows/build-docs.yml +27 -0
  2. package/README.md +3 -1
  3. package/dist/Test.d.ts +0 -0
  4. package/dist/Test.js +2 -0
  5. package/dist/Test.js.map +1 -0
  6. package/dist/index.d.ts +16 -5
  7. package/dist/index.js +22 -8
  8. package/dist/index.js.map +1 -1
  9. package/dist/models/graphql/Global.d.ts +4 -0
  10. package/dist/models/graphql/Global.js +13 -0
  11. package/dist/models/graphql/Global.js.map +1 -0
  12. package/dist/models/graphql/TweetTypes.d.ts +6 -0
  13. package/dist/models/graphql/TweetTypes.js +156 -0
  14. package/dist/models/graphql/TweetTypes.js.map +1 -0
  15. package/dist/models/graphql/UserTypes.d.ts +3 -0
  16. package/dist/models/graphql/UserTypes.js +139 -0
  17. package/dist/models/graphql/UserTypes.js.map +1 -0
  18. package/dist/queries/RootQuery.d.ts +4 -0
  19. package/dist/queries/RootQuery.js +70 -0
  20. package/dist/queries/RootQuery.js.map +1 -0
  21. package/dist/resolvers/AccountResolver.d.ts +12 -0
  22. package/dist/resolvers/AccountResolver.js +84 -0
  23. package/dist/resolvers/AccountResolver.js.map +1 -0
  24. package/dist/resolvers/ResolverBase.d.ts +5 -0
  25. package/dist/resolvers/ResolverBase.js +11 -0
  26. package/dist/resolvers/ResolverBase.js.map +1 -0
  27. package/dist/resolvers/TweetResolver.d.ts +54 -0
  28. package/dist/resolvers/TweetResolver.js +332 -0
  29. package/dist/resolvers/TweetResolver.js.map +1 -0
  30. package/dist/resolvers/UserResolver.d.ts +38 -0
  31. package/dist/resolvers/UserResolver.js +253 -0
  32. package/dist/resolvers/UserResolver.js.map +1 -0
  33. package/dist/services/AuthService.d.ts +6 -2
  34. package/dist/services/AuthService.js +4 -3
  35. package/dist/services/AuthService.js.map +1 -1
  36. package/dist/services/CacheService.d.ts +12 -7
  37. package/dist/services/CacheService.js +12 -7
  38. package/dist/services/CacheService.js.map +1 -1
  39. package/dist/services/FetcherService.d.ts +32 -12
  40. package/dist/services/FetcherService.js +45 -14
  41. package/dist/services/FetcherService.js.map +1 -1
  42. package/dist/services/accounts/AccountService.d.ts +23 -6
  43. package/dist/services/accounts/AccountService.js +34 -9
  44. package/dist/services/accounts/AccountService.js.map +1 -1
  45. package/dist/services/data/TrendService.d.ts +17 -0
  46. package/dist/services/data/TrendService.js +116 -0
  47. package/dist/services/data/TrendService.js.map +1 -0
  48. package/dist/services/data/TweetService.d.ts +22 -15
  49. package/dist/services/data/TweetService.js +22 -15
  50. package/dist/services/data/TweetService.js.map +1 -1
  51. package/dist/services/data/UserAccountService.d.ts +42 -0
  52. package/dist/services/data/UserAccountService.js +239 -0
  53. package/dist/services/data/UserAccountService.js.map +1 -0
  54. package/dist/services/data/UserService.d.ts +21 -15
  55. package/dist/services/data/UserService.js +21 -15
  56. package/dist/services/data/UserService.js.map +1 -1
  57. package/dist/services/helper/Deserializers.d.ts +19 -0
  58. package/dist/services/helper/Deserializers.js +115 -0
  59. package/dist/services/helper/Deserializers.js.map +1 -0
  60. package/dist/services/helper/Extractors.d.ts +104 -0
  61. package/dist/services/helper/Extractors.js +432 -0
  62. package/dist/services/helper/Extractors.js.map +1 -0
  63. package/dist/services/helper/Urls.d.ts +85 -0
  64. package/dist/services/helper/Urls.js +130 -0
  65. package/dist/services/helper/Urls.js.map +1 -0
  66. package/dist/services/helper/extractors/Trends.d.ts +3 -0
  67. package/dist/services/helper/extractors/Trends.js +51 -0
  68. package/dist/services/helper/extractors/Trends.js.map +1 -0
  69. package/dist/services/helper/urls/Trends.d.ts +7 -0
  70. package/dist/services/helper/urls/Trends.js +13 -0
  71. package/dist/services/helper/urls/Trends.js.map +1 -0
  72. package/dist/types/Authentication.d.ts +27 -2
  73. package/dist/types/Authentication.js.map +1 -1
  74. package/dist/types/HTTP.d.ts +3 -1
  75. package/dist/types/HTTP.js +3 -1
  76. package/dist/types/HTTP.js.map +1 -1
  77. package/dist/types/Resolvers.d.ts +6 -1
  78. package/dist/types/Service.d.ts +30 -0
  79. package/dist/types/Service.js +19 -0
  80. package/dist/types/Service.js.map +1 -0
  81. package/dist/types/Trends.d.ts +50 -0
  82. package/dist/types/Trends.js +3 -0
  83. package/dist/types/Trends.js.map +1 -0
  84. package/dist/types/Tweet.d.ts +40 -0
  85. package/dist/types/Tweet.js +5 -0
  86. package/dist/types/Tweet.js.map +1 -0
  87. package/dist/types/UserAccount.d.ts +19 -0
  88. package/dist/types/UserAccount.js +4 -0
  89. package/dist/types/UserAccount.js.map +1 -0
  90. package/dist/types/data/Errors.d.ts +9 -3
  91. package/dist/types/data/Errors.js +9 -3
  92. package/dist/types/data/Errors.js.map +1 -1
  93. package/dist/types/data/Service.d.ts +19 -5
  94. package/dist/types/data/Service.js +6 -3
  95. package/dist/types/data/Service.js.map +1 -1
  96. package/dist/types/data/Tweet.d.ts +60 -3
  97. package/dist/types/data/Tweet.js +0 -1
  98. package/dist/types/data/Tweet.js.map +1 -1
  99. package/dist/types/data/User.d.ts +20 -1
  100. package/dist/types/data/User.js +0 -1
  101. package/dist/types/data/User.js.map +1 -1
  102. package/dist/types/graphql/Errors.d.ts +15 -0
  103. package/dist/types/graphql/Errors.js +23 -0
  104. package/dist/types/graphql/Errors.js.map +1 -0
  105. package/dist/types/raw/general/Trends.d.ts +324 -0
  106. package/dist/types/raw/general/Trends.js +3 -0
  107. package/dist/types/raw/general/Trends.js.map +1 -0
  108. package/dist/types/raw/user/Tweets.d.ts +2428 -0
  109. package/dist/types/raw/user/Tweets.js +3 -0
  110. package/dist/types/raw/user/Tweets.js.map +1 -0
  111. package/package.json +5 -4
  112. package/src/index.ts +19 -6
  113. package/src/services/AuthService.ts +13 -7
  114. package/src/services/CacheService.ts +12 -7
  115. package/src/services/FetcherService.ts +62 -21
  116. package/src/services/accounts/AccountService.ts +38 -12
  117. package/src/services/data/TweetService.ts +25 -18
  118. package/src/services/data/UserService.ts +21 -15
  119. package/src/types/Authentication.ts +27 -2
  120. package/src/types/HTTP.ts +4 -2
  121. package/src/types/Resolvers.ts +14 -6
  122. package/src/types/data/Errors.ts +10 -4
  123. package/src/types/data/Service.ts +28 -11
  124. package/src/types/data/Tweet.ts +109 -31
  125. package/src/types/data/User.ts +47 -17
@@ -0,0 +1,253 @@
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
+ // TYPES
60
+ var Service_1 = require("../types/Service");
61
+ // HELPERS
62
+ var Errors_1 = require("../types/graphql/Errors");
63
+ var UserResolver = /** @class */ (function (_super) {
64
+ __extends(UserResolver, _super);
65
+ // MEMBER METHODS
66
+ function UserResolver(context) {
67
+ return _super.call(this, context) || this;
68
+ }
69
+ /**
70
+ * @returns The details of the target twitter user
71
+ * @param userName The user name of the target twitter user
72
+ * @param id The id of the target twitter user
73
+ */
74
+ UserResolver.prototype.resolveUserDetails = function (userName, id) {
75
+ return __awaiter(this, void 0, void 0, function () {
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0:
79
+ if (!userName) return [3 /*break*/, 2];
80
+ return [4 /*yield*/, this.context.users.getUserAccountDetails(userName)];
81
+ case 1: return [2 /*return*/, _a.sent()];
82
+ case 2:
83
+ if (!id) return [3 /*break*/, 4];
84
+ return [4 /*yield*/, this.context.users.getUserAccountDetailsById(id)];
85
+ case 3: return [2 /*return*/, _a.sent()];
86
+ case 4: throw new Error(Errors_1.ValidationErrors.NoUserIdentification);
87
+ }
88
+ });
89
+ });
90
+ };
91
+ /**
92
+ * @returns The list of tweets liked by the given user
93
+ * @param id The id of the user whose likes are to be fetched
94
+ * @param count The number of likes to fetch
95
+ * @param all Whether to fetch list of all tweets liked by user
96
+ * @param cursor The cursor to the batch of likes to fetch
97
+ * @param favouritesCount The total number of tweets liked by target user
98
+ */
99
+ UserResolver.prototype.resolveUserLikes = function (id, count, all, cursor, favouritesCount) {
100
+ var _a;
101
+ return __awaiter(this, void 0, void 0, function () {
102
+ var likes, next, total, batchSize, res;
103
+ return __generator(this, function (_b) {
104
+ switch (_b.label) {
105
+ case 0:
106
+ likes = [];
107
+ next = new Service_1.Cursor(cursor);
108
+ total = 0;
109
+ batchSize = 20;
110
+ // If all liked tweets are to be fetched
111
+ count = all ? favouritesCount : count;
112
+ // If required count less than batch size, setting batch size to required count
113
+ batchSize = (count < batchSize) ? count : batchSize;
114
+ _b.label = 1;
115
+ case 1:
116
+ if (!(total < count)) return [3 /*break*/, 3];
117
+ // If this is the last batch, change batch size to number of remaining tweets
118
+ batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
119
+ return [4 /*yield*/, this.context.users.getUserLikes(id, count, next.value)];
120
+ case 2:
121
+ res = _b.sent();
122
+ // If data is available
123
+ if ((_a = res.list) === null || _a === void 0 ? void 0 : _a.length) {
124
+ // Adding fetched tweets to list of tweets
125
+ likes = likes.concat(res.list);
126
+ // Updating total tweets fetched
127
+ total = likes.length;
128
+ // Getting cursor to next batch
129
+ next = res.next;
130
+ }
131
+ // If no more data is available
132
+ else {
133
+ return [3 /*break*/, 3];
134
+ }
135
+ return [3 /*break*/, 1];
136
+ case 3:
137
+ // Adding the cursor to the end of list of data
138
+ likes.push(next);
139
+ return [2 /*return*/, likes];
140
+ }
141
+ });
142
+ });
143
+ };
144
+ /**
145
+ * @returns The list of followers of the given twiiter user
146
+ * @param id The id of the user whose followers are to be fetched
147
+ * @param count The number of followers to fetch
148
+ * @param all Whether to fetch all followers list
149
+ * @param cursor The cursor to the batch of followers to fetch
150
+ * @param followerCount The total number of followers of the target user
151
+ */
152
+ UserResolver.prototype.resolveUserFollowers = function (id, count, all, cursor, followersCount) {
153
+ var _a;
154
+ return __awaiter(this, void 0, void 0, function () {
155
+ var followers, next, total, batchSize, res;
156
+ return __generator(this, function (_b) {
157
+ switch (_b.label) {
158
+ case 0:
159
+ followers = [];
160
+ next = new Service_1.Cursor(cursor);
161
+ total = 0;
162
+ batchSize = 20;
163
+ // If all followers are to be fetched
164
+ count = (all || count > followersCount) ? followersCount : count;
165
+ // If required count less than batch size, setting batch size to required count
166
+ batchSize = (count < batchSize) ? count : batchSize;
167
+ _b.label = 1;
168
+ case 1:
169
+ if (!(total < count)) return [3 /*break*/, 3];
170
+ // If this is the last batch, change batch size to number of remaining followers
171
+ batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
172
+ return [4 /*yield*/, this.context.users.getUserFollowers(id, count, next.value)];
173
+ case 2:
174
+ res = _b.sent();
175
+ // If data is available
176
+ if ((_a = res.list) === null || _a === void 0 ? void 0 : _a.length) {
177
+ // Adding fetched followers to list of followers
178
+ followers = followers.concat(res.list);
179
+ // Updating total followers fetched
180
+ total = followers.length;
181
+ // Getting cursor to next batch
182
+ next = res.next;
183
+ }
184
+ // If no more data is available
185
+ else {
186
+ return [3 /*break*/, 3];
187
+ }
188
+ return [3 /*break*/, 1];
189
+ case 3:
190
+ // Adding the cursor to the end of list of data
191
+ followers.push(next);
192
+ return [2 /*return*/, followers];
193
+ }
194
+ });
195
+ });
196
+ };
197
+ /**
198
+ * @returns The list of following of the given twiiter user
199
+ * @param id The id of the user whose followings are to be fetched
200
+ * @param count The number of following to fetch
201
+ * @param all Whether to fetch list of all followings
202
+ * @param cursor The cursor to the batch of followings to fetch
203
+ * @param followingsCount The total number of followings of the target user
204
+ */
205
+ UserResolver.prototype.resolveUserFollowing = function (id, count, all, cursor, followingsCount) {
206
+ var _a;
207
+ return __awaiter(this, void 0, void 0, function () {
208
+ var following, next, total, batchSize, res;
209
+ return __generator(this, function (_b) {
210
+ switch (_b.label) {
211
+ case 0:
212
+ following = [];
213
+ next = new Service_1.Cursor(cursor);
214
+ total = 0;
215
+ batchSize = 20;
216
+ // If all followings are to be fetched
217
+ count = (all || count > followingsCount) ? followingsCount : count;
218
+ // If required count less than batch size, setting batch size to required count
219
+ batchSize = (count < batchSize) ? count : batchSize;
220
+ _b.label = 1;
221
+ case 1:
222
+ if (!(total < count)) return [3 /*break*/, 3];
223
+ // If this is the last batch, change batch size to number of remaining following
224
+ batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
225
+ return [4 /*yield*/, this.context.users.getUserFollowing(id, count, next.value)];
226
+ case 2:
227
+ res = _b.sent();
228
+ // If data is available
229
+ if ((_a = res.list) === null || _a === void 0 ? void 0 : _a.length) {
230
+ // Adding fetched following to list of following
231
+ following = following.concat(res.list);
232
+ // Updating total following fetched
233
+ total = following.length;
234
+ // Getting cursor to next batch
235
+ next = res.next;
236
+ }
237
+ // If no more data is available
238
+ else {
239
+ return [3 /*break*/, 3];
240
+ }
241
+ return [3 /*break*/, 1];
242
+ case 3:
243
+ // Adding the cursor to the end of list of data
244
+ following.push(next);
245
+ return [2 /*return*/, following];
246
+ }
247
+ });
248
+ });
249
+ };
250
+ return UserResolver;
251
+ }(ResolverBase_1["default"]));
252
+ exports["default"] = UserResolver;
253
+ //# sourceMappingURL=UserResolver.js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,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC;wBAEnE,+EAA+E;wBAC/E,SAAS,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;;;6BAG7C,CAAA,KAAK,GAAG,KAAK,CAAA;wBAChB,gFAAgF;wBAChF,SAAS,GAAG,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;wBAG5D,qBAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,EAAA;;wBAAtE,GAAG,GAAG,SAAgE;wBAE5E,uBAAuB;wBACvB,IAAI,MAAA,GAAG,CAAC,IAAI,0CAAE,MAAM,EAAE;4BAClB,gDAAgD;4BAChD,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;4BAEvC,mCAAmC;4BACnC,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC;4BAEzB,+BAA+B;4BAC/B,IAAI,GAAG,GAAG,CAAC,IAAc,CAAC;yBAC7B;wBACD,+BAA+B;6BAC1B;4BACD,wBAAM;yBACT;;;wBAGL,+CAA+C;wBAC/C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBAErB,sBAAO,SAAS,EAAC;;;;KACpB;IACL,mBAAC;AAAD,CAAC,AAlLD,CAA0C,yBAAY,GAkLrD"}
@@ -1,10 +1,14 @@
1
1
  import { GuestCredentials, AuthCredentials } from '../types/Authentication';
2
2
  /**
3
- * @summary Handles authentication of http requests and other authentication related tasks
3
+ * Handles authentication of http requests and other authentication related tasks.
4
+ * @internal
4
5
  */
5
6
  export declare class AuthService {
7
+ /** The common bearer token for authentication. */
6
8
  private authToken;
9
+ /** The current authentication credentials. */
7
10
  private credentials;
11
+ /** Whether instance has been authenticated or not. */
8
12
  isAuthenticated: boolean;
9
13
  constructor(cookie?: string);
10
14
  /**
@@ -12,7 +16,7 @@ export declare class AuthService {
12
16
  */
13
17
  getAuthCredentials(): Promise<AuthCredentials>;
14
18
  /**
15
- * @returns The guest credentials fetched from twitter
19
+ * @returns The guest credentials fetched from twitter.
16
20
  */
17
21
  getGuestCredentials(): Promise<GuestCredentials>;
18
22
  }
@@ -47,7 +47,8 @@ var Authentication_1 = require("./helper/urls/Authentication");
47
47
  // CONFIGS
48
48
  var env_1 = require("../config/env");
49
49
  /**
50
- * @summary Handles authentication of http requests and other authentication related tasks
50
+ * Handles authentication of http requests and other authentication related tasks.
51
+ * @internal
51
52
  */
52
53
  var AuthService = /** @class */ (function () {
53
54
  // MEMBER METHODS
@@ -62,7 +63,7 @@ var AuthService = /** @class */ (function () {
62
63
  * The following regex pattern is used to extract the csrfToken from the cookie string.
63
64
  * This is done by matching any string between the characters 'ct0=' and nearest enclosing ';'.
64
65
  * (?<=pattern) starts matching after the given pattern.
65
- * (?=pattern) stops matching just before the pattern
66
+ * (?=pattern) stops matching just before the pattern.
66
67
  */
67
68
  this.credentials = { authToken: this.authToken, csrfToken: cookie.match(/(?<=ct0=).+?(?=;)/) + '', cookie: cookie };
68
69
  }
@@ -77,7 +78,7 @@ var AuthService = /** @class */ (function () {
77
78
  });
78
79
  };
79
80
  /**
80
- * @returns The guest credentials fetched from twitter
81
+ * @returns The guest credentials fetched from twitter.
81
82
  */
82
83
  AuthService.prototype.getGuestCredentials = function () {
83
84
  return __awaiter(this, void 0, void 0, function () {
@@ -1 +1 @@
1
- {"version":3,"file":"AuthService.js","sourceRoot":"","sources":["../../src/services/AuthService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,UAAU;AACV,gDAA0B;AAE1B,OAAO;AACP,+DAA6D;AAK7D,UAAU;AACV,qCAAuC;AAE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BAAY,MAAmB;QAAnB,uBAAA,EAAA,WAAmB;QAC3B,qEAAqE;QACrE,IAAI,CAAC,SAAS,GAAG,YAAM,CAAC,kBAAkB,CAAC;QAE3C,gCAAgC;QAChC,IAAI,CAAC,eAAe,GAAG,MAAM,IAAI,EAAE,CAAC;QAEpC,2CAA2C;QAC3C;;;;;WAKG;QACH,IAAI,CAAC,WAAW,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAC,CAAC;IAEvH,CAAC;IAED;;OAEG;IACG,wCAAkB,GAAxB;;;gBACI,sBAAO,IAAI,CAAC,WAAW,EAAC;;;KAC3B;IAED;;OAEG;IACG,yCAAmB,GAAzB;;;;;4BAEW,qBAAM,kBAAK,CAAC,IAAI,CAA0B,IAAA,8BAAa,GAAE,EAAE,IAAI,EAAE;4BACpE,OAAO,EAAE;gCACL,eAAe,EAAE,IAAI,CAAC,SAAS;6BAClC;yBACJ,CAAC,CAAC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,CAAC;4BACZ,SAAS,EAAE,KAAI,CAAC,SAAS;4BACzB,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,WAAW;yBACnC,CAAC,EAHa,CAGb,CAAC,EAAA;;oBARH,6CAA6C;oBAC7C,sBAAO,SAOJ,EAAC;;;;KACP;IACL,kBAAC;AAAD,CAAC,AAnDD,IAmDC;AAnDY,kCAAW"}
@@ -1,7 +1,10 @@
1
1
  /**
2
- * @summary Handles reading and writing of data from and to cache.
2
+ * Handles reading and writing of data from and to cache.
3
3
  *
4
- * **Note**: To be able to CacheService, the data to be cached must have a unique "id" field.
4
+ * This services uses a local node-cache instance to cache data, since the data to be cached has no real purpose outside of the server session.
5
+ * This serivce follows a singleton pattern, where at any point, only a single instance of this class exists.
6
+ * This is done so that all the data is cached in a single instance, which makes sharing of cached data between different endpoints possible.
7
+ * @internal
5
8
  */
6
9
  export declare class CacheService {
7
10
  private static instance;
@@ -12,14 +15,16 @@ export declare class CacheService {
12
15
  */
13
16
  static getInstance(): CacheService;
14
17
  /**
15
- * @summary Stores the input data into the cache.
16
- * @returns Whether writing to cache was successful or not
17
- * @param data The input data to store
18
+ * Stores the input data in the cache.
19
+ *
20
+ * @param data The input data to store.
21
+ * @returns Whether writing to cache was successful or not.
22
+ * @remarks In order to cache data, the data to be cached must have a unique 'id' field.
18
23
  */
19
24
  write(data: any): void;
20
25
  /**
21
- * @returns The data with the given id/rest id from cache
22
- * @param id The id/rest id of the data to be fetched from cache
26
+ * @param id The id id of the data to be fetched from cache.
27
+ * @returns The data with the given id.
23
28
  */
24
29
  read(id: string): any;
25
30
  }
@@ -32,9 +32,12 @@ var node_cache_1 = __importDefault(require("node-cache"));
32
32
  // PARSERS
33
33
  var Parsers = __importStar(require("./helper/Parser"));
34
34
  /**
35
- * @summary Handles reading and writing of data from and to cache.
35
+ * Handles reading and writing of data from and to cache.
36
36
  *
37
- * **Note**: To be able to CacheService, the data to be cached must have a unique "id" field.
37
+ * This services uses a local node-cache instance to cache data, since the data to be cached has no real purpose outside of the server session.
38
+ * This serivce follows a singleton pattern, where at any point, only a single instance of this class exists.
39
+ * This is done so that all the data is cached in a single instance, which makes sharing of cached data between different endpoints possible.
40
+ * @internal
38
41
  */
39
42
  var CacheService = /** @class */ (function () {
40
43
  // MEMBER METHODS
@@ -54,9 +57,11 @@ var CacheService = /** @class */ (function () {
54
57
  return this.instance;
55
58
  };
56
59
  /**
57
- * @summary Stores the input data into the cache.
58
- * @returns Whether writing to cache was successful or not
59
- * @param data The input data to store
60
+ * Stores the input data in the cache.
61
+ *
62
+ * @param data The input data to store.
63
+ * @returns Whether writing to cache was successful or not.
64
+ * @remarks In order to cache data, the data to be cached must have a unique 'id' field.
60
65
  */
61
66
  CacheService.prototype.write = function (data) {
62
67
  // Converting the data to a list of data
@@ -74,8 +79,8 @@ var CacheService = /** @class */ (function () {
74
79
  }
75
80
  };
76
81
  /**
77
- * @returns The data with the given id/rest id from cache
78
- * @param id The id/rest id of the data to be fetched from cache
82
+ * @param id The id id of the data to be fetched from cache.
83
+ * @returns The data with the given id.
79
84
  */
80
85
  CacheService.prototype.read = function (id) {
81
86
  // Getting data from cache
@@ -1 +1 @@
1
- {"version":3,"file":"CacheService.js","sourceRoot":"","sources":["../../src/services/CacheService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,0DAAmC;AAEnC,UAAU;AACV,uDAA2C;AAE3C;;;;GAIG;AACH;IAKI,iBAAiB;IACjB;QACI,yBAAyB;QACzB,IAAI,CAAC,MAAM,GAAG,IAAI,uBAAS,EAAE,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,wBAAW,GAAlB;QACI,uCAAuC;QACvC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;SACtC;QAED,iCAAiC;QACjC,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACI,4BAAK,GAAZ,UAAa,IAAS;QAClB,wCAAwC;QACxC,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAEhC,kCAAkC;QAClC,KAAiB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE;YAAlB,IAAI,IAAI,aAAA;YACT,gDAAgD;YAChD,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;YAE9D,0CAA0C;YAC1C,IAAG,CAAC,MAAM,EAAE;gBACR,uBAAuB;gBACvB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC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AW,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;aAC1D;SACJ;IACL,CAAC;IAED;;;OAGG;IACI,2BAAI,GAAX,UAAY,EAAU;QAClB,0BAA0B;QAC1B,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAE9B,OAAO,GAAG,CAAC;IACf,CAAC;IACL,mBAAC;AAAD,CAAC,AA1DD,IA0DC;AA1DY,oCAAY"}
@@ -1,41 +1,61 @@
1
1
  import { CurlyResult } from 'node-libcurl';
2
2
  import { AuthService } from './AuthService';
3
3
  /**
4
- * @summary Stores all the different type of http requests
4
+ * The different types of http requests.
5
5
  */
6
6
  export declare enum HttpMethods {
7
7
  POST = "POST",
8
8
  GET = "GET"
9
9
  }
10
10
  /**
11
- * @service The base serivice from which all other data services derive their behaviour
11
+ * Handles all HTTP requests.
12
+ * @internal
13
+ *
14
+ * This serves as the base service from which all other data services derive their behaviour.
12
15
  */
13
16
  export declare class FetcherService {
17
+ /** The authentication service instance. */
14
18
  private auth;
19
+ /** The caching service instance. */
15
20
  private cache;
21
+ /** Whether instance has been authenticated or not. */
16
22
  protected isAuthenticated: boolean;
23
+ /**
24
+ * @param auth The AuthService instance to use for authentication.
25
+ */
17
26
  constructor(auth: AuthService);
18
27
  /**
19
- * @summary Throws the appropriate http error after evaluation of the status code of reponse
20
- * @param res The response object received from http communication
28
+ * The middleware for handling any HTTP error.
29
+ *
30
+ * @param res The response object received.
31
+ * @throws {@link HttpStatus}.
32
+ * @returns The received response, if no HTTP errors are found.
21
33
  */
22
34
  private handleHTTPError;
23
35
  /**
24
- * @returns The absolute raw json data from give url
25
- * @param url The url to fetch data from
26
- * @param authenticate Whether to authenticate requests or not
27
- * @param method The HTTP method to use
28
- * @param data The data to be sent along with the request (works with only POST method)
36
+ * Creates an HTTP request according to the given parameters.
37
+ *
38
+ * This method internally uses node-libcurl library to make curl requests to the URL, instead of node-fetch.
39
+ * This has been done since that way it better mimics the HTTP requests made from browser.
40
+ *
41
+ * @param url The url to fetch data from.
42
+ * @param authenticate Whether to authenticate requests or not.
43
+ * @param method The HTTP method (from {@link HttpMethods}) to use.
44
+ * @param data The data to be sent along with the request (for POST request).
45
+ * @returns The {@link CurlyResult} received.
29
46
  */
30
47
  protected request<DataType>(url: string, authenticate?: boolean, method?: HttpMethods, data?: any): Promise<CurlyResult<DataType>>;
31
48
  /**
32
- * @summary Caches the extracted data
49
+ * Caches the extracted data into the {@link CacheService} instance.
50
+ *
33
51
  * @param data The extracted data to be cached
34
52
  */
35
53
  protected cacheData(data: any): void;
36
54
  /**
37
- * @returns The data with the given id (if it exists in cache)
38
- * @param id The id of the data to be read from cache
55
+ * Fetches the data with the given id from the cache.
56
+ *
57
+ * @param id The id of the data to be read from cache.
58
+ * @returns The data with the given id. If does not exists, returns undefined.
39
59
  */
40
60
  protected readData(id: string): any;
41
61
  }
@@ -81,7 +81,7 @@ var Headers = __importStar(require("./helper/Headers"));
81
81
  var UserDeserializers = __importStar(require("./helper/deserializers/Users"));
82
82
  var TweetDeserializers = __importStar(require("./helper/deserializers/Tweets"));
83
83
  /**
84
- * @summary Stores all the different type of http requests
84
+ * The different types of http requests.
85
85
  */
86
86
  var HttpMethods;
87
87
  (function (HttpMethods) {
@@ -90,31 +90,48 @@ var HttpMethods;
90
90
  })(HttpMethods = exports.HttpMethods || (exports.HttpMethods = {}));
91
91
  ;
92
92
  /**
93
- * @service The base serivice from which all other data services derive their behaviour
93
+ * Handles all HTTP requests.
94
+ * @internal
95
+ *
96
+ * This serves as the base service from which all other data services derive their behaviour.
94
97
  */
95
98
  var FetcherService = /** @class */ (function () {
96
99
  // MEMBER METHODS
100
+ /**
101
+ * @param auth The AuthService instance to use for authentication.
102
+ */
97
103
  function FetcherService(auth) {
98
104
  this.auth = auth;
99
105
  this.cache = CacheService_1.CacheService.getInstance();
100
106
  this.isAuthenticated = this.auth.isAuthenticated;
101
107
  }
102
108
  /**
103
- * @summary Throws the appropriate http error after evaluation of the status code of reponse
104
- * @param res The response object received from http communication
109
+ * The middleware for handling any HTTP error.
110
+ *
111
+ * @param res The response object received.
112
+ * @throws {@link HttpStatus}.
113
+ * @returns The received response, if no HTTP errors are found.
105
114
  */
106
115
  FetcherService.prototype.handleHTTPError = function (res) {
116
+ /**
117
+ * If the status code is not 200 => the HTTP request was not successful. hence throwing error
118
+ */
107
119
  if (res.statusCode != 200 && res.statusCode in HTTP_1.HttpStatus) {
108
120
  throw new Error(HTTP_1.HttpStatus[res.statusCode]);
109
121
  }
110
122
  return res;
111
123
  };
112
124
  /**
113
- * @returns The absolute raw json data from give url
114
- * @param url The url to fetch data from
115
- * @param authenticate Whether to authenticate requests or not
116
- * @param method The HTTP method to use
117
- * @param data The data to be sent along with the request (works with only POST method)
125
+ * Creates an HTTP request according to the given parameters.
126
+ *
127
+ * This method internally uses node-libcurl library to make curl requests to the URL, instead of node-fetch.
128
+ * This has been done since that way it better mimics the HTTP requests made from browser.
129
+ *
130
+ * @param url The url to fetch data from.
131
+ * @param authenticate Whether to authenticate requests or not.
132
+ * @param method The HTTP method (from {@link HttpMethods}) to use.
133
+ * @param data The data to be sent along with the request (for POST request).
134
+ * @returns The {@link CurlyResult} received.
118
135
  */
119
136
  FetcherService.prototype.request = function (url, authenticate, method, data) {
120
137
  if (authenticate === void 0) { authenticate = true; }
@@ -140,7 +157,15 @@ var FetcherService = /** @class */ (function () {
140
157
  _a = _e.apply(_d, [_g.sent()]);
141
158
  _g.label = 4;
142
159
  case 4:
143
- config = (_f.httpHeader = _a,
160
+ config = (
161
+ /**
162
+ * If authorization is required, using the authenticated header, using the authentication credentiials.
163
+ * Else, using the guest header, using the guest credentials.
164
+ */
165
+ _f.httpHeader = _a,
166
+ /**
167
+ * Disabling SSL peer verification because verification causes Error 404 (only while fetching tweets), likely because peer verification fails.
168
+ */
144
169
  _f.sslVerifyPeer = false,
145
170
  _f);
146
171
  if (!(method == HttpMethods.POST)) return [3 /*break*/, 6];
@@ -153,11 +178,15 @@ var FetcherService = /** @class */ (function () {
153
178
  });
154
179
  };
155
180
  /**
156
- * @summary Caches the extracted data
181
+ * Caches the extracted data into the {@link CacheService} instance.
182
+ *
157
183
  * @param data The extracted data to be cached
158
184
  */
159
185
  FetcherService.prototype.cacheData = function (data) {
160
- // Parsing the extracted data
186
+ /**
187
+ * The extracted data is in raw form.
188
+ * This raw data is deserialized into the respective known types.
189
+ */
161
190
  var users = data.users.map(function (user) { return UserDeserializers.toUser(user); });
162
191
  var tweets = data.tweets.map(function (tweet) { return TweetDeserializers.toTweet(tweet); });
163
192
  // Caching the data
@@ -165,8 +194,10 @@ var FetcherService = /** @class */ (function () {
165
194
  this.cache.write(tweets);
166
195
  };
167
196
  /**
168
- * @returns The data with the given id (if it exists in cache)
169
- * @param id The id of the data to be read from cache
197
+ * Fetches the data with the given id from the cache.
198
+ *
199
+ * @param id The id of the data to be read from cache.
200
+ * @returns The data with the given id. If does not exists, returns undefined.
170
201
  */
171
202
  FetcherService.prototype.readData = function (id) {
172
203
  // Reading data from cache
@@ -1 +1 @@
1
- {"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../src/services/FetcherService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAAkD;AAIlD,+CAA8C;AAE9C,QAAQ;AACR,sCAA2C;AAI3C,UAAU;AACV,wDAA2C;AAC3C,8EAAkE;AAClE,gFAAoE;AAGpE;;GAEG;AACH,IAAY,WAGX;AAHD,WAAY,WAAW;IACnB,4BAAa,CAAA;IACb,0BAAW,CAAA;AACf,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB;AAAA,CAAC;AAEF;;GAEG;AACH;IAMI,iBAAiB;IACjB,wBAAY,IAAiB;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,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