rettiwt-api 2.2.2 → 2.3.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.
Files changed (79) hide show
  1. package/.eslintrc.js +1 -0
  2. package/README.md +41 -22
  3. package/dist/Rettiwt.d.ts +5 -5
  4. package/dist/Rettiwt.js +6 -7
  5. package/dist/Rettiwt.js.map +1 -1
  6. package/dist/enums/Logging.d.ts +12 -0
  7. package/dist/enums/Logging.js +17 -0
  8. package/dist/enums/Logging.js.map +1 -0
  9. package/dist/index.d.ts +15 -11
  10. package/dist/index.js +15 -11
  11. package/dist/index.js.map +1 -1
  12. package/dist/models/internal/RettiwtConfig.d.ts +20 -0
  13. package/dist/models/internal/RettiwtConfig.js +23 -0
  14. package/dist/models/internal/RettiwtConfig.js.map +1 -0
  15. package/dist/models/{CursoredData.d.ts → public/CursoredData.d.ts} +2 -3
  16. package/dist/models/{CursoredData.js → public/CursoredData.js} +1 -16
  17. package/dist/models/public/CursoredData.js.map +1 -0
  18. package/dist/models/{List.d.ts → public/List.d.ts} +1 -1
  19. package/dist/models/public/List.js.map +1 -0
  20. package/dist/models/{Tweet.d.ts → public/Tweet.d.ts} +1 -1
  21. package/dist/models/{Tweet.js → public/Tweet.js} +1 -1
  22. package/dist/models/public/Tweet.js.map +1 -0
  23. package/dist/models/{User.d.ts → public/User.d.ts} +1 -1
  24. package/dist/models/public/User.js.map +1 -0
  25. package/dist/services/{FetcherService.d.ts → internal/FetcherService.d.ts} +28 -9
  26. package/dist/services/{FetcherService.js → internal/FetcherService.js} +102 -22
  27. package/dist/services/internal/FetcherService.js.map +1 -0
  28. package/dist/services/internal/LogService.d.ts +22 -0
  29. package/dist/services/internal/LogService.js +35 -0
  30. package/dist/services/internal/LogService.js.map +1 -0
  31. package/dist/services/{TweetService.d.ts → public/TweetService.d.ts} +7 -7
  32. package/dist/services/{TweetService.js → public/TweetService.js} +4 -5
  33. package/dist/services/public/TweetService.js.map +1 -0
  34. package/dist/services/{UserService.d.ts → public/UserService.d.ts} +23 -8
  35. package/dist/services/{UserService.js → public/UserService.js} +38 -6
  36. package/dist/services/public/UserService.js.map +1 -0
  37. package/dist/types/internal/RettiwtConfig.d.ts +13 -0
  38. package/dist/types/internal/RettiwtConfig.js +3 -0
  39. package/dist/types/internal/RettiwtConfig.js.map +1 -0
  40. package/dist/types/public/CursoredData.js.map +1 -0
  41. package/dist/types/{List.js.map → public/List.js.map} +1 -1
  42. package/dist/types/{Tweet.js.map → public/Tweet.js.map} +1 -1
  43. package/dist/types/{User.js.map → public/User.js.map} +1 -1
  44. package/package.json +3 -3
  45. package/src/Rettiwt.ts +11 -9
  46. package/src/enums/Logging.ts +12 -0
  47. package/src/index.ts +15 -11
  48. package/src/models/internal/RettiwtConfig.ts +29 -0
  49. package/src/models/{CursoredData.ts → public/CursoredData.ts} +7 -22
  50. package/src/models/{List.ts → public/List.ts} +9 -9
  51. package/src/models/{Tweet.ts → public/Tweet.ts} +25 -25
  52. package/src/models/{User.ts → public/User.ts} +16 -16
  53. package/src/services/{FetcherService.ts → internal/FetcherService.ts} +119 -21
  54. package/src/services/internal/LogService.ts +39 -0
  55. package/src/services/{TweetService.ts → public/TweetService.ts} +16 -16
  56. package/src/services/{UserService.ts → public/UserService.ts} +42 -14
  57. package/src/types/internal/RettiwtConfig.ts +15 -0
  58. package/dist/models/CursoredData.js.map +0 -1
  59. package/dist/models/List.js.map +0 -1
  60. package/dist/models/Tweet.js.map +0 -1
  61. package/dist/models/User.js.map +0 -1
  62. package/dist/services/FetcherService.js.map +0 -1
  63. package/dist/services/TweetService.js.map +0 -1
  64. package/dist/services/UserService.js.map +0 -1
  65. package/dist/types/CursoredData.js.map +0 -1
  66. /package/dist/models/{List.js → public/List.js} +0 -0
  67. /package/dist/models/{User.js → public/User.js} +0 -0
  68. /package/dist/types/{CursoredData.d.ts → public/CursoredData.d.ts} +0 -0
  69. /package/dist/types/{CursoredData.js → public/CursoredData.js} +0 -0
  70. /package/dist/types/{List.d.ts → public/List.d.ts} +0 -0
  71. /package/dist/types/{List.js → public/List.js} +0 -0
  72. /package/dist/types/{Tweet.d.ts → public/Tweet.d.ts} +0 -0
  73. /package/dist/types/{Tweet.js → public/Tweet.js} +0 -0
  74. /package/dist/types/{User.d.ts → public/User.d.ts} +0 -0
  75. /package/dist/types/{User.js → public/User.js} +0 -0
  76. /package/src/types/{CursoredData.ts → public/CursoredData.ts} +0 -0
  77. /package/src/types/{List.ts → public/List.ts} +0 -0
  78. /package/src/types/{Tweet.ts → public/Tweet.ts} +0 -0
  79. /package/src/types/{User.ts → public/User.ts} +0 -0
