rettiwt-api 2.0.3 → 2.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/.github/workflows/publish.yml +0 -3
- package/README.md +69 -0
- package/dist/Rettiwt.d.ts +3 -2
- package/dist/Rettiwt.js +5 -9
- package/dist/Rettiwt.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/models/CursoredData.d.ts +15 -15
- package/dist/models/CursoredData.js +18 -18
- package/dist/models/CursoredData.js.map +1 -1
- package/dist/models/List.d.ts +29 -0
- package/dist/models/List.js +27 -0
- package/dist/models/List.js.map +1 -0
- package/dist/models/Tweet.d.ts +48 -19
- package/dist/models/Tweet.js +77 -28
- package/dist/models/Tweet.js.map +1 -1
- package/dist/models/User.d.ts +3 -1
- package/dist/models/User.js +2 -0
- package/dist/models/User.js.map +1 -1
- package/dist/services/FetcherService.d.ts +19 -3
- package/dist/services/FetcherService.js +39 -6
- package/dist/services/FetcherService.js.map +1 -1
- package/dist/services/TweetService.d.ts +19 -8
- package/dist/services/TweetService.js +40 -10
- package/dist/services/TweetService.js.map +1 -1
- package/dist/services/UserService.d.ts +16 -3
- package/dist/services/UserService.js +33 -3
- package/dist/services/UserService.js.map +1 -1
- package/dist/types/CursoredData.d.ts +9 -9
- package/dist/types/List.d.ts +21 -0
- package/dist/types/List.js +3 -0
- package/dist/types/List.js.map +1 -0
- package/dist/types/Tweet.d.ts +34 -17
- package/package.json +4 -2
- package/src/Rettiwt.ts +5 -11
- package/src/index.ts +2 -0
- package/src/models/CursoredData.ts +19 -19
- package/src/models/List.ts +48 -0
- package/src/models/Tweet.ts +118 -53
- package/src/models/User.ts +5 -1
- package/src/services/FetcherService.ts +49 -7
- package/src/services/TweetService.ts +35 -11
- package/src/services/UserService.ts +27 -4
- package/src/types/CursoredData.ts +10 -10
- package/src/types/List.ts +27 -0
- package/src/types/Tweet.ts +44 -19
- package/.dockerignore +0 -2
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Args, EResourceType } from 'rettiwt-core';
|
|
2
|
-
import { AuthCredential } from 'rettiwt-auth';
|
|
3
2
|
import { CursoredData } from '../models/CursoredData';
|
|
4
3
|
import { Tweet } from '../models/Tweet';
|
|
5
4
|
import { User } from '../models/User';
|
|
@@ -11,10 +10,27 @@ import { User } from '../models/User';
|
|
|
11
10
|
export declare class FetcherService {
|
|
12
11
|
/** The credential to use for authenticating against Twitter API. */
|
|
13
12
|
private cred;
|
|
13
|
+
/** The HTTPS Agent to use for requests to Twitter API. */
|
|
14
|
+
private readonly httpsAgent;
|
|
14
15
|
/**
|
|
15
|
-
* @param
|
|
16
|
+
* @param apiKey - The apiKey (cookie) to use for authenticating Rettiwt against Twitter API.
|
|
17
|
+
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
16
18
|
*/
|
|
17
|
-
constructor(
|
|
19
|
+
constructor(apiKey: string, proxyUrl?: URL);
|
|
20
|
+
/**
|
|
21
|
+
* Returns an AuthCredential generated using the given API key.
|
|
22
|
+
*
|
|
23
|
+
* @param apiKey - The API key to use for authenticating.
|
|
24
|
+
* @returns The generated AuthCredential.
|
|
25
|
+
*/
|
|
26
|
+
private getAuthCredential;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the HttpsAgent based on whether a proxy is used or not.
|
|
29
|
+
*
|
|
30
|
+
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
31
|
+
* @returns The HttpsAgent to use.
|
|
32
|
+
*/
|
|
33
|
+
private getHttpsAgent;
|
|
18
34
|
/**
|
|
19
35
|
* The middleware for handling any http error.
|
|
20
36
|
*
|
|
@@ -43,6 +43,9 @@ exports.FetcherService = void 0;
|
|
|
43
43
|
// PACKAGES
|
|
44
44
|
var rettiwt_core_1 = require("rettiwt-core");
|
|
45
45
|
var axios_1 = __importDefault(require("axios"));
|
|
46
|
+
var https_1 = __importDefault(require("https"));
|
|
47
|
+
var rettiwt_auth_1 = require("rettiwt-auth");
|
|
48
|
+
var https_proxy_agent_1 = require("https-proxy-agent");
|
|
46
49
|
// ENUMS
|
|
47
50
|
var HTTP_1 = require("../enums/HTTP");
|
|
48
51
|
var ApiErrors_1 = require("../enums/ApiErrors");
|
|
@@ -57,11 +60,34 @@ var JsonUtils_1 = require("../helper/JsonUtils");
|
|
|
57
60
|
*/
|
|
58
61
|
var FetcherService = /** @class */ (function () {
|
|
59
62
|
/**
|
|
60
|
-
* @param
|
|
63
|
+
* @param apiKey - The apiKey (cookie) to use for authenticating Rettiwt against Twitter API.
|
|
64
|
+
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
61
65
|
*/
|
|
62
|
-
function FetcherService(
|
|
63
|
-
this.cred =
|
|
66
|
+
function FetcherService(apiKey, proxyUrl) {
|
|
67
|
+
this.cred = this.getAuthCredential(apiKey);
|
|
68
|
+
this.httpsAgent = this.getHttpsAgent(proxyUrl);
|
|
64
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns an AuthCredential generated using the given API key.
|
|
72
|
+
*
|
|
73
|
+
* @param apiKey - The API key to use for authenticating.
|
|
74
|
+
* @returns The generated AuthCredential.
|
|
75
|
+
*/
|
|
76
|
+
FetcherService.prototype.getAuthCredential = function (apiKey) {
|
|
77
|
+
return new rettiwt_auth_1.AuthCredential(apiKey.split(';'));
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Gets the HttpsAgent based on whether a proxy is used or not.
|
|
81
|
+
*
|
|
82
|
+
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
83
|
+
* @returns The HttpsAgent to use.
|
|
84
|
+
*/
|
|
85
|
+
FetcherService.prototype.getHttpsAgent = function (proxyUrl) {
|
|
86
|
+
if (proxyUrl) {
|
|
87
|
+
return new https_proxy_agent_1.HttpsProxyAgent(proxyUrl);
|
|
88
|
+
}
|
|
89
|
+
return new https_1.default.Agent();
|
|
90
|
+
};
|
|
65
91
|
/**
|
|
66
92
|
* The middleware for handling any http error.
|
|
67
93
|
*
|
|
@@ -113,13 +139,14 @@ var FetcherService = /** @class */ (function () {
|
|
|
113
139
|
method: config.type,
|
|
114
140
|
data: config.payload,
|
|
115
141
|
headers: JSON.parse(JSON.stringify(this.cred.toHeader())),
|
|
142
|
+
httpsAgent: this.httpsAgent,
|
|
116
143
|
};
|
|
117
144
|
return [4 /*yield*/, (0, axios_1.default)(axiosRequest)
|
|
118
145
|
.then(function (res) { return _this.handleHttpError(res); })
|
|
119
146
|
.then(function (res) { return _this.handleApiError(res); })];
|
|
120
147
|
case 1:
|
|
121
148
|
/**
|
|
122
|
-
* After making the request, the response is then passed to HTTP error handling
|
|
149
|
+
* After making the request, the response is then passed to HTTP error handling middleware for HTTP error handling.
|
|
123
150
|
*/
|
|
124
151
|
return [2 /*return*/, _a.sent()];
|
|
125
152
|
}
|
|
@@ -147,10 +174,16 @@ var FetcherService = /** @class */ (function () {
|
|
|
147
174
|
else if (type == rettiwt_core_1.EResourceType.USER_DETAILS || type == rettiwt_core_1.EResourceType.USER_DETAILS_BY_ID) {
|
|
148
175
|
required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'User');
|
|
149
176
|
}
|
|
150
|
-
else if (type == rettiwt_core_1.EResourceType.TWEET_SEARCH ||
|
|
177
|
+
else if (type == rettiwt_core_1.EResourceType.TWEET_SEARCH ||
|
|
178
|
+
type == rettiwt_core_1.EResourceType.USER_LIKES ||
|
|
179
|
+
type == rettiwt_core_1.EResourceType.LIST_TWEETS ||
|
|
180
|
+
type == rettiwt_core_1.EResourceType.USER_TWEETS) {
|
|
151
181
|
required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'TimelineTweet').map(function (item) { return item.tweet_results.result; });
|
|
152
182
|
}
|
|
153
|
-
else
|
|
183
|
+
else if (type == rettiwt_core_1.EResourceType.TWEET_FAVORITERS ||
|
|
184
|
+
type == rettiwt_core_1.EResourceType.TWEET_RETWEETERS ||
|
|
185
|
+
type == rettiwt_core_1.EResourceType.USER_FOLLOWERS ||
|
|
186
|
+
type == rettiwt_core_1.EResourceType.USER_FOLLOWING) {
|
|
154
187
|
required = (0, JsonUtils_1.findByFilter)(data, '__typename', 'TimelineUser').map(function (item) { return item.user_results.result; });
|
|
155
188
|
}
|
|
156
189
|
return new CursoredData_1.CursoredData(required, (_a = (0, JsonUtils_1.findByFilter)(data, 'cursorType', 'Bottom')[0]) === null || _a === void 0 ? void 0 : _a.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../src/services/FetcherService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAWsB;AACtB,gDAAsF;
|
|
1
|
+
{"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../src/services/FetcherService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAWsB;AACtB,gDAAsF;AACtF,gDAAqC;AACrC,6CAA8C;AAC9C,uDAAoD;AAEpD,QAAQ;AACR,sCAA4C;AAC5C,gDAAgD;AAEhD,SAAS;AACT,uDAAsD;AAItD,UAAU;AACV,iDAAmE;AAEnE;;;;GAIG;AACH;IAOC;;;OAGG;IACH,wBAAY,MAAc,EAAE,QAAc;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACK,0CAAiB,GAAzB,UAA0B,MAAc;QACvC,OAAO,IAAI,6BAAc,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACK,sCAAa,GAArB,UAAsB,QAAc;QACnC,IAAI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3
2
|
import { FetcherService } from './FetcherService';
|
|
4
3
|
import { Tweet } from '../models/Tweet';
|
|
5
4
|
import { User } from '../models/User';
|
|
@@ -11,11 +10,21 @@ import { CursoredData } from '../models/CursoredData';
|
|
|
11
10
|
*/
|
|
12
11
|
export declare class TweetService extends FetcherService {
|
|
13
12
|
/**
|
|
14
|
-
* @param
|
|
13
|
+
* @param apiKey - The apiKey (cookie) to use for authenticating Rettiwt against Twitter API.
|
|
14
|
+
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
15
15
|
*
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
|
-
constructor(
|
|
18
|
+
constructor(apiKey: string, proxyUrl?: URL);
|
|
19
|
+
/**
|
|
20
|
+
* Get the details of a tweet.
|
|
21
|
+
*
|
|
22
|
+
* @param id - The id of the target tweet.
|
|
23
|
+
* @returns The details of a single tweet with the given tweet id.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
details(id: string): Promise<Tweet>;
|
|
19
28
|
/**
|
|
20
29
|
* Search for tweets using a query.
|
|
21
30
|
*
|
|
@@ -28,14 +37,16 @@ export declare class TweetService extends FetcherService {
|
|
|
28
37
|
*/
|
|
29
38
|
search(query: TweetFilter, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
30
39
|
/**
|
|
31
|
-
* Get the
|
|
40
|
+
* Get the tweets from the tweet list with the given id.
|
|
32
41
|
*
|
|
33
|
-
* @param
|
|
34
|
-
* @
|
|
42
|
+
* @param listId - The id of list from where the tweets are to be fetched.
|
|
43
|
+
* @param count - The number of tweets to fetch, must be \<= 100.
|
|
44
|
+
* @param cursor - The cursor to the batch of tweets to fetch.
|
|
45
|
+
* @returns The list tweets present in the given list.
|
|
35
46
|
*
|
|
36
|
-
* @
|
|
47
|
+
* @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
|
|
37
48
|
*/
|
|
38
|
-
|
|
49
|
+
list(listId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
39
50
|
/**
|
|
40
51
|
* Get the list of users who liked a tweet.
|
|
41
52
|
*
|
|
@@ -64,13 +64,35 @@ var FetcherService_1 = require("./FetcherService");
|
|
|
64
64
|
var TweetService = /** @class */ (function (_super) {
|
|
65
65
|
__extends(TweetService, _super);
|
|
66
66
|
/**
|
|
67
|
-
* @param
|
|
67
|
+
* @param apiKey - The apiKey (cookie) to use for authenticating Rettiwt against Twitter API.
|
|
68
|
+
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
68
69
|
*
|
|
69
70
|
* @internal
|
|
70
71
|
*/
|
|
71
|
-
function TweetService(
|
|
72
|
-
return _super.call(this,
|
|
72
|
+
function TweetService(apiKey, proxyUrl) {
|
|
73
|
+
return _super.call(this, apiKey, proxyUrl) || this;
|
|
73
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Get the details of a tweet.
|
|
77
|
+
*
|
|
78
|
+
* @param id - The id of the target tweet.
|
|
79
|
+
* @returns The details of a single tweet with the given tweet id.
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
TweetService.prototype.details = function (id) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
var data;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0: return [4 /*yield*/, this.fetch(rettiwt_core_1.EResourceType.TWEET_DETAILS, { id: id })];
|
|
89
|
+
case 1:
|
|
90
|
+
data = _a.sent();
|
|
91
|
+
return [2 /*return*/, data.list[0]];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
};
|
|
74
96
|
/**
|
|
75
97
|
* Search for tweets using a query.
|
|
76
98
|
*
|
|
@@ -101,22 +123,30 @@ var TweetService = /** @class */ (function (_super) {
|
|
|
101
123
|
});
|
|
102
124
|
};
|
|
103
125
|
/**
|
|
104
|
-
* Get the
|
|
126
|
+
* Get the tweets from the tweet list with the given id.
|
|
105
127
|
*
|
|
106
|
-
* @param
|
|
107
|
-
* @
|
|
128
|
+
* @param listId - The id of list from where the tweets are to be fetched.
|
|
129
|
+
* @param count - The number of tweets to fetch, must be \<= 100.
|
|
130
|
+
* @param cursor - The cursor to the batch of tweets to fetch.
|
|
131
|
+
* @returns The list tweets present in the given list.
|
|
108
132
|
*
|
|
109
|
-
* @
|
|
133
|
+
* @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
|
|
110
134
|
*/
|
|
111
|
-
TweetService.prototype.
|
|
135
|
+
TweetService.prototype.list = function (listId, count, cursor) {
|
|
112
136
|
return __awaiter(this, void 0, void 0, function () {
|
|
113
137
|
var data;
|
|
114
138
|
return __generator(this, function (_a) {
|
|
115
139
|
switch (_a.label) {
|
|
116
|
-
case 0: return [4 /*yield*/, this.fetch(rettiwt_core_1.EResourceType.
|
|
140
|
+
case 0: return [4 /*yield*/, this.fetch(rettiwt_core_1.EResourceType.LIST_TWEETS, {
|
|
141
|
+
id: listId,
|
|
142
|
+
count: count,
|
|
143
|
+
cursor: cursor,
|
|
144
|
+
})];
|
|
117
145
|
case 1:
|
|
118
146
|
data = _a.sent();
|
|
119
|
-
|
|
147
|
+
// Sorting the tweets by date, from recent to oldest
|
|
148
|
+
data.list.sort(function (a, b) { return new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf(); });
|
|
149
|
+
return [2 /*return*/, data];
|
|
120
150
|
}
|
|
121
151
|
});
|
|
122
152
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TweetService.js","sourceRoot":"","sources":["../../src/services/TweetService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAA0D;
|
|
1
|
+
{"version":3,"file":"TweetService.js","sourceRoot":"","sources":["../../src/services/TweetService.ts"],"names":[],"mappings":";;;;;;;;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d,UAAe,OAAe;;;;;4BAEhB,qBAAM,IAAI,CAAC,IAAI,CAAC,4BAAa,CAAC,cAAc,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAA;;wBAArE,IAAI,GAAG,SAA8D;wBAE3E,sBAAO,IAAI,EAAC;;;;KACZ;IAED;;;;;;;OAOG;IACG,8BAAO,GAAb,UAAc,OAAe;;;;;4BAEf,qBAAM,IAAI,CAAC,IAAI,CAAC,4BAAa,CAAC,cAAc,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAA;;wBAArE,IAAI,GAAG,SAA8D;wBAE3E,sBAAO,IAAI,EAAC;;;;KACZ;IACF,mBAAC;AAAD,CAAC,AAhKD,CAAkC,+BAAc,GAgK/C;AAhKY,oCAAY"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AuthCredential } from 'rettiwt-auth';
|
|
2
1
|
import { FetcherService } from './FetcherService';
|
|
3
2
|
import { User } from '../models/User';
|
|
4
3
|
import { Tweet } from '../models/Tweet';
|
|
@@ -10,11 +9,12 @@ import { CursoredData } from '../models/CursoredData';
|
|
|
10
9
|
*/
|
|
11
10
|
export declare class UserService extends FetcherService {
|
|
12
11
|
/**
|
|
13
|
-
* @param
|
|
12
|
+
* @param apiKey - The apiKey (cookie) to use for authenticating Rettiwt against Twitter API.
|
|
13
|
+
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
14
14
|
*
|
|
15
15
|
* @internal
|
|
16
16
|
*/
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(apiKey: string, proxyUrl?: URL);
|
|
18
18
|
/**
|
|
19
19
|
* Get the details of a user.
|
|
20
20
|
*
|
|
@@ -57,4 +57,17 @@ export declare class UserService extends FetcherService {
|
|
|
57
57
|
* @public
|
|
58
58
|
*/
|
|
59
59
|
likes(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
60
|
+
/**
|
|
61
|
+
* Get the timeline of the given user.
|
|
62
|
+
*
|
|
63
|
+
* @param userId - The rest id of the target user.
|
|
64
|
+
* @param count - The number of timeline items to fetch, must be \<= 20.
|
|
65
|
+
* @param cursor - The cursor to the batch of timeline items to fetch.
|
|
66
|
+
* @returns The timeline of the target user.
|
|
67
|
+
*
|
|
68
|
+
* @remarks If the target user has a pinned tweet, the returned timeline has one item extra and this is always the pinned tweet.
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
timeline(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
60
73
|
}
|
|
@@ -64,12 +64,13 @@ var FetcherService_1 = require("./FetcherService");
|
|
|
64
64
|
var UserService = /** @class */ (function (_super) {
|
|
65
65
|
__extends(UserService, _super);
|
|
66
66
|
/**
|
|
67
|
-
* @param
|
|
67
|
+
* @param apiKey - The apiKey (cookie) to use for authenticating Rettiwt against Twitter API.
|
|
68
|
+
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
68
69
|
*
|
|
69
70
|
* @internal
|
|
70
71
|
*/
|
|
71
|
-
function UserService(
|
|
72
|
-
return _super.call(this,
|
|
72
|
+
function UserService(apiKey, proxyUrl) {
|
|
73
|
+
return _super.call(this, apiKey, proxyUrl) || this;
|
|
73
74
|
}
|
|
74
75
|
/**
|
|
75
76
|
* Get the details of a user.
|
|
@@ -182,6 +183,35 @@ var UserService = /** @class */ (function (_super) {
|
|
|
182
183
|
});
|
|
183
184
|
});
|
|
184
185
|
};
|
|
186
|
+
/**
|
|
187
|
+
* Get the timeline of the given user.
|
|
188
|
+
*
|
|
189
|
+
* @param userId - The rest id of the target user.
|
|
190
|
+
* @param count - The number of timeline items to fetch, must be \<= 20.
|
|
191
|
+
* @param cursor - The cursor to the batch of timeline items to fetch.
|
|
192
|
+
* @returns The timeline of the target user.
|
|
193
|
+
*
|
|
194
|
+
* @remarks If the target user has a pinned tweet, the returned timeline has one item extra and this is always the pinned tweet.
|
|
195
|
+
*
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
198
|
+
UserService.prototype.timeline = function (userId, count, cursor) {
|
|
199
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
200
|
+
var data;
|
|
201
|
+
return __generator(this, function (_a) {
|
|
202
|
+
switch (_a.label) {
|
|
203
|
+
case 0: return [4 /*yield*/, this.fetch(rettiwt_core_1.EResourceType.USER_TWEETS, {
|
|
204
|
+
id: userId,
|
|
205
|
+
count: count,
|
|
206
|
+
cursor: cursor,
|
|
207
|
+
})];
|
|
208
|
+
case 1:
|
|
209
|
+
data = _a.sent();
|
|
210
|
+
return [2 /*return*/, data];
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
};
|
|
185
215
|
return UserService;
|
|
186
216
|
}(FetcherService_1.FetcherService));
|
|
187
217
|
exports.UserService = UserService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../src/services/UserService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAA6C;
|
|
1
|
+
{"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../src/services/UserService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAA6C;AAE7C,WAAW;AACX,mDAAkD;AASlD;;;;GAIG;AACH;IAAiC,+BAAc;IAC9C;;;;;OAKG;IACH,qBAAY,MAAc,EAAE,QAAc;eACzC,kBAAM,MAAM,EAAE,QAAQ,CAAC;IACxB,CAAC;IAED;;;;;;;OAOG;IACG,6BAAO,GAAb,UAAc,EAAU;;;;;;6BAInB,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,EAArB,wBAAqB;wBAEjB,qBAAM,IAAI,CAAC,KAAK,CAAO,4BAAa,CAAC,YAAY,EAAE,EAAE,EAAE,EAA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ACG,8BAAQ,GAAd,UAAe,MAAc,EAAE,KAAc,EAAE,MAAe;;;;;4BAEhD,qBAAM,IAAI,CAAC,KAAK,CAAQ,4BAAa,CAAC,WAAW,EAAE;4BAC/D,EAAE,EAAE,MAAM;4BACV,KAAK,EAAE,KAAK;4BACZ,MAAM,EAAE,MAAM;yBACd,CAAC,EAAA;;wBAJI,IAAI,GAAG,SAIX;wBAEF,sBAAO,IAAI,EAAC;;;;KACZ;IACF,kBAAC;AAAD,CAAC,AAzHD,CAAiC,+BAAc,GAyH9C;AAzHY,kCAAW"}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The cursor to the batch of data to be fetched.
|
|
3
|
-
*
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export interface ICursor {
|
|
7
|
-
/** The cursor string. */
|
|
8
|
-
value: string;
|
|
9
|
-
}
|
|
10
1
|
/**
|
|
11
2
|
* The data that us fetched batch-wise along with a cursor.
|
|
12
3
|
*
|
|
@@ -20,3 +11,12 @@ export interface ICursoredData<T> {
|
|
|
20
11
|
/** The cursor to the next batch of data. */
|
|
21
12
|
next: ICursor;
|
|
22
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The cursor to the batch of data to be fetched.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export interface ICursor {
|
|
20
|
+
/** The cursor string. */
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The details of a single Twitter List.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface IList {
|
|
7
|
+
/** The rest id of the list. */
|
|
8
|
+
id: string;
|
|
9
|
+
/** The name of the list. */
|
|
10
|
+
name: string;
|
|
11
|
+
/** The date and time of creation of the list, int UTC string format. */
|
|
12
|
+
createdAt: string;
|
|
13
|
+
/** The list description. */
|
|
14
|
+
description: string;
|
|
15
|
+
/** The number of memeber of the list. */
|
|
16
|
+
memberCount: number;
|
|
17
|
+
/** The number of subscribers of the list. */
|
|
18
|
+
subscriberCount: number;
|
|
19
|
+
/** The rest id of the user who created the list. */
|
|
20
|
+
createdBy: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../src/types/List.ts"],"names":[],"mappings":""}
|
package/dist/types/Tweet.d.ts
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export interface ITweetEntities {
|
|
7
|
-
/** The list of hashtags mentioned in the tweet. */
|
|
8
|
-
hashtags: string[];
|
|
9
|
-
/** The list of urls mentioned in the tweet. */
|
|
10
|
-
urls: string[];
|
|
11
|
-
/** The list of IDs of users mentioned in the tweet. */
|
|
12
|
-
mentionedUsers: string[];
|
|
13
|
-
/** The list of urls to various media mentioned in the tweet. */
|
|
14
|
-
media: string[];
|
|
15
|
-
}
|
|
1
|
+
import { EMediaType } from 'rettiwt-core';
|
|
2
|
+
import { IUser } from './User';
|
|
16
3
|
/**
|
|
17
4
|
* The details of a single Tweet.
|
|
18
5
|
*
|
|
@@ -21,12 +8,14 @@ export interface ITweetEntities {
|
|
|
21
8
|
export interface ITweet {
|
|
22
9
|
/** The rest id of the tweet. */
|
|
23
10
|
id: string;
|
|
24
|
-
/** The
|
|
25
|
-
tweetBy:
|
|
11
|
+
/** The details of the user who made the tweet. */
|
|
12
|
+
tweetBy: IUser;
|
|
26
13
|
/** The date and time of creation of the tweet, in UTC string format. */
|
|
27
14
|
createdAt: string;
|
|
28
15
|
/** Additional tweet entities like urls, mentions, etc. */
|
|
29
16
|
entities: ITweetEntities;
|
|
17
|
+
/** The urls of the media contents of the tweet (if any). */
|
|
18
|
+
media: ITweetMedia[];
|
|
30
19
|
/** The rest id of the tweet which is quoted in the tweet. */
|
|
31
20
|
quoted: string;
|
|
32
21
|
/** The full text content of the tweet. */
|
|
@@ -43,4 +32,32 @@ export interface ITweet {
|
|
|
43
32
|
retweetCount: number;
|
|
44
33
|
/** The number of likes of the tweet. */
|
|
45
34
|
likeCount: number;
|
|
35
|
+
/** The number of views of a tweet. */
|
|
36
|
+
viewCount: number;
|
|
37
|
+
/** The number of bookmarks of a tweet. */
|
|
38
|
+
bookmarkCount: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The different types parsed entities like urls, media, mentions, hashtags, etc.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export interface ITweetEntities {
|
|
46
|
+
/** The list of hashtags mentioned in the tweet. */
|
|
47
|
+
hashtags: string[];
|
|
48
|
+
/** The list of urls mentioned in the tweet. */
|
|
49
|
+
urls: string[];
|
|
50
|
+
/** The list of IDs of users mentioned in the tweet. */
|
|
51
|
+
mentionedUsers: string[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A single media content.
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export interface ITweetMedia {
|
|
59
|
+
/** The type of media. */
|
|
60
|
+
type: EMediaType;
|
|
61
|
+
/** The direct URL to the media. */
|
|
62
|
+
url: string;
|
|
46
63
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rettiwt-api",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.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!",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
+
"prepare": "tsc",
|
|
9
10
|
"format": "prettier --write .",
|
|
10
11
|
"lint": "eslint --max-warnings 0 .",
|
|
11
12
|
"docs": "typedoc src/index.ts",
|
|
@@ -26,8 +27,9 @@
|
|
|
26
27
|
"homepage": "https://rishikant181.github.io/Rettiwt-API/",
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"axios": "1.3.2",
|
|
30
|
+
"https-proxy-agent": "^7.0.2",
|
|
29
31
|
"rettiwt-auth": "1.2.0",
|
|
30
|
-
"rettiwt-core": "3.
|
|
32
|
+
"rettiwt-core": "3.2.0-alpha.3"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
35
|
"@types/node": "20.4.1",
|
package/src/Rettiwt.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// PACKAGE
|
|
2
|
-
import { AuthCredential } from 'rettiwt-auth';
|
|
3
|
-
|
|
4
1
|
// SERVICES
|
|
5
2
|
import { TweetService } from './services/TweetService';
|
|
6
3
|
import { UserService } from './services/UserService';
|
|
@@ -20,14 +17,11 @@ export class Rettiwt {
|
|
|
20
17
|
/**
|
|
21
18
|
* Initializes a new Rettiwt instance using the given api key.
|
|
22
19
|
*
|
|
23
|
-
* @param apiKey - The apiKey (cookie) to
|
|
20
|
+
* @param apiKey - The apiKey (cookie) to use for authenticating Rettiwt against Twitter API.
|
|
21
|
+
* @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
|
|
24
22
|
*/
|
|
25
|
-
constructor(apiKey: string) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// Initalizing service instances
|
|
30
|
-
this.tweet = new TweetService(cred);
|
|
31
|
-
this.user = new UserService(cred);
|
|
23
|
+
constructor(apiKey: string, proxyUrl?: URL) {
|
|
24
|
+
this.tweet = new TweetService(apiKey, proxyUrl);
|
|
25
|
+
this.user = new UserService(apiKey, proxyUrl);
|
|
32
26
|
}
|
|
33
27
|
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './enums/HTTP';
|
|
|
7
7
|
|
|
8
8
|
// Exporting models
|
|
9
9
|
export * from './models/CursoredData';
|
|
10
|
+
export * from './models/List';
|
|
10
11
|
export * from './models/Tweet';
|
|
11
12
|
export * from './models/User';
|
|
12
13
|
|
|
@@ -17,5 +18,6 @@ export * from './services/UserService';
|
|
|
17
18
|
|
|
18
19
|
// Exporting types
|
|
19
20
|
export * from './types/CursoredData';
|
|
21
|
+
export * from './types/List';
|
|
20
22
|
export * from './types/Tweet';
|
|
21
23
|
export * from './types/User';
|
|
@@ -8,25 +8,6 @@ import { User } from './User';
|
|
|
8
8
|
// TYPES
|
|
9
9
|
import { ICursor, ICursoredData } from '../types/CursoredData';
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* The cursor to the batch of data to be fetched.
|
|
13
|
-
*
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
export class Cursor implements ICursor {
|
|
17
|
-
/** The cursor string. */
|
|
18
|
-
value: string;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Initializes a new cursor from the given cursor string.
|
|
22
|
-
*
|
|
23
|
-
* @param cursorStr - The string representation of the cursor.
|
|
24
|
-
*/
|
|
25
|
-
constructor(cursorStr: string) {
|
|
26
|
-
this.value = cursorStr;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
11
|
/**
|
|
31
12
|
* The data that us fetched batch-wise along with a cursor.
|
|
32
13
|
*
|
|
@@ -62,3 +43,22 @@ export class CursoredData<T extends Tweet | User> implements ICursoredData<T> {
|
|
|
62
43
|
this.next = new Cursor(next);
|
|
63
44
|
}
|
|
64
45
|
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The cursor to the batch of data to be fetched.
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export class Cursor implements ICursor {
|
|
53
|
+
/** The cursor string. */
|
|
54
|
+
value: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Initializes a new cursor from the given cursor string.
|
|
58
|
+
*
|
|
59
|
+
* @param cursorStr - The string representation of the cursor.
|
|
60
|
+
*/
|
|
61
|
+
constructor(cursorStr: string) {
|
|
62
|
+
this.value = cursorStr;
|
|
63
|
+
}
|
|
64
|
+
}
|