rettiwt-api 2.2.2 → 2.3.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.
- package/.eslintrc.js +1 -0
- package/README.md +41 -22
- package/dist/Rettiwt.d.ts +5 -5
- package/dist/Rettiwt.js +6 -7
- package/dist/Rettiwt.js.map +1 -1
- package/dist/enums/Logging.d.ts +12 -0
- package/dist/enums/Logging.js +17 -0
- package/dist/enums/Logging.js.map +1 -0
- package/dist/index.d.ts +15 -11
- package/dist/index.js +15 -11
- package/dist/index.js.map +1 -1
- package/dist/models/internal/RettiwtConfig.d.ts +20 -0
- package/dist/models/internal/RettiwtConfig.js +23 -0
- package/dist/models/internal/RettiwtConfig.js.map +1 -0
- package/dist/models/{CursoredData.d.ts → public/CursoredData.d.ts} +2 -3
- package/dist/models/{CursoredData.js → public/CursoredData.js} +1 -16
- package/dist/models/public/CursoredData.js.map +1 -0
- package/dist/models/{List.d.ts → public/List.d.ts} +1 -1
- package/dist/models/public/List.js.map +1 -0
- package/dist/models/{Tweet.d.ts → public/Tweet.d.ts} +1 -1
- package/dist/models/{Tweet.js → public/Tweet.js} +1 -1
- package/dist/models/public/Tweet.js.map +1 -0
- package/dist/models/{User.d.ts → public/User.d.ts} +1 -1
- package/dist/models/public/User.js.map +1 -0
- package/dist/services/{FetcherService.d.ts → internal/FetcherService.d.ts} +28 -9
- package/dist/services/{FetcherService.js → internal/FetcherService.js} +102 -22
- package/dist/services/internal/FetcherService.js.map +1 -0
- package/dist/services/internal/LogService.d.ts +22 -0
- package/dist/services/internal/LogService.js +35 -0
- package/dist/services/internal/LogService.js.map +1 -0
- package/dist/services/{TweetService.d.ts → public/TweetService.d.ts} +7 -7
- package/dist/services/{TweetService.js → public/TweetService.js} +4 -5
- package/dist/services/public/TweetService.js.map +1 -0
- package/dist/services/{UserService.d.ts → public/UserService.d.ts} +23 -8
- package/dist/services/{UserService.js → public/UserService.js} +38 -6
- package/dist/services/public/UserService.js.map +1 -0
- package/dist/types/internal/RettiwtConfig.d.ts +13 -0
- package/dist/types/internal/RettiwtConfig.js +3 -0
- package/dist/types/internal/RettiwtConfig.js.map +1 -0
- package/dist/types/public/CursoredData.js.map +1 -0
- package/dist/types/{List.js.map → public/List.js.map} +1 -1
- package/dist/types/{Tweet.js.map → public/Tweet.js.map} +1 -1
- package/dist/types/{User.js.map → public/User.js.map} +1 -1
- package/package.json +3 -3
- package/src/Rettiwt.ts +11 -9
- package/src/enums/Logging.ts +12 -0
- package/src/index.ts +15 -11
- package/src/models/internal/RettiwtConfig.ts +29 -0
- package/src/models/{CursoredData.ts → public/CursoredData.ts} +7 -22
- package/src/models/{List.ts → public/List.ts} +9 -9
- package/src/models/{Tweet.ts → public/Tweet.ts} +25 -25
- package/src/models/{User.ts → public/User.ts} +16 -16
- package/src/services/{FetcherService.ts → internal/FetcherService.ts} +119 -21
- package/src/services/internal/LogService.ts +39 -0
- package/src/services/{TweetService.ts → public/TweetService.ts} +16 -16
- package/src/services/{UserService.ts → public/UserService.ts} +42 -14
- package/src/types/internal/RettiwtConfig.ts +15 -0
- package/dist/models/CursoredData.js.map +0 -1
- package/dist/models/List.js.map +0 -1
- package/dist/models/Tweet.js.map +0 -1
- package/dist/models/User.js.map +0 -1
- package/dist/services/FetcherService.js.map +0 -1
- package/dist/services/TweetService.js.map +0 -1
- package/dist/services/UserService.js.map +0 -1
- package/dist/types/CursoredData.js.map +0 -1
- /package/dist/models/{List.js → public/List.js} +0 -0
- /package/dist/models/{User.js → public/User.js} +0 -0
- /package/dist/types/{CursoredData.d.ts → public/CursoredData.d.ts} +0 -0
- /package/dist/types/{CursoredData.js → public/CursoredData.js} +0 -0
- /package/dist/types/{List.d.ts → public/List.d.ts} +0 -0
- /package/dist/types/{List.js → public/List.js} +0 -0
- /package/dist/types/{Tweet.d.ts → public/Tweet.d.ts} +0 -0
- /package/dist/types/{Tweet.js → public/Tweet.js} +0 -0
- /package/dist/types/{User.d.ts → public/User.d.ts} +0 -0
- /package/dist/types/{User.js → public/User.js} +0 -0
- /package/src/types/{CursoredData.ts → public/CursoredData.ts} +0 -0
- /package/src/types/{List.ts → public/List.ts} +0 -0
- /package/src/types/{Tweet.ts → public/Tweet.ts} +0 -0
- /package/src/types/{User.ts → public/User.ts} +0 -0
|
@@ -46,13 +46,17 @@ var axios_1 = __importDefault(require("axios"));
|
|
|
46
46
|
var https_1 = __importDefault(require("https"));
|
|
47
47
|
var rettiwt_auth_1 = require("rettiwt-auth");
|
|
48
48
|
var https_proxy_agent_1 = require("https-proxy-agent");
|
|
49
|
+
// SERVICES
|
|
50
|
+
var LogService_1 = require("./LogService");
|
|
49
51
|
// ENUMS
|
|
50
|
-
var HTTP_1 = require("
|
|
51
|
-
var ApiErrors_1 = require("
|
|
52
|
-
|
|
53
|
-
var CursoredData_1 = require("
|
|
52
|
+
var HTTP_1 = require("../../enums/HTTP");
|
|
53
|
+
var ApiErrors_1 = require("../../enums/ApiErrors");
|
|
54
|
+
var Logging_1 = require("../../enums/Logging");
|
|
55
|
+
var CursoredData_1 = require("../../models/public/CursoredData");
|
|
56
|
+
var Tweet_1 = require("../../models/public/Tweet");
|
|
57
|
+
var User_1 = require("../../models/public/User");
|
|
54
58
|
// HELPERS
|
|
55
|
-
var JsonUtils_1 = require("
|
|
59
|
+
var JsonUtils_1 = require("../../helper/JsonUtils");
|
|
56
60
|
/**
|
|
57
61
|
* The base service that handles all HTTP requests.
|
|
58
62
|
*
|
|
@@ -60,12 +64,13 @@ var JsonUtils_1 = require("../helper/JsonUtils");
|
|
|
60
64
|
*/
|
|
61
65
|
var FetcherService = /** @class */ (function () {
|
|
62
66
|
/**
|
|
63
|
-
* @param
|
|
64
|
-
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
67
|
+
* @param config - The config object for configuring the Rettiwt instance.
|
|
65
68
|
*/
|
|
66
|
-
function FetcherService(
|
|
67
|
-
this.cred = this.getAuthCredential(apiKey);
|
|
68
|
-
this.
|
|
69
|
+
function FetcherService(config) {
|
|
70
|
+
this.cred = (config === null || config === void 0 ? void 0 : config.apiKey) ? this.getAuthCredential(config.apiKey) : undefined;
|
|
71
|
+
this.isAuthenticated = (config === null || config === void 0 ? void 0 : config.apiKey) ? true : false;
|
|
72
|
+
this.httpsAgent = this.getHttpsAgent(config === null || config === void 0 ? void 0 : config.proxyUrl);
|
|
73
|
+
this.logger = new LogService_1.LogService(config === null || config === void 0 ? void 0 : config.logging);
|
|
69
74
|
}
|
|
70
75
|
/**
|
|
71
76
|
* Returns an AuthCredential generated using the given API key.
|
|
@@ -74,8 +79,27 @@ var FetcherService = /** @class */ (function () {
|
|
|
74
79
|
* @returns The generated AuthCredential.
|
|
75
80
|
*/
|
|
76
81
|
FetcherService.prototype.getAuthCredential = function (apiKey) {
|
|
82
|
+
// Converting apiKey from base64 to string
|
|
83
|
+
apiKey = Buffer.from(apiKey, 'base64').toString('ascii');
|
|
77
84
|
return new rettiwt_auth_1.AuthCredential(apiKey.split(';'));
|
|
78
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* Checks the authorization status based on the requested resource.
|
|
88
|
+
*
|
|
89
|
+
* @param resourceType - The type of resource to fetch.
|
|
90
|
+
* @throws An error if not authorized to access the requested resource.
|
|
91
|
+
*/
|
|
92
|
+
FetcherService.prototype.checkAuthorization = function (resourceType) {
|
|
93
|
+
// Logging
|
|
94
|
+
this.logger.log(Logging_1.ELogActions.AUTHORIZATION, { authenticated: this.isAuthenticated });
|
|
95
|
+
// Checking authorization status
|
|
96
|
+
if (resourceType != rettiwt_core_1.EResourceType.TWEET_DETAILS &&
|
|
97
|
+
resourceType != rettiwt_core_1.EResourceType.USER_DETAILS &&
|
|
98
|
+
resourceType != rettiwt_core_1.EResourceType.USER_TWEETS &&
|
|
99
|
+
this.isAuthenticated == false) {
|
|
100
|
+
throw new Error(ApiErrors_1.EApiErrors.RESOURCE_NOT_ALLOWED);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
79
103
|
/**
|
|
80
104
|
* Gets the HttpsAgent based on whether a proxy is used or not.
|
|
81
105
|
*
|
|
@@ -93,6 +117,7 @@ var FetcherService = /** @class */ (function () {
|
|
|
93
117
|
*
|
|
94
118
|
* @param res - The response object received.
|
|
95
119
|
* @returns The received response, if no HTTP errors are found.
|
|
120
|
+
* @throws An error if any HTTP-related error has occured.
|
|
96
121
|
*/
|
|
97
122
|
FetcherService.prototype.handleHttpError = function (res) {
|
|
98
123
|
/**
|
|
@@ -108,6 +133,7 @@ var FetcherService = /** @class */ (function () {
|
|
|
108
133
|
*
|
|
109
134
|
* @param res - The response object received.
|
|
110
135
|
* @returns The received response, if no API errors are found.
|
|
136
|
+
* @throws An error if any API-related error has occured.
|
|
111
137
|
*/
|
|
112
138
|
FetcherService.prototype.handleApiError = function (res) {
|
|
113
139
|
// If error exists
|
|
@@ -128,12 +154,27 @@ var FetcherService = /** @class */ (function () {
|
|
|
128
154
|
* @returns The response received.
|
|
129
155
|
*/
|
|
130
156
|
FetcherService.prototype.request = function (config) {
|
|
157
|
+
var _a;
|
|
131
158
|
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
-
var axiosRequest;
|
|
159
|
+
var _b, _c, axiosRequest;
|
|
133
160
|
var _this = this;
|
|
134
|
-
return __generator(this, function (
|
|
135
|
-
switch (
|
|
161
|
+
return __generator(this, function (_d) {
|
|
162
|
+
switch (_d.label) {
|
|
136
163
|
case 0:
|
|
164
|
+
// Checking authorization for the requested resource
|
|
165
|
+
this.checkAuthorization(config.endpoint);
|
|
166
|
+
// If not authenticated, use guest authentication
|
|
167
|
+
_b = this;
|
|
168
|
+
if (!((_a = this.cred) !== null && _a !== void 0)) return [3 /*break*/, 1];
|
|
169
|
+
_c = _a;
|
|
170
|
+
return [3 /*break*/, 3];
|
|
171
|
+
case 1: return [4 /*yield*/, new rettiwt_auth_1.Auth().getGuestCredential()];
|
|
172
|
+
case 2:
|
|
173
|
+
_c = (_d.sent());
|
|
174
|
+
_d.label = 3;
|
|
175
|
+
case 3:
|
|
176
|
+
// If not authenticated, use guest authentication
|
|
177
|
+
_b.cred = _c;
|
|
137
178
|
axiosRequest = {
|
|
138
179
|
url: config.url,
|
|
139
180
|
method: config.type,
|
|
@@ -144,11 +185,11 @@ var FetcherService = /** @class */ (function () {
|
|
|
144
185
|
return [4 /*yield*/, (0, axios_1.default)(axiosRequest)
|
|
145
186
|
.then(function (res) { return _this.handleHttpError(res); })
|
|
146
187
|
.then(function (res) { return _this.handleApiError(res); })];
|
|
147
|
-
case
|
|
188
|
+
case 4:
|
|
148
189
|
/**
|
|
149
190
|
* After making the request, the response is then passed to HTTP error handling middleware for HTTP error handling.
|
|
150
191
|
*/
|
|
151
|
-
return [2 /*return*/,
|
|
192
|
+
return [2 /*return*/, _d.sent()];
|
|
152
193
|
}
|
|
153
194
|
});
|
|
154
195
|
});
|
|
@@ -158,8 +199,6 @@ var FetcherService = /** @class */ (function () {
|
|
|
158
199
|
*
|
|
159
200
|
* @param data - The data from which extraction is to be done.
|
|
160
201
|
* @param type - The type of data to extract.
|
|
161
|
-
* @typeParam BaseType - The base type of the raw data present in the input.
|
|
162
|
-
* @typeParam DeserializedType - The type of data produced after deserialization of BaseType.
|
|
163
202
|
* @returns The extracted data.
|
|
164
203
|
*/
|
|
165
204
|
FetcherService.prototype.extractData = function (data, type) {
|
|
@@ -177,7 +216,8 @@ var FetcherService = /** @class */ (function () {
|
|
|
177
216
|
else if (type == rettiwt_core_1.EResourceType.TWEET_SEARCH ||
|
|
178
217
|
type == rettiwt_core_1.EResourceType.USER_LIKES ||
|
|
179
218
|
type == rettiwt_core_1.EResourceType.LIST_TWEETS ||
|
|
180
|
-
type == rettiwt_core_1.EResourceType.USER_TWEETS
|
|
219
|
+
type == rettiwt_core_1.EResourceType.USER_TWEETS ||
|
|
220
|
+
type == rettiwt_core_1.EResourceType.USER_TWEETS_AND_REPLIES) {
|
|
181
221
|
required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'TimelineTweet').map(function (item) { return item.tweet_results.result; });
|
|
182
222
|
}
|
|
183
223
|
else if (type == rettiwt_core_1.EResourceType.TWEET_FAVORITERS ||
|
|
@@ -186,7 +226,42 @@ var FetcherService = /** @class */ (function () {
|
|
|
186
226
|
type == rettiwt_core_1.EResourceType.USER_FOLLOWING) {
|
|
187
227
|
required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'TimelineUser').map(function (item) { return item.user_results.result; });
|
|
188
228
|
}
|
|
189
|
-
return
|
|
229
|
+
return {
|
|
230
|
+
required: required,
|
|
231
|
+
next: (_a = (0, JsonUtils_1.findByFilter)(data, 'cursorType', 'Bottom')[0]) === null || _a === void 0 ? void 0 : _a.value,
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Deserializes the extracted data into a cursored list.
|
|
236
|
+
*
|
|
237
|
+
* @param extractedData - The list of extracted data.
|
|
238
|
+
* @param next - The cursor to the next batch of data.
|
|
239
|
+
* @returns The cursored data object.
|
|
240
|
+
*/
|
|
241
|
+
FetcherService.prototype.deserializeData = function (extractedData, next) {
|
|
242
|
+
if (extractedData === void 0) { extractedData = []; }
|
|
243
|
+
if (next === void 0) { next = ''; }
|
|
244
|
+
/** The list of deserialized data. */
|
|
245
|
+
var deserializedList = [];
|
|
246
|
+
// Deserializing the extracted raw data and storing it in the list
|
|
247
|
+
for (var _i = 0, extractedData_1 = extractedData; _i < extractedData_1.length; _i++) {
|
|
248
|
+
var item = extractedData_1[_i];
|
|
249
|
+
// If the item is a valid raw tweet
|
|
250
|
+
if (item && item.__typename == 'Tweet' && item.rest_id) {
|
|
251
|
+
// Logging
|
|
252
|
+
this.logger.log(Logging_1.ELogActions.DESERIALIZE, { type: item.__typename, id: item.rest_id });
|
|
253
|
+
// Adding deserialized Tweet to list
|
|
254
|
+
deserializedList.push(new Tweet_1.Tweet(item));
|
|
255
|
+
}
|
|
256
|
+
// If the item is a valid raw user
|
|
257
|
+
else if (item && item.__typename == 'User' && item.rest_id && item.id) {
|
|
258
|
+
// Logging
|
|
259
|
+
this.logger.log(Logging_1.ELogActions.DESERIALIZE, { type: item.__typename, id: item.rest_id });
|
|
260
|
+
// Adding deserialized User to list
|
|
261
|
+
deserializedList.push(new User_1.User(item));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return new CursoredData_1.CursoredData(deserializedList, next);
|
|
190
265
|
};
|
|
191
266
|
/**
|
|
192
267
|
* Fetches the requested resource from Twitter and returns it after processing.
|
|
@@ -198,16 +273,19 @@ var FetcherService = /** @class */ (function () {
|
|
|
198
273
|
*/
|
|
199
274
|
FetcherService.prototype.fetch = function (resourceType, args) {
|
|
200
275
|
return __awaiter(this, void 0, void 0, function () {
|
|
201
|
-
var request, res,
|
|
276
|
+
var request, res, extractedData, deserializedData;
|
|
202
277
|
return __generator(this, function (_a) {
|
|
203
278
|
switch (_a.label) {
|
|
204
279
|
case 0:
|
|
280
|
+
// Logging
|
|
281
|
+
this.logger.log(Logging_1.ELogActions.FETCH, { resourceType: resourceType, args: args });
|
|
205
282
|
request = new rettiwt_core_1.Request(resourceType, args);
|
|
206
283
|
return [4 /*yield*/, this.request(request).then(function (res) { return res.data; })];
|
|
207
284
|
case 1:
|
|
208
285
|
res = _a.sent();
|
|
209
|
-
|
|
210
|
-
|
|
286
|
+
extractedData = this.extractData(res, resourceType);
|
|
287
|
+
deserializedData = this.deserializeData(extractedData.required, extractedData.next);
|
|
288
|
+
return [2 /*return*/, deserializedData];
|
|
211
289
|
}
|
|
212
290
|
});
|
|
213
291
|
});
|
|
@@ -225,6 +303,8 @@ var FetcherService = /** @class */ (function () {
|
|
|
225
303
|
return __generator(this, function (_a) {
|
|
226
304
|
switch (_a.label) {
|
|
227
305
|
case 0:
|
|
306
|
+
// Logging
|
|
307
|
+
this.logger.log(Logging_1.ELogActions.POST, { resourceType: resourceType, args: args });
|
|
228
308
|
request = new rettiwt_core_1.Request(resourceType, args);
|
|
229
309
|
// Posting the data
|
|
230
310
|
return [4 /*yield*/, this.request(request)];
|
|
@@ -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ogService {
|
|
8
|
+
/** Whether logging is enabled or not. */
|
|
9
|
+
private readonly enabled;
|
|
10
|
+
/**
|
|
11
|
+
* Initializes a new LogService instance.
|
|
12
|
+
*
|
|
13
|
+
* @param enable - Whether to enable logging or not.
|
|
14
|
+
*/
|
|
15
|
+
constructor(enable?: boolean);
|
|
16
|
+
/**
|
|
17
|
+
* Logs the given data.
|
|
18
|
+
*
|
|
19
|
+
* @param data - The data to be logged.
|
|
20
|
+
*/
|
|
21
|
+
log(action: ELogActions, data: NonNullable<unknown>): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogService = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Handles logging of data for debug purpose.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
var LogService = /** @class */ (function () {
|
|
10
|
+
/**
|
|
11
|
+
* Initializes a new LogService instance.
|
|
12
|
+
*
|
|
13
|
+
* @param enable - Whether to enable logging or not.
|
|
14
|
+
*/
|
|
15
|
+
function LogService(enable) {
|
|
16
|
+
this.enabled = enable !== null && enable !== void 0 ? enable : false;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Logs the given data.
|
|
20
|
+
*
|
|
21
|
+
* @param data - The data to be logged.
|
|
22
|
+
*/
|
|
23
|
+
LogService.prototype.log = function (action, data) {
|
|
24
|
+
// Proceed to log only if logging is enabled
|
|
25
|
+
if (this.enabled) {
|
|
26
|
+
// Preparing the log message
|
|
27
|
+
var logMessage = "[Rettiwt-API] [".concat(action, "] [").concat(new Date().toISOString(), "] ").concat(JSON.stringify(data));
|
|
28
|
+
// Logging
|
|
29
|
+
console.log(logMessage);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return LogService;
|
|
33
|
+
}());
|
|
34
|
+
exports.LogService = LogService;
|
|
35
|
+
//# sourceMappingURL=LogService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogService.js","sourceRoot":"","sources":["../../../src/services/internal/LogService.ts"],"names":[],"mappings":";;;AAGA;;;;GAIG;AACH;IAIC;;;;OAIG;IACH,oBAAmB,MAAgB;QAClC,IAAI,CAAC,OAAO,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,KAAK,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,wBAAG,GAAV,UAAW,MAAmB,EAAE,IAA0B;QACzD,4CAA4C;QAC5C,IAAI,IAAI,CAAC,OAAO,EAAE;YACjB,4BAA4B;YAC5B,IAAM,UAAU,GAAW,yBAAkB,MAAM,gBAAM,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,eAAK,IAAI,CAAC,SAAS,CACnG,IAAI,CACJ,CAAE,CAAC;YAEJ,UAAU;YACV,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;SACxB;IACF,CAAC;IACF,iBAAC;AAAD,CAAC,AA9BD,IA8BC;AA9BY,gCAAU"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { TweetFilter } from 'rettiwt-core';
|
|
2
|
-
import { FetcherService } from '
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { FetcherService } from '../internal/FetcherService';
|
|
3
|
+
import { RettiwtConfig } from '../../models/internal/RettiwtConfig';
|
|
4
|
+
import { Tweet } from '../../models/public/Tweet';
|
|
5
|
+
import { User } from '../../models/public/User';
|
|
6
|
+
import { CursoredData } from '../../models/public/CursoredData';
|
|
6
7
|
/**
|
|
7
8
|
* Handles fetching of data related to tweets.
|
|
8
9
|
*
|
|
@@ -10,12 +11,11 @@ import { CursoredData } from '../models/CursoredData';
|
|
|
10
11
|
*/
|
|
11
12
|
export declare class TweetService extends FetcherService {
|
|
12
13
|
/**
|
|
13
|
-
* @param
|
|
14
|
-
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
14
|
+
* @param config - The config object for configuring the Rettiwt instance.
|
|
15
15
|
*
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
|
-
constructor(
|
|
18
|
+
constructor(config?: RettiwtConfig);
|
|
19
19
|
/**
|
|
20
20
|
* Get the details of a tweet.
|
|
21
21
|
*
|
|
@@ -55,7 +55,7 @@ exports.TweetService = void 0;
|
|
|
55
55
|
// PACKAGES
|
|
56
56
|
var rettiwt_core_1 = require("rettiwt-core");
|
|
57
57
|
// SERVICES
|
|
58
|
-
var FetcherService_1 = require("
|
|
58
|
+
var FetcherService_1 = require("../internal/FetcherService");
|
|
59
59
|
/**
|
|
60
60
|
* Handles fetching of data related to tweets.
|
|
61
61
|
*
|
|
@@ -64,13 +64,12 @@ var FetcherService_1 = require("./FetcherService");
|
|
|
64
64
|
var TweetService = /** @class */ (function (_super) {
|
|
65
65
|
__extends(TweetService, _super);
|
|
66
66
|
/**
|
|
67
|
-
* @param
|
|
68
|
-
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
67
|
+
* @param config - The config object for configuring the Rettiwt instance.
|
|
69
68
|
*
|
|
70
69
|
* @internal
|
|
71
70
|
*/
|
|
72
|
-
function TweetService(
|
|
73
|
-
return _super.call(this,
|
|
71
|
+
function TweetService(config) {
|
|
72
|
+
return _super.call(this, config) || this;
|
|
74
73
|
}
|
|
75
74
|
/**
|
|
76
75
|
* Get the details of a tweet.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TweetService.js","sourceRoot":"","sources":["../../../src/services/public/TweetService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAA0D;AAE1D,WAAW;AACX,6DAA4D;AAQ5D;;;;GAIG;AACH;IAAkC,gCAAc;IAC/C;;;;OAIG;IACH,sBAAmB,MAAsB;eACxC,kBAAM,MAAM,CAAC;IACd,CAAC;IAED;;;;;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;;;;;4BAEtB,qBAAM,IAAI,CAAC,IAAI,CAAC,4BAAa,CAAC,cAAc,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAA;;wBAArE,IAAI,GAAG,SAA8D;wBAE3E,sBAAO,IAAI,EAAC;;;;KACZ;IACF,mBAAC;AAAD,CAAC,AA/JD,CAAkC,+BAAc,GA+J/C;AA/JY,oCAAY"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { FetcherService } from '
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { FetcherService } from '../internal/FetcherService';
|
|
2
|
+
import { RettiwtConfig } from '../../models/internal/RettiwtConfig';
|
|
3
|
+
import { User } from '../../models/public/User';
|
|
4
|
+
import { Tweet } from '../../models/public/Tweet';
|
|
5
|
+
import { CursoredData } from '../../models/public/CursoredData';
|
|
5
6
|
/**
|
|
6
7
|
* Handles fetching of data related to user account
|
|
7
8
|
*
|
|
@@ -9,12 +10,11 @@ import { CursoredData } from '../models/CursoredData';
|
|
|
9
10
|
*/
|
|
10
11
|
export declare class UserService extends FetcherService {
|
|
11
12
|
/**
|
|
12
|
-
* @param
|
|
13
|
-
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
13
|
+
* @param config - The config object for configuring the Rettiwt instance.
|
|
14
14
|
*
|
|
15
15
|
* @internal
|
|
16
16
|
*/
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(config?: RettiwtConfig);
|
|
18
18
|
/**
|
|
19
19
|
* Get the details of a user.
|
|
20
20
|
*
|
|
@@ -65,9 +65,24 @@ export declare class UserService extends FetcherService {
|
|
|
65
65
|
* @param cursor - The cursor to the batch of timeline items to fetch.
|
|
66
66
|
* @returns The timeline of the target user.
|
|
67
67
|
*
|
|
68
|
-
* @remarks
|
|
68
|
+
* @remarks
|
|
69
|
+
* - If the target user has a pinned tweet, the returned timeline has one item extra and this is always the pinned tweet.
|
|
70
|
+
* - If timeline is fetched without authenticating, then the most popular tweets of the target user are returned instead.
|
|
69
71
|
*
|
|
70
72
|
* @public
|
|
71
73
|
*/
|
|
72
74
|
timeline(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
75
|
+
/**
|
|
76
|
+
* Get the reply timeline of the given user.
|
|
77
|
+
*
|
|
78
|
+
* @param userId - The rest id of the target user.
|
|
79
|
+
* @param count - The number of replies to fetch, must be \<= 20.
|
|
80
|
+
* @param cursor - The cursor to the batch of replies to fetch.
|
|
81
|
+
* @returns The reply timeline of the target user.
|
|
82
|
+
*
|
|
83
|
+
* @remarks If the target user has a pinned tweet, the returned reply timeline has one item extra and this is always the pinned tweet.
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
replies(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
73
88
|
}
|
|
@@ -55,7 +55,7 @@ exports.UserService = void 0;
|
|
|
55
55
|
// PACKAGES
|
|
56
56
|
var rettiwt_core_1 = require("rettiwt-core");
|
|
57
57
|
// SERVICES
|
|
58
|
-
var FetcherService_1 = require("
|
|
58
|
+
var FetcherService_1 = require("../internal/FetcherService");
|
|
59
59
|
/**
|
|
60
60
|
* Handles fetching of data related to user account
|
|
61
61
|
*
|
|
@@ -64,13 +64,12 @@ var FetcherService_1 = require("./FetcherService");
|
|
|
64
64
|
var UserService = /** @class */ (function (_super) {
|
|
65
65
|
__extends(UserService, _super);
|
|
66
66
|
/**
|
|
67
|
-
* @param
|
|
68
|
-
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
67
|
+
* @param config - The config object for configuring the Rettiwt instance.
|
|
69
68
|
*
|
|
70
69
|
* @internal
|
|
71
70
|
*/
|
|
72
|
-
function UserService(
|
|
73
|
-
return _super.call(this,
|
|
71
|
+
function UserService(config) {
|
|
72
|
+
return _super.call(this, config) || this;
|
|
74
73
|
}
|
|
75
74
|
/**
|
|
76
75
|
* Get the details of a user.
|
|
@@ -191,7 +190,9 @@ var UserService = /** @class */ (function (_super) {
|
|
|
191
190
|
* @param cursor - The cursor to the batch of timeline items to fetch.
|
|
192
191
|
* @returns The timeline of the target user.
|
|
193
192
|
*
|
|
194
|
-
* @remarks
|
|
193
|
+
* @remarks
|
|
194
|
+
* - If the target user has a pinned tweet, the returned timeline has one item extra and this is always the pinned tweet.
|
|
195
|
+
* - If timeline is fetched without authenticating, then the most popular tweets of the target user are returned instead.
|
|
195
196
|
*
|
|
196
197
|
* @public
|
|
197
198
|
*/
|
|
@@ -212,6 +213,37 @@ var UserService = /** @class */ (function (_super) {
|
|
|
212
213
|
});
|
|
213
214
|
});
|
|
214
215
|
};
|
|
216
|
+
/**
|
|
217
|
+
* Get the reply timeline of the given user.
|
|
218
|
+
*
|
|
219
|
+
* @param userId - The rest id of the target user.
|
|
220
|
+
* @param count - The number of replies to fetch, must be \<= 20.
|
|
221
|
+
* @param cursor - The cursor to the batch of replies to fetch.
|
|
222
|
+
* @returns The reply timeline of the target user.
|
|
223
|
+
*
|
|
224
|
+
* @remarks If the target user has a pinned tweet, the returned reply timeline has one item extra and this is always the pinned tweet.
|
|
225
|
+
*
|
|
226
|
+
* @public
|
|
227
|
+
*/
|
|
228
|
+
UserService.prototype.replies = function (userId, count, cursor) {
|
|
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.fetch(rettiwt_core_1.EResourceType.USER_TWEETS_AND_REPLIES, {
|
|
234
|
+
id: userId,
|
|
235
|
+
count: count,
|
|
236
|
+
cursor: cursor,
|
|
237
|
+
})];
|
|
238
|
+
case 1:
|
|
239
|
+
data = _a.sent();
|
|
240
|
+
// Filtering out other tweets made by other users in the same threads
|
|
241
|
+
data.list = data.list.filter(function (tweet) { return tweet.tweetBy.id == userId; });
|
|
242
|
+
return [2 /*return*/, data];
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
};
|
|
215
247
|
return UserService;
|
|
216
248
|
}(FetcherService_1.FetcherService));
|
|
217
249
|
exports.UserService = UserService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../../src/services/public/UserService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAA6C;AAE7C,WAAW;AACX,6DAA4D;AAU5D;;;;GAIG;AACH;IAAiC,+BAAc;IAC9C;;;;OAIG;IACH,qBAAmB,MAAsB;eACxC,kBAAM,MAAM,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACU,6BAAO,GAApB,UAAqB,EAAU;;;;;;6BAI1B,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAjB,wBAAiB;wBAEb,qBAAM,IAAI,CAAC,KAAK,CAAO,4BAAa,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAA;;wBADrE,8BAA8B;wBAC9B,IAAI,GAAG,SAA8D,CAAC;;4BAK/D,qBAAM,IAAI,CAAC,KAAK,CAAO,4BAAa,CAAC,kBAAkB,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAA;;wBAD3E,8BAA8B;wBAC9B,IAAI,GAAG,SAAoE,CAAC;;4BAG7E,sBAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC;;;;KACpB;IAED;;;;;;;;;OASG;IACU,+BAAS,GAAtB,UAAuB,MAAc,EAAE,KAAc,EAAE,MAAe;;;;;4BAExD,qBAAM,IAAI,CAAC,KAAK,CAAO,4BAAa,CAAC,cAAc,EAAE;4BACjE,EAAE,EAAE,MAAM;4BACV,KAAK,EAAE,KAAK;4BACZ,MAAM,EAAE,MAAM;yBACd,CAAC,EAAA;;wBAJI,IAAI,GAAG,SAIX;wBAEF,sBAAO,I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,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,MAAM,EAA1B,CAA0B,CAAC,CAAC;wBAEpE,sBAAO,IAAI,EAAC;;;;KACZ;IACF,kBAAC;AAAD,CAAC,AApJD,CAAiC,+BAAc,GAoJ9C;AApJY,kCAAW"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The configuration for initializing a new Rettiwt instance.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export interface IRettiwtConfig {
|
|
7
|
+
/** The apiKey (cookie) to use for authenticating Rettiwt against Twitter API. */
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
/** Optional URL with proxy configuration to use for requests to Twitter API. */
|
|
10
|
+
proxyUrl?: URL;
|
|
11
|
+
/** Whether to write logs to console or not. */
|
|
12
|
+
logging?: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RettiwtConfig.js","sourceRoot":"","sources":["../../../src/types/internal/RettiwtConfig.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CursoredData.js","sourceRoot":"","sources":["../../../src/types/public/CursoredData.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/types/public/List.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tweet.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"Tweet.js","sourceRoot":"","sources":["../../../src/types/public/Tweet.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../src/types/public/User.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rettiwt-api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"description": "An API for fetching data from TwitterAPI, without any rate limits!",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"axios": "1.3.2",
|
|
30
30
|
"https-proxy-agent": "7.0.2",
|
|
31
|
-
"rettiwt-auth": "
|
|
32
|
-
"rettiwt-core": "3.2.
|
|
31
|
+
"rettiwt-auth": "2.0.0",
|
|
32
|
+
"rettiwt-core": "3.2.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "20.4.1",
|
package/src/Rettiwt.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// SERVICES
|
|
2
|
-
import { TweetService } from './services/TweetService';
|
|
3
|
-
import { UserService } from './services/UserService';
|
|
2
|
+
import { TweetService } from './services/public/TweetService';
|
|
3
|
+
import { UserService } from './services/public/UserService';
|
|
4
|
+
|
|
5
|
+
// MODELS
|
|
6
|
+
import { RettiwtConfig } from './models/internal/RettiwtConfig';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* The class for fetching data from Twitter.
|
|
@@ -9,19 +12,18 @@ import { UserService } from './services/UserService';
|
|
|
9
12
|
*/
|
|
10
13
|
export class Rettiwt {
|
|
11
14
|
/** The instance used to fetch data related to tweets. */
|
|
12
|
-
tweet: TweetService;
|
|
15
|
+
public tweet: TweetService;
|
|
13
16
|
|
|
14
17
|
/** The instance used to fetch data related to users. */
|
|
15
|
-
user: UserService;
|
|
18
|
+
public user: UserService;
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
21
|
* Initializes a new Rettiwt instance using the given api key.
|
|
19
22
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
23
|
+
* @param config - The config object for configuring the Rettiwt instance.
|
|
22
24
|
*/
|
|
23
|
-
constructor(
|
|
24
|
-
this.tweet = new TweetService(
|
|
25
|
-
this.user = new UserService(
|
|
25
|
+
public constructor(config?: RettiwtConfig) {
|
|
26
|
+
this.tweet = new TweetService(config);
|
|
27
|
+
this.user = new UserService(config);
|
|
26
28
|
}
|
|
27
29
|
}
|