rettiwt-api 1.2.0 → 1.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 (160) hide show
  1. package/dist/enums/Errors.d.ts +2 -1
  2. package/dist/enums/Errors.js +1 -0
  3. package/dist/enums/Errors.js.map +1 -1
  4. package/dist/graphql/queries/RootQuery.js.map +1 -1
  5. package/dist/graphql/resolvers/TweetResolver.d.ts +5 -5
  6. package/dist/graphql/resolvers/TweetResolver.js +4 -4
  7. package/dist/graphql/resolvers/TweetResolver.js.map +1 -1
  8. package/dist/graphql/types/UserTypes.js.map +1 -1
  9. package/dist/index.d.ts +5 -3
  10. package/dist/index.js +7 -5
  11. package/dist/index.js.map +1 -1
  12. package/dist/models/args/TweetListArgs.js +2 -2
  13. package/dist/models/args/TweetListArgs.js.map +1 -1
  14. package/dist/models/args/UserListArgs.js +2 -2
  15. package/dist/models/args/UserListArgs.js.map +1 -1
  16. package/dist/models/data/Tweet.d.ts +3 -3
  17. package/dist/models/data/Tweet.js.map +1 -1
  18. package/dist/models/data/User.d.ts +2 -2
  19. package/dist/models/data/User.js.map +1 -1
  20. package/dist/services/data/TweetService.d.ts +2 -2
  21. package/dist/services/data/TweetService.js +8 -9
  22. package/dist/services/data/TweetService.js.map +1 -1
  23. package/dist/services/data/UserService.js +12 -22
  24. package/dist/services/data/UserService.js.map +1 -1
  25. package/dist/services/helper/Headers.js +20 -20
  26. package/dist/services/helper/Headers.js.map +1 -1
  27. package/dist/services/helper/extractors/Tweets.d.ts +5 -14
  28. package/dist/services/helper/extractors/Tweets.js +25 -89
  29. package/dist/services/helper/extractors/Tweets.js.map +1 -1
  30. package/dist/services/helper/extractors/Users.d.ts +4 -13
  31. package/dist/services/helper/extractors/Users.js +1 -53
  32. package/dist/services/helper/extractors/Users.js.map +1 -1
  33. package/dist/services/util/FetcherService.d.ts +3 -3
  34. package/dist/services/util/FetcherService.js +10 -22
  35. package/dist/services/util/FetcherService.js.map +1 -1
  36. package/dist/types/Args.d.ts +0 -27
  37. package/dist/types/Args.js +0 -1
  38. package/dist/types/Args.js.map +1 -1
  39. package/docs/assets/search.js +1 -1
  40. package/docs/classes/AccountService.html +17 -17
  41. package/docs/classes/AuthCookie.html +7 -7
  42. package/docs/classes/AuthService.html +7 -7
  43. package/docs/classes/CacheService.html +7 -7
  44. package/docs/classes/Cursor.html +3 -3
  45. package/docs/classes/CursoredData.html +4 -4
  46. package/docs/classes/DataValidationError.html +24 -23
  47. package/docs/classes/FetcherService.html +15 -15
  48. package/docs/classes/Tweet.html +16 -16
  49. package/docs/classes/TweetEntities.html +8 -8
  50. package/docs/classes/TweetFilter.html +58 -56
  51. package/docs/classes/TweetListArgs.html +4 -4
  52. package/docs/classes/TweetService.html +15 -15
  53. package/docs/classes/User.html +18 -18
  54. package/docs/classes/UserListArgs.html +4 -4
  55. package/docs/classes/UserService.html +15 -15
  56. package/docs/enums/HttpMethods.html +3 -3
  57. package/docs/functions/Rettiwt.html +5 -4
  58. package/docs/index.html +4 -3
  59. package/docs/interfaces/IAuthCookie.html +5 -5
  60. package/docs/interfaces/ICursor.html +2 -2
  61. package/docs/interfaces/ICursoredData.html +3 -3
  62. package/docs/interfaces/IDataContext.html +4 -4
  63. package/docs/interfaces/IDataValidationError.html +109 -0
  64. package/docs/interfaces/IListArgs.html +3 -3
  65. package/docs/interfaces/ITweet.html +13 -13
  66. package/docs/interfaces/ITweetEntities.html +5 -5
  67. package/docs/interfaces/ITweetFilter.html +42 -42
  68. package/docs/interfaces/IUser.html +15 -15
  69. package/docs/modules.html +8 -6
  70. package/package.json +3 -2
  71. package/src/enums/Errors.ts +2 -1
  72. package/src/graphql/queries/RootQuery.ts +1 -1
  73. package/src/graphql/resolvers/TweetResolver.ts +12 -59
  74. package/src/graphql/types/UserTypes.ts +1 -1
  75. package/src/index.ts +5 -3
  76. package/src/models/args/TweetListArgs.ts +2 -2
  77. package/src/models/args/UserListArgs.ts +1 -1
  78. package/src/models/data/Tweet.ts +3 -3
  79. package/src/models/data/User.ts +2 -2
  80. package/src/services/data/TweetService.ts +25 -22
  81. package/src/services/data/UserService.ts +38 -42
  82. package/src/services/helper/Headers.ts +32 -32
  83. package/src/services/helper/Parser.ts +2 -2
  84. package/src/services/helper/extractors/Tweets.ts +35 -97
  85. package/src/services/helper/extractors/Users.ts +11 -62
  86. package/src/services/util/FetcherService.ts +13 -20
  87. package/src/types/Args.ts +0 -37
  88. package/Dockerfile +0 -9
  89. package/dist/models/args/TweetFilter.d.ts +0 -65
  90. package/dist/models/args/TweetFilter.js +0 -121
  91. package/dist/models/args/TweetFilter.js.map +0 -1
  92. package/dist/models/errors/DataValidationError.d.ts +0 -20
  93. package/dist/models/errors/DataValidationError.js +0 -23
  94. package/dist/models/errors/DataValidationError.js.map +0 -1
  95. package/dist/twitter/Url.d.ts +0 -22
  96. package/dist/twitter/Url.js +0 -32
  97. package/dist/twitter/Url.js.map +0 -1
  98. package/dist/twitter/enums/Resources.d.ts +0 -15
  99. package/dist/twitter/enums/Resources.js +0 -21
  100. package/dist/twitter/enums/Resources.js.map +0 -1
  101. package/dist/twitter/params/Query.d.ts +0 -67
  102. package/dist/twitter/params/Query.js +0 -64
  103. package/dist/twitter/params/Query.js.map +0 -1
  104. package/dist/twitter/payloads/Args.d.ts +0 -16
  105. package/dist/twitter/payloads/Args.js +0 -16
  106. package/dist/twitter/payloads/Args.js.map +0 -1
  107. package/dist/twitter/payloads/Features.d.ts +0 -28
  108. package/dist/twitter/payloads/Features.js +0 -37
  109. package/dist/twitter/payloads/Features.js.map +0 -1
  110. package/dist/twitter/payloads/Variables.d.ts +0 -41
  111. package/dist/twitter/payloads/Variables.js +0 -64
  112. package/dist/twitter/payloads/Variables.js.map +0 -1
  113. package/dist/twitter/types/request/Query.d.ts +0 -86
  114. package/dist/twitter/types/request/Query.js +0 -4
  115. package/dist/twitter/types/request/Query.js.map +0 -1
  116. package/dist/twitter/types/tweet/Favouriters.d.ts +0 -164
  117. package/dist/twitter/types/tweet/Favouriters.js +0 -3
  118. package/dist/twitter/types/tweet/Favouriters.js.map +0 -1
  119. package/dist/twitter/types/tweet/Retweeters.d.ts +0 -171
  120. package/dist/twitter/types/tweet/Retweeters.js +0 -3
  121. package/dist/twitter/types/tweet/Retweeters.js.map +0 -1
  122. package/dist/twitter/types/tweet/Tweet.d.ts +0 -746
  123. package/dist/twitter/types/tweet/Tweet.js +0 -3
  124. package/dist/twitter/types/tweet/Tweet.js.map +0 -1
  125. package/dist/twitter/types/tweet/Tweets.d.ts +0 -386
  126. package/dist/twitter/types/tweet/Tweets.js +0 -3
  127. package/dist/twitter/types/tweet/Tweets.js.map +0 -1
  128. package/dist/twitter/types/user/Followers.d.ts +0 -176
  129. package/dist/twitter/types/user/Followers.js +0 -3
  130. package/dist/twitter/types/user/Followers.js.map +0 -1
  131. package/dist/twitter/types/user/Following.d.ts +0 -176
  132. package/dist/twitter/types/user/Following.js +0 -3
  133. package/dist/twitter/types/user/Following.js.map +0 -1
  134. package/dist/twitter/types/user/Likes.d.ts +0 -1059
  135. package/dist/twitter/types/user/Likes.js +0 -3
  136. package/dist/twitter/types/user/Likes.js.map +0 -1
  137. package/dist/twitter/types/user/Tweets.d.ts +0 -1512
  138. package/dist/twitter/types/user/Tweets.js +0 -3
  139. package/dist/twitter/types/user/Tweets.js.map +0 -1
  140. package/dist/twitter/types/user/User.d.ts +0 -117
  141. package/dist/twitter/types/user/User.js +0 -3
  142. package/dist/twitter/types/user/User.js.map +0 -1
  143. package/src/models/args/TweetFilter.ts +0 -140
  144. package/src/models/errors/DataValidationError.ts +0 -29
  145. package/src/twitter/Url.ts +0 -37
  146. package/src/twitter/enums/Resources.ts +0 -15
  147. package/src/twitter/params/Query.ts +0 -100
  148. package/src/twitter/payloads/Args.ts +0 -21
  149. package/src/twitter/payloads/Features.ts +0 -33
  150. package/src/twitter/payloads/Variables.ts +0 -73
  151. package/src/twitter/types/request/Query.ts +0 -91
  152. package/src/twitter/types/tweet/Favouriters.ts +0 -193
  153. package/src/twitter/types/tweet/Retweeters.ts +0 -201
  154. package/src/twitter/types/tweet/Tweet.ts +0 -882
  155. package/src/twitter/types/tweet/Tweets.ts +0 -444
  156. package/src/twitter/types/user/Followers.ts +0 -208
  157. package/src/twitter/types/user/Following.ts +0 -208
  158. package/src/twitter/types/user/Likes.ts +0 -1247
  159. package/src/twitter/types/user/Tweets.ts +0 -1747
  160. package/src/twitter/types/user/User.ts +0 -135
