rettiwt-api 4.2.0 → 5.0.0-alpha.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.
|
@@ -29,7 +29,7 @@ export declare class Tweet {
|
|
|
29
29
|
/** The number of replies to the tweet. */
|
|
30
30
|
replyCount: number;
|
|
31
31
|
/** The rest id of the tweet to which the tweet is a reply. */
|
|
32
|
-
replyTo?:
|
|
32
|
+
replyTo?: Tweet;
|
|
33
33
|
/** The number of retweets of the tweet. */
|
|
34
34
|
retweetCount: number;
|
|
35
35
|
/** The tweet which is retweeted in this tweet (if any). */
|
|
@@ -40,12 +40,15 @@ export declare class Tweet {
|
|
|
40
40
|
viewCount: number;
|
|
41
41
|
/**
|
|
42
42
|
* @param tweet - The raw tweet details.
|
|
43
|
+
* @param response - The raw response
|
|
43
44
|
*/
|
|
44
|
-
constructor(tweet: IRawTweet);
|
|
45
|
+
constructor(tweet: IRawTweet, response: NonNullable<unknown>);
|
|
46
|
+
private getParentTweet;
|
|
45
47
|
/**
|
|
46
48
|
* Extract and deserialize the original quoted tweet from the given raw tweet.
|
|
47
49
|
*
|
|
48
50
|
* @param tweet - The raw tweet.
|
|
51
|
+
* @param response - The raw response
|
|
49
52
|
*
|
|
50
53
|
* @returns - The deserialized original quoted tweet.
|
|
51
54
|
*/
|
|
@@ -54,6 +57,7 @@ export declare class Tweet {
|
|
|
54
57
|
* Extract and deserialize the original retweeted tweet from the given raw tweet.
|
|
55
58
|
*
|
|
56
59
|
* @param tweet - The raw tweet.
|
|
60
|
+
* @param response - The raw response
|
|
57
61
|
*
|
|
58
62
|
* @returns - The deserialized original retweeted tweet.
|
|
59
63
|
*/
|
|
@@ -14,17 +14,18 @@ var User_1 = require("./User");
|
|
|
14
14
|
var Tweet = /** @class */ (function () {
|
|
15
15
|
/**
|
|
16
16
|
* @param tweet - The raw tweet details.
|
|
17
|
+
* @param response - The raw response
|
|
17
18
|
*/
|
|
18
|
-
function Tweet(tweet) {
|
|
19
|
+
function Tweet(tweet, response) {
|
|
19
20
|
var _a, _b;
|
|
20
21
|
this.id = tweet.rest_id;
|
|
21
22
|
this.createdAt = tweet.legacy.created_at;
|
|
22
23
|
this.tweetBy = new User_1.User(tweet.core.user_results.result);
|
|
23
24
|
this.entities = new TweetEntities(tweet.legacy.entities);
|
|
24
25
|
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 = this.getQuotedTweet(tweet);
|
|
26
|
+
this.quoted = this.getQuotedTweet(tweet, response);
|
|
26
27
|
this.fullText = tweet.note_tweet ? tweet.note_tweet.note_tweet_results.result.text : tweet.legacy.full_text;
|
|
27
|
-
this.replyTo = tweet
|
|
28
|
+
this.replyTo = this.getParentTweet(tweet, response);
|
|
28
29
|
this.lang = tweet.legacy.lang;
|
|
29
30
|
this.quoteCount = tweet.legacy.quote_count;
|
|
30
31
|
this.replyCount = tweet.legacy.reply_count;
|
|
@@ -32,26 +33,38 @@ var Tweet = /** @class */ (function () {
|
|
|
32
33
|
this.likeCount = tweet.legacy.favorite_count;
|
|
33
34
|
this.viewCount = tweet.views.count ? parseInt(tweet.views.count) : 0;
|
|
34
35
|
this.bookmarkCount = tweet.legacy.bookmark_count;
|
|
35
|
-
this.retweetedTweet = this.getRetweetedTweet(tweet);
|
|
36
|
+
this.retweetedTweet = this.getRetweetedTweet(tweet, response);
|
|
36
37
|
}
|
|
38
|
+
Tweet.prototype.getParentTweet = function (tweet, response) {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
// Getting parent tweet ID, if any
|
|
41
|
+
var parentTweetId = (_b = (_a = tweet.legacy) === null || _a === void 0 ? void 0 : _a.in_reply_to_status_id_str) !== null && _b !== void 0 ? _b : '';
|
|
42
|
+
// If no parent tweet
|
|
43
|
+
if (parentTweetId.length == 0) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// Getting the details of parent tweet
|
|
47
|
+
return Tweet.single(response, parentTweetId);
|
|
48
|
+
};
|
|
37
49
|
/**
|
|
38
50
|
* Extract and deserialize the original quoted tweet from the given raw tweet.
|
|
39
51
|
*
|
|
40
52
|
* @param tweet - The raw tweet.
|
|
53
|
+
* @param response - The raw response
|
|
41
54
|
*
|
|
42
55
|
* @returns - The deserialized original quoted tweet.
|
|
43
56
|
*/
|
|
44
|
-
Tweet.prototype.getQuotedTweet = function (tweet) {
|
|
57
|
+
Tweet.prototype.getQuotedTweet = function (tweet, response) {
|
|
45
58
|
var _a, _b, _c, _d, _e, _f;
|
|
46
59
|
// If tweet with limited visibility
|
|
47
60
|
if (tweet.quoted_status_result &&
|
|
48
61
|
((_b = (_a = tweet.quoted_status_result) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.__typename) == 'TweetWithVisibilityResults' &&
|
|
49
62
|
((_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);
|
|
63
|
+
return new Tweet(tweet.quoted_status_result.result.tweet, response);
|
|
51
64
|
}
|
|
52
65
|
// If normal tweet
|
|
53
66
|
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);
|
|
67
|
+
return new Tweet(tweet.quoted_status_result.result, response);
|
|
55
68
|
}
|
|
56
69
|
// Else, skip
|
|
57
70
|
else {
|
|
@@ -62,20 +75,21 @@ var Tweet = /** @class */ (function () {
|
|
|
62
75
|
* Extract and deserialize the original retweeted tweet from the given raw tweet.
|
|
63
76
|
*
|
|
64
77
|
* @param tweet - The raw tweet.
|
|
78
|
+
* @param response - The raw response
|
|
65
79
|
*
|
|
66
80
|
* @returns - The deserialized original retweeted tweet.
|
|
67
81
|
*/
|
|
68
|
-
Tweet.prototype.getRetweetedTweet = function (tweet) {
|
|
82
|
+
Tweet.prototype.getRetweetedTweet = function (tweet, response) {
|
|
69
83
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
70
84
|
// If retweet with limited visibility
|
|
71
85
|
if (((_a = tweet.legacy) === null || _a === void 0 ? void 0 : _a.retweeted_status_result) &&
|
|
72
86
|
((_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
87
|
((_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);
|
|
88
|
+
return new Tweet(tweet.legacy.retweeted_status_result.result.tweet, response);
|
|
75
89
|
}
|
|
76
90
|
// If normal tweet
|
|
77
91
|
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);
|
|
92
|
+
return new Tweet(tweet.legacy.retweeted_status_result.result, response);
|
|
79
93
|
}
|
|
80
94
|
// Else, skip
|
|
81
95
|
else {
|
|
@@ -103,13 +117,13 @@ var Tweet = /** @class */ (function () {
|
|
|
103
117
|
if (((_a = item.tweet_results) === null || _a === void 0 ? void 0 : _a.result) &&
|
|
104
118
|
((_c = (_b = item.tweet_results) === null || _b === void 0 ? void 0 : _b.result) === null || _c === void 0 ? void 0 : _c.__typename) == 'TweetWithVisibilityResults' &&
|
|
105
119
|
((_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));
|
|
120
|
+
tweets.push(new Tweet(item.tweet_results.result.tweet, response));
|
|
107
121
|
}
|
|
108
122
|
// If normal tweet
|
|
109
123
|
else if ((_h = (_g = item.tweet_results) === null || _g === void 0 ? void 0 : _g.result) === null || _h === void 0 ? void 0 : _h.legacy) {
|
|
110
124
|
// Logging
|
|
111
125
|
LogService_1.LogService.log(Logging_1.ELogActions.DESERIALIZE, { id: item.tweet_results.result.rest_id });
|
|
112
|
-
tweets.push(new Tweet(item.tweet_results.result));
|
|
126
|
+
tweets.push(new Tweet(item.tweet_results.result, response));
|
|
113
127
|
}
|
|
114
128
|
// If invalid/unrecognized tweet
|
|
115
129
|
else {
|
|
@@ -142,7 +156,7 @@ var Tweet = /** @class */ (function () {
|
|
|
142
156
|
if (item.legacy) {
|
|
143
157
|
// Logging
|
|
144
158
|
LogService_1.LogService.log(Logging_1.ELogActions.DESERIALIZE, { id: item.rest_id });
|
|
145
|
-
tweets.push(new Tweet(item));
|
|
159
|
+
tweets.push(new Tweet(item, response));
|
|
146
160
|
}
|
|
147
161
|
else {
|
|
148
162
|
// Logging
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;OAGG;IACH,eAAmB,KAAgB,EAAE,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/data/Tweet.ts
CHANGED
|
@@ -55,7 +55,7 @@ export class Tweet {
|
|
|
55
55
|
public replyCount: number;
|
|
56
56
|
|
|
57
57
|
/** The rest id of the tweet to which the tweet is a reply. */
|
|
58
|
-
public replyTo?:
|
|
58
|
+
public replyTo?: Tweet;
|
|
59
59
|
|
|
60
60
|
/** The number of retweets of the tweet. */
|
|
61
61
|
public retweetCount: number;
|
|
@@ -71,16 +71,17 @@ export class Tweet {
|
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* @param tweet - The raw tweet details.
|
|
74
|
+
* @param response - The raw response
|
|
74
75
|
*/
|
|
75
|
-
public constructor(tweet: IRawTweet) {
|
|
76
|
+
public constructor(tweet: IRawTweet, response: NonNullable<unknown>) {
|
|
76
77
|
this.id = tweet.rest_id;
|
|
77
78
|
this.createdAt = tweet.legacy.created_at;
|
|
78
79
|
this.tweetBy = new User(tweet.core.user_results.result);
|
|
79
80
|
this.entities = new TweetEntities(tweet.legacy.entities);
|
|
80
81
|
this.media = tweet.legacy.extended_entities?.media?.map((media) => new TweetMedia(media));
|
|
81
|
-
this.quoted = this.getQuotedTweet(tweet);
|
|
82
|
+
this.quoted = this.getQuotedTweet(tweet, response);
|
|
82
83
|
this.fullText = tweet.note_tweet ? tweet.note_tweet.note_tweet_results.result.text : tweet.legacy.full_text;
|
|
83
|
-
this.replyTo = tweet
|
|
84
|
+
this.replyTo = this.getParentTweet(tweet, response);
|
|
84
85
|
this.lang = tweet.legacy.lang;
|
|
85
86
|
this.quoteCount = tweet.legacy.quote_count;
|
|
86
87
|
this.replyCount = tweet.legacy.reply_count;
|
|
@@ -88,28 +89,42 @@ export class Tweet {
|
|
|
88
89
|
this.likeCount = tweet.legacy.favorite_count;
|
|
89
90
|
this.viewCount = tweet.views.count ? parseInt(tweet.views.count) : 0;
|
|
90
91
|
this.bookmarkCount = tweet.legacy.bookmark_count;
|
|
91
|
-
this.retweetedTweet = this.getRetweetedTweet(tweet);
|
|
92
|
+
this.retweetedTweet = this.getRetweetedTweet(tweet, response);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private getParentTweet(tweet: IRawTweet, response: NonNullable<unknown>): Tweet | undefined {
|
|
96
|
+
// Getting parent tweet ID, if any
|
|
97
|
+
const parentTweetId: string = tweet.legacy?.in_reply_to_status_id_str ?? '';
|
|
98
|
+
|
|
99
|
+
// If no parent tweet
|
|
100
|
+
if (parentTweetId.length == 0) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Getting the details of parent tweet
|
|
105
|
+
return Tweet.single(response, parentTweetId);
|
|
92
106
|
}
|
|
93
107
|
|
|
94
108
|
/**
|
|
95
109
|
* Extract and deserialize the original quoted tweet from the given raw tweet.
|
|
96
110
|
*
|
|
97
111
|
* @param tweet - The raw tweet.
|
|
112
|
+
* @param response - The raw response
|
|
98
113
|
*
|
|
99
114
|
* @returns - The deserialized original quoted tweet.
|
|
100
115
|
*/
|
|
101
|
-
private getQuotedTweet(tweet: IRawTweet): Tweet | undefined {
|
|
116
|
+
private getQuotedTweet(tweet: IRawTweet, response: NonNullable<unknown>): Tweet | undefined {
|
|
102
117
|
// If tweet with limited visibility
|
|
103
118
|
if (
|
|
104
119
|
tweet.quoted_status_result &&
|
|
105
120
|
tweet.quoted_status_result?.result?.__typename == 'TweetWithVisibilityResults' &&
|
|
106
121
|
(tweet.quoted_status_result.result as ILimitedVisibilityTweet)?.tweet?.legacy
|
|
107
122
|
) {
|
|
108
|
-
return new Tweet((tweet.quoted_status_result.result as ILimitedVisibilityTweet).tweet);
|
|
123
|
+
return new Tweet((tweet.quoted_status_result.result as ILimitedVisibilityTweet).tweet, response);
|
|
109
124
|
}
|
|
110
125
|
// If normal tweet
|
|
111
126
|
else if ((tweet.quoted_status_result?.result as ITweet)?.rest_id) {
|
|
112
|
-
return new Tweet(tweet.quoted_status_result.result as ITweet);
|
|
127
|
+
return new Tweet(tweet.quoted_status_result.result as ITweet, response);
|
|
113
128
|
}
|
|
114
129
|
// Else, skip
|
|
115
130
|
else {
|
|
@@ -121,21 +136,22 @@ export class Tweet {
|
|
|
121
136
|
* Extract and deserialize the original retweeted tweet from the given raw tweet.
|
|
122
137
|
*
|
|
123
138
|
* @param tweet - The raw tweet.
|
|
139
|
+
* @param response - The raw response
|
|
124
140
|
*
|
|
125
141
|
* @returns - The deserialized original retweeted tweet.
|
|
126
142
|
*/
|
|
127
|
-
private getRetweetedTweet(tweet: IRawTweet): Tweet | undefined {
|
|
143
|
+
private getRetweetedTweet(tweet: IRawTweet, response: NonNullable<unknown>): Tweet | undefined {
|
|
128
144
|
// If retweet with limited visibility
|
|
129
145
|
if (
|
|
130
146
|
tweet.legacy?.retweeted_status_result &&
|
|
131
147
|
tweet.legacy?.retweeted_status_result?.result?.__typename == 'TweetWithVisibilityResults' &&
|
|
132
148
|
(tweet.legacy?.retweeted_status_result?.result as ILimitedVisibilityTweet)?.tweet?.legacy
|
|
133
149
|
) {
|
|
134
|
-
return new Tweet((tweet.legacy.retweeted_status_result.result as ILimitedVisibilityTweet).tweet);
|
|
150
|
+
return new Tweet((tweet.legacy.retweeted_status_result.result as ILimitedVisibilityTweet).tweet, response);
|
|
135
151
|
}
|
|
136
152
|
// If normal tweet
|
|
137
153
|
else if ((tweet.legacy?.retweeted_status_result?.result as ITweet)?.rest_id) {
|
|
138
|
-
return new Tweet(tweet.legacy.retweeted_status_result.result as ITweet);
|
|
154
|
+
return new Tweet(tweet.legacy.retweeted_status_result.result as ITweet, response);
|
|
139
155
|
}
|
|
140
156
|
// Else, skip
|
|
141
157
|
else {
|
|
@@ -166,14 +182,14 @@ export class Tweet {
|
|
|
166
182
|
item.tweet_results?.result?.__typename == 'TweetWithVisibilityResults' &&
|
|
167
183
|
(item.tweet_results?.result as ILimitedVisibilityTweet)?.tweet?.legacy
|
|
168
184
|
) {
|
|
169
|
-
tweets.push(new Tweet((item.tweet_results.result as ILimitedVisibilityTweet).tweet));
|
|
185
|
+
tweets.push(new Tweet((item.tweet_results.result as ILimitedVisibilityTweet).tweet, response));
|
|
170
186
|
}
|
|
171
187
|
// If normal tweet
|
|
172
188
|
else if ((item.tweet_results?.result as ITweet)?.legacy) {
|
|
173
189
|
// Logging
|
|
174
190
|
LogService.log(ELogActions.DESERIALIZE, { id: (item.tweet_results.result as ITweet).rest_id });
|
|
175
191
|
|
|
176
|
-
tweets.push(new Tweet(item.tweet_results.result as ITweet));
|
|
192
|
+
tweets.push(new Tweet(item.tweet_results.result as ITweet, response));
|
|
177
193
|
}
|
|
178
194
|
// If invalid/unrecognized tweet
|
|
179
195
|
else {
|
|
@@ -210,7 +226,7 @@ export class Tweet {
|
|
|
210
226
|
// Logging
|
|
211
227
|
LogService.log(ELogActions.DESERIALIZE, { id: item.rest_id });
|
|
212
228
|
|
|
213
|
-
tweets.push(new Tweet(item));
|
|
229
|
+
tweets.push(new Tweet(item, response));
|
|
214
230
|
} else {
|
|
215
231
|
// Logging
|
|
216
232
|
LogService.log(ELogActions.WARNING, {
|