rettiwt-api 4.2.0-alpha.1 → 4.2.0-alpha.2
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/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 +2 -1
- package/dist/collections/Extractors.js +3 -0
- package/dist/collections/Extractors.js.map +1 -1
- package/dist/collections/Groups.js +1 -0
- package/dist/collections/Groups.js.map +1 -1
- package/dist/collections/Requests.js +1 -0
- 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/enums/Resource.d.ts +1 -0
- package/dist/enums/Resource.js +1 -0
- package/dist/enums/Resource.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/models/args/FetchArgs.js +11 -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 +45 -5
- package/dist/models/data/Tweet.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/package.json +2 -2
- package/src/Rettiwt.ts +5 -0
- package/src/cli.ts +2 -0
- package/src/collections/Extractors.ts +3 -0
- package/src/collections/Groups.ts +1 -0
- package/src/collections/Requests.ts +1 -0
- package/src/commands/List.ts +49 -0
- package/src/enums/Resource.ts +1 -0
- package/src/index.ts +3 -0
- package/src/models/args/FetchArgs.ts +11 -1
- package/src/models/data/Tweet.ts +52 -5
- package/src/services/public/FetcherService.ts +17 -17
- package/src/services/public/ListService.ts +112 -0
|
@@ -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,I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AAC,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"}
|
|
@@ -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,6CAA4C;AAE5C;;;;GA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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;eACzC,kBAAM,MA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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rettiwt-api",
|
|
3
|
-
"version": "4.2.0-alpha.
|
|
3
|
+
"version": "4.2.0-alpha.2",
|
|
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.4.0-alpha.
|
|
39
|
+
"rettiwt-core": "4.4.0-alpha.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "20.4.1",
|
package/src/Rettiwt.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AuthService } from './services/public/AuthService';
|
|
2
|
+
import { ListService } from './services/public/ListService';
|
|
2
3
|
import { TweetService } from './services/public/TweetService';
|
|
3
4
|
import { UserService } from './services/public/UserService';
|
|
4
5
|
import { IRettiwtConfig } from './types/RettiwtConfig';
|
|
@@ -48,6 +49,9 @@ export class Rettiwt {
|
|
|
48
49
|
/** The instance used to authenticate. */
|
|
49
50
|
public auth: AuthService;
|
|
50
51
|
|
|
52
|
+
/** The instance used to fetch data related to lists. */
|
|
53
|
+
public list: ListService;
|
|
54
|
+
|
|
51
55
|
/** The instance used to fetch data related to tweets. */
|
|
52
56
|
public tweet: TweetService;
|
|
53
57
|
|
|
@@ -61,6 +65,7 @@ export class Rettiwt {
|
|
|
61
65
|
*/
|
|
62
66
|
public constructor(config?: IRettiwtConfig) {
|
|
63
67
|
this.auth = new AuthService(config);
|
|
68
|
+
this.list = new ListService(config);
|
|
64
69
|
this.tweet = new TweetService(config);
|
|
65
70
|
this.user = new UserService(config);
|
|
66
71
|
}
|
package/src/cli.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { createCommand } from 'commander';
|
|
4
4
|
|
|
5
5
|
import auth from './commands/Auth';
|
|
6
|
+
import list from './commands/List';
|
|
6
7
|
import tweet from './commands/Tweet';
|
|
7
8
|
import user from './commands/User';
|
|
8
9
|
import { Rettiwt } from './Rettiwt';
|
|
@@ -32,6 +33,7 @@ const rettiwt: Rettiwt = new Rettiwt({
|
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
// Adding sub-commands
|
|
36
|
+
program.addCommand(list(rettiwt));
|
|
35
37
|
program.addCommand(tweet(rettiwt));
|
|
36
38
|
program.addCommand(user(rettiwt));
|
|
37
39
|
program.addCommand(auth(rettiwt));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IInitializeMediaUploadResponse,
|
|
3
|
+
IListMembersResponse,
|
|
3
4
|
IListTweetsResponse,
|
|
4
5
|
ITweetDetailsResponse,
|
|
5
6
|
ITweetLikeResponse,
|
|
@@ -42,6 +43,8 @@ import { User } from '../models/data/User';
|
|
|
42
43
|
*/
|
|
43
44
|
export const extractors = {
|
|
44
45
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
46
|
+
LIST_MEMBERS: (response: IListMembersResponse): CursoredData<User> =>
|
|
47
|
+
new CursoredData<User>(response, EBaseType.USER),
|
|
45
48
|
LIST_TWEETS: (response: IListTweetsResponse): CursoredData<Tweet> =>
|
|
46
49
|
new CursoredData<Tweet>(response, EBaseType.TWEET),
|
|
47
50
|
|
|
@@ -19,6 +19,7 @@ const request = new Request();
|
|
|
19
19
|
*/
|
|
20
20
|
export const requests: { [key in keyof typeof EResourceType]: (args: FetchArgs | PostArgs) => AxiosRequestConfig } = {
|
|
21
21
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
22
|
+
LIST_MEMBERS: (args: FetchArgs) => request.list.members(args.id!, args.count, args.cursor),
|
|
22
23
|
LIST_TWEETS: (args: FetchArgs) => request.list.tweets(args.id!, args.count, args.cursor),
|
|
23
24
|
|
|
24
25
|
MEDIA_UPLOAD_APPEND: (args: PostArgs) => request.media.appendUpload(args.upload!.id!, args.upload!.media!),
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Command, createCommand } from 'commander';
|
|
2
|
+
|
|
3
|
+
import { output } from '../helper/CliUtils';
|
|
4
|
+
import { Rettiwt } from '../Rettiwt';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new 'list' command which uses the given Rettiwt instance.
|
|
8
|
+
*
|
|
9
|
+
* @param rettiwt - The Rettiwt instance to use.
|
|
10
|
+
* @returns The created 'list' command.
|
|
11
|
+
*/
|
|
12
|
+
function createListCommand(rettiwt: Rettiwt): Command {
|
|
13
|
+
// Creating the 'list' command
|
|
14
|
+
const list = createCommand('list').description('Access resources releated to lists');
|
|
15
|
+
|
|
16
|
+
// Members
|
|
17
|
+
list.command('members')
|
|
18
|
+
.description('Fetch the list of members of the given tweet list')
|
|
19
|
+
.argument('<id>', 'The id of the tweet list')
|
|
20
|
+
.argument('[count]', 'The number of members to fetch')
|
|
21
|
+
.argument('[cursor]', 'The cursor to the batch of members to fetch')
|
|
22
|
+
.action(async (id: string, count?: string, cursor?: string) => {
|
|
23
|
+
try {
|
|
24
|
+
const members = await rettiwt.list.members(id, count ? parseInt(count) : undefined, cursor);
|
|
25
|
+
output(members);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
output(error);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Tweets
|
|
32
|
+
list.command('tweets')
|
|
33
|
+
.description('Fetch the list of tweets in the tweet list with the given id')
|
|
34
|
+
.argument('<id>', 'The id of the tweet list')
|
|
35
|
+
.argument('[count]', 'The number of tweets to fetch')
|
|
36
|
+
.argument('[cursor]', 'The cursor to the batch of tweets to fetch')
|
|
37
|
+
.action(async (id: string, count?: string, cursor?: string) => {
|
|
38
|
+
try {
|
|
39
|
+
const tweets = await rettiwt.list.tweets(id, count ? parseInt(count) : undefined, cursor);
|
|
40
|
+
output(tweets);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
output(error);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return list;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default createListCommand;
|
package/src/enums/Resource.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -38,6 +38,7 @@ export * from './types/ErrorHandler';
|
|
|
38
38
|
// RAW TYPES
|
|
39
39
|
export {
|
|
40
40
|
IInitializeMediaUploadResponse,
|
|
41
|
+
IListMembersResponse,
|
|
41
42
|
IListTweetsResponse,
|
|
42
43
|
ITweetDetailsResponse,
|
|
43
44
|
ITweetLikeResponse,
|
|
@@ -53,6 +54,7 @@ export {
|
|
|
53
54
|
ITweetUnretweetResponse,
|
|
54
55
|
} from 'rettiwt-core';
|
|
55
56
|
export {
|
|
57
|
+
IUserBookmarksResponse,
|
|
56
58
|
IUserDetailsResponse,
|
|
57
59
|
IUserFollowedResponse,
|
|
58
60
|
IUserFollowersResponse,
|
|
@@ -61,6 +63,7 @@ export {
|
|
|
61
63
|
IUserHighlightsResponse,
|
|
62
64
|
IUserLikesResponse,
|
|
63
65
|
IUserMediaResponse,
|
|
66
|
+
IUserNotifications as IUserNotificationsResponse,
|
|
64
67
|
IUserRecommendedResponse,
|
|
65
68
|
IUserSubscriptionsResponse,
|
|
66
69
|
IUserTweetsAndRepliesResponse,
|
|
@@ -52,6 +52,7 @@ export class FetchArgs {
|
|
|
52
52
|
})
|
|
53
53
|
@IsOptional({
|
|
54
54
|
groups: [
|
|
55
|
+
EResourceType.LIST_MEMBERS,
|
|
55
56
|
EResourceType.LIST_TWEETS,
|
|
56
57
|
EResourceType.TWEET_RETWEETERS,
|
|
57
58
|
EResourceType.TWEET_SEARCH,
|
|
@@ -68,6 +69,7 @@ export class FetchArgs {
|
|
|
68
69
|
})
|
|
69
70
|
@Min(1, {
|
|
70
71
|
groups: [
|
|
72
|
+
EResourceType.LIST_MEMBERS,
|
|
71
73
|
EResourceType.LIST_TWEETS,
|
|
72
74
|
EResourceType.TWEET_RETWEETERS,
|
|
73
75
|
EResourceType.TWEET_SEARCH,
|
|
@@ -84,6 +86,7 @@ export class FetchArgs {
|
|
|
84
86
|
})
|
|
85
87
|
@Max(100, {
|
|
86
88
|
groups: [
|
|
89
|
+
EResourceType.LIST_MEMBERS,
|
|
87
90
|
EResourceType.LIST_TWEETS,
|
|
88
91
|
EResourceType.TWEET_RETWEETERS,
|
|
89
92
|
EResourceType.USER_FOLLOWERS,
|
|
@@ -119,6 +122,7 @@ export class FetchArgs {
|
|
|
119
122
|
})
|
|
120
123
|
@IsOptional({
|
|
121
124
|
groups: [
|
|
125
|
+
EResourceType.LIST_MEMBERS,
|
|
122
126
|
EResourceType.LIST_TWEETS,
|
|
123
127
|
EResourceType.TWEET_RETWEETERS,
|
|
124
128
|
EResourceType.TWEET_SEARCH,
|
|
@@ -137,6 +141,7 @@ export class FetchArgs {
|
|
|
137
141
|
})
|
|
138
142
|
@IsString({
|
|
139
143
|
groups: [
|
|
144
|
+
EResourceType.LIST_MEMBERS,
|
|
140
145
|
EResourceType.LIST_TWEETS,
|
|
141
146
|
EResourceType.TWEET_RETWEETERS,
|
|
142
147
|
EResourceType.TWEET_SEARCH,
|
|
@@ -163,6 +168,7 @@ export class FetchArgs {
|
|
|
163
168
|
*/
|
|
164
169
|
@IsEmpty({
|
|
165
170
|
groups: [
|
|
171
|
+
EResourceType.LIST_MEMBERS,
|
|
166
172
|
EResourceType.LIST_TWEETS,
|
|
167
173
|
EResourceType.TWEET_DETAILS,
|
|
168
174
|
EResourceType.TWEET_DETAILS_ALT,
|
|
@@ -202,6 +208,7 @@ export class FetchArgs {
|
|
|
202
208
|
})
|
|
203
209
|
@IsNotEmpty({
|
|
204
210
|
groups: [
|
|
211
|
+
EResourceType.LIST_MEMBERS,
|
|
205
212
|
EResourceType.LIST_TWEETS,
|
|
206
213
|
EResourceType.TWEET_DETAILS,
|
|
207
214
|
EResourceType.TWEET_DETAILS_ALT,
|
|
@@ -220,6 +227,7 @@ export class FetchArgs {
|
|
|
220
227
|
})
|
|
221
228
|
@IsString({
|
|
222
229
|
groups: [
|
|
230
|
+
EResourceType.LIST_MEMBERS,
|
|
223
231
|
EResourceType.LIST_TWEETS,
|
|
224
232
|
EResourceType.TWEET_DETAILS,
|
|
225
233
|
EResourceType.TWEET_DETAILS_ALT,
|
|
@@ -238,6 +246,7 @@ export class FetchArgs {
|
|
|
238
246
|
})
|
|
239
247
|
@IsNumberString(undefined, {
|
|
240
248
|
groups: [
|
|
249
|
+
EResourceType.LIST_MEMBERS,
|
|
241
250
|
EResourceType.LIST_TWEETS,
|
|
242
251
|
EResourceType.TWEET_DETAILS,
|
|
243
252
|
EResourceType.TWEET_DETAILS_ALT,
|
|
@@ -267,6 +276,7 @@ export class FetchArgs {
|
|
|
267
276
|
*/
|
|
268
277
|
@IsEmpty({
|
|
269
278
|
groups: [
|
|
279
|
+
EResourceType.LIST_MEMBERS,
|
|
270
280
|
EResourceType.LIST_TWEETS,
|
|
271
281
|
EResourceType.TWEET_DETAILS,
|
|
272
282
|
EResourceType.TWEET_DETAILS_ALT,
|
|
@@ -298,7 +308,7 @@ export class FetchArgs {
|
|
|
298
308
|
this.count = args.count;
|
|
299
309
|
this.cursor = args.cursor;
|
|
300
310
|
this.filter = args.filter ? new TweetFilter(args.filter) : undefined;
|
|
301
|
-
this.results = args.results
|
|
311
|
+
this.results = args.results;
|
|
302
312
|
|
|
303
313
|
// Validating this object
|
|
304
314
|
const validationResult = validateSync(this, { groups: [resource] });
|