rettiwt-api 4.2.0-alpha.1 → 4.2.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 +35 -0
- package/.github/workflows/documentation.yml +1 -4
- package/.github/workflows/publish-alpha.yml +1 -4
- package/.github/workflows/publish.yml +1 -4
- package/.tool-versions +1 -1
- package/README.md +14 -8
- package/dist/Rettiwt.d.ts +3 -0
- package/dist/Rettiwt.js +2 -0
- package/dist/Rettiwt.js.map +1 -1
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/collections/Extractors.d.ts +3 -1
- package/dist/collections/Extractors.js +6 -0
- package/dist/collections/Extractors.js.map +1 -1
- package/dist/collections/Groups.js +2 -0
- package/dist/collections/Groups.js.map +1 -1
- package/dist/collections/Requests.js +3 -1
- package/dist/collections/Requests.js.map +1 -1
- package/dist/commands/List.d.ts +10 -0
- package/dist/commands/List.js +104 -0
- package/dist/commands/List.js.map +1 -0
- package/dist/commands/Tweet.js +2 -1
- package/dist/commands/Tweet.js.map +1 -1
- package/dist/commands/User.js +62 -39
- package/dist/commands/User.js.map +1 -1
- package/dist/enums/Resource.d.ts +2 -0
- package/dist/enums/Resource.js +2 -0
- package/dist/enums/Resource.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +0 -3
- package/dist/index.js.map +1 -1
- package/dist/models/args/FetchArgs.d.ts +6 -0
- package/dist/models/args/FetchArgs.js +24 -2
- package/dist/models/args/FetchArgs.js.map +1 -1
- package/dist/models/data/Tweet.d.ts +18 -0
- package/dist/models/data/Tweet.js +62 -7
- package/dist/models/data/Tweet.js.map +1 -1
- package/dist/models/data/User.js +1 -1
- package/dist/models/data/User.js.map +1 -1
- package/dist/services/public/AuthService.js +1 -1
- package/dist/services/public/AuthService.js.map +1 -1
- package/dist/services/public/FetcherService.d.ts +5 -5
- package/dist/services/public/FetcherService.js +12 -12
- package/dist/services/public/FetcherService.js.map +1 -1
- package/dist/services/public/ListService.d.ts +71 -0
- package/dist/services/public/ListService.js +169 -0
- package/dist/services/public/ListService.js.map +1 -0
- package/dist/services/public/UserService.d.ts +26 -0
- package/dist/services/public/UserService.js +44 -0
- package/dist/services/public/UserService.js.map +1 -1
- package/package.json +3 -4
- package/src/Rettiwt.ts +5 -0
- package/src/cli.ts +2 -0
- package/src/collections/Extractors.ts +7 -1
- package/src/collections/Groups.ts +2 -0
- package/src/collections/Requests.ts +3 -1
- package/src/commands/List.ts +49 -0
- package/src/commands/Tweet.ts +2 -2
- package/src/commands/User.ts +13 -0
- package/src/enums/Resource.ts +2 -0
- package/src/index.ts +3 -1
- package/src/models/args/FetchArgs.ts +28 -1
- package/src/models/data/Notification.ts +1 -1
- package/src/models/data/Tweet.ts +75 -8
- package/src/models/data/User.ts +1 -1
- package/src/services/public/AuthService.ts +3 -1
- package/src/services/public/FetcherService.ts +17 -17
- package/src/services/public/ListService.ts +112 -0
- package/src/services/public/UserService.ts +42 -1
- package/.yarnrc.yml +0 -1
|
@@ -16,13 +16,13 @@ var Tweet = /** @class */ (function () {
|
|
|
16
16
|
* @param tweet - The raw tweet details.
|
|
17
17
|
*/
|
|
18
18
|
function Tweet(tweet) {
|
|
19
|
-
var _a, _b
|
|
19
|
+
var _a, _b;
|
|
20
20
|
this.id = tweet.rest_id;
|
|
21
21
|
this.createdAt = tweet.legacy.created_at;
|
|
22
22
|
this.tweetBy = new User_1.User(tweet.core.user_results.result);
|
|
23
23
|
this.entities = new TweetEntities(tweet.legacy.entities);
|
|
24
24
|
this.media = (_b = (_a = tweet.legacy.extended_entities) === null || _a === void 0 ? void 0 : _a.media) === null || _b === void 0 ? void 0 : _b.map(function (media) { return new TweetMedia(media); });
|
|
25
|
-
this.quoted =
|
|
25
|
+
this.quoted = this.getQuotedTweet(tweet);
|
|
26
26
|
this.fullText = tweet.note_tweet ? tweet.note_tweet.note_tweet_results.result.text : tweet.legacy.full_text;
|
|
27
27
|
this.replyTo = tweet.legacy.in_reply_to_status_id_str;
|
|
28
28
|
this.lang = tweet.legacy.lang;
|
|
@@ -32,10 +32,56 @@ var Tweet = /** @class */ (function () {
|
|
|
32
32
|
this.likeCount = tweet.legacy.favorite_count;
|
|
33
33
|
this.viewCount = tweet.views.count ? parseInt(tweet.views.count) : 0;
|
|
34
34
|
this.bookmarkCount = tweet.legacy.bookmark_count;
|
|
35
|
-
this.retweetedTweet = (
|
|
36
|
-
? new Tweet(tweet.legacy.retweeted_status_result.result)
|
|
37
|
-
: undefined;
|
|
35
|
+
this.retweetedTweet = this.getRetweetedTweet(tweet);
|
|
38
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Extract and deserialize the original quoted tweet from the given raw tweet.
|
|
39
|
+
*
|
|
40
|
+
* @param tweet - The raw tweet.
|
|
41
|
+
*
|
|
42
|
+
* @returns - The deserialized original quoted tweet.
|
|
43
|
+
*/
|
|
44
|
+
Tweet.prototype.getQuotedTweet = function (tweet) {
|
|
45
|
+
var _a, _b, _c, _d, _e, _f;
|
|
46
|
+
// If tweet with limited visibility
|
|
47
|
+
if (tweet.quoted_status_result &&
|
|
48
|
+
((_b = (_a = tweet.quoted_status_result) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.__typename) == 'TweetWithVisibilityResults' &&
|
|
49
|
+
((_d = (_c = tweet.quoted_status_result.result) === null || _c === void 0 ? void 0 : _c.tweet) === null || _d === void 0 ? void 0 : _d.legacy)) {
|
|
50
|
+
return new Tweet(tweet.quoted_status_result.result.tweet);
|
|
51
|
+
}
|
|
52
|
+
// If normal tweet
|
|
53
|
+
else if ((_f = (_e = tweet.quoted_status_result) === null || _e === void 0 ? void 0 : _e.result) === null || _f === void 0 ? void 0 : _f.rest_id) {
|
|
54
|
+
return new Tweet(tweet.quoted_status_result.result);
|
|
55
|
+
}
|
|
56
|
+
// Else, skip
|
|
57
|
+
else {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Extract and deserialize the original retweeted tweet from the given raw tweet.
|
|
63
|
+
*
|
|
64
|
+
* @param tweet - The raw tweet.
|
|
65
|
+
*
|
|
66
|
+
* @returns - The deserialized original retweeted tweet.
|
|
67
|
+
*/
|
|
68
|
+
Tweet.prototype.getRetweetedTweet = function (tweet) {
|
|
69
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
70
|
+
// If retweet with limited visibility
|
|
71
|
+
if (((_a = tweet.legacy) === null || _a === void 0 ? void 0 : _a.retweeted_status_result) &&
|
|
72
|
+
((_d = (_c = (_b = tweet.legacy) === null || _b === void 0 ? void 0 : _b.retweeted_status_result) === null || _c === void 0 ? void 0 : _c.result) === null || _d === void 0 ? void 0 : _d.__typename) == 'TweetWithVisibilityResults' &&
|
|
73
|
+
((_h = (_g = (_f = (_e = tweet.legacy) === null || _e === void 0 ? void 0 : _e.retweeted_status_result) === null || _f === void 0 ? void 0 : _f.result) === null || _g === void 0 ? void 0 : _g.tweet) === null || _h === void 0 ? void 0 : _h.legacy)) {
|
|
74
|
+
return new Tweet(tweet.legacy.retweeted_status_result.result.tweet);
|
|
75
|
+
}
|
|
76
|
+
// If normal tweet
|
|
77
|
+
else if ((_l = (_k = (_j = tweet.legacy) === null || _j === void 0 ? void 0 : _j.retweeted_status_result) === null || _k === void 0 ? void 0 : _k.result) === null || _l === void 0 ? void 0 : _l.rest_id) {
|
|
78
|
+
return new Tweet(tweet.legacy.retweeted_status_result.result);
|
|
79
|
+
}
|
|
80
|
+
// Else, skip
|
|
81
|
+
else {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
39
85
|
/**
|
|
40
86
|
* Extracts and deserializes the list of tweets from the given raw response data.
|
|
41
87
|
*
|
|
@@ -46,18 +92,26 @@ var Tweet = /** @class */ (function () {
|
|
|
46
92
|
* @internal
|
|
47
93
|
*/
|
|
48
94
|
Tweet.list = function (response) {
|
|
49
|
-
var _a, _b;
|
|
95
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
50
96
|
var tweets = [];
|
|
51
97
|
// Extracting the matching data
|
|
52
98
|
var extract = (0, JsonUtils_1.findByFilter)(response, '__typename', 'TimelineTweet');
|
|
53
99
|
// Deserializing valid data
|
|
54
100
|
for (var _i = 0, extract_1 = extract; _i < extract_1.length; _i++) {
|
|
55
101
|
var item = extract_1[_i];
|
|
56
|
-
|
|
102
|
+
// If tweet with limited visibility
|
|
103
|
+
if (((_a = item.tweet_results) === null || _a === void 0 ? void 0 : _a.result) &&
|
|
104
|
+
((_c = (_b = item.tweet_results) === null || _b === void 0 ? void 0 : _b.result) === null || _c === void 0 ? void 0 : _c.__typename) == 'TweetWithVisibilityResults' &&
|
|
105
|
+
((_f = (_e = (_d = item.tweet_results) === null || _d === void 0 ? void 0 : _d.result) === null || _e === void 0 ? void 0 : _e.tweet) === null || _f === void 0 ? void 0 : _f.legacy)) {
|
|
106
|
+
tweets.push(new Tweet(item.tweet_results.result.tweet));
|
|
107
|
+
}
|
|
108
|
+
// If normal tweet
|
|
109
|
+
else if ((_h = (_g = item.tweet_results) === null || _g === void 0 ? void 0 : _g.result) === null || _h === void 0 ? void 0 : _h.legacy) {
|
|
57
110
|
// Logging
|
|
58
111
|
LogService_1.LogService.log(Logging_1.ELogActions.DESERIALIZE, { id: item.tweet_results.result.rest_id });
|
|
59
112
|
tweets.push(new Tweet(item.tweet_results.result));
|
|
60
113
|
}
|
|
114
|
+
// If invalid/unrecognized tweet
|
|
61
115
|
else {
|
|
62
116
|
// Logging
|
|
63
117
|
LogService_1.LogService.log(Logging_1.ELogActions.WARNING, {
|
|
@@ -169,6 +223,7 @@ var TweetMedia = /** @class */ (function () {
|
|
|
169
223
|
}
|
|
170
224
|
// If the media is a video
|
|
171
225
|
else {
|
|
226
|
+
this.thumbnailUrl = media.media_url_https;
|
|
172
227
|
/** The highest bitrate of all variants. */
|
|
173
228
|
var highestRate_1 = 0;
|
|
174
229
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tweet.js","sourceRoot":"","sources":["../../../src/models/data/Tweet.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Tweet.js","sourceRoot":"","sources":["../../../src/models/data/Tweet.ts"],"names":[],"mappings":";;;AAAA,6CAQsB;AAEtB,+CAAkD;AAClD,oDAAsD;AAEtD,iEAAgE;AAEhE,+BAA8B;AAE9B;;;;GAIG;AACH;IAiDC;;OAEG;IACH,eAAmB,KAAgB;;QAClC,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,WAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACxD,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,CAAC,KAAK,GAAG,MAAA,MAAA,KAAK,CAAC,MAAM,CAAC,iBAAiB,0CAAE,KAAK,0CAAE,GAAG,CAAC,UAAC,KAAK,IAAK,OAAA,IAAI,UAAU,CAAC,KAAK,CAAC,EAArB,CAAqB,CAAC,CAAC;QAC1F,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC;QAC5G,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,yBAAyB,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,UA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;SACD;IACF,CAAC;IACF,oBAAC;AAAD,CAAC,AAnCD,IAmCC;AAnCY,sCAAa;AAqC1B;;;;GAIG;AACH;IAUC;;OAEG;IACH,oBAAmB,KAAwB;QAA3C,iBA4BC;;QAlCD,mCAAmC;QAC5B,QAAG,GAAW,EAAE,CAAC;QAMvB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QAEvB,0BAA0B;QAC1B,IAAI,KAAK,CAAC,IAAI,IAAI,yBAAU,CAAC,KAAK,EAAE;YACnC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,eAAe,CAAC;SACjC;QACD,wBAAwB;aACnB,IAAI,KAAK,CAAC,IAAI,IAAI,yBAAU,CAAC,GAAG,EAAE;YACtC,IAAI,CAAC,GAAG,GAAG,MAAA,KAAK,CAAC,UAAU,0CAAE,QAAQ,CAAC,CAAC,EAAE,GAAa,CAAC;SACvD;QACD,0BAA0B;aACrB;YACJ,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,eAAe,CAAC;YAE1C,2CAA2C;YAC3C,IAAI,aAAW,GAAW,CAAC,CAAC;YAE5B;;eAEG;YACH,MAAA,KAAK,CAAC,UAAU,0CAAE,QAAQ,CAAC,OAAO,CAAC,UAAC,OAAO;gBAC1C,IAAI,OAAO,CAAC,OAAO,GAAG,aAAW,EAAE;oBAClC,aAAW,GAAG,OAAO,CAAC,OAAO,CAAC;oBAC9B,KAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;iBACvB;YACF,CAAC,CAAC,CAAC;SACH;IACF,CAAC;IACF,iBAAC;AAAD,CAAC,AA1CD,IA0CC;AA1CY,gCAAU"}
|
package/dist/models/data/User.js
CHANGED
|
@@ -77,7 +77,7 @@ var User = /** @class */ (function () {
|
|
|
77
77
|
// Deserializing valid data
|
|
78
78
|
for (var _i = 0, extract_2 = extract; _i < extract_2.length; _i++) {
|
|
79
79
|
var item = extract_2[_i];
|
|
80
|
-
if (item.legacy) {
|
|
80
|
+
if (item.legacy && item.legacy.created_at) {
|
|
81
81
|
// Logging
|
|
82
82
|
LogService_1.LogService.log(Logging_1.ELogActions.DESERIALIZE, { id: item.rest_id });
|
|
83
83
|
users.push(new User(item));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../src/models/data/User.ts"],"names":[],"mappings":";;;AAEA,+CAAkD;AAClD,oDAAsD;AACtD,iEAAgE;AAEhE;;;;GAIG;AACH;IA2CC;;OAEG;IACH,cAAmB,IAAc;QAChC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;QACxF,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC;QACxC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;QAClD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;QACjD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;QAChD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QAC/E,IAAI,CAA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CAAC,CAAC;QAEpE,2BAA2B;QAC3B,KAAmB,UAAO,EAAP,mBAAO,EAAP,qBAAO,EAAP,IAAO,EAAE;YAAvB,IAAM,IAAI,gBAAA;YACd,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;gBAC1C,UAAU;gBACV,uBAAU,CAAC,GAAG,CAAC,qBAAW,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;gBAE9D,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;aAC3B;iBAAM;gBACN,UAAU;gBACV,uBAAU,CAAC,GAAG,CAAC,qBAAW,CAAC,OAAO,EAAE;oBACnC,MAAM,EAAE,qBAAW,CAAC,WAAW;oBAC/B,OAAO,EAAE,0BAA0B;iBACnC,CAAC,CAAC;aACH;SACD;QAED,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5C,CAAC;IACF,WAAC;AAAD,CAAC,AAlID,IAkIC;AAlIY,oBAAI"}
|
|
@@ -102,7 +102,7 @@ var AuthService = /** @class */ (function (_super) {
|
|
|
102
102
|
// Getting the cookie string from the API key
|
|
103
103
|
var cookieString = AuthService.decodeCookie(apiKey);
|
|
104
104
|
// Searching for the user id in the cookie string
|
|
105
|
-
var searchResults = cookieString.match(/((?<=twid="u=)(
|
|
105
|
+
var searchResults = cookieString.match(/((?<=twid="u=)(\d+)(?="))|((?<=twid=u%3D)(\d+)(?=;))/);
|
|
106
106
|
// If user id was found
|
|
107
107
|
if (searchResults) {
|
|
108
108
|
return searchResults[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthService.js","sourceRoot":"","sources":["../../../src/services/public/AuthService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CACA,SAIE,CACF,CAAC,QAAQ,EAAE,CAAC,MAAiB,mCAAI,EAAE;wBAErC,8CAA8C;wBAC9C,MAAM,GAAG,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;wBAE1C,sBAAO,MAAM,EAAC;;;;KACd;IACF,kBAAC;AAAD,CAAC,AAzID,CAAiC,+BAAc,GAyI9C;AAzIY,kCAAW"}
|
|
@@ -9,15 +9,15 @@ import { IRettiwtConfig } from '../../types/RettiwtConfig';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class FetcherService {
|
|
11
11
|
/** The api key to use for authenticating against Twitter API as user. */
|
|
12
|
-
private readonly
|
|
12
|
+
private readonly _apiKey?;
|
|
13
13
|
/** The service used to handle HTTP and API errors */
|
|
14
|
-
private readonly
|
|
14
|
+
private readonly _errorHandler;
|
|
15
15
|
/** The guest key to use for authenticating against Twitter API as guest. */
|
|
16
|
-
private readonly
|
|
16
|
+
private readonly _guestKey?;
|
|
17
17
|
/** The URL To the proxy server to use for all others. */
|
|
18
|
-
private readonly
|
|
18
|
+
private readonly _proxyUrl?;
|
|
19
19
|
/** The max wait time for a response. */
|
|
20
|
-
private readonly
|
|
20
|
+
private readonly _timeout;
|
|
21
21
|
/** The URL to the proxy server to use only for authentication. */
|
|
22
22
|
protected readonly authProxyUrl?: URL;
|
|
23
23
|
/** The id of the authenticated user (if any). */
|
|
@@ -76,13 +76,13 @@ var FetcherService = /** @class */ (function () {
|
|
|
76
76
|
function FetcherService(config) {
|
|
77
77
|
var _a, _b, _c, _d;
|
|
78
78
|
LogService_1.LogService.enabled = (_a = config === null || config === void 0 ? void 0 : config.logging) !== null && _a !== void 0 ? _a : false;
|
|
79
|
-
this.
|
|
80
|
-
this.
|
|
79
|
+
this._apiKey = config === null || config === void 0 ? void 0 : config.apiKey;
|
|
80
|
+
this._guestKey = config === null || config === void 0 ? void 0 : config.guestKey;
|
|
81
81
|
this.userId = (config === null || config === void 0 ? void 0 : config.apiKey) ? AuthService_1.AuthService.getUserId(config.apiKey) : undefined;
|
|
82
82
|
this.authProxyUrl = (_b = config === null || config === void 0 ? void 0 : config.authProxyUrl) !== null && _b !== void 0 ? _b : config === null || config === void 0 ? void 0 : config.proxyUrl;
|
|
83
|
-
this.
|
|
84
|
-
this.
|
|
85
|
-
this.
|
|
83
|
+
this._proxyUrl = config === null || config === void 0 ? void 0 : config.proxyUrl;
|
|
84
|
+
this._timeout = (_c = config === null || config === void 0 ? void 0 : config.timeout) !== null && _c !== void 0 ? _c : 0;
|
|
85
|
+
this._errorHandler = (_d = config === null || config === void 0 ? void 0 : config.errorHandler) !== null && _d !== void 0 ? _d : new ErrorService_1.ErrorService();
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Checks the authorization status based on the requested resource.
|
|
@@ -109,15 +109,15 @@ var FetcherService = /** @class */ (function () {
|
|
|
109
109
|
return __generator(this, function (_a) {
|
|
110
110
|
switch (_a.label) {
|
|
111
111
|
case 0:
|
|
112
|
-
if (!this.
|
|
112
|
+
if (!this._apiKey) return [3 /*break*/, 1];
|
|
113
113
|
// Logging
|
|
114
114
|
LogService_1.LogService.log(Logging_1.ELogActions.GET, { target: 'USER_CREDENTIAL' });
|
|
115
|
-
return [2 /*return*/, new rettiwt_auth_1.AuthCredential(AuthService_1.AuthService.decodeCookie(this.
|
|
115
|
+
return [2 /*return*/, new rettiwt_auth_1.AuthCredential(AuthService_1.AuthService.decodeCookie(this._apiKey).split(';'))];
|
|
116
116
|
case 1:
|
|
117
|
-
if (!this.
|
|
117
|
+
if (!this._guestKey) return [3 /*break*/, 2];
|
|
118
118
|
// Logging
|
|
119
119
|
LogService_1.LogService.log(Logging_1.ELogActions.GET, { target: 'GUEST_CREDENTIAL' });
|
|
120
|
-
return [2 /*return*/, new rettiwt_auth_1.AuthCredential(undefined, this.
|
|
120
|
+
return [2 /*return*/, new rettiwt_auth_1.AuthCredential(undefined, this._guestKey)];
|
|
121
121
|
case 2:
|
|
122
122
|
// Logging
|
|
123
123
|
LogService_1.LogService.log(Logging_1.ELogActions.GET, { target: 'NEW_GUEST_CREDENTIAL' });
|
|
@@ -206,7 +206,7 @@ var FetcherService = /** @class */ (function () {
|
|
|
206
206
|
this.checkAuthorization(resource);
|
|
207
207
|
// Validating args
|
|
208
208
|
args = this.validateArgs(resource, args);
|
|
209
|
-
httpsAgent = this.getHttpsAgent(this.
|
|
209
|
+
httpsAgent = this.getHttpsAgent(this._proxyUrl);
|
|
210
210
|
return [4 /*yield*/, this.getCredential()];
|
|
211
211
|
case 1:
|
|
212
212
|
cred = _a.sent();
|
|
@@ -215,7 +215,7 @@ var FetcherService = /** @class */ (function () {
|
|
|
215
215
|
config.headers = __assign(__assign({}, config.headers), cred.toHeader());
|
|
216
216
|
config.httpAgent = httpsAgent;
|
|
217
217
|
config.httpsAgent = httpsAgent;
|
|
218
|
-
config.timeout = this.
|
|
218
|
+
config.timeout = this._timeout;
|
|
219
219
|
_a.label = 2;
|
|
220
220
|
case 2:
|
|
221
221
|
_a.trys.push([2, 4, , 5]);
|
|
@@ -226,7 +226,7 @@ var FetcherService = /** @class */ (function () {
|
|
|
226
226
|
case 4:
|
|
227
227
|
error_1 = _a.sent();
|
|
228
228
|
// If error, delegate handling to error handler
|
|
229
|
-
this.
|
|
229
|
+
this._errorHandler.handle(error_1);
|
|
230
230
|
throw error_1;
|
|
231
231
|
case 5: return [2 /*return*/];
|
|
232
232
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../../src/services/public/FetcherService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAqC;AAErC,gDAA0B;AAC1B,uDAAoD;AACpD,6CAAoD;AAEpD,mDAAmG;AACnG,uDAAsD;AACtD,uCAA6C;AAC7C,+CAAkD;AAElD,yDAAwD;AACxD,uDAAsD;AAItD,yDAAwD;AACxD,qDAAoD;AAEpD,6CAA4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../../models/data/User';
|
|
4
|
+
import { IRettiwtConfig } from '../../types/RettiwtConfig';
|
|
5
|
+
import { FetcherService } from './FetcherService';
|
|
6
|
+
export declare class ListService extends FetcherService {
|
|
7
|
+
/**
|
|
8
|
+
* @param config - The config object for configuring the Rettiwt instance.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
constructor(config?: IRettiwtConfig);
|
|
13
|
+
/**
|
|
14
|
+
* Get the list of members of a tweet list.
|
|
15
|
+
*
|
|
16
|
+
* @param id - The id of target list.
|
|
17
|
+
* @param count - The number of members to fetch, must be \<= 100.
|
|
18
|
+
* @param cursor - The cursor to the batch of members to fetch.
|
|
19
|
+
*
|
|
20
|
+
* @returns The list tweets in the given list.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```
|
|
24
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
25
|
+
*
|
|
26
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
27
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
28
|
+
*
|
|
29
|
+
* // Fetching the first 100 members of the Twitter list with id '1234567890'
|
|
30
|
+
* rettiwt.list.members('1234567890')
|
|
31
|
+
* .then(res => {
|
|
32
|
+
* console.log(res);
|
|
33
|
+
* })
|
|
34
|
+
* .catch(err => {
|
|
35
|
+
* console.log(err);
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
|
|
40
|
+
*/
|
|
41
|
+
members(id: string, count?: number, cursor?: string): Promise<CursoredData<User>>;
|
|
42
|
+
/**
|
|
43
|
+
* Get the list of tweets from a tweet list.
|
|
44
|
+
*
|
|
45
|
+
* @param id - The id of target list.
|
|
46
|
+
* @param count - The number of tweets to fetch, must be \<= 100.
|
|
47
|
+
* @param cursor - The cursor to the batch of tweets to fetch.
|
|
48
|
+
*
|
|
49
|
+
* @returns The list tweets in the given list.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```
|
|
53
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
54
|
+
*
|
|
55
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
56
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
57
|
+
*
|
|
58
|
+
* // Fetching the most recent 100 tweets of the Twitter list with id '1234567890'
|
|
59
|
+
* rettiwt.list.tweets('1234567890')
|
|
60
|
+
* .then(res => {
|
|
61
|
+
* console.log(res);
|
|
62
|
+
* })
|
|
63
|
+
* .catch(err => {
|
|
64
|
+
* console.log(err);
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
|
|
69
|
+
*/
|
|
70
|
+
tweets(id: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
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.ListService = void 0;
|
|
55
|
+
var Extractors_1 = require("../../collections/Extractors");
|
|
56
|
+
var Resource_1 = require("../../enums/Resource");
|
|
57
|
+
var FetcherService_1 = require("./FetcherService");
|
|
58
|
+
var ListService = /** @class */ (function (_super) {
|
|
59
|
+
__extends(ListService, _super);
|
|
60
|
+
/**
|
|
61
|
+
* @param config - The config object for configuring the Rettiwt instance.
|
|
62
|
+
*
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
function ListService(config) {
|
|
66
|
+
return _super.call(this, config) || this;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the list of members of a tweet list.
|
|
70
|
+
*
|
|
71
|
+
* @param id - The id of target list.
|
|
72
|
+
* @param count - The number of members to fetch, must be \<= 100.
|
|
73
|
+
* @param cursor - The cursor to the batch of members to fetch.
|
|
74
|
+
*
|
|
75
|
+
* @returns The list tweets in the given list.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```
|
|
79
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
80
|
+
*
|
|
81
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
82
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
83
|
+
*
|
|
84
|
+
* // Fetching the first 100 members of the Twitter list with id '1234567890'
|
|
85
|
+
* rettiwt.list.members('1234567890')
|
|
86
|
+
* .then(res => {
|
|
87
|
+
* console.log(res);
|
|
88
|
+
* })
|
|
89
|
+
* .catch(err => {
|
|
90
|
+
* console.log(err);
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
|
|
95
|
+
*/
|
|
96
|
+
ListService.prototype.members = function (id, count, cursor) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
+
var resource, response, data;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0:
|
|
102
|
+
resource = Resource_1.EResourceType.LIST_MEMBERS;
|
|
103
|
+
return [4 /*yield*/, this.request(resource, {
|
|
104
|
+
id: id,
|
|
105
|
+
count: count,
|
|
106
|
+
cursor: cursor,
|
|
107
|
+
})];
|
|
108
|
+
case 1:
|
|
109
|
+
response = _a.sent();
|
|
110
|
+
data = Extractors_1.extractors[resource](response);
|
|
111
|
+
return [2 /*return*/, data];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Get the list of tweets from a tweet list.
|
|
118
|
+
*
|
|
119
|
+
* @param id - The id of target list.
|
|
120
|
+
* @param count - The number of tweets to fetch, must be \<= 100.
|
|
121
|
+
* @param cursor - The cursor to the batch of tweets to fetch.
|
|
122
|
+
*
|
|
123
|
+
* @returns The list tweets in the given list.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```
|
|
127
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
128
|
+
*
|
|
129
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
130
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
131
|
+
*
|
|
132
|
+
* // Fetching the most recent 100 tweets of the Twitter list with id '1234567890'
|
|
133
|
+
* rettiwt.list.tweets('1234567890')
|
|
134
|
+
* .then(res => {
|
|
135
|
+
* console.log(res);
|
|
136
|
+
* })
|
|
137
|
+
* .catch(err => {
|
|
138
|
+
* console.log(err);
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
|
|
143
|
+
*/
|
|
144
|
+
ListService.prototype.tweets = function (id, count, cursor) {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
146
|
+
var resource, response, data;
|
|
147
|
+
return __generator(this, function (_a) {
|
|
148
|
+
switch (_a.label) {
|
|
149
|
+
case 0:
|
|
150
|
+
resource = Resource_1.EResourceType.LIST_TWEETS;
|
|
151
|
+
return [4 /*yield*/, this.request(resource, {
|
|
152
|
+
id: id,
|
|
153
|
+
count: count,
|
|
154
|
+
cursor: cursor,
|
|
155
|
+
})];
|
|
156
|
+
case 1:
|
|
157
|
+
response = _a.sent();
|
|
158
|
+
data = Extractors_1.extractors[resource](response);
|
|
159
|
+
// Sorting the tweets by date, from recent to oldest
|
|
160
|
+
data.list.sort(function (a, b) { return new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf(); });
|
|
161
|
+
return [2 /*return*/, data];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
return ListService;
|
|
167
|
+
}(FetcherService_1.FetcherService));
|
|
168
|
+
exports.ListService = ListService;
|
|
169
|
+
//# sourceMappingURL=ListService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListService.js","sourceRoot":"","sources":["../../../src/services/public/ListService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,2DAA0D;AAC1D,iDAAqD;AAMrD,mDAAkD;AAElD;IAAiC,+BAAc;IAC9C;;;;OAIG;IACH,qBAAmB,MAAuB;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16,6 +16,32 @@ export declare class UserService extends FetcherService {
|
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
18
|
constructor(config?: IRettiwtConfig);
|
|
19
|
+
/**
|
|
20
|
+
* Get the list of bookmarks of the logged in user.
|
|
21
|
+
*
|
|
22
|
+
* @param count - The number of bookmakrs to fetch, must be \<= 100.
|
|
23
|
+
* @param cursor - The cursor to the batch of bookmarks to fetch.
|
|
24
|
+
*
|
|
25
|
+
* @returns The list of tweets bookmarked by the target user.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```
|
|
29
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
30
|
+
*
|
|
31
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
32
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
33
|
+
*
|
|
34
|
+
* // Fetching the most recent 100 liked Tweets of the logged in User
|
|
35
|
+
* rettiwt.user.bookmarks()
|
|
36
|
+
* .then(res => {
|
|
37
|
+
* console.log(res);
|
|
38
|
+
* })
|
|
39
|
+
* .catch(err => {
|
|
40
|
+
* console.log(err);
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
bookmarks(count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
19
45
|
/**
|
|
20
46
|
* Get the details of a user.
|
|
21
47
|
*
|
|
@@ -82,6 +82,50 @@ var UserService = /** @class */ (function (_super) {
|
|
|
82
82
|
function UserService(config) {
|
|
83
83
|
return _super.call(this, config) || this;
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the list of bookmarks of the logged in user.
|
|
87
|
+
*
|
|
88
|
+
* @param count - The number of bookmakrs to fetch, must be \<= 100.
|
|
89
|
+
* @param cursor - The cursor to the batch of bookmarks to fetch.
|
|
90
|
+
*
|
|
91
|
+
* @returns The list of tweets bookmarked by the target user.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```
|
|
95
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
96
|
+
*
|
|
97
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
98
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
99
|
+
*
|
|
100
|
+
* // Fetching the most recent 100 liked Tweets of the logged in User
|
|
101
|
+
* rettiwt.user.bookmarks()
|
|
102
|
+
* .then(res => {
|
|
103
|
+
* console.log(res);
|
|
104
|
+
* })
|
|
105
|
+
* .catch(err => {
|
|
106
|
+
* console.log(err);
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
UserService.prototype.bookmarks = function (count, cursor) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
+
var resource, response, data;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
switch (_a.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
resource = Resource_1.EResourceType.USER_BOOKMARKS;
|
|
117
|
+
return [4 /*yield*/, this.request(resource, {
|
|
118
|
+
count: count,
|
|
119
|
+
cursor: cursor,
|
|
120
|
+
})];
|
|
121
|
+
case 1:
|
|
122
|
+
response = _a.sent();
|
|
123
|
+
data = Extractors_1.extractors[resource](response);
|
|
124
|
+
return [2 /*return*/, data];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
};
|
|
85
129
|
/**
|
|
86
130
|
* Get the details of a user.
|
|
87
131
|
*
|