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
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.FetcherService = void 0;
43
+ // PACKAGES
44
+ var rettiwt_core_1 = require("rettiwt-core");
45
+ var axios_1 = __importDefault(require("axios"));
46
+ // ENUMS
47
+ var HTTP_1 = require("../enums/HTTP");
48
+ var ApiErrors_1 = require("../enums/ApiErrors");
49
+ // MODELS
50
+ var CursoredData_1 = require("../models/CursoredData");
51
+ // HELPERS
52
+ var JsonUtils_1 = require("../helper/JsonUtils");
53
+ /**
54
+ * The base service that handles all HTTP requests.
55
+ *
56
+ * @internal
57
+ */
58
+ var FetcherService = /** @class */ (function () {
59
+ /**
60
+ * @param cred - The credentials to use for authenticating against Twitter API.
61
+ */
62
+ function FetcherService(cred) {
63
+ this.cred = cred;
64
+ }
65
+ /**
66
+ * The middleware for handling any http error.
67
+ *
68
+ * @param res - The response object received.
69
+ * @returns The received response, if no HTTP errors are found.
70
+ */
71
+ FetcherService.prototype.handleHttpError = function (res) {
72
+ /**
73
+ * If the status code is not 200 =\> the HTTP request was not successful. hence throwing error
74
+ */
75
+ if (res.status != 200 && res.status in HTTP_1.EHttpStatus) {
76
+ throw new Error(HTTP_1.EHttpStatus[res.status]);
77
+ }
78
+ return res;
79
+ };
80
+ /**
81
+ * The middleware for handling any Twitter API-level errors.
82
+ *
83
+ * @param res - The response object received.
84
+ * @returns The received response, if no API errors are found.
85
+ */
86
+ FetcherService.prototype.handleApiError = function (res) {
87
+ // If error exists
88
+ if (res.data.errors && res.data.errors.length) {
89
+ // Getting the error code
90
+ var code = res.data.errors[0].code;
91
+ // Getting the error message
92
+ var message = ApiErrors_1.EApiErrors[(0, JsonUtils_1.findKeyByValue)(rettiwt_core_1.EErrorCodes, "".concat(code))];
93
+ // Throw the error
94
+ throw new Error(message);
95
+ }
96
+ return res;
97
+ };
98
+ /**
99
+ * Makes an HTTP request according to the given parameters.
100
+ *
101
+ * @param config - The request configuration.
102
+ * @returns The response received.
103
+ */
104
+ FetcherService.prototype.request = function (config) {
105
+ return __awaiter(this, void 0, void 0, function () {
106
+ var axiosRequest;
107
+ var _this = this;
108
+ return __generator(this, function (_a) {
109
+ switch (_a.label) {
110
+ case 0:
111
+ axiosRequest = {
112
+ url: config.url,
113
+ method: config.type,
114
+ data: config.payload,
115
+ headers: JSON.parse(JSON.stringify(this.cred.toHeader())),
116
+ };
117
+ return [4 /*yield*/, (0, axios_1.default)(axiosRequest)
118
+ .then(function (res) { return _this.handleHttpError(res); })
119
+ .then(function (res) { return _this.handleApiError(res); })];
120
+ case 1:
121
+ /**
122
+ * After making the request, the response is then passed to HTTP error handling middlware for HTTP error handling.
123
+ */
124
+ return [2 /*return*/, _a.sent()];
125
+ }
126
+ });
127
+ });
128
+ };
129
+ /**
130
+ * Extracts the required data based on the type of resource passed as argument.
131
+ *
132
+ * @param data - The data from which extraction is to be done.
133
+ * @param type - The type of data to extract.
134
+ * @typeParam BaseType - The base type of the raw data present in the input.
135
+ * @typeParam DeserializedType - The type of data produced after deserialization of BaseType.
136
+ * @returns The extracted data.
137
+ */
138
+ FetcherService.prototype.extractData = function (data, type) {
139
+ var _a;
140
+ /**
141
+ * The required extracted data.
142
+ */
143
+ var required = [];
144
+ // For 'Tweet' resources
145
+ if (type == rettiwt_core_1.EResourceType.TWEET_DETAILS ||
146
+ type == rettiwt_core_1.EResourceType.TWEET_SEARCH ||
147
+ type == rettiwt_core_1.EResourceType.USER_LIKES) {
148
+ required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'Tweet');
149
+ }
150
+ // For 'User' resources
151
+ else {
152
+ required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'User');
153
+ }
154
+ return new CursoredData_1.CursoredData(required, (_a = (0, JsonUtils_1.findByFilter)(data, 'cursorType', 'Bottom')[0]) === null || _a === void 0 ? void 0 : _a.value);
155
+ };
156
+ /**
157
+ * Fetches the requested resource from Twitter and returns it after processing.
158
+ *
159
+ * @param resourceType - The type of resource to fetch.
160
+ * @param args - Resource specific arguments.
161
+ * @typeParam OutType - The type of deserialized data returned.
162
+ * @returns The processed data requested from Twitter.
163
+ */
164
+ FetcherService.prototype.fetch = function (resourceType, args) {
165
+ return __awaiter(this, void 0, void 0, function () {
166
+ var request, res, data;
167
+ return __generator(this, function (_a) {
168
+ switch (_a.label) {
169
+ case 0:
170
+ request = new rettiwt_core_1.Request(resourceType, args);
171
+ return [4 /*yield*/, this.request(request).then(function (res) { return res.data; })];
172
+ case 1:
173
+ res = _a.sent();
174
+ data = this.extractData(res, resourceType);
175
+ return [2 /*return*/, data];
176
+ }
177
+ });
178
+ });
179
+ };
180
+ /**
181
+ * Posts the requested resource to Twitter and returns the response.
182
+ *
183
+ * @param resourceType - The type of resource to post.
184
+ * @param args - Resource specific arguments.
185
+ * @returns Whether posting was successful or not.
186
+ */
187
+ FetcherService.prototype.post = function (resourceType, args) {
188
+ return __awaiter(this, void 0, void 0, function () {
189
+ var request;
190
+ return __generator(this, function (_a) {
191
+ switch (_a.label) {
192
+ case 0:
193
+ request = new rettiwt_core_1.Request(resourceType, args);
194
+ // Posting the data
195
+ return [4 /*yield*/, this.request(request)];
196
+ case 1:
197
+ // Posting the data
198
+ _a.sent();
199
+ return [2 /*return*/, true];
200
+ }
201
+ });
202
+ });
203
+ };
204
+ return FetcherService;
205
+ }());
206
+ exports.FetcherService = FetcherService;
207
+ //# sourceMappingURL=FetcherService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../src/services/FetcherService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CASsB;AACtB,gDAAsF;AAGtF,QAAQ;AACR,sCAA4C;AAC5C,gDAAgD;AAEhD,SAAS;AACT,uDAAsD;AAItD,UAAU;AACV,iDAAmE;AAEnE;;;;GAIG;AACH;IAIC;;OAEG;IACH,wBAAY,IAAoB;QAC/B,IAAI,CAAC,IAAI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ACa,6BAAI,GAApB,UAAqB,YAA2B,EAAE,IAAU;;;;;;wBAErD,OAAO,GAAY,IAAI,sBAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;wBAEzD,mBAAmB;wBACnB,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAA;;wBAD3B,mBAAmB;wBACnB,SAA2B,CAAC;wBAE5B,sBAAO,IAAI,EAAC;;;;KACZ;IACF,qBAAC;AAAD,CAAC,AAvJD,IAuJC;AAvJY,wCAAc"}
@@ -0,0 +1,88 @@
1
+ import { TweetFilter } from 'rettiwt-core';
2
+ import { AuthCredential } from 'rettiwt-auth';
3
+ import { FetcherService } from './FetcherService';
4
+ import { Tweet } from '../models/Tweet';
5
+ import { User } from '../models/User';
6
+ import { CursoredData } from '../models/CursoredData';
7
+ /**
8
+ * Handles fetching of data related to tweets.
9
+ *
10
+ * @public
11
+ */
12
+ export declare class TweetService extends FetcherService {
13
+ /**
14
+ * @param cred - The credentials to use for authenticating against Twitter API.
15
+ *
16
+ * @internal
17
+ */
18
+ constructor(cred: AuthCredential);
19
+ /**
20
+ * Search for tweets using a query.
21
+ *
22
+ * @param query - The query be used for searching the tweets.
23
+ * @param count - The number of tweets to fetch, must be \<= 20.
24
+ * @param cursor - The cursor to the batch of tweets to fetch.
25
+ * @returns The list of tweets that match the given filter.
26
+ *
27
+ * @public
28
+ */
29
+ search(query: TweetFilter, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
30
+ /**
31
+ * Get the details of a tweet.
32
+ *
33
+ * @param id - The id of the target tweet.
34
+ * @returns The details of a single tweet with the given tweet id.
35
+ *
36
+ * @public
37
+ */
38
+ details(id: string): Promise<Tweet>;
39
+ /**
40
+ * Get the list of users who liked a tweet.
41
+ *
42
+ * @param tweetId - The rest id of the target tweet.
43
+ * @param count - The number of favoriters to fetch, must be \<= 100.
44
+ * @param cursor - The cursor to the batch of favoriters to fetch.
45
+ * @returns The list of users who liked the given tweet.
46
+ *
47
+ * @public
48
+ */
49
+ favoriters(tweetId: string, count?: number, cursor?: string): Promise<CursoredData<User>>;
50
+ /**
51
+ * Get the list of users who retweeted a tweet.
52
+ *
53
+ * @param tweetId - The rest id of the target tweet.
54
+ * @param count - The number of retweeters to fetch, must be \<= 100.
55
+ * @param cursor - The cursor to the batch of retweeters to fetch.
56
+ * @returns The list of users who retweeted the given tweet.
57
+ *
58
+ * @public
59
+ */
60
+ retweeters(tweetId: string, count?: number, cursor?: string): Promise<CursoredData<User>>;
61
+ /**
62
+ * Post a tweet.
63
+ *
64
+ * @param tweetText - The text to be posted, length must be \<= 280 characters.
65
+ * @returns Whether posting was successful or not.
66
+ *
67
+ * @public
68
+ */
69
+ tweet(tweetText: string): Promise<boolean>;
70
+ /**
71
+ * Favorite the tweet with the given id.
72
+ *
73
+ * @param tweetId - The id of the tweet to be favorited.
74
+ * @returns Whether favoriting was successful or not.
75
+ *
76
+ * @public
77
+ */
78
+ favorite(tweetId: string): Promise<boolean>;
79
+ /**
80
+ * Retweet the tweet with the given id.
81
+ *
82
+ * @param tweetId - The id of the tweet with the given id.
83
+ * @returns Whether retweeting was successful or not.
84
+ *
85
+ * @public
86
+ */
87
+ retweet(tweetId: string): Promise<boolean>;
88
+ }
@@ -0,0 +1,244 @@
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 (g && (g = 0, op[0] && (_ = 0)), _) 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
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.TweetService = void 0;
55
+ // PACKAGES
56
+ var rettiwt_core_1 = require("rettiwt-core");
57
+ // SERVICES
58
+ var FetcherService_1 = require("./FetcherService");
59
+ /**
60
+ * Handles fetching of data related to tweets.
61
+ *
62
+ * @public
63
+ */
64
+ var TweetService = /** @class */ (function (_super) {
65
+ __extends(TweetService, _super);
66
+ /**
67
+ * @param cred - The credentials to use for authenticating against Twitter API.
68
+ *
69
+ * @internal
70
+ */
71
+ function TweetService(cred) {
72
+ return _super.call(this, cred) || this;
73
+ }
74
+ /**
75
+ * Search for tweets using a query.
76
+ *
77
+ * @param query - The query be used for searching the tweets.
78
+ * @param count - The number of tweets to fetch, must be \<= 20.
79
+ * @param cursor - The cursor to the batch of tweets to fetch.
80
+ * @returns The list of tweets that match the given filter.
81
+ *
82
+ * @public
83
+ */
84
+ TweetService.prototype.search = function (query, count, cursor) {
85
+ return __awaiter(this, void 0, void 0, function () {
86
+ var data;
87
+ return __generator(this, function (_a) {
88
+ switch (_a.label) {
89
+ case 0: return [4 /*yield*/, this.fetch(rettiwt_core_1.EResourceType.TWEET_SEARCH, {
90
+ filter: query,
91
+ count: count,
92
+ cursor: cursor,
93
+ })];
94
+ case 1:
95
+ data = _a.sent();
96
+ // Sorting the tweets by date, from recent to oldest
97
+ data.list.sort(function (a, b) { return new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf(); });
98
+ return [2 /*return*/, data];
99
+ }
100
+ });
101
+ });
102
+ };
103
+ /**
104
+ * Get the details of a tweet.
105
+ *
106
+ * @param id - The id of the target tweet.
107
+ * @returns The details of a single tweet with the given tweet id.
108
+ *
109
+ * @public
110
+ */
111
+ TweetService.prototype.details = function (id) {
112
+ return __awaiter(this, void 0, void 0, function () {
113
+ var data;
114
+ return __generator(this, function (_a) {
115
+ switch (_a.label) {
116
+ case 0: return [4 /*yield*/, this.fetch(rettiwt_core_1.EResourceType.TWEET_DETAILS, { id: id })];
117
+ case 1:
118
+ data = _a.sent();
119
+ return [2 /*return*/, data.list[0]];
120
+ }
121
+ });
122
+ });
123
+ };
124
+ /**
125
+ * Get the list of users who liked a tweet.
126
+ *
127
+ * @param tweetId - The rest id of the target tweet.
128
+ * @param count - The number of favoriters to fetch, must be \<= 100.
129
+ * @param cursor - The cursor to the batch of favoriters to fetch.
130
+ * @returns The list of users who liked the given tweet.
131
+ *
132
+ * @public
133
+ */
134
+ TweetService.prototype.favoriters = function (tweetId, count, cursor) {
135
+ return __awaiter(this, void 0, void 0, function () {
136
+ var data;
137
+ return __generator(this, function (_a) {
138
+ switch (_a.label) {
139
+ case 0: return [4 /*yield*/, this.fetch(rettiwt_core_1.EResourceType.TWEET_FAVORITERS, {
140
+ id: tweetId,
141
+ count: count,
142
+ cursor: cursor,
143
+ })];
144
+ case 1:
145
+ data = _a.sent();
146
+ return [2 /*return*/, data];
147
+ }
148
+ });
149
+ });
150
+ };
151
+ /**
152
+ * Get the list of users who retweeted a tweet.
153
+ *
154
+ * @param tweetId - The rest id of the target tweet.
155
+ * @param count - The number of retweeters to fetch, must be \<= 100.
156
+ * @param cursor - The cursor to the batch of retweeters to fetch.
157
+ * @returns The list of users who retweeted the given tweet.
158
+ *
159
+ * @public
160
+ */
161
+ TweetService.prototype.retweeters = function (tweetId, count, cursor) {
162
+ return __awaiter(this, void 0, void 0, function () {
163
+ var data;
164
+ return __generator(this, function (_a) {
165
+ switch (_a.label) {
166
+ case 0: return [4 /*yield*/, this.fetch(rettiwt_core_1.EResourceType.TWEET_RETWEETERS, {
167
+ id: tweetId,
168
+ count: count,
169
+ cursor: cursor,
170
+ })];
171
+ case 1:
172
+ data = _a.sent();
173
+ return [2 /*return*/, data];
174
+ }
175
+ });
176
+ });
177
+ };
178
+ /**
179
+ * Post a tweet.
180
+ *
181
+ * @param tweetText - The text to be posted, length must be \<= 280 characters.
182
+ * @returns Whether posting was successful or not.
183
+ *
184
+ * @public
185
+ */
186
+ TweetService.prototype.tweet = function (tweetText) {
187
+ return __awaiter(this, void 0, void 0, function () {
188
+ var data;
189
+ return __generator(this, function (_a) {
190
+ switch (_a.label) {
191
+ case 0: return [4 /*yield*/, this.post(rettiwt_core_1.EResourceType.CREATE_TWEET, { tweetText: tweetText })];
192
+ case 1:
193
+ data = _a.sent();
194
+ return [2 /*return*/, data];
195
+ }
196
+ });
197
+ });
198
+ };
199
+ /**
200
+ * Favorite the tweet with the given id.
201
+ *
202
+ * @param tweetId - The id of the tweet to be favorited.
203
+ * @returns Whether favoriting was successful or not.
204
+ *
205
+ * @public
206
+ */
207
+ TweetService.prototype.favorite = function (tweetId) {
208
+ return __awaiter(this, void 0, void 0, function () {
209
+ var data;
210
+ return __generator(this, function (_a) {
211
+ switch (_a.label) {
212
+ case 0: return [4 /*yield*/, this.post(rettiwt_core_1.EResourceType.FAVORITE_TWEET, { id: tweetId })];
213
+ case 1:
214
+ data = _a.sent();
215
+ return [2 /*return*/, data];
216
+ }
217
+ });
218
+ });
219
+ };
220
+ /**
221
+ * Retweet the tweet with the given id.
222
+ *
223
+ * @param tweetId - The id of the tweet with the given id.
224
+ * @returns Whether retweeting was successful or not.
225
+ *
226
+ * @public
227
+ */
228
+ TweetService.prototype.retweet = function (tweetId) {
229
+ return __awaiter(this, void 0, void 0, function () {
230
+ var data;
231
+ return __generator(this, function (_a) {
232
+ switch (_a.label) {
233
+ case 0: return [4 /*yield*/, this.post(rettiwt_core_1.EResourceType.CREATE_RETWEET, { id: tweetId })];
234
+ case 1:
235
+ data = _a.sent();
236
+ return [2 /*return*/, data];
237
+ }
238
+ });
239
+ });
240
+ };
241
+ return TweetService;
242
+ }(FetcherService_1.FetcherService));
243
+ exports.TweetService = TweetService;
244
+ //# sourceMappingURL=TweetService.js.map
@@ -0,0 +1 @@
1
+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60 @@
1
+ import { AuthCredential } from 'rettiwt-auth';
2
+ import { FetcherService } from './FetcherService';
3
+ import { User } from '../models/User';
4
+ import { Tweet } from '../models/Tweet';
5
+ import { CursoredData } from '../models/CursoredData';
6
+ /**
7
+ * Handles fetching of data related to user account
8
+ *
9
+ * @public
10
+ */
11
+ export declare class UserService extends FetcherService {
12
+ /**
13
+ * @param cred - The credentials to use for authenticating against Twitter API.
14
+ *
15
+ * @internal
16
+ */
17
+ constructor(cred: AuthCredential);
18
+ /**
19
+ * Get the details of a user.
20
+ *
21
+ * @param id - The username/id of the target user.
22
+ * @returns The details of the given user.
23
+ *
24
+ * @public
25
+ */
26
+ details(id: string): Promise<User>;
27
+ /**
28
+ * Get the list of users who are followed by the given user.
29
+ *
30
+ * @param userId - The rest id of the target user.
31
+ * @param count - The number of following to fetch, must be \<= 100.
32
+ * @param cursor - The cursor to the batch of following to fetch.
33
+ * @returns The list of users followed by the target user.
34
+ *
35
+ * @public
36
+ */
37
+ following(userId: string, count?: number, cursor?: string): Promise<CursoredData<User>>;
38
+ /**
39
+ * Get the list followers of a given user.
40
+ *
41
+ * @param userId - The rest id of the target user.
42
+ * @param count - The number of followers to fetch, must be \<= 100.
43
+ * @param cursor - The cursor to the batch of followers to fetch.
44
+ * @returns The list of users following the target user.
45
+ *
46
+ * @public
47
+ */
48
+ followers(userId: string, count?: number, cursor?: string): Promise<CursoredData<User>>;
49
+ /**
50
+ * Get the list of tweets liked by the given user.
51
+ *
52
+ * @param userId - The rest id of the target user.
53
+ * @param count - The number of likes to fetch, must be \<= 100.
54
+ * @param cursor - The cursor to the batch of likes to fetch.
55
+ * @returns The list of tweets liked by the target user.
56
+ *
57
+ * @public
58
+ */
59
+ likes(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
60
+ }