rettiwt-api 2.2.1 → 2.3.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.
- package/.eslintrc.js +1 -0
- package/README.md +39 -20
- 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} +100 -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} +20 -7
- package/dist/services/{UserService.js → public/UserService.js} +35 -5
- 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 +2 -2
- 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} +116 -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} +39 -13
- 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.
|
|
@@ -76,6 +81,23 @@ var FetcherService = /** @class */ (function () {
|
|
|
76
81
|
FetcherService.prototype.getAuthCredential = function (apiKey) {
|
|
77
82
|
return new rettiwt_auth_1.AuthCredential(apiKey.split(';'));
|
|
78
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* Checks the authorization status based on the requested resource.
|
|
86
|
+
*
|
|
87
|
+
* @param resourceType - The type of resource to fetch.
|
|
88
|
+
* @throws An error if not authorized to access the requested resource.
|
|
89
|
+
*/
|
|
90
|
+
FetcherService.prototype.checkAuthorization = function (resourceType) {
|
|
91
|
+
// Logging
|
|
92
|
+
this.logger.log(Logging_1.ELogActions.AUTHORIZATION, { authenticated: this.isAuthenticated });
|
|
93
|
+
// Checking authorization status
|
|
94
|
+
if (resourceType != rettiwt_core_1.EResourceType.TWEET_DETAILS &&
|
|
95
|
+
resourceType != rettiwt_core_1.EResourceType.USER_DETAILS &&
|
|
96
|
+
resourceType != rettiwt_core_1.EResourceType.USER_TWEETS &&
|
|
97
|
+
this.isAuthenticated == false) {
|
|
98
|
+
throw new Error(ApiErrors_1.EApiErrors.RESOURCE_NOT_ALLOWED);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
79
101
|
/**
|
|
80
102
|
* Gets the HttpsAgent based on whether a proxy is used or not.
|
|
81
103
|
*
|
|
@@ -93,6 +115,7 @@ var FetcherService = /** @class */ (function () {
|
|
|
93
115
|
*
|
|
94
116
|
* @param res - The response object received.
|
|
95
117
|
* @returns The received response, if no HTTP errors are found.
|
|
118
|
+
* @throws An error if any HTTP-related error has occured.
|
|
96
119
|
*/
|
|
97
120
|
FetcherService.prototype.handleHttpError = function (res) {
|
|
98
121
|
/**
|
|
@@ -108,6 +131,7 @@ var FetcherService = /** @class */ (function () {
|
|
|
108
131
|
*
|
|
109
132
|
* @param res - The response object received.
|
|
110
133
|
* @returns The received response, if no API errors are found.
|
|
134
|
+
* @throws An error if any API-related error has occured.
|
|
111
135
|
*/
|
|
112
136
|
FetcherService.prototype.handleApiError = function (res) {
|
|
113
137
|
// If error exists
|
|
@@ -128,12 +152,27 @@ var FetcherService = /** @class */ (function () {
|
|
|
128
152
|
* @returns The response received.
|
|
129
153
|
*/
|
|
130
154
|
FetcherService.prototype.request = function (config) {
|
|
155
|
+
var _a;
|
|
131
156
|
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
-
var axiosRequest;
|
|
157
|
+
var _b, _c, axiosRequest;
|
|
133
158
|
var _this = this;
|
|
134
|
-
return __generator(this, function (
|
|
135
|
-
switch (
|
|
159
|
+
return __generator(this, function (_d) {
|
|
160
|
+
switch (_d.label) {
|
|
136
161
|
case 0:
|
|
162
|
+
// Checking authorization for the requested resource
|
|
163
|
+
this.checkAuthorization(config.endpoint);
|
|
164
|
+
// If not authenticated, use guest authentication
|
|
165
|
+
_b = this;
|
|
166
|
+
if (!((_a = this.cred) !== null && _a !== void 0)) return [3 /*break*/, 1];
|
|
167
|
+
_c = _a;
|
|
168
|
+
return [3 /*break*/, 3];
|
|
169
|
+
case 1: return [4 /*yield*/, new rettiwt_auth_1.Auth().getGuestCredential()];
|
|
170
|
+
case 2:
|
|
171
|
+
_c = (_d.sent());
|
|
172
|
+
_d.label = 3;
|
|
173
|
+
case 3:
|
|
174
|
+
// If not authenticated, use guest authentication
|
|
175
|
+
_b.cred = _c;
|
|
137
176
|
axiosRequest = {
|
|
138
177
|
url: config.url,
|
|
139
178
|
method: config.type,
|
|
@@ -144,11 +183,11 @@ var FetcherService = /** @class */ (function () {
|
|
|
144
183
|
return [4 /*yield*/, (0, axios_1.default)(axiosRequest)
|
|
145
184
|
.then(function (res) { return _this.handleHttpError(res); })
|
|
146
185
|
.then(function (res) { return _this.handleApiError(res); })];
|
|
147
|
-
case
|
|
186
|
+
case 4:
|
|
148
187
|
/**
|
|
149
188
|
* After making the request, the response is then passed to HTTP error handling middleware for HTTP error handling.
|
|
150
189
|
*/
|
|
151
|
-
return [2 /*return*/,
|
|
190
|
+
return [2 /*return*/, _d.sent()];
|
|
152
191
|
}
|
|
153
192
|
});
|
|
154
193
|
});
|
|
@@ -158,8 +197,6 @@ var FetcherService = /** @class */ (function () {
|
|
|
158
197
|
*
|
|
159
198
|
* @param data - The data from which extraction is to be done.
|
|
160
199
|
* @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
200
|
* @returns The extracted data.
|
|
164
201
|
*/
|
|
165
202
|
FetcherService.prototype.extractData = function (data, type) {
|
|
@@ -177,7 +214,8 @@ var FetcherService = /** @class */ (function () {
|
|
|
177
214
|
else if (type == rettiwt_core_1.EResourceType.TWEET_SEARCH ||
|
|
178
215
|
type == rettiwt_core_1.EResourceType.USER_LIKES ||
|
|
179
216
|
type == rettiwt_core_1.EResourceType.LIST_TWEETS ||
|
|
180
|
-
type == rettiwt_core_1.EResourceType.USER_TWEETS
|
|
217
|
+
type == rettiwt_core_1.EResourceType.USER_TWEETS ||
|
|
218
|
+
type == rettiwt_core_1.EResourceType.USER_TWEETS_AND_REPLIES) {
|
|
181
219
|
required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'TimelineTweet').map(function (item) { return item.tweet_results.result; });
|
|
182
220
|
}
|
|
183
221
|
else if (type == rettiwt_core_1.EResourceType.TWEET_FAVORITERS ||
|
|
@@ -186,7 +224,42 @@ var FetcherService = /** @class */ (function () {
|
|
|
186
224
|
type == rettiwt_core_1.EResourceType.USER_FOLLOWING) {
|
|
187
225
|
required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'TimelineUser').map(function (item) { return item.user_results.result; });
|
|
188
226
|
}
|
|
189
|
-
return
|
|
227
|
+
return {
|
|
228
|
+
required: required,
|
|
229
|
+
next: (_a = (0, JsonUtils_1.findByFilter)(data, 'cursorType', 'Bottom')[0]) === null || _a === void 0 ? void 0 : _a.value,
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* Deserializes the extracted data into a cursored list.
|
|
234
|
+
*
|
|
235
|
+
* @param extractedData - The list of extracted data.
|
|
236
|
+
* @param next - The cursor to the next batch of data.
|
|
237
|
+
* @returns The cursored data object.
|
|
238
|
+
*/
|
|
239
|
+
FetcherService.prototype.deserializeData = function (extractedData, next) {
|
|
240
|
+
if (extractedData === void 0) { extractedData = []; }
|
|
241
|
+
if (next === void 0) { next = ''; }
|
|
242
|
+
/** The list of deserialized data. */
|
|
243
|
+
var deserializedList = [];
|
|
244
|
+
// Deserializing the extracted raw data and storing it in the list
|
|
245
|
+
for (var _i = 0, extractedData_1 = extractedData; _i < extractedData_1.length; _i++) {
|
|
246
|
+
var item = extractedData_1[_i];
|
|
247
|
+
// If the item is a valid raw tweet
|
|
248
|
+
if (item && item.__typename == 'Tweet' && item.rest_id) {
|
|
249
|
+
// Logging
|
|
250
|
+
this.logger.log(Logging_1.ELogActions.DESERIALIZE, { type: item.__typename, id: item.rest_id });
|
|
251
|
+
// Adding deserialized Tweet to list
|
|
252
|
+
deserializedList.push(new Tweet_1.Tweet(item));
|
|
253
|
+
}
|
|
254
|
+
// If the item is a valid raw user
|
|
255
|
+
else if (item && item.__typename == 'User' && item.rest_id && item.id) {
|
|
256
|
+
// Logging
|
|
257
|
+
this.logger.log(Logging_1.ELogActions.DESERIALIZE, { type: item.__typename, id: item.rest_id });
|
|
258
|
+
// Adding deserialized User to list
|
|
259
|
+
deserializedList.push(new User_1.User(item));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return new CursoredData_1.CursoredData(deserializedList, next);
|
|
190
263
|
};
|
|
191
264
|
/**
|
|
192
265
|
* Fetches the requested resource from Twitter and returns it after processing.
|
|
@@ -198,16 +271,19 @@ var FetcherService = /** @class */ (function () {
|
|
|
198
271
|
*/
|
|
199
272
|
FetcherService.prototype.fetch = function (resourceType, args) {
|
|
200
273
|
return __awaiter(this, void 0, void 0, function () {
|
|
201
|
-
var request, res,
|
|
274
|
+
var request, res, extractedData, deserializedData;
|
|
202
275
|
return __generator(this, function (_a) {
|
|
203
276
|
switch (_a.label) {
|
|
204
277
|
case 0:
|
|
278
|
+
// Logging
|
|
279
|
+
this.logger.log(Logging_1.ELogActions.FETCH, { resourceType: resourceType, args: args });
|
|
205
280
|
request = new rettiwt_core_1.Request(resourceType, args);
|
|
206
281
|
return [4 /*yield*/, this.request(request).then(function (res) { return res.data; })];
|
|
207
282
|
case 1:
|
|
208
283
|
res = _a.sent();
|
|
209
|
-
|
|
210
|
-
|
|
284
|
+
extractedData = this.extractData(res, resourceType);
|
|
285
|
+
deserializedData = this.deserializeData(extractedData.required, extractedData.next);
|
|
286
|
+
return [2 /*return*/, deserializedData];
|
|
211
287
|
}
|
|
212
288
|
});
|
|
213
289
|
});
|
|
@@ -225,6 +301,8 @@ var FetcherService = /** @class */ (function () {
|
|
|
225
301
|
return __generator(this, function (_a) {
|
|
226
302
|
switch (_a.label) {
|
|
227
303
|
case 0:
|
|
304
|
+
// Logging
|
|
305
|
+
this.logger.log(Logging_1.ELogActions.POST, { resourceType: resourceType, args: args });
|
|
228
306
|
request = new rettiwt_core_1.Request(resourceType, args);
|
|
229
307
|
// Posting the data
|
|
230
308
|
return [4 /*yield*/, this.request(request)];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../../src/services/internal/FetcherService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;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I,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,IAAI,EAAR,CAAQ,CAAC,EAAA;;wBAAzD,GAAG,GAAG,SAAmD;wBAGzD,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;wBAGpD,gBAAgB,GAAG,IAAI,CAAC,eAAe,CAAU,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;wBAEnG,sBAAO,gBAAgB,EAAC;;;;KACxB;IAED;;;;;;OAMG;IACa,6BAAI,GAApB,UAAqB,YAA2B,EAAE,IAAU;;;;;;wBAC3D,UAAU;wBACV,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,qBAAW,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;wBAGxE,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,AA1RD,IA0RC;AA1RY,wCAAc"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ELogActions } from '../../enums/Logging';
|
|
2
|
+
/**
|
|
3
|
+
* Handles logging of data for debug purpose.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class LogService {
|
|
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;;;;;;;OAOG;IACU,8BAAO,GAApB,UAAqB,EAAU;;;;;4BAEjB,qBAAM,IAAI,CAAC,KAAK,CAAQ,4BAAa,CAAC,aAAa,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAA;;wBAAvE,IAAI,GAAG,SAAgE;wBAE7E,sBAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC;;;;KAC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"}
|
|
@@ -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
|
*
|
|
@@ -70,4 +70,17 @@ export declare class UserService extends FetcherService {
|
|
|
70
70
|
* @public
|
|
71
71
|
*/
|
|
72
72
|
timeline(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
73
|
+
/**
|
|
74
|
+
* Get the reply timeline of the given user.
|
|
75
|
+
*
|
|
76
|
+
* @param userId - The rest id of the target user.
|
|
77
|
+
* @param count - The number of replies to fetch, must be \<= 20.
|
|
78
|
+
* @param cursor - The cursor to the batch of replies to fetch.
|
|
79
|
+
* @returns The reply timeline of the target user.
|
|
80
|
+
*
|
|
81
|
+
* @remarks If the target user has a pinned tweet, the returned reply timeline has one item extra and this is always the pinned tweet.
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
replies(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
73
86
|
}
|
|
@@ -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.
|
|
@@ -212,6 +211,37 @@ var UserService = /** @class */ (function (_super) {
|
|
|
212
211
|
});
|
|
213
212
|
});
|
|
214
213
|
};
|
|
214
|
+
/**
|
|
215
|
+
* Get the reply timeline of the given user.
|
|
216
|
+
*
|
|
217
|
+
* @param userId - The rest id of the target user.
|
|
218
|
+
* @param count - The number of replies to fetch, must be \<= 20.
|
|
219
|
+
* @param cursor - The cursor to the batch of replies to fetch.
|
|
220
|
+
* @returns The reply timeline of the target user.
|
|
221
|
+
*
|
|
222
|
+
* @remarks If the target user has a pinned tweet, the returned reply timeline has one item extra and this is always the pinned tweet.
|
|
223
|
+
*
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
UserService.prototype.replies = function (userId, count, cursor) {
|
|
227
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
228
|
+
var data;
|
|
229
|
+
return __generator(this, function (_a) {
|
|
230
|
+
switch (_a.label) {
|
|
231
|
+
case 0: return [4 /*yield*/, this.fetch(rettiwt_core_1.EResourceType.USER_TWEETS_AND_REPLIES, {
|
|
232
|
+
id: userId,
|
|
233
|
+
count: count,
|
|
234
|
+
cursor: cursor,
|
|
235
|
+
})];
|
|
236
|
+
case 1:
|
|
237
|
+
data = _a.sent();
|
|
238
|
+
// Filtering out other tweets made by other users in the same threads
|
|
239
|
+
data.list = data.list.filter(function (tweet) { return tweet.tweetBy.id == userId; });
|
|
240
|
+
return [2 /*return*/, data];
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
};
|
|
215
245
|
return UserService;
|
|
216
246
|
}(FetcherService_1.FetcherService));
|
|
217
247
|
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;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AAM,EAAE,MAAM;yBACd,CAAC,EAAA;;wBAJI,IAAI,GAAG,SAIX;wBAEF,sBAAO,IAAI,EAAC;;;;KACZ;IAED;;;;;;;;;;;OAWG;IACU,6BAAO,GAApB,UAAqB,MAAc,EAAE,KAAc,EAAE,MAAe;;;;;4BAEtD,qBAAM,IAAI,CAAC,KAAK,CAAQ,4BAAa,CAAC,uBAAuB,EAAE;4BAC3E,EAAE,EAAE,MAAM;4BACV,KAAK,EAAE,KAAK;4BACZ,MAAM,EAAE,MAAM;yBACd,CAAC,EAAA;;wBAJI,IAAI,GAAG,SAIX;wBAEF,qEAAqE;wBACrE,IAAI,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,AAlJD,CAAiC,+BAAc,GAkJ9C;AAlJY,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.0",
|
|
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!",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"axios": "1.3.2",
|
|
30
30
|
"https-proxy-agent": "7.0.2",
|
|
31
31
|
"rettiwt-auth": "1.2.0",
|
|
32
|
-
"rettiwt-core": "3.2.
|
|
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
|
}
|
package/src/index.ts
CHANGED
|
@@ -4,20 +4,24 @@ export * from './Rettiwt';
|
|
|
4
4
|
// Exporting enums
|
|
5
5
|
export * from './enums/ApiErrors';
|
|
6
6
|
export * from './enums/HTTP';
|
|
7
|
+
export * from './enums/Logging';
|
|
7
8
|
|
|
8
9
|
// Exporting models
|
|
9
|
-
export * from './models/
|
|
10
|
-
export * from './models/
|
|
11
|
-
export * from './models/
|
|
12
|
-
export * from './models/
|
|
10
|
+
export * from './models/internal/RettiwtConfig';
|
|
11
|
+
export * from './models/public/CursoredData';
|
|
12
|
+
export * from './models/public/List';
|
|
13
|
+
export * from './models/public/Tweet';
|
|
14
|
+
export * from './models/public/User';
|
|
13
15
|
|
|
14
16
|
// Exporting services
|
|
15
|
-
export * from './services/FetcherService';
|
|
16
|
-
export * from './services/
|
|
17
|
-
export * from './services/
|
|
17
|
+
export * from './services/internal/FetcherService';
|
|
18
|
+
export * from './services/internal/LogService';
|
|
19
|
+
export * from './services/public/TweetService';
|
|
20
|
+
export * from './services/public/UserService';
|
|
18
21
|
|
|
19
22
|
// Exporting types
|
|
20
|
-
export * from './types/
|
|
21
|
-
export * from './types/
|
|
22
|
-
export * from './types/
|
|
23
|
-
export * from './types/
|
|
23
|
+
export * from './types/internal/RettiwtConfig';
|
|
24
|
+
export * from './types/public/CursoredData';
|
|
25
|
+
export * from './types/public/List';
|
|
26
|
+
export * from './types/public/Tweet';
|
|
27
|
+
export * from './types/public/User';
|