rettiwt-api 5.0.1 → 6.0.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 +13 -8
- package/README.md +8 -1
- package/dist/cli.js +17 -14
- package/dist/cli.js.map +1 -1
- package/dist/collections/Extractors.d.ts +1 -1
- package/dist/collections/Extractors.js +21 -21
- package/dist/collections/Extractors.js.map +1 -1
- package/dist/collections/Groups.d.ts +4 -4
- package/dist/collections/Groups.js +45 -45
- package/dist/collections/Groups.js.map +1 -1
- package/dist/collections/Requests.d.ts +3 -3
- package/dist/collections/Requests.js +3 -3
- package/dist/collections/Requests.js.map +1 -1
- package/dist/collections/Tweet.d.ts +4 -4
- package/dist/collections/Tweet.js +5 -5
- package/dist/collections/Tweet.js.map +1 -1
- package/dist/commands/Tweet.js +48 -12
- package/dist/commands/Tweet.js.map +1 -1
- package/dist/enums/Api.d.ts +1 -1
- package/dist/enums/Api.js +7 -7
- package/dist/enums/Api.js.map +1 -1
- package/dist/enums/Authentication.d.ts +1 -1
- package/dist/enums/Authentication.js +7 -7
- package/dist/enums/Authentication.js.map +1 -1
- package/dist/enums/Data.d.ts +1 -1
- package/dist/enums/Data.js +7 -7
- package/dist/enums/Data.js.map +1 -1
- package/dist/enums/Logging.d.ts +1 -1
- package/dist/enums/Logging.js +11 -11
- package/dist/enums/Logging.js.map +1 -1
- package/dist/enums/Media.d.ts +1 -1
- package/dist/enums/Media.js +7 -7
- package/dist/enums/Media.js.map +1 -1
- package/dist/enums/Notification.d.ts +1 -1
- package/dist/enums/Notification.js +9 -9
- package/dist/enums/Notification.js.map +1 -1
- package/dist/enums/Resource.d.ts +1 -1
- package/dist/enums/Resource.js +42 -42
- package/dist/enums/Resource.js.map +1 -1
- package/dist/enums/Tweet.d.ts +1 -1
- package/dist/enums/Tweet.js +7 -7
- package/dist/enums/Tweet.js.map +1 -1
- package/dist/enums/raw/Analytics.d.ts +2 -2
- package/dist/enums/raw/Analytics.js +21 -21
- package/dist/enums/raw/Analytics.js.map +1 -1
- package/dist/enums/raw/Media.d.ts +1 -1
- package/dist/enums/raw/Media.js +7 -7
- package/dist/enums/raw/Media.js.map +1 -1
- package/dist/enums/raw/Notification.d.ts +1 -1
- package/dist/enums/raw/Notification.js +8 -8
- package/dist/enums/raw/Notification.js.map +1 -1
- package/dist/enums/raw/Tweet.d.ts +2 -2
- package/dist/enums/raw/Tweet.js +12 -12
- package/dist/enums/raw/Tweet.js.map +1 -1
- package/dist/models/RettiwtConfig.d.ts +3 -2
- package/dist/models/RettiwtConfig.js +7 -5
- package/dist/models/RettiwtConfig.js.map +1 -1
- package/dist/models/args/FetchArgs.d.ts +7 -5
- package/dist/models/args/FetchArgs.js +15 -9
- package/dist/models/args/FetchArgs.js.map +1 -1
- package/dist/models/auth/AuthCredential.d.ts +2 -2
- package/dist/models/auth/AuthCredential.js +3 -3
- package/dist/models/auth/AuthCredential.js.map +1 -1
- package/dist/models/data/CursoredData.d.ts +2 -2
- package/dist/models/data/CursoredData.js +3 -3
- package/dist/models/data/CursoredData.js.map +1 -1
- package/dist/models/data/Notification.d.ts +2 -2
- package/dist/models/data/Notification.js +3 -3
- package/dist/models/data/Notification.js.map +1 -1
- package/dist/models/data/Tweet.d.ts +4 -4
- package/dist/models/data/Tweet.js +18 -18
- package/dist/models/data/Tweet.js.map +1 -1
- package/dist/models/data/User.js +9 -9
- package/dist/models/data/User.js.map +1 -1
- package/dist/requests/Tweet.d.ts +2 -2
- package/dist/requests/Tweet.js +2 -2
- package/dist/requests/Tweet.js.map +1 -1
- package/dist/requests/User.d.ts +2 -2
- package/dist/requests/User.js.map +1 -1
- package/dist/services/internal/AuthService.js +1 -1
- package/dist/services/internal/AuthService.js.map +1 -1
- package/dist/services/internal/ErrorService.d.ts +2 -2
- package/dist/services/internal/ErrorService.js +4 -4
- package/dist/services/internal/ErrorService.js.map +1 -1
- package/dist/services/internal/LogService.d.ts +2 -2
- package/dist/services/internal/LogService.js.map +1 -1
- package/dist/services/internal/TidService.d.ts +4 -4
- package/dist/services/internal/TidService.js +10 -10
- package/dist/services/internal/TidService.js.map +1 -1
- package/dist/services/public/FetcherService.d.ts +7 -7
- package/dist/services/public/FetcherService.js +79 -35
- package/dist/services/public/FetcherService.js.map +1 -1
- package/dist/services/public/ListService.js +4 -4
- package/dist/services/public/ListService.js.map +1 -1
- package/dist/services/public/TweetService.d.ts +3 -3
- package/dist/services/public/TweetService.js +35 -35
- package/dist/services/public/TweetService.js.map +1 -1
- package/dist/services/public/UserService.js +37 -37
- package/dist/services/public/UserService.js.map +1 -1
- package/dist/types/RettiwtConfig.d.ts +6 -0
- package/dist/types/args/FetchArgs.d.ts +14 -6
- package/dist/types/auth/AuthCredential.d.ts +2 -2
- package/dist/types/data/Notification.d.ts +2 -2
- package/dist/types/data/Tweet.d.ts +2 -2
- package/dist/types/raw/base/Media.d.ts +2 -2
- package/dist/types/raw/base/Notification.d.ts +2 -2
- package/package.json +18 -18
- package/src/cli.ts +20 -14
- package/src/collections/Extractors.ts +21 -21
- package/src/collections/Groups.ts +45 -45
- package/src/collections/Requests.ts +4 -4
- package/src/collections/Tweet.ts +6 -6
- package/src/commands/Tweet.ts +49 -12
- package/src/enums/Api.ts +1 -1
- package/src/enums/Authentication.ts +1 -1
- package/src/enums/Data.ts +1 -1
- package/src/enums/Logging.ts +1 -1
- package/src/enums/Media.ts +1 -1
- package/src/enums/Notification.ts +1 -1
- package/src/enums/Resource.ts +1 -1
- package/src/enums/Tweet.ts +1 -1
- package/src/enums/raw/Analytics.ts +2 -2
- package/src/enums/raw/Media.ts +1 -1
- package/src/enums/raw/Notification.ts +1 -1
- package/src/enums/raw/Tweet.ts +2 -2
- package/src/models/RettiwtConfig.ts +7 -5
- package/src/models/args/FetchArgs.ts +17 -11
- package/src/models/auth/AuthCredential.ts +5 -5
- package/src/models/data/CursoredData.ts +5 -5
- package/src/models/data/Notification.ts +6 -6
- package/src/models/data/Tweet.ts +22 -22
- package/src/models/data/User.ts +10 -10
- package/src/requests/Tweet.ts +4 -4
- package/src/requests/User.ts +3 -3
- package/src/services/internal/AuthService.ts +2 -2
- package/src/services/internal/ErrorService.ts +4 -4
- package/src/services/internal/LogService.ts +2 -2
- package/src/services/internal/TidService.ts +11 -11
- package/src/services/public/FetcherService.ts +54 -38
- package/src/services/public/ListService.ts +6 -6
- package/src/services/public/TweetService.ts +39 -39
- package/src/services/public/UserService.ts +40 -40
- package/src/types/RettiwtConfig.ts +7 -0
- package/src/types/args/FetchArgs.ts +18 -8
- package/src/types/auth/AuthCredential.ts +2 -2
- package/src/types/data/Notification.ts +2 -2
- package/src/types/data/Tweet.ts +2 -2
- package/src/types/raw/base/Media.ts +2 -2
- package/src/types/raw/base/Notification.ts +2 -2
- package/.tool-versions +0 -1
|
@@ -1,10 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
5
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
36
|
exports.FetcherService = void 0;
|
|
7
|
-
const axios_1 =
|
|
37
|
+
const axios_1 = __importStar(require("axios"));
|
|
8
38
|
const cookiejar_1 = require("cookiejar");
|
|
9
39
|
const Groups_1 = require("../../collections/Groups");
|
|
10
40
|
const Requests_1 = require("../../collections/Requests");
|
|
@@ -54,12 +84,12 @@ class FetcherService {
|
|
|
54
84
|
*
|
|
55
85
|
* @throws An error if not authorized to access the requested resource.
|
|
56
86
|
*/
|
|
57
|
-
|
|
87
|
+
_checkAuthorization(resource) {
|
|
58
88
|
// Logging
|
|
59
|
-
LogService_1.LogService.log(Logging_1.
|
|
89
|
+
LogService_1.LogService.log(Logging_1.LogActions.AUTHORIZATION, { authenticated: this.config.userId != undefined });
|
|
60
90
|
// Checking authorization status
|
|
61
|
-
if (!Groups_1.
|
|
62
|
-
throw new Error(Api_1.
|
|
91
|
+
if (!Groups_1.AllowGuestAuthenticationGroup.includes(resource) && this.config.userId == undefined) {
|
|
92
|
+
throw new Error(Api_1.ApiErrors.RESOURCE_NOT_ALLOWED);
|
|
63
93
|
}
|
|
64
94
|
}
|
|
65
95
|
/**
|
|
@@ -67,17 +97,17 @@ class FetcherService {
|
|
|
67
97
|
*
|
|
68
98
|
* @returns The generated AuthCredential
|
|
69
99
|
*/
|
|
70
|
-
async
|
|
100
|
+
async _getCredential() {
|
|
71
101
|
if (this.config.apiKey) {
|
|
72
102
|
// Logging
|
|
73
|
-
LogService_1.LogService.log(Logging_1.
|
|
103
|
+
LogService_1.LogService.log(Logging_1.LogActions.GET, { target: 'USER_CREDENTIAL' });
|
|
74
104
|
return new AuthCredential_1.AuthCredential(AuthService_1.AuthService.decodeCookie(this.config.apiKey)
|
|
75
105
|
.split(';')
|
|
76
106
|
.map((item) => new cookiejar_1.Cookie(item)));
|
|
77
107
|
}
|
|
78
108
|
else {
|
|
79
109
|
// Logging
|
|
80
|
-
LogService_1.LogService.log(Logging_1.
|
|
110
|
+
LogService_1.LogService.log(Logging_1.LogActions.GET, { target: 'NEW_GUEST_CREDENTIAL' });
|
|
81
111
|
return this._auth.guest();
|
|
82
112
|
}
|
|
83
113
|
}
|
|
@@ -89,7 +119,7 @@ class FetcherService {
|
|
|
89
119
|
*
|
|
90
120
|
* @returns The header containing the transaction ID.
|
|
91
121
|
*/
|
|
92
|
-
async
|
|
122
|
+
async _getTransactionHeader(method, url) {
|
|
93
123
|
// Getting the URL path excluding all params
|
|
94
124
|
const path = new URL(url).pathname.split('?')[0].trim();
|
|
95
125
|
// Generating the transaction ID
|
|
@@ -113,22 +143,22 @@ class FetcherService {
|
|
|
113
143
|
*
|
|
114
144
|
* @returns The validated args.
|
|
115
145
|
*/
|
|
116
|
-
|
|
117
|
-
if (Groups_1.
|
|
146
|
+
_validateArgs(resource, args) {
|
|
147
|
+
if (Groups_1.FetchResourcesGroup.includes(resource)) {
|
|
118
148
|
// Logging
|
|
119
|
-
LogService_1.LogService.log(Logging_1.
|
|
149
|
+
LogService_1.LogService.log(Logging_1.LogActions.VALIDATE, { target: 'FETCH_ARGS' });
|
|
120
150
|
return new FetchArgs_1.FetchArgs(args);
|
|
121
151
|
}
|
|
122
|
-
else if (Groups_1.
|
|
152
|
+
else if (Groups_1.PostResourcesGroup.includes(resource)) {
|
|
123
153
|
// Logging
|
|
124
|
-
LogService_1.LogService.log(Logging_1.
|
|
154
|
+
LogService_1.LogService.log(Logging_1.LogActions.VALIDATE, { target: 'POST_ARGS' });
|
|
125
155
|
return new PostArgs_1.PostArgs(args);
|
|
126
156
|
}
|
|
127
157
|
}
|
|
128
158
|
/**
|
|
129
159
|
* Introduces a delay using the configured delay/delay function.
|
|
130
160
|
*/
|
|
131
|
-
async
|
|
161
|
+
async _wait() {
|
|
132
162
|
// If no delay is set, skip
|
|
133
163
|
if (this._delay == undefined) {
|
|
134
164
|
return;
|
|
@@ -175,38 +205,52 @@ class FetcherService {
|
|
|
175
205
|
* ```
|
|
176
206
|
*/
|
|
177
207
|
async request(resource, args) {
|
|
208
|
+
/** The error, if any. */
|
|
209
|
+
let error = undefined;
|
|
178
210
|
// Logging
|
|
179
|
-
LogService_1.LogService.log(Logging_1.
|
|
211
|
+
LogService_1.LogService.log(Logging_1.LogActions.REQUEST, { resource: resource, args: args });
|
|
180
212
|
// Checking authorization for the requested resource
|
|
181
|
-
this.
|
|
213
|
+
this._checkAuthorization(resource);
|
|
182
214
|
// Validating args
|
|
183
|
-
args = this.
|
|
215
|
+
args = this._validateArgs(resource, args);
|
|
184
216
|
// Getting credentials from key
|
|
185
|
-
const cred = await this.
|
|
217
|
+
const cred = await this._getCredential();
|
|
186
218
|
// Getting request configuration
|
|
187
|
-
const config = Requests_1.
|
|
219
|
+
const config = Requests_1.Requests[resource](args);
|
|
188
220
|
// Setting additional request parameters
|
|
189
221
|
config.headers = {
|
|
190
222
|
...config.headers,
|
|
191
223
|
...cred.toHeader(),
|
|
192
|
-
...(await this.
|
|
224
|
+
...(await this._getTransactionHeader(config.method ?? '', config.url ?? '')),
|
|
193
225
|
...this.config.headers,
|
|
194
226
|
};
|
|
195
227
|
config.httpAgent = this.config.httpsAgent;
|
|
196
228
|
config.httpsAgent = this.config.httpsAgent;
|
|
197
229
|
config.timeout = this._timeout;
|
|
198
|
-
//
|
|
199
|
-
|
|
200
|
-
//
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
230
|
+
// Using retries for error 404
|
|
231
|
+
for (let retry = 1; retry <= this.config.maxRetries; retry++) {
|
|
232
|
+
// Sending the request
|
|
233
|
+
try {
|
|
234
|
+
// Introducing a delay
|
|
235
|
+
await this._wait();
|
|
236
|
+
// Returning the reponse body
|
|
237
|
+
return (await (0, axios_1.default)(config)).data;
|
|
238
|
+
}
|
|
239
|
+
catch (err) {
|
|
240
|
+
// If it's an error 404, retry
|
|
241
|
+
if ((0, axios_1.isAxiosError)(err) && err.status === 404) {
|
|
242
|
+
error = err;
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
// Else, delegate error handling
|
|
246
|
+
else {
|
|
247
|
+
this._errorHandler.handle(err);
|
|
248
|
+
throw err;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
209
251
|
}
|
|
252
|
+
/** If request not successful even after retries, throw the error */
|
|
253
|
+
throw error;
|
|
210
254
|
}
|
|
211
255
|
}
|
|
212
256
|
exports.FetcherService = FetcherService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../../src/services/public/FetcherService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FetcherService.js","sourceRoot":"","sources":["../../../src/services/public/FetcherService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA4C;AAC5C,yCAAmC;AAEnC,qDAAkH;AAClH,yDAAsD;AACtD,yCAA4C;AAC5C,iDAAiD;AAEjD,2DAAwD;AACxD,yDAAsD;AACtD,qEAAkE;AAQlE,yDAAsD;AACtD,2DAAwD;AACxD,uDAAoD;AACpD,uDAAoD;AAEpD;;;;GAIG;AACH,MAAa,cAAc;IAC1B,uCAAuC;IACtB,KAAK,CAAc;IAEpC,4CAA4C;IAC3B,MAAM,CAA6C;I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AI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;oBAC7C,KAAK,GAAG,GAAG,CAAC;oBACZ,SAAS;gBACV,CAAC;gBACD,gCAAgC;qBAC3B,CAAC;oBACL,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;oBAC/B,MAAM,GAAG,CAAC;gBACX,CAAC;YACF,CAAC;QACF,CAAC;QAED,oEAAoE;QACpE,MAAM,KAAK,CAAC;IACb,CAAC;CACD;AApOD,wCAoOC"}
|
|
@@ -43,7 +43,7 @@ class ListService extends FetcherService_1.FetcherService {
|
|
|
43
43
|
* @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
|
|
44
44
|
*/
|
|
45
45
|
async members(id, count, cursor) {
|
|
46
|
-
const resource = Resource_1.
|
|
46
|
+
const resource = Resource_1.ResourceType.LIST_MEMBERS;
|
|
47
47
|
// Fetching the raw list of members
|
|
48
48
|
const response = await this.request(resource, {
|
|
49
49
|
id: id,
|
|
@@ -51,7 +51,7 @@ class ListService extends FetcherService_1.FetcherService {
|
|
|
51
51
|
cursor: cursor,
|
|
52
52
|
});
|
|
53
53
|
// Deserializing response
|
|
54
|
-
const data = Extractors_1.
|
|
54
|
+
const data = Extractors_1.Extractors[resource](response);
|
|
55
55
|
return data;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
@@ -84,7 +84,7 @@ class ListService extends FetcherService_1.FetcherService {
|
|
|
84
84
|
* @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
|
|
85
85
|
*/
|
|
86
86
|
async tweets(id, count, cursor) {
|
|
87
|
-
const resource = Resource_1.
|
|
87
|
+
const resource = Resource_1.ResourceType.LIST_TWEETS;
|
|
88
88
|
// Fetching raw list tweets
|
|
89
89
|
const response = await this.request(resource, {
|
|
90
90
|
id: id,
|
|
@@ -92,7 +92,7 @@ class ListService extends FetcherService_1.FetcherService {
|
|
|
92
92
|
cursor: cursor,
|
|
93
93
|
});
|
|
94
94
|
// Deserializing response
|
|
95
|
-
const data = Extractors_1.
|
|
95
|
+
const data = Extractors_1.Extractors[resource](response);
|
|
96
96
|
// Sorting the tweets by date, from recent to oldest
|
|
97
97
|
data.list.sort((a, b) => new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf());
|
|
98
98
|
return data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListService.js","sourceRoot":"","sources":["../../../src/services/public/ListService.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAC1D,
|
|
1
|
+
{"version":3,"file":"ListService.js","sourceRoot":"","sources":["../../../src/services/public/ListService.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAC1D,mDAAoD;AAQpD,qDAAkD;AAElD,MAAa,WAAY,SAAQ,+BAAc;IAC9C;;;;OAIG;IACH,YAAmB,MAAqB;QACvC,KAAK,CAAC,MAAM,CAAC,CAAC;IACf,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACI,KAAK,CAAC,OAAO,CAAC,EAAU,EAAE,KAAc,EAAE,MAAe;QAC/D,MAAM,QAAQ,GAAiB,uBAAY,CAAC,YAAY,CAAC;QAEzD,mCAAmC;QACnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAuB,QAAQ,EAAE;YACnE,EAAE,EAAE,EAAE;YACN,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,MAAM;SACd,CAAC,CAAC;QAEH,yBAAyB;QACzB,MAAM,IAAI,GAAG,uBAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC;QAE5C,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACI,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,KAAc,EAAE,MAAe;QAC9D,MAAM,QAAQ,GAAG,uBAAY,CAAC,WAAW,CAAC;QAE1C,2BAA2B;QAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAsB,QAAQ,EAAE;YAClE,EAAE,EAAE,EAAE;YACN,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,MAAM;SACd,CAAC,CAAC;QAEH,yBAAyB;QACzB,MAAM,IAAI,GAAG,uBAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC;QAE5C,oDAAoD;QACpD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAE5F,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAtGD,kCAsGC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TweetRepliesSortType } from '../../enums/Tweet';
|
|
2
2
|
import { CursoredData } from '../../models/data/CursoredData';
|
|
3
3
|
import { Tweet } from '../../models/data/Tweet';
|
|
4
4
|
import { User } from '../../models/data/User';
|
|
@@ -212,7 +212,7 @@ export declare class TweetService extends FetcherService {
|
|
|
212
212
|
*
|
|
213
213
|
* @param id - The ID of the target tweet.
|
|
214
214
|
* @param cursor - The cursor to the batch of replies to fetch.
|
|
215
|
-
* @param sortBy - The sorting order of the replies to fetch. Default is {@link
|
|
215
|
+
* @param sortBy - The sorting order of the replies to fetch. Default is {@link TweetRepliesSortType.RECENT}.
|
|
216
216
|
*
|
|
217
217
|
* @returns The list of replies to the given tweet.
|
|
218
218
|
*
|
|
@@ -238,7 +238,7 @@ export declare class TweetService extends FetcherService {
|
|
|
238
238
|
*
|
|
239
239
|
* If the given tweet is the start of/part of a thread, the first batch always contains all the tweets in the thread.
|
|
240
240
|
*/
|
|
241
|
-
replies(id: string, cursor?: string, sortBy?:
|
|
241
|
+
replies(id: string, cursor?: string, sortBy?: TweetRepliesSortType): Promise<CursoredData<Tweet>>;
|
|
242
242
|
/**
|
|
243
243
|
* Retweet a tweet.
|
|
244
244
|
*
|
|
@@ -74,29 +74,29 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
74
74
|
let resource;
|
|
75
75
|
// If user is authenticated and details of single tweet required
|
|
76
76
|
if (this.config.userId != undefined && typeof id == 'string') {
|
|
77
|
-
resource = Resource_1.
|
|
77
|
+
resource = Resource_1.ResourceType.TWEET_DETAILS_ALT;
|
|
78
78
|
// Fetching raw tweet details
|
|
79
79
|
const response = await this.request(resource, { id: id });
|
|
80
80
|
// Deserializing response
|
|
81
|
-
const data = Extractors_1.
|
|
81
|
+
const data = Extractors_1.Extractors[resource](response, id);
|
|
82
82
|
return data;
|
|
83
83
|
}
|
|
84
84
|
// If user is authenticated and details of multiple tweets required
|
|
85
85
|
else if (this.config.userId != undefined && Array.isArray(id)) {
|
|
86
|
-
resource = Resource_1.
|
|
86
|
+
resource = Resource_1.ResourceType.TWEET_DETAILS_BULK;
|
|
87
87
|
// Fetching raw tweet details
|
|
88
88
|
const response = await this.request(resource, { ids: id });
|
|
89
89
|
// Deserializing response
|
|
90
|
-
const data = Extractors_1.
|
|
90
|
+
const data = Extractors_1.Extractors[resource](response, id);
|
|
91
91
|
return data;
|
|
92
92
|
}
|
|
93
93
|
// If user is not authenticated
|
|
94
94
|
else {
|
|
95
|
-
resource = Resource_1.
|
|
95
|
+
resource = Resource_1.ResourceType.TWEET_DETAILS;
|
|
96
96
|
// Fetching raw tweet details
|
|
97
97
|
const response = await this.request(resource, { id: String(id) });
|
|
98
98
|
// Deserializing response
|
|
99
|
-
const data = Extractors_1.
|
|
99
|
+
const data = Extractors_1.Extractors[resource](response, String(id));
|
|
100
100
|
return data;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -126,13 +126,13 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
126
126
|
* ```
|
|
127
127
|
*/
|
|
128
128
|
async like(id) {
|
|
129
|
-
const resource = Resource_1.
|
|
129
|
+
const resource = Resource_1.ResourceType.TWEET_LIKE;
|
|
130
130
|
// Favoriting the tweet
|
|
131
131
|
const response = await this.request(resource, {
|
|
132
132
|
id: id,
|
|
133
133
|
});
|
|
134
134
|
// Deserializing response
|
|
135
|
-
const data = Extractors_1.
|
|
135
|
+
const data = Extractors_1.Extractors[resource](response) ?? false;
|
|
136
136
|
return data;
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
@@ -163,7 +163,7 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
163
163
|
* ```
|
|
164
164
|
*/
|
|
165
165
|
async likers(id, count, cursor) {
|
|
166
|
-
const resource = Resource_1.
|
|
166
|
+
const resource = Resource_1.ResourceType.TWEET_LIKERS;
|
|
167
167
|
// Fetching raw likers
|
|
168
168
|
const response = await this.request(resource, {
|
|
169
169
|
id: id,
|
|
@@ -171,7 +171,7 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
171
171
|
cursor: cursor,
|
|
172
172
|
});
|
|
173
173
|
// Deserializing response
|
|
174
|
-
const data = Extractors_1.
|
|
174
|
+
const data = Extractors_1.Extractors[resource](response);
|
|
175
175
|
return data;
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
@@ -258,11 +258,11 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
258
258
|
* ```
|
|
259
259
|
*/
|
|
260
260
|
async post(options) {
|
|
261
|
-
const resource = Resource_1.
|
|
261
|
+
const resource = Resource_1.ResourceType.TWEET_POST;
|
|
262
262
|
// Posting the tweet
|
|
263
263
|
const response = await this.request(resource, { tweet: options });
|
|
264
264
|
// Deserializing response
|
|
265
|
-
const data = Extractors_1.
|
|
265
|
+
const data = Extractors_1.Extractors[resource](response);
|
|
266
266
|
return data;
|
|
267
267
|
}
|
|
268
268
|
/**
|
|
@@ -270,7 +270,7 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
270
270
|
*
|
|
271
271
|
* @param id - The ID of the target tweet.
|
|
272
272
|
* @param cursor - The cursor to the batch of replies to fetch.
|
|
273
|
-
* @param sortBy - The sorting order of the replies to fetch. Default is {@link
|
|
273
|
+
* @param sortBy - The sorting order of the replies to fetch. Default is {@link TweetRepliesSortType.RECENT}.
|
|
274
274
|
*
|
|
275
275
|
* @returns The list of replies to the given tweet.
|
|
276
276
|
*
|
|
@@ -296,8 +296,8 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
296
296
|
*
|
|
297
297
|
* If the given tweet is the start of/part of a thread, the first batch always contains all the tweets in the thread.
|
|
298
298
|
*/
|
|
299
|
-
async replies(id, cursor, sortBy = Tweet_1.
|
|
300
|
-
const resource = Resource_1.
|
|
299
|
+
async replies(id, cursor, sortBy = Tweet_1.TweetRepliesSortType.LATEST) {
|
|
300
|
+
const resource = Resource_1.ResourceType.TWEET_REPLIES;
|
|
301
301
|
// Fetching raw list of replies
|
|
302
302
|
const response = await this.request(resource, {
|
|
303
303
|
id: id,
|
|
@@ -305,7 +305,7 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
305
305
|
sortBy: sortBy,
|
|
306
306
|
});
|
|
307
307
|
// Deserializing response
|
|
308
|
-
const data = Extractors_1.
|
|
308
|
+
const data = Extractors_1.Extractors[resource](response);
|
|
309
309
|
return data;
|
|
310
310
|
}
|
|
311
311
|
/**
|
|
@@ -334,11 +334,11 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
334
334
|
* ```
|
|
335
335
|
*/
|
|
336
336
|
async retweet(id) {
|
|
337
|
-
const resource = Resource_1.
|
|
337
|
+
const resource = Resource_1.ResourceType.TWEET_RETWEET;
|
|
338
338
|
// Retweeting the tweet
|
|
339
339
|
const response = await this.request(resource, { id: id });
|
|
340
340
|
// Deserializing response
|
|
341
|
-
const data = Extractors_1.
|
|
341
|
+
const data = Extractors_1.Extractors[resource](response) ?? false;
|
|
342
342
|
return data;
|
|
343
343
|
}
|
|
344
344
|
/**
|
|
@@ -369,7 +369,7 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
369
369
|
* ```
|
|
370
370
|
*/
|
|
371
371
|
async retweeters(id, count, cursor) {
|
|
372
|
-
const resource = Resource_1.
|
|
372
|
+
const resource = Resource_1.ResourceType.TWEET_RETWEETERS;
|
|
373
373
|
// Fetching raw list of retweeters
|
|
374
374
|
const response = await this.request(resource, {
|
|
375
375
|
id: id,
|
|
@@ -377,7 +377,7 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
377
377
|
cursor: cursor,
|
|
378
378
|
});
|
|
379
379
|
// Deserializing response
|
|
380
|
-
const data = Extractors_1.
|
|
380
|
+
const data = Extractors_1.Extractors[resource](response);
|
|
381
381
|
return data;
|
|
382
382
|
}
|
|
383
383
|
/**
|
|
@@ -411,11 +411,11 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
411
411
|
* Scheduling a tweet is similar to {@link post}ing, except that an extra parameter called `scheduleFor` is used.
|
|
412
412
|
*/
|
|
413
413
|
async schedule(options) {
|
|
414
|
-
const resource = Resource_1.
|
|
414
|
+
const resource = Resource_1.ResourceType.TWEET_SCHEDULE;
|
|
415
415
|
// Scheduling the tweet
|
|
416
416
|
const response = await this.request(resource, { tweet: options });
|
|
417
417
|
// Deserializing response
|
|
418
|
-
const data = Extractors_1.
|
|
418
|
+
const data = Extractors_1.Extractors[resource](response);
|
|
419
419
|
return data;
|
|
420
420
|
}
|
|
421
421
|
/**
|
|
@@ -451,7 +451,7 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
451
451
|
* For details about available filters, refer to {@link TweetFilter}
|
|
452
452
|
*/
|
|
453
453
|
async search(filter, count, cursor) {
|
|
454
|
-
const resource = Resource_1.
|
|
454
|
+
const resource = Resource_1.ResourceType.TWEET_SEARCH;
|
|
455
455
|
// Fetching raw list of filtered tweets
|
|
456
456
|
const response = await this.request(resource, {
|
|
457
457
|
filter: filter,
|
|
@@ -459,7 +459,7 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
459
459
|
cursor: cursor,
|
|
460
460
|
});
|
|
461
461
|
// Deserializing response
|
|
462
|
-
const data = Extractors_1.
|
|
462
|
+
const data = Extractors_1.Extractors[resource](response);
|
|
463
463
|
// Sorting the tweets by date, from recent to oldest
|
|
464
464
|
data.list.sort((a, b) => new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf());
|
|
465
465
|
return data;
|
|
@@ -552,11 +552,11 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
552
552
|
* ```
|
|
553
553
|
*/
|
|
554
554
|
async unlike(id) {
|
|
555
|
-
const resource = Resource_1.
|
|
555
|
+
const resource = Resource_1.ResourceType.TWEET_UNLIKE;
|
|
556
556
|
// Unliking the tweet
|
|
557
557
|
const response = await this.request(resource, { id: id });
|
|
558
558
|
// Deserializing the response
|
|
559
|
-
const data = Extractors_1.
|
|
559
|
+
const data = Extractors_1.Extractors[resource](response) ?? false;
|
|
560
560
|
return data;
|
|
561
561
|
}
|
|
562
562
|
/**
|
|
@@ -585,11 +585,11 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
585
585
|
* ```
|
|
586
586
|
*/
|
|
587
587
|
async unpost(id) {
|
|
588
|
-
const resource = Resource_1.
|
|
588
|
+
const resource = Resource_1.ResourceType.TWEET_UNPOST;
|
|
589
589
|
// Unposting the tweet
|
|
590
590
|
const response = await this.request(resource, { id: id });
|
|
591
591
|
// Deserializing the response
|
|
592
|
-
const data = Extractors_1.
|
|
592
|
+
const data = Extractors_1.Extractors[resource](response) ?? false;
|
|
593
593
|
return data;
|
|
594
594
|
}
|
|
595
595
|
/**
|
|
@@ -618,11 +618,11 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
618
618
|
* ```
|
|
619
619
|
*/
|
|
620
620
|
async unretweet(id) {
|
|
621
|
-
const resource = Resource_1.
|
|
621
|
+
const resource = Resource_1.ResourceType.TWEET_UNRETWEET;
|
|
622
622
|
// Unretweeting the tweet
|
|
623
623
|
const response = await this.request(resource, { id: id });
|
|
624
624
|
// Deserializing the response
|
|
625
|
-
const data = Extractors_1.
|
|
625
|
+
const data = Extractors_1.Extractors[resource](response) ?? false;
|
|
626
626
|
return data;
|
|
627
627
|
}
|
|
628
628
|
/**
|
|
@@ -651,11 +651,11 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
651
651
|
* ```
|
|
652
652
|
*/
|
|
653
653
|
async unschedule(id) {
|
|
654
|
-
const resource = Resource_1.
|
|
654
|
+
const resource = Resource_1.ResourceType.TWEET_UNSCHEDULE;
|
|
655
655
|
// Unscheduling the tweet
|
|
656
656
|
const response = await this.request(resource, { id: id });
|
|
657
657
|
// Deserializing the response
|
|
658
|
-
const data = Extractors_1.
|
|
658
|
+
const data = Extractors_1.Extractors[resource](response) ?? false;
|
|
659
659
|
return data;
|
|
660
660
|
}
|
|
661
661
|
/**
|
|
@@ -692,13 +692,13 @@ class TweetService extends FetcherService_1.FetcherService {
|
|
|
692
692
|
async upload(media) {
|
|
693
693
|
// INITIALIZE
|
|
694
694
|
const size = typeof media == 'string' ? (0, fs_1.statSync)(media).size : media.byteLength;
|
|
695
|
-
const id = (await this.request(Resource_1.
|
|
695
|
+
const id = (await this.request(Resource_1.ResourceType.MEDIA_UPLOAD_INITIALIZE, {
|
|
696
696
|
upload: { size: size },
|
|
697
697
|
})).media_id_string;
|
|
698
698
|
// APPEND
|
|
699
|
-
await this.request(Resource_1.
|
|
699
|
+
await this.request(Resource_1.ResourceType.MEDIA_UPLOAD_APPEND, { upload: { id: id, media: media } });
|
|
700
700
|
// FINALIZE
|
|
701
|
-
await this.request(Resource_1.
|
|
701
|
+
await this.request(Resource_1.ResourceType.MEDIA_UPLOAD_FINALIZE, { upload: { id: id } });
|
|
702
702
|
return id;
|
|
703
703
|
}
|
|
704
704
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TweetService.js","sourceRoot":"","sources":["../../../src/services/public/TweetService.ts"],"names":[],"mappings":";;;AAAA,2BAA8B;AAE9B,6DAA0D;AAC1D,
|
|
1
|
+
{"version":3,"file":"T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