rettiwt-api 4.1.1 → 4.1.3
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.
|
@@ -42,6 +42,22 @@ export declare class Tweet {
|
|
|
42
42
|
* @param tweet - The raw tweet details.
|
|
43
43
|
*/
|
|
44
44
|
constructor(tweet: IRawTweet);
|
|
45
|
+
/**
|
|
46
|
+
* Extract and deserialize the original quoted tweet from the given raw tweet.
|
|
47
|
+
*
|
|
48
|
+
* @param tweet - The raw tweet.
|
|
49
|
+
*
|
|
50
|
+
* @returns - The deserialized original quoted tweet.
|
|
51
|
+
*/
|
|
52
|
+
private getQuotedTweet;
|
|
53
|
+
/**
|
|
54
|
+
* Extract and deserialize the original retweeted tweet from the given raw tweet.
|
|
55
|
+
*
|
|
56
|
+
* @param tweet - The raw tweet.
|
|
57
|
+
*
|
|
58
|
+
* @returns - The deserialized original retweeted tweet.
|
|
59
|
+
*/
|
|
60
|
+
private getRetweetedTweet;
|
|
45
61
|
/**
|
|
46
62
|
* Extracts and deserializes the list of tweets from the given raw response data.
|
|
47
63
|
*
|
|
@@ -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,49 @@ 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
|
+
// If tweet with limited visibility
|
|
46
|
+
if (tweet.quoted_status_result &&
|
|
47
|
+
Object.entries(tweet.quoted_status_result).length &&
|
|
48
|
+
tweet.quoted_status_result.result.__typename == 'TweetWithVisibilityResults') {
|
|
49
|
+
return new Tweet(tweet.quoted_status_result.result.tweet);
|
|
50
|
+
}
|
|
51
|
+
// If normal tweet
|
|
52
|
+
else if (tweet.quoted_status_result && Object.entries(tweet.quoted_status_result).length) {
|
|
53
|
+
return new Tweet(tweet.quoted_status_result.result);
|
|
54
|
+
}
|
|
55
|
+
// Else, skip
|
|
56
|
+
else {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Extract and deserialize the original retweeted tweet from the given raw tweet.
|
|
62
|
+
*
|
|
63
|
+
* @param tweet - The raw tweet.
|
|
64
|
+
*
|
|
65
|
+
* @returns - The deserialized original retweeted tweet.
|
|
66
|
+
*/
|
|
67
|
+
Tweet.prototype.getRetweetedTweet = function (tweet) {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
// If valid retweeted tweet
|
|
70
|
+
if ((_b = (_a = tweet.legacy.retweeted_status_result) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.rest_id) {
|
|
71
|
+
return new Tweet(tweet.legacy.retweeted_status_result.result);
|
|
72
|
+
}
|
|
73
|
+
// Else, skip
|
|
74
|
+
else {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
39
78
|
/**
|
|
40
79
|
* Extracts and deserializes the list of tweets from the given raw response data.
|
|
41
80
|
*
|
|
@@ -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,E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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,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,AArCD,IAqCC;AArCY,gCAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rettiwt-api",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
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!",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"commander": "11.1.0",
|
|
37
37
|
"https-proxy-agent": "7.0.2",
|
|
38
38
|
"rettiwt-auth": "2.1.0",
|
|
39
|
-
"rettiwt-core": "4.3.
|
|
39
|
+
"rettiwt-core": "4.3.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "20.4.1",
|
package/src/models/data/Tweet.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EMediaType,
|
|
3
|
+
ILimitedVisibilityTweet,
|
|
3
4
|
IExtendedMedia as IRawExtendedMedia,
|
|
4
5
|
ITweet as IRawTweet,
|
|
5
6
|
IEntities as IRawTweetEntities,
|
|
@@ -77,7 +78,7 @@ export class Tweet {
|
|
|
77
78
|
this.tweetBy = new User(tweet.core.user_results.result);
|
|
78
79
|
this.entities = new TweetEntities(tweet.legacy.entities);
|
|
79
80
|
this.media = tweet.legacy.extended_entities?.media?.map((media) => new TweetMedia(media));
|
|
80
|
-
this.quoted =
|
|
81
|
+
this.quoted = this.getQuotedTweet(tweet);
|
|
81
82
|
this.fullText = tweet.note_tweet ? tweet.note_tweet.note_tweet_results.result.text : tweet.legacy.full_text;
|
|
82
83
|
this.replyTo = tweet.legacy.in_reply_to_status_id_str;
|
|
83
84
|
this.lang = tweet.legacy.lang;
|
|
@@ -87,9 +88,51 @@ export class Tweet {
|
|
|
87
88
|
this.likeCount = tweet.legacy.favorite_count;
|
|
88
89
|
this.viewCount = tweet.views.count ? parseInt(tweet.views.count) : 0;
|
|
89
90
|
this.bookmarkCount = tweet.legacy.bookmark_count;
|
|
90
|
-
this.retweetedTweet = tweet
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
this.retweetedTweet = this.getRetweetedTweet(tweet);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Extract and deserialize the original quoted tweet from the given raw tweet.
|
|
96
|
+
*
|
|
97
|
+
* @param tweet - The raw tweet.
|
|
98
|
+
*
|
|
99
|
+
* @returns - The deserialized original quoted tweet.
|
|
100
|
+
*/
|
|
101
|
+
private getQuotedTweet(tweet: IRawTweet): Tweet | undefined {
|
|
102
|
+
// If tweet with limited visibility
|
|
103
|
+
if (
|
|
104
|
+
tweet.quoted_status_result &&
|
|
105
|
+
Object.entries(tweet.quoted_status_result).length &&
|
|
106
|
+
tweet.quoted_status_result.result.__typename == 'TweetWithVisibilityResults'
|
|
107
|
+
) {
|
|
108
|
+
return new Tweet((tweet.quoted_status_result.result as ILimitedVisibilityTweet).tweet);
|
|
109
|
+
}
|
|
110
|
+
// If normal tweet
|
|
111
|
+
else if (tweet.quoted_status_result && Object.entries(tweet.quoted_status_result).length) {
|
|
112
|
+
return new Tweet(tweet.quoted_status_result.result as ITweet);
|
|
113
|
+
}
|
|
114
|
+
// Else, skip
|
|
115
|
+
else {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Extract and deserialize the original retweeted tweet from the given raw tweet.
|
|
122
|
+
*
|
|
123
|
+
* @param tweet - The raw tweet.
|
|
124
|
+
*
|
|
125
|
+
* @returns - The deserialized original retweeted tweet.
|
|
126
|
+
*/
|
|
127
|
+
private getRetweetedTweet(tweet: IRawTweet): Tweet | undefined {
|
|
128
|
+
// If valid retweeted tweet
|
|
129
|
+
if (tweet.legacy.retweeted_status_result?.result?.rest_id) {
|
|
130
|
+
return new Tweet(tweet.legacy.retweeted_status_result.result);
|
|
131
|
+
}
|
|
132
|
+
// Else, skip
|
|
133
|
+
else {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
93
136
|
}
|
|
94
137
|
|
|
95
138
|
/**
|