rettiwt-api 2.4.2 → 2.5.1
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 +5 -0
- package/.github/workflows/documentation.yml +1 -1
- package/.github/workflows/publish.yml +1 -1
- package/.prettierrc +1 -1
- package/README.md +69 -19
- package/dist/Rettiwt.d.ts +7 -4
- package/dist/Rettiwt.js +4 -2
- package/dist/Rettiwt.js.map +1 -1
- package/dist/cli.js +4 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/Auth.d.ts +2 -1
- package/dist/commands/Auth.js +10 -17
- package/dist/commands/Auth.js.map +1 -1
- package/dist/commands/Tweet.js +36 -3
- package/dist/commands/Tweet.js.map +1 -1
- package/dist/enums/{ApiErrors.js → Api.js} +1 -1
- package/dist/enums/Api.js.map +1 -0
- package/dist/enums/Http.d.ts +68 -0
- package/dist/enums/Http.js +73 -0
- package/dist/enums/Http.js.map +1 -0
- package/dist/enums/Logging.d.ts +1 -0
- package/dist/enums/Logging.js +1 -0
- package/dist/enums/Logging.js.map +1 -1
- package/dist/index.d.ts +15 -14
- package/dist/index.js +22 -17
- package/dist/index.js.map +1 -1
- package/dist/models/args/TweetArgs.d.ts +44 -0
- package/dist/models/args/TweetArgs.js +82 -0
- package/dist/models/args/TweetArgs.js.map +1 -0
- package/dist/models/{public → data}/CursoredData.d.ts +5 -3
- package/dist/models/{public → data}/CursoredData.js +1 -0
- package/dist/models/data/CursoredData.js.map +1 -0
- package/dist/{types/public → models/data}/List.d.ts +8 -1
- package/dist/models/data/List.js.map +1 -0
- package/dist/models/data/Media.d.ts +14 -0
- package/dist/models/data/Media.js +19 -0
- package/dist/models/data/Media.js.map +1 -0
- package/dist/{types/public → models/data}/Tweet.d.ts +26 -8
- package/dist/models/{public → data}/Tweet.js +4 -0
- package/dist/models/data/Tweet.js.map +1 -0
- package/dist/{types/public → models/data}/User.d.ts +8 -1
- package/dist/models/data/User.js.map +1 -0
- package/dist/models/errors/ApiError.d.ts +17 -0
- package/dist/models/errors/ApiError.js +42 -0
- package/dist/models/errors/ApiError.js.map +1 -0
- package/dist/models/errors/HttpError.d.ts +17 -0
- package/dist/models/errors/HttpError.js +42 -0
- package/dist/models/errors/HttpError.js.map +1 -0
- package/dist/models/errors/RettiwtError.d.ts +8 -0
- package/dist/models/errors/RettiwtError.js +34 -0
- package/dist/models/errors/RettiwtError.js.map +1 -0
- package/dist/models/errors/TimeoutError.d.ts +14 -0
- package/dist/models/errors/TimeoutError.js +39 -0
- package/dist/models/errors/TimeoutError.js.map +1 -0
- package/dist/services/internal/ErrorService.d.ts +85 -0
- package/dist/services/internal/ErrorService.js +144 -0
- package/dist/services/internal/ErrorService.js.map +1 -0
- package/dist/services/internal/FetcherService.d.ts +22 -24
- package/dist/services/internal/FetcherService.js +79 -59
- package/dist/services/internal/FetcherService.js.map +1 -1
- package/dist/services/public/AuthService.d.ts +66 -0
- package/dist/services/public/AuthService.js +160 -0
- package/dist/services/public/AuthService.js.map +1 -0
- package/dist/services/public/TweetService.d.ts +27 -8
- package/dist/services/public/TweetService.js +45 -8
- package/dist/services/public/TweetService.js.map +1 -1
- package/dist/services/public/UserService.d.ts +5 -5
- package/dist/services/public/UserService.js.map +1 -1
- package/dist/types/ErrorHandler.d.ts +13 -0
- package/dist/types/{public/User.js → ErrorHandler.js} +1 -1
- package/dist/types/ErrorHandler.js.map +1 -0
- package/dist/types/RettiwtConfig.d.ts +32 -0
- package/dist/types/RettiwtConfig.js.map +1 -0
- package/package.json +6 -5
- package/src/Rettiwt.ts +10 -5
- package/src/cli.ts +4 -2
- package/src/commands/Auth.ts +5 -16
- package/src/commands/Tweet.ts +56 -3
- package/src/enums/Http.ts +68 -0
- package/src/enums/Logging.ts +1 -0
- package/src/index.ts +25 -18
- package/src/models/args/TweetArgs.ts +98 -0
- package/src/models/{public → data}/CursoredData.ts +6 -5
- package/src/models/{public → data}/List.ts +14 -4
- package/src/models/data/Media.ts +19 -0
- package/src/models/{public → data}/Tweet.ts +39 -5
- package/src/models/{public → data}/User.ts +28 -4
- package/src/models/errors/ApiError.ts +24 -0
- package/src/models/errors/HttpError.ts +24 -0
- package/src/models/errors/RettiwtError.ts +12 -0
- package/src/models/errors/TimeoutError.ts +18 -0
- package/src/services/internal/ErrorService.ts +158 -0
- package/src/services/internal/FetcherService.ts +94 -80
- package/src/services/public/AuthService.ts +97 -0
- package/src/services/public/TweetService.ts +48 -10
- package/src/services/public/UserService.ts +7 -5
- package/src/types/ErrorHandler.ts +13 -0
- package/src/types/RettiwtConfig.ts +40 -0
- package/dist/enums/ApiErrors.js.map +0 -1
- package/dist/enums/HTTP.d.ts +0 -17
- package/dist/enums/HTTP.js +0 -22
- package/dist/enums/HTTP.js.map +0 -1
- package/dist/models/internal/RettiwtConfig.d.ts +0 -18
- package/dist/models/internal/RettiwtConfig.js +0 -24
- package/dist/models/internal/RettiwtConfig.js.map +0 -1
- package/dist/models/public/CursoredData.js.map +0 -1
- package/dist/models/public/List.d.ts +0 -22
- package/dist/models/public/List.js.map +0 -1
- package/dist/models/public/Tweet.d.ts +0 -62
- package/dist/models/public/Tweet.js.map +0 -1
- package/dist/models/public/User.d.ts +0 -29
- package/dist/models/public/User.js.map +0 -1
- package/dist/types/internal/RettiwtConfig.d.ts +0 -15
- package/dist/types/internal/RettiwtConfig.js.map +0 -1
- package/dist/types/public/CursoredData.d.ts +0 -22
- package/dist/types/public/CursoredData.js +0 -3
- package/dist/types/public/CursoredData.js.map +0 -1
- package/dist/types/public/List.js +0 -3
- package/dist/types/public/List.js.map +0 -1
- package/dist/types/public/Tweet.js +0 -3
- package/dist/types/public/Tweet.js.map +0 -1
- package/dist/types/public/User.js.map +0 -1
- package/src/enums/HTTP.ts +0 -17
- package/src/models/internal/RettiwtConfig.ts +0 -26
- package/src/types/internal/RettiwtConfig.ts +0 -18
- package/src/types/public/CursoredData.ts +0 -24
- package/src/types/public/List.ts +0 -27
- package/src/types/public/Tweet.ts +0 -86
- package/src/types/public/User.ts +0 -48
- /package/dist/enums/{ApiErrors.d.ts → Api.d.ts} +0 -0
- /package/dist/models/{public → data}/List.js +0 -0
- /package/dist/models/{public → data}/User.js +0 -0
- /package/dist/types/{internal/RettiwtConfig.js → RettiwtConfig.js} +0 -0
- /package/src/enums/{ApiErrors.ts → Api.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TweetService.js","sourceRoot":"","sources":["../../../src/services/public/TweetService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,
|
|
1
|
+
{"version":3,"file":"TweetService.js","sourceRoot":"","sources":["../../../src/services/public/TweetService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAW;AACX,6CAAqE;AAErE,WAAW;AACX,6DAA4D;AAS5D,yDAAwE;AAExE;;;;GAIG;AACH;IAAkC,gCAAc;IAC/C;;;;OAIG;IACH,sBAAmB,MAAuB;eACzC,kBAAM,MAAM,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACU,8BAAO,GAApB,UAAqB,EAAU;;;;;4BAEjB,qBAAM,IAAI,CAAC,KAAK,CAAQ,4BAAa,CAAC,aAAa,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAA;;wBAAvE,IAAI,GAAG,SAAgE;wBAE7E,sBAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC;;;;KACpB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACU,6BAAM,GAAnB,UAAoB,KAAkB,EAAE,KAAc,EAAE,MAAe;;;;;4BAEzD,qBAAM,IAAI,CAAC,KAAK,CAAQ,4BAAa,CAAC,YAAY,EAAE;4BAChE,MAAM,EAAE,KAAK;4BACb,KAAK,EAAE,KAAK;4BACZ,MAAM,EAAE,MA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;IACU,+BAAQ,GAArB,UAAsB,OAAe;;;;;4BAEvB,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;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACU,8BAAO,GAApB,UAAqB,OAAe;;;;;4BAEtB,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,AA5UD,CAAkC,+BAAc,GA4U/C;AA5UY,oCAAY"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FetcherService } from '../internal/FetcherService';
|
|
2
|
-
import {
|
|
3
|
-
import { User } from '../../models/
|
|
4
|
-
import { Tweet } from '../../models/
|
|
5
|
-
import { CursoredData } from '../../models/
|
|
2
|
+
import { IRettiwtConfig } from '../../types/RettiwtConfig';
|
|
3
|
+
import { User } from '../../models/data/User';
|
|
4
|
+
import { Tweet } from '../../models/data/Tweet';
|
|
5
|
+
import { CursoredData } from '../../models/data/CursoredData';
|
|
6
6
|
/**
|
|
7
7
|
* Handles fetching of data related to user account
|
|
8
8
|
*
|
|
@@ -14,7 +14,7 @@ export declare class UserService extends FetcherService {
|
|
|
14
14
|
*
|
|
15
15
|
* @internal
|
|
16
16
|
*/
|
|
17
|
-
constructor(config?:
|
|
17
|
+
constructor(config?: IRettiwtConfig);
|
|
18
18
|
/**
|
|
19
19
|
* Get the details of a user.
|
|
20
20
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../../src/services/public/UserService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;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,EAAE,KAAK;4BACZ,MAAM,EAAE,MAAM;yBACd,CAAC,EAAA;;wBAJI,IAAI,GAAG,SAIX;wBAEF,qEAAqE;wBACrE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,MAAM,EAA1B,CAA0B,CAAC,CAAC;wBAEpE,sBAAO,IAAI,EAAC;;;;KACZ;IACF,kBAAC;AAAD,CAAC,AA3QD,CAAiC,+BAAc,GA2Q9C;AA3QY,kCAAW"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the error handler that processes API/HTTP errors in the responses.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface IErrorHandler {
|
|
7
|
+
/**
|
|
8
|
+
* The method called when an error response is received from Twitter API.
|
|
9
|
+
*
|
|
10
|
+
* @param error - The error caught while making request to Twitter API.
|
|
11
|
+
*/
|
|
12
|
+
handle(error: unknown): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorHandler.js","sourceRoot":"","sources":["../../src/types/ErrorHandler.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IErrorHandler } from './ErrorHandler';
|
|
2
|
+
/**
|
|
3
|
+
* The configuration for initializing a new Rettiwt instance.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface IRettiwtConfig {
|
|
8
|
+
/** The apiKey (cookie) to use for authenticating Rettiwt against Twitter API. */
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
/** The guestKey (guest token) to use for guest access to Twitter API. */
|
|
11
|
+
guestKey?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Optional URL to proxy server to use for requests to Twitter API.
|
|
14
|
+
*
|
|
15
|
+
* @remarks When deploying to cloud platforms, if setting {@link IRettiwtConfig.authProxyUrl} does not resolve Error 429, then this might be required.
|
|
16
|
+
*/
|
|
17
|
+
proxyUrl?: URL;
|
|
18
|
+
/**
|
|
19
|
+
* Optional URL to proxy server to use for authentication against Twitter API.
|
|
20
|
+
*
|
|
21
|
+
* @remarks Required when deploying to cloud platforms to bypass Error 429.
|
|
22
|
+
*
|
|
23
|
+
* @defaultValue Same as {@link IRettiwtConfig.proxyUrl}
|
|
24
|
+
*/
|
|
25
|
+
authProxyUrl?: URL;
|
|
26
|
+
/** The max wait time (in milli-seconds) for a response; if not set, Twitter server timeout is used. */
|
|
27
|
+
timeout?: number;
|
|
28
|
+
/** Whether to write logs to console or not. */
|
|
29
|
+
logging?: boolean;
|
|
30
|
+
/** Optional custom error handler to define error conditions and process API/HTTP errors in responses. */
|
|
31
|
+
errorHandler?: IErrorHandler;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RettiwtConfig.js","sourceRoot":"","sources":["../../src/types/RettiwtConfig.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rettiwt-api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
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!",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"prepare": "tsc",
|
|
13
13
|
"format": "prettier --write .",
|
|
14
14
|
"lint": "eslint --max-warnings 0 .",
|
|
15
|
-
"docs": "typedoc src/index.ts",
|
|
15
|
+
"docs": "typedoc --excludePrivate --excludeProtected --excludeInternal src/index.ts",
|
|
16
16
|
"debug": "nodemon ./dist/index.js --inspect=0.0.0.0:9229"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
@@ -29,11 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://rishikant181.github.io/Rettiwt-API/",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"axios": "1.3
|
|
32
|
+
"axios": "1.6.3",
|
|
33
|
+
"class-validator": "0.14.1",
|
|
33
34
|
"commander": "11.1.0",
|
|
34
35
|
"https-proxy-agent": "7.0.2",
|
|
35
|
-
"rettiwt-auth": "2.
|
|
36
|
-
"rettiwt-core": "3.
|
|
36
|
+
"rettiwt-auth": "2.1.0",
|
|
37
|
+
"rettiwt-core": "3.3.1"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@types/node": "20.4.1",
|
package/src/Rettiwt.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
// SERVICES
|
|
2
|
+
import { AuthService } from './services/public/AuthService';
|
|
2
3
|
import { TweetService } from './services/public/TweetService';
|
|
3
4
|
import { UserService } from './services/public/UserService';
|
|
4
5
|
|
|
5
|
-
//
|
|
6
|
-
import {
|
|
6
|
+
// TYPES
|
|
7
|
+
import { IRettiwtConfig } from './types/RettiwtConfig';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* The class for accessing Twitter API.
|
|
10
11
|
*
|
|
11
12
|
* The created Rettiwt instance can be configured by passing in a configuration object to the constructor.
|
|
12
13
|
*
|
|
13
|
-
* For details regarding the available configuration options, refer to {@link
|
|
14
|
+
* For details regarding the available configuration options, refer to {@link IRettiwtConfig}
|
|
14
15
|
*
|
|
15
16
|
* @example Creating a Rettiwt instance with 'guest' authentication:
|
|
16
17
|
* ```
|
|
@@ -41,12 +42,15 @@ import { RettiwtConfig } from './models/internal/RettiwtConfig';
|
|
|
41
42
|
* import { Rettiwt } from 'rettiwt-api';
|
|
42
43
|
*
|
|
43
44
|
* // Creating a new Rettiwt instance
|
|
44
|
-
* const rettiwt = new Rettiwt({ apiKey: 'API_KEY',
|
|
45
|
+
* const rettiwt = new Rettiwt({ apiKey: 'API_KEY', logging: true, proxyUrl: 'URL_TO_PROXY_SERVER' });
|
|
45
46
|
* ```
|
|
46
47
|
*
|
|
47
48
|
* @public
|
|
48
49
|
*/
|
|
49
50
|
export class Rettiwt {
|
|
51
|
+
/** The instance used to authenticate. */
|
|
52
|
+
public auth: AuthService;
|
|
53
|
+
|
|
50
54
|
/** The instance used to fetch data related to tweets. */
|
|
51
55
|
public tweet: TweetService;
|
|
52
56
|
|
|
@@ -58,7 +62,8 @@ export class Rettiwt {
|
|
|
58
62
|
*
|
|
59
63
|
* @param config - The config object for configuring the Rettiwt instance.
|
|
60
64
|
*/
|
|
61
|
-
public constructor(config?:
|
|
65
|
+
public constructor(config?: IRettiwtConfig) {
|
|
66
|
+
this.auth = new AuthService(config);
|
|
62
67
|
this.tweet = new TweetService(config);
|
|
63
68
|
this.user = new UserService(config);
|
|
64
69
|
}
|
package/src/cli.ts
CHANGED
|
@@ -19,7 +19,8 @@ const program = createCommand('rettiwt')
|
|
|
19
19
|
program
|
|
20
20
|
.option('-k, --key <string>', 'The API key to use for authentication')
|
|
21
21
|
.option('-l, --log', 'Enable logging to console')
|
|
22
|
-
.option('-p, --proxy <string>', 'The URL to the proxy to use')
|
|
22
|
+
.option('-p, --proxy <string>', 'The URL to the proxy to use')
|
|
23
|
+
.option('-t, --timeout <number>', 'The timout (in milli-seconds) to use for requests');
|
|
23
24
|
|
|
24
25
|
// Parsing the program to get supplied options
|
|
25
26
|
program.parse();
|
|
@@ -29,12 +30,13 @@ const rettiwt: Rettiwt = new Rettiwt({
|
|
|
29
30
|
apiKey: process.env.API_KEY ?? (program.opts().key as string),
|
|
30
31
|
logging: program.opts().log ? true : false,
|
|
31
32
|
proxyUrl: program.opts().proxy as URL,
|
|
33
|
+
timeout: program.opts().timeout ? Number(program.opts().timeout) : undefined,
|
|
32
34
|
});
|
|
33
35
|
|
|
34
36
|
// Adding sub-commands
|
|
35
37
|
program.addCommand(tweet(rettiwt));
|
|
36
38
|
program.addCommand(user(rettiwt));
|
|
37
|
-
program.addCommand(auth());
|
|
39
|
+
program.addCommand(auth(rettiwt));
|
|
38
40
|
|
|
39
41
|
// Finalizing the CLI
|
|
40
42
|
program.parse();
|
package/src/commands/Auth.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// PACKAGES
|
|
2
2
|
import { Command, createCommand } from 'commander';
|
|
3
|
-
import {
|
|
3
|
+
import { Rettiwt } from '../Rettiwt';
|
|
4
4
|
|
|
5
5
|
// UTILITY
|
|
6
6
|
import { output } from '../helper/CliUtils';
|
|
7
7
|
|
|
8
|
-
function createAuthCommand(): Command {
|
|
8
|
+
function createAuthCommand(rettiwt: Rettiwt): Command {
|
|
9
9
|
// Creating the 'auth' command
|
|
10
10
|
const auth = createCommand('auth').description('Manage authentication');
|
|
11
11
|
|
|
@@ -16,26 +16,15 @@ function createAuthCommand(): Command {
|
|
|
16
16
|
.argument('<username>', 'The username associated with the Twitter account')
|
|
17
17
|
.argument('<password>', 'The password to the Twitter account')
|
|
18
18
|
.action(async (email: string, username: string, password: string) => {
|
|
19
|
-
|
|
20
|
-
let apiKey: string =
|
|
21
|
-
(
|
|
22
|
-
await new Auth().getUserCredential({ email: email, userName: username, password: password })
|
|
23
|
-
).toHeader().cookie ?? '';
|
|
24
|
-
|
|
25
|
-
// Converting the credentials to base64 string
|
|
26
|
-
apiKey = Buffer.from(apiKey).toString('base64');
|
|
19
|
+
const apiKey: string = await rettiwt.auth.login(email, username, password);
|
|
27
20
|
output(apiKey);
|
|
28
21
|
});
|
|
29
22
|
|
|
30
23
|
// Guest
|
|
31
24
|
auth.command('guest')
|
|
32
|
-
.description('Generate a new guest
|
|
25
|
+
.description('Generate a new guest key')
|
|
33
26
|
.action(async () => {
|
|
34
|
-
|
|
35
|
-
let guestKey: string = (await new Auth().getGuestCredential()).guestToken ?? '';
|
|
36
|
-
|
|
37
|
-
// Converting the credentials to base64 string
|
|
38
|
-
guestKey = Buffer.from(guestKey).toString('base64');
|
|
27
|
+
const guestKey: string = await rettiwt.auth.guest();
|
|
39
28
|
output(guestKey);
|
|
40
29
|
});
|
|
41
30
|
|
package/src/commands/Tweet.ts
CHANGED
|
@@ -35,7 +35,26 @@ function createTweetCommand(rettiwt: Rettiwt): Command {
|
|
|
35
35
|
.option('-f, --from <string>', "Matches the tweets made by list of given users, separated by ';'")
|
|
36
36
|
.option('-t, --to <string>', "Matches the tweets made to the list of given users, separated by ';'")
|
|
37
37
|
.option('-w, --words <string>', "Matches the tweets containing the given list of words, separated by ';'")
|
|
38
|
+
.option('-p, --phrase <string>', 'Matches the tweets containing the exact phrase')
|
|
39
|
+
.option(
|
|
40
|
+
'--optional-words <string>',
|
|
41
|
+
"Matches the tweets containing any of the given list of words, separated by ';'",
|
|
42
|
+
)
|
|
43
|
+
.option(
|
|
44
|
+
'--exclude-words <string>',
|
|
45
|
+
"Matches the tweets that do not contain any of the give list of words, separated by ';'",
|
|
46
|
+
)
|
|
38
47
|
.option('-h, --hashtags <string>', "Matches the tweets containing the given list of hashtags, separated by ';'")
|
|
48
|
+
.option(
|
|
49
|
+
'-m, --mentions <string>',
|
|
50
|
+
"Matches the tweets that mention the give list of usernames, separated by ';'",
|
|
51
|
+
)
|
|
52
|
+
.option('-r, --min-replies <number>', 'Matches the tweets that have a minimum of given number of replies')
|
|
53
|
+
.option('-l, --min-likes <number>', 'Matches the tweets that have a minimum of given number of likes')
|
|
54
|
+
.option('-x, --min-retweets <number>', 'Matches the tweets that have a minimum of given number of retweets')
|
|
55
|
+
.option('-q, --quoted <string>', 'Matches the tweets that quote the tweet with the given id')
|
|
56
|
+
.option('--exclude-links', 'Matches tweets that do not contain links')
|
|
57
|
+
.option('--exclude-replies', 'Matches the tweets that are not replies')
|
|
39
58
|
.option('-s, --start <string>', 'Matches the tweets made since the given date (valid date string)')
|
|
40
59
|
.option('-e, --end <string>', 'Matches the tweets made upto the given date (valid date string)')
|
|
41
60
|
.action(async (count?: string, cursor?: string, options?: TweetSearchOptions) => {
|
|
@@ -88,8 +107,12 @@ function createTweetCommand(rettiwt: Rettiwt): Command {
|
|
|
88
107
|
.command('post')
|
|
89
108
|
.description('Post a tweet (text only)')
|
|
90
109
|
.argument('<text>', 'The text to post as a tweet')
|
|
91
|
-
.
|
|
92
|
-
|
|
110
|
+
.option('-m, --media [string]', "The path to the media item(s) to be posted, separated by ';'")
|
|
111
|
+
.action(async (text: string, options?: { media?: string }) => {
|
|
112
|
+
const result = await rettiwt.tweet.tweet(
|
|
113
|
+
text,
|
|
114
|
+
options?.media ? options?.media.split(';').map((item) => ({ path: item })) : undefined,
|
|
115
|
+
);
|
|
93
116
|
output(result);
|
|
94
117
|
});
|
|
95
118
|
|
|
@@ -125,7 +148,17 @@ class TweetSearchOptions {
|
|
|
125
148
|
public from?: string;
|
|
126
149
|
public to?: string;
|
|
127
150
|
public words?: string;
|
|
151
|
+
public phrase?: string;
|
|
152
|
+
public optionalWords?: string;
|
|
153
|
+
public excludeWords?: string;
|
|
128
154
|
public hashtags?: string;
|
|
155
|
+
public mentions?: string;
|
|
156
|
+
public minReplies?: number;
|
|
157
|
+
public minLikes?: number;
|
|
158
|
+
public minRetweets?: number;
|
|
159
|
+
public quoted?: string;
|
|
160
|
+
public excludeLinks?: boolean = false;
|
|
161
|
+
public excludeReplies?: boolean = false;
|
|
129
162
|
public start?: string;
|
|
130
163
|
public end?: string;
|
|
131
164
|
|
|
@@ -138,7 +171,17 @@ class TweetSearchOptions {
|
|
|
138
171
|
this.from = options?.from;
|
|
139
172
|
this.to = options?.to;
|
|
140
173
|
this.words = options?.words;
|
|
174
|
+
this.phrase = options?.phrase;
|
|
175
|
+
this.optionalWords = options?.optionalWords;
|
|
176
|
+
this.excludeWords = options?.excludeWords;
|
|
141
177
|
this.hashtags = options?.hashtags;
|
|
178
|
+
this.mentions = options?.mentions;
|
|
179
|
+
this.minReplies = options?.minReplies;
|
|
180
|
+
this.minLikes = options?.minLikes;
|
|
181
|
+
this.minRetweets = options?.minRetweets;
|
|
182
|
+
this.quoted = options?.quoted;
|
|
183
|
+
this.excludeLinks = options?.excludeLinks;
|
|
184
|
+
this.excludeReplies = options?.excludeReplies;
|
|
142
185
|
this.start = options?.start;
|
|
143
186
|
this.end = options?.end;
|
|
144
187
|
}
|
|
@@ -152,8 +195,18 @@ class TweetSearchOptions {
|
|
|
152
195
|
return new TweetFilter({
|
|
153
196
|
fromUsers: this.from ? this.from.split(';') : undefined,
|
|
154
197
|
toUsers: this.to ? this.to.split(';') : undefined,
|
|
155
|
-
|
|
198
|
+
includeWords: this.words ? this.words.split(';') : undefined,
|
|
199
|
+
includePhrase: this.phrase,
|
|
200
|
+
optionalWords: this.optionalWords ? this.optionalWords.split(';') : undefined,
|
|
201
|
+
excludeWords: this.excludeWords ? this.excludeWords.split(';') : undefined,
|
|
156
202
|
hashtags: this.hashtags ? this.hashtags.split(';') : undefined,
|
|
203
|
+
mentions: this.mentions ? this.mentions.split(';') : undefined,
|
|
204
|
+
minReplies: this.minReplies,
|
|
205
|
+
minLikes: this.minLikes,
|
|
206
|
+
minRetweets: this.minRetweets,
|
|
207
|
+
quoted: this.quoted,
|
|
208
|
+
links: !this.excludeLinks,
|
|
209
|
+
replies: !this.excludeReplies,
|
|
157
210
|
startDate: this.start ? new Date(this.start) : undefined,
|
|
158
211
|
endDate: this.end ? new Date(this.end) : undefined,
|
|
159
212
|
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The different types of http status codes
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export enum EHttpStatus {
|
|
7
|
+
CONTINUE = 100,
|
|
8
|
+
SWITCHING_PROTOCOLS = 101,
|
|
9
|
+
PROCESSING = 102,
|
|
10
|
+
OK = 200,
|
|
11
|
+
CREATED = 201,
|
|
12
|
+
ACCEPTED = 202,
|
|
13
|
+
NON_AUTHORITATIVE_INFORMATION = 203,
|
|
14
|
+
NO_CONTENT = 204,
|
|
15
|
+
RESET_CONTENT = 205,
|
|
16
|
+
PARTIAL_CONTENT = 206,
|
|
17
|
+
MULTI_STATUS = 207,
|
|
18
|
+
ALREADY_REPORTED = 208,
|
|
19
|
+
IM_USED = 226,
|
|
20
|
+
MULTIPLE_CHOICES = 300,
|
|
21
|
+
MOVED_PERMANENTLY = 301,
|
|
22
|
+
FOUND = 302,
|
|
23
|
+
SEE_OTHER = 303,
|
|
24
|
+
NOT_MODIFIED = 304,
|
|
25
|
+
USE_PROXY = 305,
|
|
26
|
+
SWITCH_PROXY = 306,
|
|
27
|
+
TEMPORARY_REDIRECT = 307,
|
|
28
|
+
PERMANENT_REDIRECT = 308,
|
|
29
|
+
BAD_REQUEST = 400,
|
|
30
|
+
UNAUTHORIZED = 401,
|
|
31
|
+
PAYMENT_REQUIRED = 402,
|
|
32
|
+
FORBIDDEN = 403,
|
|
33
|
+
NOT_FOUND = 404,
|
|
34
|
+
METHOD_NOT_ALLOWED = 405,
|
|
35
|
+
NOT_ACCEPTABLE = 406,
|
|
36
|
+
PROXY_AUTHENTICATION_REQUIRED = 407,
|
|
37
|
+
REQUEST_TIMEOUT = 408,
|
|
38
|
+
CONFLICT = 409,
|
|
39
|
+
GONE = 410,
|
|
40
|
+
LENGTH_REQUIRED = 411,
|
|
41
|
+
PRECONDITION_FAILED = 412,
|
|
42
|
+
PAYLOAD_TOO_LARGE = 413,
|
|
43
|
+
URI_TOO_LONG = 414,
|
|
44
|
+
UNSUPPORTED_MEDIA_TYPE = 415,
|
|
45
|
+
RANGE_NOT_SATISFIABLE = 416,
|
|
46
|
+
EXPECTATION_FAILED = 417,
|
|
47
|
+
I_AM_A_TEAPOT = 418,
|
|
48
|
+
MISDIRECTED_REQUEST = 421,
|
|
49
|
+
UNPROCESSABLE_ENTITY = 422,
|
|
50
|
+
LOCKED = 423,
|
|
51
|
+
FAILED_DEPENDENCY = 424,
|
|
52
|
+
UPGRADE_REQUIRED = 426,
|
|
53
|
+
PRECONDITION_REQUIRED = 428,
|
|
54
|
+
TOO_MANY_REQUESTS = 429,
|
|
55
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
|
|
56
|
+
UNAVAILABLE_FOR_LEGAL_REASONS = 451,
|
|
57
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
58
|
+
NOT_IMPLEMENTED = 501,
|
|
59
|
+
BAD_GATEWAY = 502,
|
|
60
|
+
SERVICE_UNAVAILABLE = 503,
|
|
61
|
+
GATEWAY_TIMEOUT = 504,
|
|
62
|
+
HTTP_VERSION_NOT_SUPPORTED = 505,
|
|
63
|
+
VARIANT_ALSO_NEGOTIATES = 506,
|
|
64
|
+
INSUFFICIENT_STORAGE = 507,
|
|
65
|
+
LOOP_DETECTED = 508,
|
|
66
|
+
NOT_EXTENDED = 510,
|
|
67
|
+
NETWORK_AUTHENTICATION_REQUIRED = 511,
|
|
68
|
+
}
|
package/src/enums/Logging.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
// MAIN
|
|
2
2
|
export * from './Rettiwt';
|
|
3
3
|
|
|
4
|
-
//
|
|
5
|
-
export
|
|
6
|
-
|
|
4
|
+
// EXTERNAL
|
|
5
|
+
export { TweetFilter } from 'rettiwt-core';
|
|
6
|
+
|
|
7
|
+
// ENUMS
|
|
8
|
+
export * from './enums/Api';
|
|
9
|
+
export * from './enums/Http';
|
|
7
10
|
export * from './enums/Logging';
|
|
8
11
|
|
|
9
|
-
//
|
|
10
|
-
export * from './models/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export * from './models/
|
|
14
|
-
export * from './models/
|
|
15
|
-
export
|
|
12
|
+
// ARGS MODELS
|
|
13
|
+
export * from './models/args/TweetArgs';
|
|
14
|
+
|
|
15
|
+
// ERROR MODELS
|
|
16
|
+
export * from './models/errors/ApiError';
|
|
17
|
+
export * from './models/errors/HttpError';
|
|
18
|
+
export * from './models/errors/RettiwtError';
|
|
19
|
+
|
|
20
|
+
// DATA MODELS
|
|
21
|
+
export * from './models/data/CursoredData';
|
|
22
|
+
export * from './models/data/List';
|
|
23
|
+
export * from './models/data/Tweet';
|
|
24
|
+
export * from './models/data/User';
|
|
16
25
|
|
|
17
|
-
//
|
|
26
|
+
// SERVICES
|
|
27
|
+
export * from './services/internal/ErrorService';
|
|
18
28
|
export * from './services/internal/FetcherService';
|
|
19
29
|
export * from './services/internal/LogService';
|
|
30
|
+
export * from './services/public/AuthService';
|
|
20
31
|
export * from './services/public/TweetService';
|
|
21
32
|
export * from './services/public/UserService';
|
|
22
33
|
|
|
23
|
-
//
|
|
24
|
-
export * from './types/
|
|
25
|
-
export * from './types/
|
|
26
|
-
export * from './types/public/List';
|
|
27
|
-
export * from './types/public/Tweet';
|
|
28
|
-
export * from './types/public/User';
|
|
29
|
-
export { ITweetFilter } from 'rettiwt-core';
|
|
34
|
+
// TYPES
|
|
35
|
+
export * from './types/RettiwtConfig';
|
|
36
|
+
export * from './types/ErrorHandler';
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// PACKAGES
|
|
2
|
+
import {
|
|
3
|
+
ArrayMaxSize,
|
|
4
|
+
IsArray,
|
|
5
|
+
IsNotEmpty,
|
|
6
|
+
IsNumberString,
|
|
7
|
+
IsObject,
|
|
8
|
+
IsOptional,
|
|
9
|
+
IsString,
|
|
10
|
+
MaxLength,
|
|
11
|
+
validateSync,
|
|
12
|
+
} from 'class-validator';
|
|
13
|
+
import { DataValidationError } from 'rettiwt-core';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The arguments specifying the tweet to be posted.
|
|
17
|
+
*/
|
|
18
|
+
export class TweetArgs {
|
|
19
|
+
/**
|
|
20
|
+
* The text content of the tweet.
|
|
21
|
+
*
|
|
22
|
+
* @remarks Length must be \<= 280 characters.
|
|
23
|
+
*/
|
|
24
|
+
@IsNotEmpty()
|
|
25
|
+
@IsString()
|
|
26
|
+
@MaxLength(280)
|
|
27
|
+
public text: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The media content of the tweet.
|
|
31
|
+
*
|
|
32
|
+
* @remarks Max number of media that can be posted is 4.
|
|
33
|
+
*/
|
|
34
|
+
@IsOptional()
|
|
35
|
+
@IsArray()
|
|
36
|
+
@ArrayMaxSize(4)
|
|
37
|
+
@IsObject({ each: true })
|
|
38
|
+
public media?: TweetMediaArgs[];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param tweet - The tweet arguments specifying the tweet.
|
|
42
|
+
*/
|
|
43
|
+
public constructor(tweet: TweetArgs) {
|
|
44
|
+
this.text = tweet.text;
|
|
45
|
+
this.media = tweet.media ? tweet.media.map((item) => new TweetMediaArgs(item)) : undefined;
|
|
46
|
+
|
|
47
|
+
// Validating this object
|
|
48
|
+
const validationResult = validateSync(this);
|
|
49
|
+
|
|
50
|
+
// If validation error occured
|
|
51
|
+
if (validationResult.length) {
|
|
52
|
+
throw new DataValidationError(validationResult);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The arguments specifying the media to be posted in a single tweet.
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
export class TweetMediaArgs {
|
|
63
|
+
/**
|
|
64
|
+
* The path to the media file.
|
|
65
|
+
*
|
|
66
|
+
* @remarks The size of the media file must be \<= 5242880 bytes.
|
|
67
|
+
*/
|
|
68
|
+
@IsNotEmpty()
|
|
69
|
+
@IsString()
|
|
70
|
+
public path: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The list of id of users to be tagged in the media.
|
|
74
|
+
*
|
|
75
|
+
* @remarks Max number of tags is 10.
|
|
76
|
+
*/
|
|
77
|
+
@IsOptional()
|
|
78
|
+
@IsArray()
|
|
79
|
+
@ArrayMaxSize(10)
|
|
80
|
+
@IsNumberString(undefined, { each: true })
|
|
81
|
+
public tags?: string[];
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param media - The media arguments specifying the media.
|
|
85
|
+
*/
|
|
86
|
+
public constructor(media: TweetMediaArgs) {
|
|
87
|
+
this.path = media.path;
|
|
88
|
+
this.tags = media.tags ?? [];
|
|
89
|
+
|
|
90
|
+
// Validating this object
|
|
91
|
+
const validationResult = validateSync(this);
|
|
92
|
+
|
|
93
|
+
// If validation error occured
|
|
94
|
+
if (validationResult.length) {
|
|
95
|
+
throw new DataValidationError(validationResult);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
import { Tweet } from './Tweet';
|
|
3
3
|
import { User } from './User';
|
|
4
4
|
|
|
5
|
-
// TYPES
|
|
6
|
-
import { ICursor, ICursoredData } from '../../types/public/CursoredData';
|
|
7
|
-
|
|
8
5
|
/**
|
|
9
6
|
* The data that us fetched batch-wise along with a cursor.
|
|
10
7
|
*
|
|
@@ -12,8 +9,11 @@ import { ICursor, ICursoredData } from '../../types/public/CursoredData';
|
|
|
12
9
|
*
|
|
13
10
|
* @public
|
|
14
11
|
*/
|
|
15
|
-
export class CursoredData<T extends Tweet | User>
|
|
12
|
+
export class CursoredData<T extends Tweet | User> {
|
|
13
|
+
/** The list of data of the given type. */
|
|
16
14
|
public list: T[] = [];
|
|
15
|
+
|
|
16
|
+
/** The cursor to the next batch of data. */
|
|
17
17
|
public next: Cursor;
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -31,7 +31,8 @@ export class CursoredData<T extends Tweet | User> implements ICursoredData<T> {
|
|
|
31
31
|
*
|
|
32
32
|
* @public
|
|
33
33
|
*/
|
|
34
|
-
export class Cursor
|
|
34
|
+
export class Cursor {
|
|
35
|
+
/** The cursor string. */
|
|
35
36
|
public value: string;
|
|
36
37
|
|
|
37
38
|
/**
|
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
// PACKAGES
|
|
2
2
|
import { IList as IRawList } from 'rettiwt-core';
|
|
3
3
|
|
|
4
|
-
// TYPES
|
|
5
|
-
import { IList } from '../../types/public/List';
|
|
6
|
-
|
|
7
4
|
/**
|
|
8
5
|
* The details of a single Twitter List.
|
|
9
6
|
*
|
|
10
7
|
* @public
|
|
11
8
|
*/
|
|
12
|
-
export class List
|
|
9
|
+
export class List {
|
|
10
|
+
/** The rest id of the list. */
|
|
13
11
|
public id: string;
|
|
12
|
+
|
|
13
|
+
/** The name of the list. */
|
|
14
14
|
public name: string;
|
|
15
|
+
|
|
16
|
+
/** The date and time of creation of the list, int UTC string format. */
|
|
15
17
|
public createdAt: string;
|
|
18
|
+
|
|
19
|
+
/** The list description. */
|
|
16
20
|
public description: string;
|
|
21
|
+
|
|
22
|
+
/** The number of memeber of the list. */
|
|
17
23
|
public memberCount: number;
|
|
24
|
+
|
|
25
|
+
/** The number of subscribers of the list. */
|
|
18
26
|
public subscriberCount: number;
|
|
27
|
+
|
|
28
|
+
/** The rest id of the user who created the list. */
|
|
19
29
|
public createdBy: string;
|
|
20
30
|
|
|
21
31
|
/**
|