package/.eslintrc.js CHANGED
@@ -41,6 +41,7 @@ module.exports = {
41
41
  ],
42
42
  '@typescript-eslint/explicit-function-return-type': 'error',
43
43
  '@typescript-eslint/explicit-module-boundary-types': 'error',
44
+ '@typescript-eslint/explicit-member-accessibility': 'error',
44
45
  '@typescript-eslint/no-explicit-any': 'warn',
45
46
  '@typescript-eslint/no-extraneous-class': [
46
47
  'warn',
package/README.md CHANGED
@@ -18,26 +18,21 @@ Although the above process initializes a new project, that is, in fact, not nece
18
18
 
19
19
  ## Getting started
20
20
 
21
- 1. Generate credentials using [rettiwt-auth](https://www.npmjs.com/package/rettiwt-auth) package, by following these [steps](https://rishikant181.github.io/Rettiwt-Auth/#md:cli-usage).
22
- 2. Copy the value of the 'cookies' field from the generated credentials and store it somewhere safe. Let's call this our API_KEY.
23
- 3. Create a new instance of Rettiwt, passing in the API key:
24
- `const rettiwt = Rettiwt(API_KEY);`
21
+ 1. Generate credentials using [rettiwt-auth](https://www.npmjs.com/package/rettiwt-auth) package, by following these [steps](https://rishikant181.github.io/Rettiwt-Auth/#md:1-generating-credentials-as-an-api-key-for-use-with-rettiwt-api).
22
+ 2. The generated string is the API_KEY.
23
+ 3. Create a new instance of Rettiwt, passing in the API key as a config object:
24
+ `const rettiwt = Rettiwt({ apiKey: API_KEY });`
25
+ The available options in the config object can be found [here](https://rishikant181.github.io/Rettiwt-API/classes/RettiwtConfig.html).
25
26
  4. Use the created [Rettiwt](https://rishikant181.github.io/Rettiwt-API/classes/Rettiwt.html) instance to fetch data from Twitter.
26
27
 
27
- **Note:** The API_KEY (cookie) that we generated, is a very sensitive information and provides all access to the Twitter account. Therefore, it is generally recommended to store it as an environment variable and use it from there.
28
+ **Notes:**
28
29
 
29
- ## Using a proxy
30
-
31
- For masking of IP address using a proxy server, use the following code snippet for instantiation of Rettiwt:
32
-
33
- ```
34
- /**
35
- * proxyUrl is the URL or configuration for the proxy server you want to use.`
36
- */
37
- const rettiwt = Rettiwt(API_KEY, proxyUrl);
38
- ```
30
+ - The API_KEY that we generated, is a very sensitive information and provides all access to the Twitter account. Therefore, it is generally recommended to store it as an environment variable and use it from there.
39
31
 
40
- This creates a Rettiwt instance which uses the given proxy server for making requests to Twitter.
32
+ - It's also possible to use this package without using a Twitter account, by omitting the 'apiKey' parameter in the config object. However, in this case, functionality is limited to accessing only the following resources:
33
+ - Getting the details of a user (by username)
34
+ - Getting the details of a tweet
35
+ - Getting the tweet timeline of a user (only most recent 100 entries)
41
36
 
42
37
  ## Usage
43
38
 
@@ -49,7 +44,7 @@ The following examples may help you to get started using the library:
49
44
  const { Rettiwt } = require('rettiwt-api');
50
45
 
51
46
  // Creating a new Rettiwt instance using the API_KEY
52
- const rettiwt = new Rettiwt(API_KEY);
47
+ const rettiwt = new Rettiwt({ apiKey: API_KEY });
53
48
 
54
49
  // Fetching the details of the user whose username is <username>
55
50
  rettiwt.user.details('<username>')
@@ -67,7 +62,7 @@ rettiwt.user.details('<username>')
67
62
  const { Rettiwt } = require('rettiwt-api');
68
63
 
69
64
  // Creating a new Rettiwt instance using the API_KEY
70
- const rettiwt = new Rettiwt(API_KEY);
65
+ const rettiwt = new Rettiwt({ apiKey: API_KEY });
71
66
 
72
67
  /**
73
68
  * Fetching the list of tweets that:
@@ -94,7 +89,7 @@ The previous example fetches the the list of tweets matching the given filter. S
94
89
  const { Rettiwt } = require('rettiwt-api');
95
90
 
96
91
  // Creating a new Rettiwt instance using the API_KEY
97
- const rettiwt = new Rettiwt(API_KEY);
92
+ const rettiwt = new Rettiwt({ apiKey: API_KEY });
98
93
 
99
94
  /**
100
95
  * Fetching the list of tweets that:
@@ -115,7 +110,31 @@ rettiwt.tweet.search({
115
110
  });
116
111
  ```
117
112
 
118
- For more information regarding the different available filter options, please refer to [TweetFilter](https://rishikant181.github.io/Rettiwt-API/classes/TweetFilter.html).
113
+ For more information regarding the different available filter options, please refer to [TweetFilter](https://rishikant181.github.io/Rettiwt-Core/classes/TweetFilter.html).
114
+
115
+ ## Using a proxy
116
+
117
+ For masking of IP address using a proxy server, use the following code snippet for instantiation of Rettiwt:
118
+
119
+ ```
120
+ /**
121
+ * PROXY_URL is the URL or configuration for the proxy server you want to use.`
122
+ */
123
+ const rettiwt = Rettiwt({ apiKey: API_KEY, proxyUrl: PROXY_URL });
124
+ ```
125
+
126
+ This creates a Rettiwt instance which uses the given proxy server for making requests to Twitter.
127
+
128
+ ## Debug logs
129
+
130
+ Sometimes, when the library shows unexpected behaviour, for troubleshooting purposes, debug logs can be enabled which will help in tracking down the issue and working on a potential fix. Currently, debug logs are printed to the console and are enabled by setting the 'logging' property of the config to true, while creating an instance of Rettiwt:
131
+
132
+ ```
133
+ /**
134
+ * By default, is no value for 'logging' is supplied, logging is disabled.
135
+ */
136
+ const rettiwt = Rettiwt({ apiKey: API_KEY, logging: true });
137
+ ```
119
138
 
120
139
  ## Features
121
140
 
@@ -138,7 +157,8 @@ So far, the following operations are supported:
138
157
  - [Getting the list of users who follow the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#followers)
139
158
  - [Getting the list of users who are followed by the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#following)
140
159
  - [Getting the list of tweets favorited/liked by the given user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#likes)
141
- - [Getting the timeline of a user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#timeline)
160
+ - [Getting the tweet timeline of a user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#timeline)
161
+ - [Getting the reply timeline of a user](https://rishikant181.github.io/Rettiwt-API/classes/UserService.html#replies)
142
162
 
143
163
  ## API Reference
144
164
 
@@ -147,5 +167,4 @@ The complete API reference can be found at [this](https://rishikant181.github.io
147
167
  ## Additional information
148
168
 
149
169
  - This API uses the cookies of a Twitter account to fetch data from Twitter and as such, there is always a chance (altough a measly one) of getting the account banned by Twitter algorithm.
150
- - From personal experience, not a single one of my accounts has ever been banned by using this library, and this is coming from someone who has been using his primary Twitter account to fetch large amounts of data from Twitter for over 1.5 years now, since the conception of this project.
151
170
  - There have been no reports of accounts getting banned, but you have been warned, even though the chances of getting banned is negligible, it is not zero!
package/dist/Rettiwt.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { TweetService } from './services/TweetService';
2
- import { UserService } from './services/UserService';
1
+ import { TweetService } from './services/public/TweetService';
2
+ import { UserService } from './services/public/UserService';
3
+ import { RettiwtConfig } from './models/internal/RettiwtConfig';
3
4
  /**
4
5
  * The class for fetching data from Twitter.
5
6
  *
@@ -13,8 +14,7 @@ export declare class Rettiwt {
13
14
  /**
14
15
  * Initializes a new Rettiwt instance using the given api key.
15
16
  *
16
- * @param apiKey - The apiKey (cookie) to use for authenticating Rettiwt against Twitter API.
17
- * @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
17
+ * @param config - The config object for configuring the Rettiwt instance.
18
18
  */
19
- constructor(apiKey: string, proxyUrl?: URL);
19
+ constructor(config?: RettiwtConfig);
20
20
  }
package/dist/Rettiwt.js CHANGED
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Rettiwt = void 0;
4
4
  // SERVICES
5
- var TweetService_1 = require("./services/TweetService");
6
- var UserService_1 = require("./services/UserService");
5
+ var TweetService_1 = require("./services/public/TweetService");
6
+ var UserService_1 = require("./services/public/UserService");
7
7
  /**
8
8
  * The class for fetching data from Twitter.
9
9
  *
@@ -13,12 +13,11 @@ var Rettiwt = /** @class */ (function () {
13
13
  /**
14
14
  * Initializes a new Rettiwt instance using the given api key.
15
15
  *
16
- * @param apiKey - The apiKey (cookie) to use for authenticating Rettiwt against Twitter API.
17
- * @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
16
+ * @param config - The config object for configuring the Rettiwt instance.
18
17
  */
19
- function Rettiwt(apiKey, proxyUrl) {
20
- this.tweet = new TweetService_1.TweetService(apiKey, proxyUrl);
21
- this.user = new UserService_1.UserService(apiKey, proxyUrl);
18
+ function Rettiwt(config) {
19
+ this.tweet = new TweetService_1.TweetService(config);
20
+ this.user = new UserService_1.UserService(config);
22
21
  }
23
22
  return Rettiwt;
24
23
  }());
@@ -1 +1 @@
1
- {"version":3,"file":"Rettiwt.js","sourceRoot":"","sources":["../src/Rettiwt.ts"],"names":[],"mappings":";;;AAAA,WAAW;AACX,wDAAuD;AACvD,sDAAqD;AAErD;;;;GAIG;AACH;IAOC;;;;;OAKG;IACH,iBAAY,MAAc,EAAE,QAAc;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,2BAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,IAAI,yBAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IACF,cAAC;AAAD,CAAC,AAjBD,IAiBC;AAjBY,0BAAO"}
1
+ {"version":3,"file":"Rettiwt.js","sourceRoot":"","sources":["../src/Rettiwt.ts"],"names":[],"mappings":";;;AAAA,WAAW;AACX,+DAA8D;AAC9D,6DAA4D;AAK5D;;;;GAIG;AACH;IAOC;;;;OAIG;IACH,iBAAmB,MAAsB;QACxC,IAAI,CAAC,KAAK,GAAG,IAAI,2BAAY,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,yBAAW,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IACF,cAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,0BAAO"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The different types of actions that are logged.
3
+ *
4
+ * @internal
5
+ */
6
+ export declare enum ELogActions {
7
+ FETCH = "FETCH",
8
+ POST = "POST",
9
+ EXTRACT = "EXTRACT",
10
+ DESERIALIZE = "DESERIALIZE",
11
+ AUTHORIZATION = "AUTHORIZATION"
12
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ELogActions = void 0;
4
+ /**
5
+ * The different types of actions that are logged.
6
+ *
7
+ * @internal
8
+ */
9
+ var ELogActions;
10
+ (function (ELogActions) {
11
+ ELogActions["FETCH"] = "FETCH";
12
+ ELogActions["POST"] = "POST";
13
+ ELogActions["EXTRACT"] = "EXTRACT";
14
+ ELogActions["DESERIALIZE"] = "DESERIALIZE";
15
+ ELogActions["AUTHORIZATION"] = "AUTHORIZATION";
16
+ })(ELogActions || (exports.ELogActions = ELogActions = {}));
17
+ //# sourceMappingURL=Logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Logging.js","sourceRoot":"","sources":["../../src/enums/Logging.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,IAAY,WAMX;AAND,WAAY,WAAW;IACtB,8BAAe,CAAA;IACf,4BAAa,CAAA;IACb,kCAAmB,CAAA;IACnB,0CAA2B,CAAA;IAC3B,8CAA+B,CAAA;AAChC,CAAC,EANW,WAAW,2BAAX,WAAW,QAMtB"}
package/dist/index.d.ts CHANGED
@@ -1,14 +1,18 @@
1
1
  export * from './Rettiwt';
2
2
  export * from './enums/ApiErrors';
3
3
  export * from './enums/HTTP';
4
- export * from './models/CursoredData';
5
- export * from './models/List';
6
- export * from './models/Tweet';
7
- export * from './models/User';
8
- export * from './services/FetcherService';
9
- export * from './services/TweetService';
10
- export * from './services/UserService';
11
- export * from './types/CursoredData';
12
- export * from './types/List';
13
- export * from './types/Tweet';
14
- export * from './types/User';
4
+ export * from './enums/Logging';
5
+ export * from './models/internal/RettiwtConfig';
6
+ export * from './models/public/CursoredData';
7
+ export * from './models/public/List';
8
+ export * from './models/public/Tweet';
9
+ export * from './models/public/User';
10
+ export * from './services/internal/FetcherService';
11
+ export * from './services/internal/LogService';
12
+ export * from './services/public/TweetService';
13
+ export * from './services/public/UserService';
14
+ export * from './types/internal/RettiwtConfig';
15
+ export * from './types/public/CursoredData';
16
+ export * from './types/public/List';
17
+ export * from './types/public/Tweet';
18
+ export * from './types/public/User';
package/dist/index.js CHANGED
@@ -19,18 +19,22 @@ __exportStar(require("./Rettiwt"), exports);
19
19
  // Exporting enums
20
20
  __exportStar(require("./enums/ApiErrors"), exports);
21
21
  __exportStar(require("./enums/HTTP"), exports);
22
+ __exportStar(require("./enums/Logging"), exports);
22
23
  // Exporting models
23
- __exportStar(require("./models/CursoredData"), exports);
24
- __exportStar(require("./models/List"), exports);
25
- __exportStar(require("./models/Tweet"), exports);
26
- __exportStar(require("./models/User"), exports);
24
+ __exportStar(require("./models/internal/RettiwtConfig"), exports);
25
+ __exportStar(require("./models/public/CursoredData"), exports);
26
+ __exportStar(require("./models/public/List"), exports);
27
+ __exportStar(require("./models/public/Tweet"), exports);
28
+ __exportStar(require("./models/public/User"), exports);
27
29
  // Exporting services
28
- __exportStar(require("./services/FetcherService"), exports);
29
- __exportStar(require("./services/TweetService"), exports);
30
- __exportStar(require("./services/UserService"), exports);
30
+ __exportStar(require("./services/internal/FetcherService"), exports);
31
+ __exportStar(require("./services/internal/LogService"), exports);
32
+ __exportStar(require("./services/public/TweetService"), exports);
33
+ __exportStar(require("./services/public/UserService"), exports);
31
34
  // Exporting types
32
- __exportStar(require("./types/CursoredData"), exports);
33
- __exportStar(require("./types/List"), exports);
34
- __exportStar(require("./types/Tweet"), exports);
35
- __exportStar(require("./types/User"), exports);
35
+ __exportStar(require("./types/internal/RettiwtConfig"), exports);
36
+ __exportStar(require("./types/public/CursoredData"), exports);
37
+ __exportStar(require("./types/public/List"), exports);
38
+ __exportStar(require("./types/public/Tweet"), exports);
39
+ __exportStar(require("./types/public/User"), exports);
36
40
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO;AACP,4CAA0B;AAE1B,kBAAkB;AAClB,oDAAkC;AAClC,+CAA6B;AAE7B,mBAAmB;AACnB,wDAAsC;AACtC,gDAA8B;AAC9B,iDAA+B;AAC/B,gDAA8B;AAE9B,qBAAqB;AACrB,4DAA0C;AAC1C,0DAAwC;AACxC,yDAAuC;AAEvC,kBAAkB;AAClB,uDAAqC;AACrC,+CAA6B;AAC7B,gDAA8B;AAC9B,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO;AACP,4CAA0B;AAE1B,kBAAkB;AAClB,oDAAkC;AAClC,+CAA6B;AAC7B,kDAAgC;AAEhC,mBAAmB;AACnB,kEAAgD;AAChD,+DAA6C;AAC7C,uDAAqC;AACrC,wDAAsC;AACtC,uDAAqC;AAErC,qBAAqB;AACrB,qEAAmD;AACnD,iEAA+C;AAC/C,iEAA+C;AAC/C,gEAA8C;AAE9C,kBAAkB;AAClB,iEAA+C;AAC/C,8DAA4C;AAC5C,sDAAoC;AACpC,uDAAqC;AACrC,sDAAoC"}
@@ -0,0 +1,20 @@
1
+ import { IRettiwtConfig } from '../../types/internal/RettiwtConfig';
2
+ /**
3
+ * The configuration for initializing a new Rettiwt instance.
4
+ *
5
+ * @internal
6
+ */
7
+ export declare class RettiwtConfig implements IRettiwtConfig {
8
+ /** The apiKey (cookie) to use for authenticating Rettiwt against Twitter API. */
9
+ apiKey?: string;
10
+ /** Optional URL with proxy configuration to use for requests to Twitter API. */
11
+ proxyUrl?: URL;
12
+ /** Whether to write logs to console or not. */
13
+ logging?: boolean;
14
+ /**
15
+ * Initializes a new configuration object from the given config.
16
+ *
17
+ * @param config - The configuration object.
18
+ */
19
+ constructor(config: RettiwtConfig);
20
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RettiwtConfig = void 0;
4
+ /**
5
+ * The configuration for initializing a new Rettiwt instance.
6
+ *
7
+ * @internal
8
+ */
9
+ var RettiwtConfig = /** @class */ (function () {
10
+ /**
11
+ * Initializes a new configuration object from the given config.
12
+ *
13
+ * @param config - The configuration object.
14
+ */
15
+ function RettiwtConfig(config) {
16
+ this.apiKey = config.apiKey;
17
+ this.proxyUrl = config.proxyUrl;
18
+ this.logging = config.logging;
19
+ }
20
+ return RettiwtConfig;
21
+ }());
22
+ exports.RettiwtConfig = RettiwtConfig;
23
+ //# sourceMappingURL=RettiwtConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RettiwtConfig.js","sourceRoot":"","sources":["../../../src/models/internal/RettiwtConfig.ts"],"names":[],"mappings":";;;AAGA;;;;GAIG;AACH;IAUC;;;;OAIG;IACH,uBAAmB,MAAqB;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,CAAC;IACF,oBAAC;AAAD,CAAC,AApBD,IAoBC;AApBY,sCAAa"}
@@ -1,7 +1,6 @@
1
- import { ITweet as IRawTweet, IUser as IRawUser } from 'rettiwt-core';
2
1
  import { Tweet } from './Tweet';
3
2
  import { User } from './User';
4
- import { ICursor, ICursoredData } from '../types/CursoredData';
3
+ import { ICursor, ICursoredData } from '../../types/public/CursoredData';
5
4
  /**
6
5
  * The data that us fetched batch-wise along with a cursor.
7
6
  *
@@ -18,7 +17,7 @@ export declare class CursoredData<T extends Tweet | User> implements ICursoredDa
18
17
  * @param list - The list of data item to store.
19
18
  * @param next - The cursor to the next batch of data.
20
19
  */
21
- constructor(list?: (IRawTweet | IRawUser)[], next?: string);
20
+ constructor(list?: T[], next?: string);
22
21
  }
23
22
  /**
24
23
  * The cursor to the batch of data to be fetched.
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Cursor = exports.CursoredData = void 0;
4
- // MODELS
5
- var Tweet_1 = require("./Tweet");
6
- var User_1 = require("./User");
7
4
  /**
8
5
  * The data that us fetched batch-wise along with a cursor.
9
6
  *
@@ -21,19 +18,7 @@ var CursoredData = /** @class */ (function () {
21
18
  if (next === void 0) { next = ''; }
22
19
  /** The list of data of the given type. */
23
20
  this.list = [];
24
- // Deserializing the input raw data and storing it in the list
25
- for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
26
- var item = list_1[_i];
27
- // If the item is a valid raw tweet
28
- if (item && item.__typename == 'Tweet' && item.rest_id) {
29
- this.list.push(new Tweet_1.Tweet(item));
30
- }
31
- // If the item is a valid raw user
32
- else if (item && item.__typename == 'User' && item.rest_id && item.id) {
33
- this.list.push(new User_1.User(item));
34
- }
35
- }
36
- // Initializing cursors
21
+ this.list = list;
37
22
  this.next = new Cursor(next);
38
23
  }
39
24
  return CursoredData;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CursoredData.js","sourceRoot":"","sources":["../../../src/models/public/CursoredData.ts"],"names":[],"mappings":";;;AAOA;;;;;;GAMG;AACH;IAOC;;;OAGG;IACH,sBAAmB,IAAc,EAAE,IAAiB;QAAjC,qBAAA,EAAA,SAAc;QAAE,qBAAA,EAAA,SAAiB;QAVpD,0CAA0C;QACnC,SAAI,GAAQ,EAAE,CAAC;QAUrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IACF,mBAAC;AAAD,CAAC,AAfD,IAeC;AAfY,oCAAY;AAiBzB;;;;GAIG;AACH;IAIC;;;;OAIG;IACH,gBAAmB,SAAiB;QACnC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACxB,CAAC;IACF,aAAC;AAAD,CAAC,AAZD,IAYC;AAZY,wBAAM"}
@@ -1,5 +1,5 @@
1
1
  import { IList as IRawList } from 'rettiwt-core';
2
- import { IList } from '../types/List';
2
+ import { IList } from '../../types/public/List';
3
3
  /**
4
4
  * The details of a single Twitter List.
5
5
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/models/public/List.ts"],"names":[],"mappings":";;;AAMA;;;;GAIG;AACH;IAsBC;;;;OAIG;IACH,cAAmB,IAAc;QAChC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;QACzD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;IAC9C,CAAC;IACF,WAAC;AAAD,CAAC,AApCD,IAoCC;AApCY,oBAAI"}
@@ -1,5 +1,5 @@
1
1
  import { ITweet as IRawTweet, IEntities as IRawTweetEntities, IExtendedMedia as IRawExtendedMedia, EMediaType } from 'rettiwt-core';
2
- import { ITweet, ITweetEntities } from '../types/Tweet';
2
+ import { ITweet, ITweetEntities } from '../../types/public/Tweet';
3
3
  import { User } from './User';
4
4
  /**
5
5
  * The details of a single Tweet.
@@ -6,7 +6,7 @@ var rettiwt_core_1 = require("rettiwt-core");
6
6
  // MODELS
7
7
  var User_1 = require("./User");
8
8
  // PARSERS
9
- var JsonUtils_1 = require("../helper/JsonUtils");
9
+ var JsonUtils_1 = require("../../helper/JsonUtils");
10
10
  /**
11
11
  * The details of a single Tweet.
12
12
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tweet.js","sourceRoot":"","sources":["../../../src/models/public/Tweet.ts"],"names":[],"mappings":"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"}
@@ -1,5 +1,5 @@
1
1
  import { IUser as IRawUser } from 'rettiwt-core';
2
- import { IUser } from '../types/User';
2
+ import { IUser } from '../../types/public/User';
3
3
  /**
4
4
  * The details of a single user.
5
5
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"User.js","sourceRoot":"","sources":["../../../src/models/public/User.ts"],"names":[],"mappings":";;;AAMA;;;;GAIG;AACH;IA2CC;;;;OAIG;IACH,cAAmB,IAAc;QAChC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QACvC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACpD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;QAClD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;QACjD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;QAChD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;QACvD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;QACpD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC;IACzD,CAAC;IACF,WAAC;AAAD,CAAC,AAhED,IAgEC;AAhEY,oBAAI"}
@@ -1,7 +1,8 @@
1
1
  import { Args, EResourceType } from 'rettiwt-core';
2
- import { CursoredData } from '../models/CursoredData';
3
- import { Tweet } from '../models/Tweet';
4
- import { User } from '../models/User';
2
+ import { RettiwtConfig } from '../../models/internal/RettiwtConfig';
3
+ import { CursoredData } from '../../models/public/CursoredData';
4
+ import { Tweet } from '../../models/public/Tweet';
5
+ import { User } from '../../models/public/User';
5
6
  /**
6
7
  * The base service that handles all HTTP requests.
7
8
  *
@@ -9,14 +10,17 @@ import { User } from '../models/User';
9
10
  */
10
11
  export declare class FetcherService {
11
12
  /** The credential to use for authenticating against Twitter API. */
12
- private cred;
13
+ private cred?;
14
+ /** Whether the instance is authenticated or not. */
15
+ private readonly isAuthenticated;
13
16
  /** The HTTPS Agent to use for requests to Twitter API. */
14
17
  private readonly httpsAgent;
18
+ /** The log service instance to use to logging. */
19
+ private readonly logger;
15
20
  /**
16
- * @param apiKey - The apiKey (cookie) to use for authenticating Rettiwt against Twitter API.
17
- * @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API.
21
+ * @param config - The config object for configuring the Rettiwt instance.
18
22
  */
19
- constructor(apiKey: string, proxyUrl?: URL);
23
+ constructor(config?: RettiwtConfig);
20
24
  /**
21
25
  * Returns an AuthCredential generated using the given API key.
22
26
  *
@@ -24,6 +28,13 @@ export declare class FetcherService {
24
28
  * @returns The generated AuthCredential.
25
29
  */
26
30
  private getAuthCredential;
31
+ /**
32
+ * Checks the authorization status based on the requested resource.
33
+ *
34
+ * @param resourceType - The type of resource to fetch.
35
+ * @throws An error if not authorized to access the requested resource.
36
+ */
37
+ private checkAuthorization;
27
38
  /**
28
39
  * Gets the HttpsAgent based on whether a proxy is used or not.
29
40
  *
@@ -36,6 +47,7 @@ export declare class FetcherService {
36
47
  *
37
48
  * @param res - The response object received.
38
49
  * @returns The received response, if no HTTP errors are found.
50
+ * @throws An error if any HTTP-related error has occured.
39
51
  */
40
52
  private handleHttpError;
41
53
  /**
@@ -43,6 +55,7 @@ export declare class FetcherService {
43
55
  *
44
56
  * @param res - The response object received.
45
57
  * @returns The received response, if no API errors are found.
58
+ * @throws An error if any API-related error has occured.
46
59
  */
47
60
  private handleApiError;
48
61
  /**
@@ -57,11 +70,17 @@ export declare class FetcherService {
57
70
  *
58
71
  * @param data - The data from which extraction is to be done.
59
72
  * @param type - The type of data to extract.
60
- * @typeParam BaseType - The base type of the raw data present in the input.
61
- * @typeParam DeserializedType - The type of data produced after deserialization of BaseType.
62
73
  * @returns The extracted data.
63
74
  */
64
75
  private extractData;
76
+ /**
77
+ * Deserializes the extracted data into a cursored list.
78
+ *
79
+ * @param extractedData - The list of extracted data.
80
+ * @param next - The cursor to the next batch of data.
81
+ * @returns The cursored data object.
82
+ */
83
+ private deserializeData;
65
84
  /**
66
85
  * Fetches the requested resource from Twitter and returns it after processing.
67
86
  *