@@ -1,11 +1,14 @@
1
+ // PACKAGE
2
+ import {
3
+ IUserDetailsResponse,
4
+ IUserFollowersResponse,
5
+ IUserFollowingResponse,
6
+ IUserLikesResponse
7
+ } from 'rettiwt-core';
8
+
1
9
  // TYPES
2
10
  import { IDataExtract } from '../../../types/Resolvers'
3
11
  import { DataErrors } from '../../../enums/Errors';
4
- import RawUser from '../../../twitter/types/user/User';
5
- import RawUserTweets from '../../../twitter/types/user/Tweets';
6
- import RawUserFollowers from '../../../twitter/types/user/Followers';
7
- import RawUserFollowing from '../../../twitter/types/user/Following';
8
- import RawUserLikes from '../../../twitter/types/user/Likes';
9
12
 
10
13
  // PARSERS
11
14
  import * as Parsers from '../Parser';
@@ -14,7 +17,7 @@ import * as Parsers from '../Parser';
14
17
  * @returns The raw user account data formatted and sorted into required and additional data
15
18
  * @param res The raw response received from Twitter
16
19
  */
17
- export function extractUserDetails(res: RawUser): IDataExtract {
20
+ export function extractUserDetails(res: IUserDetailsResponse): IDataExtract {
18
21
  let required: any[] = []; // To store the reqruied raw data
19
22
  let cursor: string = ''; // To store the cursor to next batch
20
23
  let users: any[] = []; // To store additional user data
@@ -38,65 +41,11 @@ export function extractUserDetails(res: RawUser): IDataExtract {
38
41
  };
39
42
  }
40
43
 
41
- /**
42
- * @returns The raw user tweet data formatted and sorted into required and additional data
43
- * @param res The raw response received from Twitter
44
- */
45
- export function extractUserTweets(res: RawUserTweets): IDataExtract {
46
- let required: any[] = []; // To store the reqruied raw data
47
- let cursor: string = ''; // To store the cursor to next batch
48
- let users: any[] = []; // To store additional user data
49
- let tweets: any[] = []; // To store additional tweet data
50
-
51
- // If user does not exist
52
- if (Parsers.isJSONEmpty(res.data.user)) {
53
- throw new Error(DataErrors.UserNotFound);
54
- }
55
-
56
- // Extracting the raw list
57
- res.data.user.result.timeline_v2.timeline.instructions.forEach(item => {
58
- if (item.type === 'TimelineAddEntries') {
59
- // If no tweets found
60
- if (item.entries?.length == 2) {
61
- // Returning the data
62
- return {
63
- required: required,
64
- cursor: cursor,
65
- users: users,
66
- tweets: tweets
67
- };
68
- }
69
-
70
- // Destructuring data
71
- item.entries.forEach(entry => {
72
- // If entry is of type tweet and tweet exists
73
- if (entry.entryId.indexOf('tweet') != -1 && entry.content.itemContent?.tweet_results.result.__typename === 'Tweet') {
74
- required.push(entry.content.itemContent.tweet_results.result);
75
- users.push(entry.content.itemContent.tweet_results.result.core.user_results.result);
76
- tweets.push(entry.content.itemContent.tweet_results.result);
77
- }
78
- // If entry is of type cursor
79
- else if (entry.entryId.indexOf('cursor-bottom') != -1) {
80
- cursor = entry.content.value ?? '';
81
- }
82
- });
83
- }
84
- });
85
-
86
- // Returning the data
87
- return {
88
- required: required,
89
- cursor: cursor,
90
- users: users,
91
- tweets: tweets
92
- };
93
- }
94
-
95
44
  /**
96
45
  * @returns The raw user following/followers data formatted and sorted into required and additional data
97
46
  * @param res The raw response received from TwitterAPI
98
47
  */
99
- export function extractUserFollow(res: RawUserFollowers | RawUserFollowing): IDataExtract {
48
+ export function extractUserFollow(res: IUserFollowersResponse | IUserFollowingResponse): IDataExtract {
100
49
  let required: any[] = []; // To store the reqruied raw data
101
50
  let cursor: string = ''; // To store the cursor to next batch
102
51
  let users: any[] = []; // To store additional user data
@@ -149,7 +98,7 @@ export function extractUserFollow(res: RawUserFollowers | RawUserFollowing): IDa
149
98
  * @returns The raw user likes data formatted and sorted into required and additional data
150
99
  * @param res The raw response received from TwitterAPI
151
100
  */
152
- export function extractUserLikes(res: RawUserLikes): IDataExtract {
101
+ export function extractUserLikes(res: IUserLikesResponse): IDataExtract {
153
102
  let required: any[] = []; // To store the reqruied raw data
154
103
  let cursor: string = ''; // To store the cursor to next batch
155
104
  let users: any[] = []; // To store additional user data
@@ -1,5 +1,6 @@
1
1
  // PACKAGES
2
- import { curly, CurlyResult } from 'node-libcurl';
2
+ import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
3
+ import { ITweet as IRawTweet, IUser as IRawUser } from 'rettiwt-core';
3
4
 
4
5
  // SERVICES
5
6
  import { AuthService } from '../auth/AuthService';
@@ -9,10 +10,6 @@ import { CacheService } from './CacheService';
9
10
  import { Tweet } from '../../models/data/Tweet';
10
11
  import { User } from '../../models/data/User';
11
12
 
12
- // TYPES
13
- import { Result as RawUser } from '../../twitter/types/user/User';
14
- import { Result as RawTweet } from '../../twitter/types/tweet/Tweet';
15
-
16
13
  // ENUMS
17
14
  import { HttpStatus } from "../../enums/HTTP";
18
15
 
@@ -64,12 +61,12 @@ export class FetcherService {
64
61
  *
65
62
  * @throws {@link HttpStatus} error, if any HTTP error is found.
66
63
  */
67
- private handleHTTPError(res: CurlyResult): CurlyResult {
64
+ private handleHTTPError(res: AxiosResponse): AxiosResponse {
68
65
  /**
69
66
  * If the status code is not 200 => the HTTP request was not successful. hence throwing error
70
67
  */
71
- if (res.statusCode != 200 && res.statusCode in HttpStatus) {
72
- throw new Error(HttpStatus[res.statusCode])
68
+ if (res.status != 200 && res.status in HttpStatus) {
69
+ throw new Error(HttpStatus[res.status])
73
70
  }
74
71
 
75
72
  return res;
@@ -86,22 +83,18 @@ export class FetcherService {
86
83
  * @param method The HTTP method (from {@link HttpMethods}) to use.
87
84
  * @param data The data to be sent along with the request (for POST request).
88
85
  *
89
- * @returns The {@link CurlyResult} received.
86
+ * @returns The {@link AxiosResponse} received.
90
87
  */
91
- protected async request<DataType>(url: string, authenticate: boolean = true, method: HttpMethods = HttpMethods.GET, data?: any): Promise<CurlyResult<DataType>> {
88
+ protected async request<DataType>(url: string, authenticate: boolean = true, method: HttpMethods = HttpMethods.GET, data?: any): Promise<AxiosResponse<DataType>> {
92
89
  /**
93
90
  * Creating the request configuration based on the params
94
91
  */
95
- let config: CurlyOptions = {
92
+ let config: AxiosRequestConfig = {
96
93
  /**
97
94
  * If authorization is required, using the authenticated header, using the authentication credentiials.
98
95
  * Else, using the guest header, using the guest credentials.
99
96
  */
100
- httpHeader: authenticate ? Headers.authorizedHeader(await this.auth.getAuthCredentials()) : Headers.guestHeader(await this.auth.getGuestCredentials()),
101
- /**
102
- * Disabling SSL peer verification because verification causes Error 404 (only while fetching tweets), likely because peer verification fails.
103
- */
104
- sslVerifyPeer: false,
97
+ headers: authenticate ? Headers.authorizedHeader(await this.auth.getAuthCredentials()) : Headers.guestHeader(await this.auth.getGuestCredentials()),
105
98
  };
106
99
 
107
100
  /**
@@ -110,11 +103,11 @@ export class FetcherService {
110
103
  */
111
104
  // If POST request is to be made
112
105
  if (method == HttpMethods.POST) {
113
- return await curly.post(url, { ...config, postFields: JSON.stringify(data) }).then(res => this.handleHTTPError(res));
106
+ return await axios.post(url, data, config).then(res => this.handleHTTPError(res));
114
107
  }
115
108
  // If GET request is to be made
116
109
  else {
117
- return await curly.get(url, config).then(res => this.handleHTTPError(res));
110
+ return await axios.get(url, config).then(res => this.handleHTTPError(res));
118
111
  }
119
112
  }
120
113
 
@@ -128,8 +121,8 @@ export class FetcherService {
128
121
  * The extracted data is in raw form.
129
122
  * This raw data is deserialized into the respective known types.
130
123
  */
131
- let users = data.users.map((user: RawUser) => new User(user));
132
- let tweets = data.tweets.map((tweet: RawTweet) => new Tweet(tweet));
124
+ let users = data.users.map((user: IRawUser) => new User(user));
125
+ let tweets = data.tweets.map((tweet: IRawTweet) => new Tweet(tweet));
133
126
 
134
127
  // Caching the data
135
128
  this.cache.write(users);
package/src/types/Args.ts CHANGED
@@ -1,40 +1,3 @@
1
- /**
2
- * The filter to be used for fetching tweets from Twitter.
3
- *
4
- * @public
5
- */
6
- export interface ITweetFilter {
7
- /** The list of words to search. */
8
- words?: string[];
9
-
10
- /** The list of hashtags to search. */
11
- hashtags?: string[];
12
-
13
- /** The list of usernames whose tweets are to be searched. */
14
- fromUsers?: string[];
15
-
16
- /** The list of username to whom the tweets to be searched, are adressed. */
17
- toUsers?: string[];
18
-
19
- /** The list of username mentioned in the tweets to search. */
20
- mentions?: string[];
21
-
22
- /** The date starting from which tweets are to be searched. */
23
- startDate?: string;
24
-
25
- /** The date upto which tweets are to be searched. */
26
- endDate?: string;
27
-
28
- /** The id of the tweet, after which the tweets are to be searched. */
29
- sinceId?: string;
30
-
31
- /** The id of the tweet which is quoted in the tweets to search. */
32
- quoted?: string;
33
-
34
- /** Whether to fetch tweets that are links or not. */
35
- links?: boolean;
36
- };
37
-
38
1
  /**
39
2
  * The arguments for fetching cursored list.
40
3
  *
package/Dockerfile DELETED
@@ -1,9 +0,0 @@
1
- FROM node:18.12-alpine3.17
2
- WORKDIR /app
3
- COPY ./package.json .
4
- RUN npm install
5
- COPY . .
6
- RUN npm run build
7
- ENV DEVELOPMENT=false
8
- ENV APP_PORT=3000
9
- CMD npm run start
@@ -1,65 +0,0 @@
1
- import { ITweetFilter } from '../../types/Args';
2
- /**
3
- * The this to be used for fetching tweets from Twitter.
4
- *
5
- * @internal
6
- */
7
- export declare class TweetFilter implements ITweetFilter {
8
- /** The list of words to search. */
9
- words?: string[];
10
- /** The list of hashtags to search.
11
- *
12
- * @remarks
13
- * '#' must be excluded from the hashtag!
14
- */
15
- hashtags?: string[];
16
- /** The list of usernames whose tweets are to be searched.
17
- *
18
- * @remarks
19
- * '@' must be excluded from the username!
20
- */
21
- fromUsers?: string[];
22
- /** The list of username to whom the tweets to be searched, are adressed.
23
- *
24
- * @remarks
25
- * '@' must be excluded from the username!
26
- */
27
- toUsers?: string[];
28
- /** The list of username mentioned in the tweets to search.
29
- *
30
- * @remarks
31
- * '@' must be excluded from the username!
32
- */
33
- mentions?: string[];
34
- /** The date starting from which tweets are to be searched.
35
- *
36
- * @remarks
37
- * Must be in the format YYYY-MM-DD.
38
- */
39
- startDate?: string;
40
- /** The date upto which tweets are to be searched.
41
- *
42
- * @remarks
43
- * Must be in the format YYYY-MM-DD.
44
- */
45
- endDate?: string;
46
- /** The id of the tweet, after which the tweets are to be searched. */
47
- sinceId?: string;
48
- /** The id of the tweet which is quoted in the tweets to search. */
49
- quoted?: string;
50
- /** Whether to fetch tweets that are links or not.
51
- *
52
- * @defaultValue false
53
- */
54
- links?: boolean;
55
- /**
56
- * @param this The incoming this in JSON format.
57
- */
58
- constructor(filter: TweetFilter);
59
- /**
60
- * Converts this object to it's string representation.
61
- *
62
- * @returns 'this' object's string representation.
63
- */
64
- toString(): string;
65
- }
@@ -1,121 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- exports.__esModule = true;
12
- exports.TweetFilter = void 0;
13
- // PACKAGE
14
- var class_validator_1 = require("class-validator");
15
- var DataValidationError_1 = require("../errors/DataValidationError");
16
- /**
17
- * The this to be used for fetching tweets from Twitter.
18
- *
19
- * @internal
20
- */
21
- var TweetFilter = /** @class */ (function () {
22
- /**
23
- * @param this The incoming this in JSON format.
24
- */
25
- function TweetFilter(filter) {
26
- this.endDate = filter.endDate;
27
- this.fromUsers = filter.fromUsers;
28
- this.hashtags = filter.hashtags;
29
- this.links = filter.links;
30
- this.mentions = filter.mentions;
31
- this.quoted = filter.quoted;
32
- this.sinceId = filter.sinceId;
33
- this.startDate = filter.startDate;
34
- this.toUsers = filter.toUsers;
35
- this.words = filter.words;
36
- // Validating the this
37
- var validationResult = (0, class_validator_1.validateSync)(this);
38
- // If valiation error occured
39
- if (validationResult.length) {
40
- throw new DataValidationError_1.DataValidationError(validationResult);
41
- }
42
- }
43
- /**
44
- * Converts this object to it's string representation.
45
- *
46
- * @returns 'this' object's string representation.
47
- */
48
- TweetFilter.prototype.toString = function () {
49
- return [
50
- this.words ? this.words.join(' ') : '',
51
- this.hashtags ? "(".concat(this.hashtags.map(function (hashtag) { return '#' + hashtag; }).join(' OR '), ")") : '',
52
- this.fromUsers ? "(".concat(this.fromUsers.map(function (user) { return "from:".concat(user); }).join(' OR '), ")") : '',
53
- this.toUsers ? "(".concat(this.toUsers.map(function (user) { return "to:".concat(user); }).join(' OR '), ")") : '',
54
- this.mentions ? "(".concat(this.mentions.map(function (mention) { return '@' + mention; }).join(' OR '), ")") : '',
55
- this.startDate ? "since:".concat(this.startDate) : '',
56
- this.endDate ? "until:".concat(this.endDate) : '',
57
- this.sinceId ? "since_id:".concat(this.sinceId) : '',
58
- this.quoted ? "quoted_tweet_id:".concat(this.quoted) : ''
59
- ]
60
- .filter(function (item) { return item !== '()' && item !== ''; })
61
- .join(' ') + (!this.links ? ' -this:links' : '');
62
- };
63
- __decorate([
64
- (0, class_validator_1.IsArray)(),
65
- (0, class_validator_1.IsString)({ each: true }),
66
- (0, class_validator_1.IsOptional)(),
67
- __metadata("design:type", Array)
68
- ], TweetFilter.prototype, "words");
69
- __decorate([
70
- (0, class_validator_1.IsArray)(),
71
- (0, class_validator_1.IsString)({ each: true }),
72
- (0, class_validator_1.IsOptional)(),
73
- __metadata("design:type", Array)
74
- ], TweetFilter.prototype, "hashtags");
75
- __decorate([
76
- (0, class_validator_1.IsArray)(),
77
- (0, class_validator_1.IsString)({ each: true }),
78
- (0, class_validator_1.IsOptional)(),
79
- __metadata("design:type", Array)
80
- ], TweetFilter.prototype, "fromUsers");
81
- __decorate([
82
- (0, class_validator_1.IsArray)(),
83
- (0, class_validator_1.IsString)({ each: true }),
84
- (0, class_validator_1.IsOptional)(),
85
- __metadata("design:type", Array)
86
- ], TweetFilter.prototype, "toUsers");
87
- __decorate([
88
- (0, class_validator_1.IsArray)(),
89
- (0, class_validator_1.IsString)({ each: true }),
90
- (0, class_validator_1.IsOptional)(),
91
- __metadata("design:type", Array)
92
- ], TweetFilter.prototype, "mentions");
93
- __decorate([
94
- (0, class_validator_1.IsOptional)(),
95
- (0, class_validator_1.IsDateString)(),
96
- __metadata("design:type", String)
97
- ], TweetFilter.prototype, "startDate");
98
- __decorate([
99
- (0, class_validator_1.IsOptional)(),
100
- (0, class_validator_1.IsDateString)(),
101
- __metadata("design:type", String)
102
- ], TweetFilter.prototype, "endDate");
103
- __decorate([
104
- (0, class_validator_1.IsNumberString)(),
105
- (0, class_validator_1.IsOptional)(),
106
- __metadata("design:type", String)
107
- ], TweetFilter.prototype, "sinceId");
108
- __decorate([
109
- (0, class_validator_1.IsNumberString)(),
110
- (0, class_validator_1.IsOptional)(),
111
- __metadata("design:type", String)
112
- ], TweetFilter.prototype, "quoted");
113
- __decorate([
114
- (0, class_validator_1.IsBoolean)(),
115
- (0, class_validator_1.IsOptional)(),
116
- __metadata("design:type", Boolean)
117
- ], TweetFilter.prototype, "links");
118
- return TweetFilter;
119
- }());
120
- exports.TweetFilter = TweetFilter;
121
- //# sourceMappingURL=TweetFilter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TweetFilter.js","sourceRoot":"","sources":["../../../src/models/args/TweetFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,UAAU;AACV,mDAAuH;AAIvH,qEAAoE;AAEpE;;;;GAIG;AACH;IAmFI;;OAEG;IACH,qBAAY,MAAmB;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;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,IAAI,EAAE,IAAI,EAAE,CAAC;QACxB,IAAA,4BAAU,GAAE;;yCACO;IAUpB;QAHC,IAAA,yBAAO,GAAE;QACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACxB,IAAA,4BAAU,GAAE;;0CACQ;IAUrB;QAHC,IAAA,yBAAO,GAAE;QACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACxB,IAAA,4BAAU,GAAE;;wCACM;IAUnB;QAHC,IAAA,yBAAO,GAAE;QACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACxB,IAAA,4BAAU,GAAE;;yCACO;IASpB;QAFC,IAAA,4BAAU,GAAE;QACZ,IAAA,8BAAY,GAAE;;0CACI;IASnB;QAFC,IAAA,4BAAU,GAAE;QACZ,IAAA,8BAAY,GAAE;;wCACE;IAKjB;QAFC,IAAA,gCAAc,GAAE;QAChB,IAAA,4BAAU,GAAE;;wCACI;IAKjB;QAFC,IAAA,gCAAc,GAAE;QAChB,IAAA,4BAAU,GAAE;;uCACG;IAQhB;QAFC,IAAA,2BAAS,GAAE;QACX,IAAA,4BAAU,GAAE;;sCACG;IA8CpB,kBAAC;CAAA,AA/HD,IA+HC;AA/HY,kCAAW"}
@@ -1,20 +0,0 @@
1
- import { ValidationError } from "class-validator";
2
- /**
3
- * Error when any fields of a JSON data fails to validate.
4
- *
5
- * @internal
6
- *
7
- * @param errorDetails The details of about the specific fields that failed to validate.
8
- */
9
- export declare class DataValidationError implements Error {
10
- /** The name of the error. */
11
- name: string;
12
- /** The user-friendly error message. */
13
- message: string;
14
- /** The error data. */
15
- data: ValidationError[];
16
- /**
17
- * @param data The error details.
18
- */
19
- constructor(errorDetails: ValidationError[]);
20
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.DataValidationError = void 0;
4
- /**
5
- * Error when any fields of a JSON data fails to validate.
6
- *
7
- * @internal
8
- *
9
- * @param errorDetails The details of about the specific fields that failed to validate.
10
- */
11
- var DataValidationError = /** @class */ (function () {
12
- /**
13
- * @param data The error details.
14
- */
15
- function DataValidationError(errorDetails) {
16
- this.name = 'ValidationError';
17
- this.message = 'One or more validation errors occured. Refer to data for details';
18
- this.data = errorDetails;
19
- }
20
- return DataValidationError;
21
- }());
22
- exports.DataValidationError = DataValidationError;
23
- //# sourceMappingURL=DataValidationError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DataValidationError.js","sourceRoot":"","sources":["../../../src/models/errors/DataValidationError.ts"],"names":[],"mappings":";;;AAGA;;;;;;GAMG;AACH;IAUI;;OAEG;IACH,6BAAY,YAA+B;QACvC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,kEAAkE,CAAC;QAClF,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC7B,CAAC;IACL,0BAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,kDAAmB"}
@@ -1,22 +0,0 @@
1
- import { ResourceType } from "./enums/Resources";
2
- import { Args } from './payloads/Args';
3
- /**
4
- * A class that deals with generation of URLs to various resources on Twitter.
5
- */
6
- export declare class Url {
7
- /** The base Twitter API url. */
8
- private baseUrl;
9
- /** The fully initialized target resource URL. */
10
- fullUrl: string;
11
- /**
12
- * Initializes a URL for fetching the specified resource, using the given arguments.
13
- *
14
- * @param resourceType The type of resource to fetch.
15
- * @param args Any additional arguments.
16
- */
17
- constructor(resourceType: ResourceType, args: Args);
18
- /**
19
- * @returns The string representation of thi Url.
20
- */
21
- toString(): string;
22
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.Url = void 0;
4
- var Query_1 = require("./params/Query");
5
- /**
6
- * A class that deals with generation of URLs to various resources on Twitter.
7
- */
8
- var Url = /** @class */ (function () {
9
- /**
10
- * Initializes a URL for fetching the specified resource, using the given arguments.
11
- *
12
- * @param resourceType The type of resource to fetch.
13
- * @param args Any additional arguments.
14
- */
15
- function Url(resourceType, args) {
16
- /** The base Twitter API url. */
17
- this.baseUrl = 'https://api.twitter.com';
18
- /**
19
- * Initializing full URL along with additional URL parameters.
20
- */
21
- this.fullUrl = "".concat(this.baseUrl).concat(resourceType, "?").concat(new Query_1.Query(resourceType, args).toString());
22
- }
23
- /**
24
- * @returns The string representation of thi Url.
25
- */
26
- Url.prototype.toString = function () {
27
- return this.fullUrl;
28
- };
29
- return Url;
30
- }());
31
- exports.Url = Url;
32
- //# sourceMappingURL=Url.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Url.js","sourceRoot":"","sources":["../../src/twitter/Url.ts"],"names":[],"mappings":";;;AAKA,wCAAuC;AAEvC;;GAEG;AACH;IAOI;;;;;OAKG;IACH,aAAY,YAA0B,EAAE,IAAU;QAZlD,gCAAgC;QACxB,YAAO,GAAW,yBAAyB,CAAC;QAYhD;;WAEG;QACH,IAAI,CAAC,OAAO,GAAG,UAAG,IAAI,CAAC,OAAO,SAAG,YAAY,cAAI,IAAI,aAAK,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAE,CAAC;IAChG,CAAC;IAED;;OAEG;IACI,sBAAQ,GAAf;QACI,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IACL,UAAC;AAAD,CAAC,AA1BD,IA0BC;AA1BY,kBAAG"}
@@ -1,15 +0,0 @@
1
- /**
2
- * The different types of resources that can be fetched.
3
- */
4
- export declare enum ResourceType {
5
- 'TWEETS' = "/2/search/adaptive.json",
6
- 'TWEET_DETAILS' = "/graphql/lXI2kaM2hgmbf7h42kpxuA/TweetDetail",
7
- 'TWEET_LIKES' = "/graphql/56ZwFC3Vui31fF8IYX8EGA/Favoriters",
8
- 'TWEET_RETWEETS' = "/graphql/Wd7DVeLqMj_JQiTL0tjJwQ/Retweeters",
9
- 'USER_DETAILS' = "/graphql/hVhfo_TquFTmgL7gYwf91Q/UserByScreenName",
10
- 'USER_DETAILS_BY_ID' = "/graphql/mi_IjXgFyr41N9zkszPz9w/UserByRestId",
11
- 'USER_TWEETS' = "/graphql/xxLjoOBBPpYBHbBTI-hevQ/UserTweetsAndReplies",
12
- 'USER_FOLLOWING' = "/graphql/mSnjZc5CTm2Z5Lu_i4XsPQ/Following",
13
- 'USER_FOLLOWERS' = "/graphql/nwlAnaw7oKXcVLi91ehy7Q/Followers",
14
- 'USER_LIKES' = "/graphql/gP4ZKghLd4tpILgS6VudAQ/Likes"
15
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.ResourceType = void 0;
4
- /**
5
- * The different types of resources that can be fetched.
6
- */
7
- var ResourceType;
8
- (function (ResourceType) {
9
- ResourceType["TWEETS"] = "/2/search/adaptive.json";
10
- ResourceType["TWEET_DETAILS"] = "/graphql/lXI2kaM2hgmbf7h42kpxuA/TweetDetail";
11
- ResourceType["TWEET_LIKES"] = "/graphql/56ZwFC3Vui31fF8IYX8EGA/Favoriters";
12
- ResourceType["TWEET_RETWEETS"] = "/graphql/Wd7DVeLqMj_JQiTL0tjJwQ/Retweeters";
13
- ResourceType["USER_DETAILS"] = "/graphql/hVhfo_TquFTmgL7gYwf91Q/UserByScreenName";
14
- ResourceType["USER_DETAILS_BY_ID"] = "/graphql/mi_IjXgFyr41N9zkszPz9w/UserByRestId";
15
- ResourceType["USER_TWEETS"] = "/graphql/xxLjoOBBPpYBHbBTI-hevQ/UserTweetsAndReplies";
16
- ResourceType["USER_FOLLOWING"] = "/graphql/mSnjZc5CTm2Z5Lu_i4XsPQ/Following";
17
- ResourceType["USER_FOLLOWERS"] = "/graphql/nwlAnaw7oKXcVLi91ehy7Q/Followers";
18
- ResourceType["USER_LIKES"] = "/graphql/gP4ZKghLd4tpILgS6VudAQ/Likes";
19
- })(ResourceType = exports.ResourceType || (exports.ResourceType = {}));
20
- ;
21
- //# sourceMappingURL=Resources.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Resources.js","sourceRoot":"","sources":["../../../src/twitter/enums/Resources.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,YAWX;AAXD,WAAY,YAAY;IACpB,kDAAoC,CAAA;IACpC,6EAA+D,CAAA;IAC/D,0EAA4D,CAAA;IAC5D,6EAA+D,CAAA;IAC/D,iFAAmE,CAAA;IACnE,mFAAqE,CAAA;IACrE,oFAAsE,CAAA;IACtE,4EAA8D,CAAA;IAC9D,4EAA8D,CAAA;IAC9D,oEAAsD,CAAA;AAC1D,CAAC,EAXW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAWvB;AAAA,CAAC"}
@@ -1,67 +0,0 @@
1
- import { Args } from '../payloads/Args';
2
- import { IQuery } from '../types/request/Query';
3
- import { ResourceType } from '../enums/Resources';
4
- /**
5
- * The URL query parameters that must be sent while making requests to Twitter API.
6
- */
7
- export declare class Query implements IQuery {
8
- cards_platform?: string;
9
- count?: number;
10
- cursor?: string;
11
- ext?: string;
12
- include_blocked_by?: number;
13
- include_blocking?: number;
14
- include_can_dm?: number;
15
- include_can_media_tag?: number;
16
- include_cards?: number;
17
- include_entities?: boolean;
18
- include_ext_alt_text?: boolean;
19
- include_ext_collab_control?: boolean;
20
- include_ext_edit_control?: boolean;
21
- include_ext_has_nft_avatar?: number;
22
- include_ext_is_blue_verified?: number;
23
- include_ext_limited_action_results?: boolean;
24
- include_ext_media_availability?: boolean;
25
- include_ext_media_color?: boolean;
26
- include_ext_sensitive_media_warning?: boolean;
27
- include_ext_trusted_friends_metadata?: boolean;
28
- include_ext_verified_type?: number;
29
- include_ext_views?: boolean;
30
- include_followed_by?: number;
31
- include_mute_edge?: number;
32
- include_profile_interstitial_type?: number;
33
- include_quote_count?: boolean;
34
- include_reply_count?: number;
35
- include_user_entities?: boolean;
36
- include_want_retweets?: number;
37
- pc?: number;
38
- q?: string;
39
- query_source?: string;
40
- send_error_codes?: boolean;
41
- simple_quoted_tweet?: boolean;
42
- skip_status?: number;
43
- spelling_corrections?: number;
44
- tweet_mode?: string;
45
- tweet_search_mode?: string;
46
- /**
47
- * Variables for fetching data.
48
- */
49
- variables?: string;
50
- /**
51
- * Additional data features that must be fetched.
52
- */
53
- features?: string;
54
- /**
55
- * Initializes the URL parameters.
56
- *
57
- * @param resourceType The type of resource requested.
58
- * @param args Additional user-defined arguments to be sent in the request.
59
- */
60
- constructor(resourceType: ResourceType, args: Args);
61
- /**
62
- * Converts this object to it's string representation.
63
- *
64
- * @returns 'this' object's string representation;
65
- */
66
- toString(): string;
67
- }