rettiwt-api 1.0.6 → 1.0.8

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 (177) hide show
  1. package/dist/{queries → graphql/queries}/RootQuery.d.ts +0 -0
  2. package/dist/{queries → graphql/queries}/RootQuery.js +4 -3
  3. package/dist/graphql/queries/RootQuery.js.map +1 -0
  4. package/dist/{resolvers → graphql/resolvers}/AccountResolver.d.ts +1 -1
  5. package/dist/{resolvers → graphql/resolvers}/AccountResolver.js +0 -0
  6. package/dist/graphql/resolvers/AccountResolver.js.map +1 -0
  7. package/dist/{resolvers → graphql/resolvers}/ResolverBase.d.ts +1 -1
  8. package/dist/{resolvers → graphql/resolvers}/ResolverBase.js +0 -0
  9. package/dist/graphql/resolvers/ResolverBase.js.map +1 -0
  10. package/dist/{resolvers → graphql/resolvers}/TweetResolver.d.ts +10 -18
  11. package/dist/{resolvers → graphql/resolvers}/TweetResolver.js +51 -83
  12. package/dist/graphql/resolvers/TweetResolver.js.map +1 -0
  13. package/dist/{resolvers → graphql/resolvers}/UserResolver.d.ts +5 -4
  14. package/dist/{resolvers → graphql/resolvers}/UserResolver.js +51 -35
  15. package/dist/graphql/resolvers/UserResolver.js.map +1 -0
  16. package/dist/{models/graphql → graphql/types}/Global.d.ts +0 -0
  17. package/dist/{models/graphql → graphql/types}/Global.js +0 -0
  18. package/dist/graphql/types/Global.js.map +1 -0
  19. package/dist/graphql/types/TweetTypes.d.ts +4 -0
  20. package/dist/{models/graphql → graphql/types}/TweetTypes.js +17 -13
  21. package/dist/graphql/types/TweetTypes.js.map +1 -0
  22. package/dist/graphql/types/UserTypes.d.ts +3 -0
  23. package/dist/{models/graphql → graphql/types}/UserTypes.js +9 -11
  24. package/dist/graphql/types/UserTypes.js.map +1 -0
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +2 -2
  27. package/dist/index.js.map +1 -1
  28. package/dist/server.js +3 -3
  29. package/dist/server.js.map +1 -1
  30. package/dist/services/AuthService.js +2 -2
  31. package/dist/services/AuthService.js.map +1 -1
  32. package/dist/services/CacheService.d.ts +3 -3
  33. package/dist/services/CacheService.js +22 -75
  34. package/dist/services/CacheService.js.map +1 -1
  35. package/dist/services/FetcherService.d.ts +3 -2
  36. package/dist/services/FetcherService.js +11 -29
  37. package/dist/services/FetcherService.js.map +1 -1
  38. package/dist/services/data/TweetService.d.ts +15 -16
  39. package/dist/services/data/TweetService.js +71 -50
  40. package/dist/services/data/TweetService.js.map +1 -1
  41. package/dist/services/data/UserAccountService.d.ts +3 -3
  42. package/dist/services/data/UserAccountService.js +22 -8
  43. package/dist/services/data/UserAccountService.js.map +1 -1
  44. package/dist/services/data/UserService.d.ts +42 -0
  45. package/dist/services/data/UserService.js +255 -0
  46. package/dist/services/data/UserService.js.map +1 -0
  47. package/dist/services/helper/Extractors.js +1 -1
  48. package/dist/services/helper/Extractors.js.map +1 -1
  49. package/dist/services/helper/Parser.d.ts +1 -1
  50. package/dist/services/helper/Parser.js +4 -3
  51. package/dist/services/helper/Parser.js.map +1 -1
  52. package/dist/services/helper/Urls.d.ts +2 -2
  53. package/dist/services/helper/Urls.js +19 -3
  54. package/dist/services/helper/Urls.js.map +1 -1
  55. package/dist/services/helper/deserializers/Tweets.d.ts +12 -0
  56. package/dist/services/helper/deserializers/Tweets.js +92 -0
  57. package/dist/services/helper/deserializers/Tweets.js.map +1 -0
  58. package/dist/services/{accounting/Flows.d.ts → helper/deserializers/User.d.ts} +0 -0
  59. package/dist/services/helper/deserializers/User.js +2 -0
  60. package/dist/services/helper/deserializers/User.js.map +1 -0
  61. package/dist/services/helper/deserializers/Users.d.ts +7 -0
  62. package/dist/services/helper/deserializers/Users.js +27 -0
  63. package/dist/services/helper/deserializers/Users.js.map +1 -0
  64. package/dist/services/helper/extractors/TweetExtractors.d.ts +0 -0
  65. package/dist/services/helper/extractors/TweetExtractors.js +2 -0
  66. package/dist/services/helper/extractors/TweetExtractors.js.map +1 -0
  67. package/dist/services/helper/extractors/Tweets.d.ts +34 -0
  68. package/dist/services/helper/extractors/Tweets.js +266 -0
  69. package/dist/services/helper/extractors/Tweets.js.map +1 -0
  70. package/dist/services/helper/extractors/UserExtractors.d.ts +45 -0
  71. package/dist/services/helper/extractors/UserExtractors.js +176 -0
  72. package/dist/services/helper/extractors/UserExtractors.js.map +1 -0
  73. package/dist/services/helper/extractors/Users.d.ts +23 -0
  74. package/dist/services/helper/extractors/Users.js +154 -0
  75. package/dist/services/helper/extractors/Users.js.map +1 -0
  76. package/dist/services/helper/urls/Authentication.d.ts +4 -0
  77. package/dist/services/helper/urls/Authentication.js +11 -0
  78. package/dist/services/helper/urls/Authentication.js.map +1 -0
  79. package/dist/services/helper/urls/Tweets.d.ts +32 -0
  80. package/dist/services/helper/urls/Tweets.js +51 -0
  81. package/dist/services/helper/urls/Tweets.js.map +1 -0
  82. package/dist/services/helper/urls/Urls.d.ts +4 -0
  83. package/dist/services/helper/urls/Urls.js +11 -0
  84. package/dist/services/helper/urls/Urls.js.map +1 -0
  85. package/dist/services/helper/urls/Users.d.ts +31 -0
  86. package/dist/services/helper/urls/Users.js +66 -0
  87. package/dist/services/helper/urls/Users.js.map +1 -0
  88. package/dist/types/{graphql/Errors.d.ts → Errors.d.ts} +0 -0
  89. package/dist/types/{graphql/Errors.js → Errors.js} +0 -0
  90. package/dist/types/Errors.js.map +1 -0
  91. package/dist/types/Resolvers.d.ts +9 -0
  92. package/dist/types/Resolvers.js +3 -0
  93. package/dist/types/Resolvers.js.map +1 -0
  94. package/dist/types/Tweet.d.ts +1 -0
  95. package/dist/types/Tweet.js.map +1 -1
  96. package/dist/types/User.d.ts +19 -0
  97. package/dist/types/User.js +4 -0
  98. package/dist/types/User.js.map +1 -0
  99. package/dist/types/data/Errors.d.ts +27 -0
  100. package/dist/types/data/Errors.js +35 -0
  101. package/dist/types/data/Errors.js.map +1 -0
  102. package/dist/types/data/Service.d.ts +29 -0
  103. package/dist/types/data/Service.js +19 -0
  104. package/dist/types/data/Service.js.map +1 -0
  105. package/dist/types/data/Tweet.d.ts +41 -0
  106. package/dist/types/data/Tweet.js +5 -0
  107. package/dist/types/data/Tweet.js.map +1 -0
  108. package/dist/types/data/User.d.ts +19 -0
  109. package/dist/types/data/User.js +4 -0
  110. package/dist/types/data/User.js.map +1 -0
  111. package/dist/types/raw/http/Error.d.ts +34 -0
  112. package/dist/types/raw/{user/Users.js → http/Error.js} +1 -1
  113. package/dist/types/raw/http/Error.js.map +1 -0
  114. package/dist/types/raw/http/Response.d.ts +34 -0
  115. package/dist/types/raw/http/Response.js +3 -0
  116. package/dist/types/raw/http/Response.js.map +1 -0
  117. package/package.json +1 -1
  118. package/src/{queries → graphql/queries}/RootQuery.ts +5 -4
  119. package/src/{resolvers → graphql/resolvers}/AccountResolver.ts +21 -21
  120. package/src/{resolvers → graphql/resolvers}/ResolverBase.ts +1 -1
  121. package/src/{resolvers → graphql/resolvers}/TweetResolver.ts +48 -30
  122. package/src/{resolvers → graphql/resolvers}/UserResolver.ts +41 -27
  123. package/src/{models/graphql → graphql/types}/Global.ts +0 -0
  124. package/src/{models/graphql → graphql/types}/TweetTypes.ts +16 -12
  125. package/src/{models/graphql → graphql/types}/UserTypes.ts +13 -15
  126. package/src/index.ts +2 -2
  127. package/src/server.ts +3 -3
  128. package/src/services/AuthService.ts +1 -1
  129. package/src/services/CacheService.ts +6 -8
  130. package/src/services/FetcherService.ts +11 -14
  131. package/src/services/data/TweetService.ts +58 -37
  132. package/src/services/data/UserService.ts +187 -0
  133. package/src/services/helper/Parser.ts +6 -4
  134. package/src/services/helper/{Deserializers.ts → deserializers/Tweets.ts} +3 -28
  135. package/src/services/helper/deserializers/Users.ts +26 -0
  136. package/src/services/helper/extractors/Tweets.ts +252 -0
  137. package/src/services/helper/extractors/Users.ts +137 -0
  138. package/src/services/helper/urls/Authentication.ts +6 -0
  139. package/src/services/helper/urls/Tweets.ts +46 -0
  140. package/src/services/helper/urls/Users.ts +62 -0
  141. package/src/types/Resolvers.ts +9 -0
  142. package/src/types/data/Errors.ts +28 -0
  143. package/src/types/{Service.ts → data/Service.ts} +4 -5
  144. package/src/types/{Tweet.ts → data/Tweet.ts} +1 -0
  145. package/src/types/{UserAccount.ts → data/User.ts} +0 -0
  146. package/tsconfig.json +2 -2
  147. package/dist/models/graphql/Global.js.map +0 -1
  148. package/dist/models/graphql/TweetTypes.d.ts +0 -6
  149. package/dist/models/graphql/TweetTypes.js.map +0 -1
  150. package/dist/models/graphql/UserTypes.d.ts +0 -3
  151. package/dist/models/graphql/UserTypes.js.map +0 -1
  152. package/dist/queries/RootQuery.js.map +0 -1
  153. package/dist/resolvers/AccountResolver.js.map +0 -1
  154. package/dist/resolvers/ResolverBase.js.map +0 -1
  155. package/dist/resolvers/TweetResolver.js.map +0 -1
  156. package/dist/resolvers/UserResolver.js.map +0 -1
  157. package/dist/services/AccountsService.d.ts +0 -17
  158. package/dist/services/AccountsService.js +0 -171
  159. package/dist/services/AccountsService.js.map +0 -1
  160. package/dist/services/accounting/AccountsService.d.ts +0 -20
  161. package/dist/services/accounting/AccountsService.js +0 -147
  162. package/dist/services/accounting/AccountsService.js.map +0 -1
  163. package/dist/services/accounting/Flows.js +0 -2
  164. package/dist/services/accounting/Flows.js.map +0 -1
  165. package/dist/services/accounting/LoginFlows.d.ts +0 -20
  166. package/dist/services/accounting/LoginFlows.js +0 -70
  167. package/dist/services/accounting/LoginFlows.js.map +0 -1
  168. package/dist/test/Test.js +0 -2
  169. package/dist/test/Test.js.map +0 -1
  170. package/dist/types/graphql/Errors.js.map +0 -1
  171. package/dist/types/raw/user/Users.d.ts +0 -120
  172. package/dist/types/raw/user/Users.js.map +0 -1
  173. package/src/services/data/UserAccountService.ts +0 -176
  174. package/src/services/helper/Extractors.ts +0 -455
  175. package/src/services/helper/Urls.ts +0 -109
  176. package/src/types/graphql/Errors.ts +0 -16
  177. package/src/types/raw/user/Tweets.ts +0 -2847
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @summary Stores the data returned from extractors
3
+ */
4
+ export interface DataExtract {
5
+ required: any;
6
+ cursor: string;
7
+ users: any;
8
+ tweets: any;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ //# sourceMappingURL=Resolvers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Resolvers.js","sourceRoot":"","sources":["../../src/types/Resolvers.ts"],"names":[],"mappings":""}
@@ -9,6 +9,7 @@ export interface TweetFilter {
9
9
  mentions?: string[];
10
10
  startDate?: string;
11
11
  endDate?: string;
12
+ sinceId?: string;
12
13
  quoted?: string;
13
14
  links?: boolean;
14
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Tweet.js","sourceRoot":"","sources":["../../src/types/Tweet.ts"],"names":[],"mappings":";AAAA,kFAAkF;;AAejF,CAAC"}
1
+ {"version":3,"file":"Tweet.js","sourceRoot":"","sources":["../../src/types/Tweet.ts"],"names":[],"mappings":";AAAA,kFAAkF;;AAgBjF,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @summary Stores the complete details of the given user's account
3
+ */
4
+ export interface User {
5
+ id: string;
6
+ userName: string;
7
+ fullName: string;
8
+ createdAt: string;
9
+ description: string;
10
+ isVerified: boolean;
11
+ favouritesCount: number;
12
+ followersCount: number;
13
+ followingsCount: number;
14
+ statusesCount: number;
15
+ location: string;
16
+ pinnedTweet: string;
17
+ profileBanner: string;
18
+ profileImage: string;
19
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // This file contains various objects for handling data related to User Account
3
+ exports.__esModule = true;
4
+ //# sourceMappingURL=User.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"User.js","sourceRoot":"","sources":["../../src/types/User.ts"],"names":[],"mappings":";AAAA,+EAA+E"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @summary Stores different types of error messages related to authentication
3
+ */
4
+ export declare enum AuthenticationErrors {
5
+ NotAuthenticated = "Cannot fetch this data without authentication"
6
+ }
7
+ /**
8
+ * @summary Stores different types error messages for validation errors
9
+ */
10
+ export declare enum ValidationErrors {
11
+ InvalidTweetFilter = "Atleast one of fromUsers/toUsers/mentions/hashtags/words argument is required",
12
+ NoUserIdentification = "Either userName or id must be given",
13
+ InvalidCount = "Invalid count provided",
14
+ InvalidTweetIdCount = "Atleast one Tweet ID must be provided"
15
+ }
16
+ /**
17
+ * @summary Stores all the different type of error messages that are returned by services
18
+ */
19
+ export declare const DataErrors: {
20
+ UserNotFound: (id: string) => string;
21
+ TweetNotFound: (id: string) => string;
22
+ NoTweetsFound: () => string;
23
+ NoLikersFound: (id: string) => string;
24
+ NoRetweetersFound: (id: string) => string;
25
+ NoFollowsFound: (id: string) => string;
26
+ NoLikedTweetsFound: (id: string) => string;
27
+ };
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.DataErrors = exports.ValidationErrors = exports.AuthenticationErrors = void 0;
4
+ /**
5
+ * @summary Stores different types of error messages related to authentication
6
+ */
7
+ var AuthenticationErrors;
8
+ (function (AuthenticationErrors) {
9
+ AuthenticationErrors["NotAuthenticated"] = "Cannot fetch this data without authentication";
10
+ })(AuthenticationErrors = exports.AuthenticationErrors || (exports.AuthenticationErrors = {}));
11
+ ;
12
+ /**
13
+ * @summary Stores different types error messages for validation errors
14
+ */
15
+ var ValidationErrors;
16
+ (function (ValidationErrors) {
17
+ ValidationErrors["InvalidTweetFilter"] = "Atleast one of fromUsers/toUsers/mentions/hashtags/words argument is required";
18
+ ValidationErrors["NoUserIdentification"] = "Either userName or id must be given";
19
+ ValidationErrors["InvalidCount"] = "Invalid count provided";
20
+ ValidationErrors["InvalidTweetIdCount"] = "Atleast one Tweet ID must be provided";
21
+ })(ValidationErrors = exports.ValidationErrors || (exports.ValidationErrors = {}));
22
+ ;
23
+ /**
24
+ * @summary Stores all the different type of error messages that are returned by services
25
+ */
26
+ exports.DataErrors = {
27
+ UserNotFound: function (id) { return "An account with username/id ".concat(id, " was not found"); },
28
+ TweetNotFound: function (id) { return "A tweet with the given id ".concat(id, " was not found"); },
29
+ NoTweetsFound: function () { return "No tweets matching the given criteria found"; },
30
+ NoLikersFound: function (id) { return "No likers found for the tweet with the given id ".concat(id); },
31
+ NoRetweetersFound: function (id) { return "No retweeters found for the tweet with the given id ".concat(id); },
32
+ NoFollowsFound: function (id) { return "No follow details were found for the user with the given id ".concat(id); },
33
+ NoLikedTweetsFound: function (id) { return "No liked tweets were found for the user with the given id".concat(id); }
34
+ };
35
+ //# sourceMappingURL=Errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Errors.js","sourceRoot":"","sources":["../../../src/types/data/Errors.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,IAAY,oBAEX;AAFD,WAAY,oBAAoB;IAC5B,0FAAkE,CAAA;AACtE,CAAC,EAFW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAE/B;AAAA,CAAC;AAEF;;GAEG;AACH,IAAY,gBAKX;AALD,WAAY,gBAAgB;IACxB,wHAAoG,CAAA;IACpG,gFAA4D,CAAA;IAC5D,2DAAuC,CAAA;IACvC,iFAA6D,CAAA;AACjE,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B;AAAA,CAAC;AAEF;;GAEG;AACU,QAAA,UAAU,GAAG;IACtB,YAAY,EAAE,UAAC,EAAU,IAAK,OAAA,sCAA+B,EAAE,mBAAgB,EAAjD,CAAiD;IAC/E,aAAa,EAAE,UAAC,EAAU,IAAK,OAAA,oCAA6B,EAAE,mBAAgB,EAA/C,CAA+C;IAC9E,aAAa,EAAE,cAAM,OAAA,6CAA6C,EAA7C,CAA6C;IAClE,aAAa,EAAE,UAAC,EAAU,IAAK,OAAA,0DAAmD,EAAE,CAAE,EAAvD,CAAuD;IACtF,iBAAiB,EAAE,UAAC,EAAU,IAAK,OAAA,8DAAuD,EAAE,CAAE,EAA3D,CAA2D;IAC9F,cAAc,EAAE,UAAC,EAAU,IAAK,OAAA,sEAA+D,EAAE,CAAE,EAAnE,CAAmE;IACnG,kBAAkB,EAAE,UAAC,EAAU,IAAK,OAAA,mEAA4D,EAAE,CAAE,EAAhE,CAAgE;CACvG,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { AccountService } from "../../services/accounts/AccountService";
2
+ import { TweetService } from "../../services/data/TweetService";
3
+ import { UserService } from "../../services/data/UserService";
4
+ /**
5
+ * @summary Stores the cursor to the batch of data
6
+ */
7
+ export declare class Cursor {
8
+ value: string;
9
+ /**
10
+ * @summary Initializes a new cursor from the given cursor string
11
+ * @param cursorStr The string representation of the cursor
12
+ */
13
+ constructor(cursorStr: string);
14
+ }
15
+ /**
16
+ * @summary Stores cursored data that is returned by services
17
+ */
18
+ export interface CursoredData<Type> {
19
+ list?: Type[];
20
+ next?: Cursor;
21
+ }
22
+ /**
23
+ * @summary Stores the data context from where data is to be fetched
24
+ */
25
+ export interface DataContext {
26
+ users: UserService;
27
+ tweets: TweetService;
28
+ account: AccountService;
29
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.Cursor = void 0;
4
+ /**
5
+ * @summary Stores the cursor to the batch of data
6
+ */
7
+ var Cursor = /** @class */ (function () {
8
+ // MEMBER DATA
9
+ /**
10
+ * @summary Initializes a new cursor from the given cursor string
11
+ * @param cursorStr The string representation of the cursor
12
+ */
13
+ function Cursor(cursorStr) {
14
+ this.value = cursorStr;
15
+ }
16
+ return Cursor;
17
+ }());
18
+ exports.Cursor = Cursor;
19
+ //# sourceMappingURL=Service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Service.js","sourceRoot":"","sources":["../../../src/types/data/Service.ts"],"names":[],"mappings":";;;AAKA;;GAEG;AACH;IAII,cAAc;IACd;;;OAGG;IACH,gBAAY,SAAiB;QACzB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IAC3B,CAAC;IACL,aAAC;AAAD,CAAC,AAZD,IAYC;AAZY,wBAAM"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @summary Stores the filter to be used for fetching tweets from TwitterAPI
3
+ */
4
+ export interface TweetFilter {
5
+ words?: string[];
6
+ hashtags?: string[];
7
+ fromUsers?: string[];
8
+ toUsers?: string[];
9
+ mentions?: string[];
10
+ startDate?: string;
11
+ endDate?: string;
12
+ sinceId?: string;
13
+ quoted?: string;
14
+ links?: boolean;
15
+ }
16
+ /**
17
+ * @summary Stores the different types of tweet elements like urls, media, mentions, hashtags, etc
18
+ */
19
+ export interface TweetEntities {
20
+ hashtags: string[];
21
+ urls: string[];
22
+ mentionedUsers: string[];
23
+ media: string[];
24
+ }
25
+ /**
26
+ * @summary Stores a single tweet
27
+ */
28
+ export interface Tweet {
29
+ id: string;
30
+ tweetBy: string;
31
+ createdAt: string;
32
+ entities: TweetEntities;
33
+ quoted: string;
34
+ fullText: string;
35
+ replyTo: string;
36
+ lang: string;
37
+ quoteCount: number;
38
+ replyCount: number;
39
+ retweetCount: number;
40
+ likeCount: number;
41
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // This file contains various objects related to handling of Tweets made by a user
3
+ exports.__esModule = true;
4
+ ;
5
+ //# sourceMappingURL=Tweet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tweet.js","sourceRoot":"","sources":["../../../src/types/data/Tweet.ts"],"names":[],"mappings":";AAAA,kFAAkF;;AAgBjF,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @summary Stores the complete details of the given user's account
3
+ */
4
+ export interface User {
5
+ id: string;
6
+ userName: string;
7
+ fullName: string;
8
+ createdAt: string;
9
+ description: string;
10
+ isVerified: boolean;
11
+ favouritesCount: number;
12
+ followersCount: number;
13
+ followingsCount: number;
14
+ statusesCount: number;
15
+ location: string;
16
+ pinnedTweet: string;
17
+ profileBanner: string;
18
+ profileImage: string;
19
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // This file contains various objects for handling data related to User Account
3
+ exports.__esModule = true;
4
+ //# sourceMappingURL=User.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"User.js","sourceRoot":"","sources":["../../../src/types/data/User.ts"],"names":[],"mappings":";AAAA,+EAA+E"}
@@ -0,0 +1,34 @@
1
+ export interface Root {
2
+ errors: Error[];
3
+ data: Data;
4
+ }
5
+ export interface Error {
6
+ message: string;
7
+ locations: Location[];
8
+ path: string[];
9
+ extensions: Extensions;
10
+ code: number;
11
+ kind: string;
12
+ name: string;
13
+ source: string;
14
+ tracing: Tracing2;
15
+ }
16
+ export interface Location {
17
+ line: number;
18
+ column: number;
19
+ }
20
+ export interface Extensions {
21
+ name: string;
22
+ source: string;
23
+ code: number;
24
+ kind: string;
25
+ tracing: Tracing;
26
+ }
27
+ export interface Tracing {
28
+ trace_id: string;
29
+ }
30
+ export interface Tracing2 {
31
+ trace_id: string;
32
+ }
33
+ export interface Data {
34
+ }
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- //# sourceMappingURL=Users.js.map
3
+ //# sourceMappingURL=Error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Error.js","sourceRoot":"","sources":["../../../../src/types/raw/http/Error.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ export default interface Reponse<Type> {
2
+ errors: Error[];
3
+ data: Type;
4
+ }
5
+ export interface Error {
6
+ message: string;
7
+ locations: Location[];
8
+ path: string[];
9
+ extensions: Extensions;
10
+ code: number;
11
+ kind: string;
12
+ name: string;
13
+ source: string;
14
+ tracing: Tracing2;
15
+ }
16
+ export interface Location {
17
+ line: number;
18
+ column: number;
19
+ }
20
+ export interface Extensions {
21
+ name: string;
22
+ source: string;
23
+ code: number;
24
+ kind: string;
25
+ tracing: Tracing;
26
+ }
27
+ export interface Tracing {
28
+ trace_id: string;
29
+ }
30
+ export interface Tracing2 {
31
+ trace_id: string;
32
+ }
33
+ export interface Data {
34
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ //# sourceMappingURL=Response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Response.js","sourceRoot":"","sources":["../../../../src/types/raw/http/Response.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rettiwt-api",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
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!",
@@ -2,9 +2,9 @@
2
2
  import { GraphQLBoolean, GraphQLInt, GraphQLList, GraphQLObjectType, GraphQLString } from 'graphql'
3
3
 
4
4
  // TYPES
5
- import { User } from '../models/graphql/UserTypes';
6
- import { Tweet, TweetList } from '../models/graphql/TweetTypes';
7
- import { TweetFilter } from '../types/Tweet';
5
+ import { User } from '../types/UserTypes';
6
+ import { Tweet, TweetList } from '../types/TweetTypes';
7
+ import { TweetFilter } from '../../types/data/Tweet';
8
8
 
9
9
  // RESOLVERS
10
10
  import UserResolver from '../resolvers/UserResolver';
@@ -46,9 +46,10 @@ export const rootQuery = new GraphQLObjectType({
46
46
  words: { type: new GraphQLList(GraphQLString) },
47
47
  startDate: { type: GraphQLString },
48
48
  endDate: { type: GraphQLString },
49
+ sinceId: { type: GraphQLString },
49
50
  quoted: { type: GraphQLString },
50
51
  links: { type: GraphQLBoolean, defaultValue: false },
51
- count: { type: GraphQLInt, defaultValue: 20 },
52
+ count: { type: GraphQLInt, defaultValue: 10 },
52
53
  cursor: { type: GraphQLString, defaultValue: '' }
53
54
  },
54
55
  resolve: (parent, args, context) => new TweetResolver(context).resolveTweets(args as TweetFilter, args.count, args.cursor)
@@ -1,22 +1,22 @@
1
- // RESOLVERS
2
- import ResolverBase from './ResolverBase';
3
-
4
- // TYPES
5
- import { DataContext } from '../types/Service';
6
-
7
- export default class AccountResolver extends ResolverBase {
8
- // MEMBER METHODS
9
- constructor(context: DataContext) {
10
- super(context);
11
- }
12
-
13
- /**
14
- * @param email The email of the account to be logged into
15
- * @param userName The username associated with the account
16
- * @param password The password to the account
17
- * @returns The cookie string that can be used to authenticate against twitter
18
- */
19
- async resolveLogin(email: string, userName: string, password: string): Promise<string> {
20
- return await this.context.account.login(email, userName, password);
21
- }
1
+ // RESOLVERS
2
+ import ResolverBase from './ResolverBase';
3
+
4
+ // TYPES
5
+ import { DataContext } from '../../types/data/Service';
6
+
7
+ export default class AccountResolver extends ResolverBase {
8
+ // MEMBER METHODS
9
+ constructor(context: DataContext) {
10
+ super(context);
11
+ }
12
+
13
+ /**
14
+ * @param email The email of the account to be logged into
15
+ * @param userName The username associated with the account
16
+ * @param password The password to the account
17
+ * @returns The cookie string that can be used to authenticate against twitter
18
+ */
19
+ async resolveLogin(email: string, userName: string, password: string): Promise<string> {
20
+ return await this.context.account.login(email, userName, password);
21
+ }
22
22
  }
@@ -1,5 +1,5 @@
1
1
  // TYPES
2
- import { DataContext } from '../types/Service';
2
+ import { DataContext } from '../../types/data/Service';
3
3
 
4
4
  export default class ResolverBase {
5
5
  // MEMBER DATA
@@ -2,16 +2,17 @@
2
2
  import ResolverBase from './ResolverBase';
3
3
 
4
4
  // TYPES
5
- import { TweetFilter } from '../types/Tweet';
6
- import { Cursor, DataContext } from '../types/Service';
7
-
8
- // HELPERS
9
- import { ValidationErrors } from '../types/graphql/Errors';
5
+ import { TweetFilter } from '../../types/data/Tweet';
6
+ import { Cursor, DataContext } from '../../types/data/Service';
7
+ import { DataErrors, ValidationErrors } from '../../types/data/Errors';
10
8
 
11
9
  export default class TweetResolver extends ResolverBase {
10
+ // MEMBER DATA
11
+ private batchSize: number; // To store the batch size while fetching data
12
12
  // MEMBER METHODS
13
13
  constructor(context: DataContext) {
14
14
  super(context);
15
+ this.batchSize = 20;
15
16
  }
16
17
 
17
18
  /**
@@ -29,14 +30,13 @@ export default class TweetResolver extends ResolverBase {
29
30
  /**
30
31
  * @returns The list of tweets matching the given filter
31
32
  * @param filter The filter to be used for fetching matching tweets
32
- * @param count The number of tweets to fetch
33
+ * @param count The number of tweets to fetch, must be >= 1
33
34
  * @param cursor The cursor to the batch of tweets to fetch
34
35
  */
35
- async resolveTweets(filter: TweetFilter, count: number, cursor: string): Promise<any[]> {
36
+ async resolveTweets(filter: TweetFilter, count: number, cursor: string): Promise<any> {
36
37
  let tweets: any[] = []; // To store the list of tweets
37
38
  let next: Cursor = new Cursor(cursor); // To store cursor to next batch
38
39
  let total: number = 0; // To store the total number of tweets fetched
39
- let batchSize: number = 20; // To store the batchsize to use
40
40
 
41
41
  // Checking if the given tweet filter is valid or not
42
42
  if (!(filter.fromUsers || filter.toUsers || filter.words || filter.hashtags || filter.mentions || filter.quoted)) {
@@ -44,15 +44,15 @@ export default class TweetResolver extends ResolverBase {
44
44
  }
45
45
 
46
46
  // If required count less than batch size, setting batch size to required count
47
- batchSize = (count < batchSize) ? count : batchSize;
47
+ this.batchSize = (count < this.batchSize) ? count : this.batchSize;
48
48
 
49
49
  // Repeatedly fetching data as long as total data fetched is less than requried
50
- while (total < count) {
50
+ do {
51
51
  // If this is the last batch, change batch size to number of remaining tweets
52
- batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
52
+ this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
53
53
 
54
54
  // Getting the data
55
- const res = await this.context.tweets.getTweets(filter, count, next.value);
55
+ const res = await this.context.tweets.getTweets(filter, this.batchSize, next.value);
56
56
 
57
57
  // If data is available
58
58
  if (res.list?.length) {
@@ -69,6 +69,11 @@ export default class TweetResolver extends ResolverBase {
69
69
  else {
70
70
  break;
71
71
  }
72
+ } while (total < count);
73
+
74
+ // If no tweets found
75
+ if (!tweets.length) {
76
+ return new Error(DataErrors.NoTweetsFound);
72
77
  }
73
78
 
74
79
  // Adding the cursor to the end of list of data
@@ -80,7 +85,7 @@ export default class TweetResolver extends ResolverBase {
80
85
  /**
81
86
  * @returns The list of quotes of the given tweet
82
87
  * @param id The id of the tweet whose quotes are to be fetched
83
- * @param count The number of quotes to be fetched
88
+ * @param count The number of quotes to be fetched, must be >= 1 (when no cursor if provided)
84
89
  * @param all Whether to fetch all quotes or not
85
90
  * @param cursor The cursor to the batch of tweet quotes to fetch
86
91
  * @param quoteCount The total number of quotes of the given tweet
@@ -89,7 +94,7 @@ export default class TweetResolver extends ResolverBase {
89
94
  let quotes: any[] = []; // To store the list of quotes
90
95
 
91
96
  // If all tweets are to be fetched
92
- count = (all || count > quoteCount) ? quoteCount : count;
97
+ count = all ? quoteCount : count;
93
98
 
94
99
  // Preparing the filter to use
95
100
  let filter = {
@@ -112,30 +117,29 @@ export default class TweetResolver extends ResolverBase {
112
117
  /**
113
118
  * @returns The list of likers of the given tweet
114
119
  * @param id The id of the tweet whose likers are to be fetched
115
- * @param count The total number of likers to fetch
120
+ * @param count The total number of likers to fetch, must be >= 10 (when no cursor if provided)
116
121
  * @param all Whether to fetch all the likers of the tweet
117
122
  * @param cursor The cursor to the batch of likers to fetch
118
123
  * @param likesCount The total number of like of the tweet
119
124
  */
120
- async resolveTweetLikers(id: string, count: number, all: boolean, cursor: string, likesCount: number): Promise<any[]> {
125
+ async resolveTweetLikers(id: string, count: number, all: boolean, cursor: string, likesCount: number): Promise<any> {
121
126
  let likers: any[] = []; // To store the list of likers
122
127
  let next: Cursor = new Cursor(cursor); // To store cursor to next batch
123
128
  let total: number = 0; // To store the total number of likers fetched
124
- let batchSize: number = 20; // To store the batchsize to use
125
129
 
126
130
  // If all likers are to be fetched
127
- count = (all || count > likesCount) ? likesCount : count;
131
+ count = all ? likesCount : count;
128
132
 
129
133
  // If required count less than batch size, setting batch size to required count
130
- batchSize = (count < batchSize) ? count : batchSize;
134
+ this.batchSize = (count < this.batchSize) ? count : this.batchSize;
131
135
 
132
136
  // Repeatedly fetching data as long as total data fetched is less than requried
133
- while (total < count) {
137
+ do {
134
138
  // If this is the last batch, change batch size to number of remaining likers
135
- batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
139
+ this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
136
140
 
137
141
  // Getting the data
138
- const res = await this.context.tweets.getTweetLikers(id, count, next.value);
142
+ const res = await this.context.tweets.getTweetLikers(id, this.batchSize, next.value);
139
143
 
140
144
  // If data is available
141
145
  if (res.list?.length) {
@@ -152,6 +156,11 @@ export default class TweetResolver extends ResolverBase {
152
156
  else {
153
157
  break;
154
158
  }
159
+ } while (total < count);
160
+
161
+ // If no likers found
162
+ if (!likers.length) {
163
+ return new Error(DataErrors.NoLikersFound);
155
164
  }
156
165
 
157
166
  // Adding the cursor to the end of list of data
@@ -163,30 +172,29 @@ export default class TweetResolver extends ResolverBase {
163
172
  /**
164
173
  * @returns The list of retweeters of the given tweet
165
174
  * @param id The id of the tweet whose retweeters are to be fetched
166
- * @param count The total number of retweeters to fetch
175
+ * @param count The total number of retweeters to fetch, must be >= 10 (when no cursor if provided)
167
176
  * @param all Whether to fetch all retweeters
168
177
  * @param cursor The cursor to the batch of retweeters to fetch
169
178
  * @param retweetsCount The total number of retweets of the
170
179
  */
171
- async resolveTweetRetweeters(id: string, count: number, all: boolean, cursor: string, retweetsCount: number): Promise<any[]> {
180
+ async resolveTweetRetweeters(id: string, count: number, all: boolean, cursor: string, retweetsCount: number): Promise<any> {
172
181
  let retweeters: any[] = []; // To store the list of retweeters
173
182
  let next: Cursor = new Cursor(cursor); // To store cursor to next batch
174
183
  let total: number = 0; // To store the total number of retweeters fetched
175
- let batchSize: number = 20; // To store the batchsize to use
176
184
 
177
185
  // If all retweeters are to be fetched
178
- count = (all || count > retweetsCount) ? retweetsCount : count;
186
+ count = all ? retweetsCount : count;
179
187
 
180
188
  // If required count less than batch size, setting batch size to required count
181
- batchSize = (count < batchSize) ? count : batchSize;
189
+ this.batchSize = (count < this.batchSize) ? count : this.batchSize;
182
190
 
183
191
  // Repeatedly fetching data as long as total data fetched is less than requried
184
- while (total < count) {
192
+ do {
185
193
  // If this is the last batch, change batch size to number of remaining retweeters
186
- batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
194
+ this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
187
195
 
188
196
  // Getting the data
189
- const res = await this.context.tweets.getTweetRetweeters(id, count, next.value);
197
+ const res = await this.context.tweets.getTweetRetweeters(id, this.batchSize, next.value);
190
198
 
191
199
  // If data is available
192
200
  if (res.list?.length) {
@@ -203,6 +211,11 @@ export default class TweetResolver extends ResolverBase {
203
211
  else {
204
212
  break;
205
213
  }
214
+ } while (total < count);
215
+
216
+ // If no retweeters found
217
+ if (!retweeters.length) {
218
+ return new Error(DataErrors.NoRetweetersFound);
206
219
  }
207
220
 
208
221
  // Adding the cursor to the end of list of data
@@ -212,6 +225,9 @@ export default class TweetResolver extends ResolverBase {
212
225
  }
213
226
 
214
227
  /**
228
+ * THIS IS DISABLED FOR USE FOR NOW BECAUSE TWITTER DOESN'T HAVE ANY ENDPOINT FOR FETCHING REPLIES.
229
+ * THE DATA THIS RETURNS IS INCONSISTENT!
230
+ *
215
231
  * @returns The list of replies of the given tweet
216
232
  * @param id The id of the tweet whose replies are to be fetched
217
233
  * @param count The total number of replies to fetch
@@ -219,6 +235,7 @@ export default class TweetResolver extends ResolverBase {
219
235
  * @param cursor The cursor to the batch of replies to fetch
220
236
  * @param repliesCount The total number of replies to the target tweet
221
237
  */
238
+ /*
222
239
  async resolveTweetReplies(id: string, count: number, all: boolean, cursor: string, repliesCount: number): Promise<any[]> {
223
240
  let replies: any[] = []; // To store the list of replies
224
241
  let next: Cursor = new Cursor(cursor); // To store cursor to next batch
@@ -254,4 +271,5 @@ export default class TweetResolver extends ResolverBase {
254
271
 
255
272
  return replies;
256
273
  }
274
+ */
257
275
  }