rettiwt-api 1.0.6 → 1.0.7

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 -9
  11. package/dist/{resolvers → graphql/resolvers}/TweetResolver.js +51 -35
  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 +5 -7
  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 +6 -6
  39. package/dist/services/data/TweetService.js +44 -27
  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 +32 -0
  68. package/dist/services/helper/extractors/Tweets.js +264 -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 +20 -0
  74. package/dist/services/helper/extractors/Users.js +151 -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 +26 -0
  100. package/dist/types/data/Errors.js +36 -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 +43 -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 +9 -11
  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 +53 -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
File without changes
@@ -7,8 +7,8 @@ exports.rootQuery = void 0;
7
7
  // PACKAGE
8
8
  var graphql_1 = require("graphql");
9
9
  // TYPES
10
- var UserTypes_1 = require("../models/graphql/UserTypes");
11
- var TweetTypes_1 = require("../models/graphql/TweetTypes");
10
+ var UserTypes_1 = require("../types/UserTypes");
11
+ var TweetTypes_1 = require("../types/TweetTypes");
12
12
  // RESOLVERS
13
13
  var UserResolver_1 = __importDefault(require("../resolvers/UserResolver"));
14
14
  var TweetResolver_1 = __importDefault(require("../resolvers/TweetResolver"));
@@ -48,9 +48,10 @@ exports.rootQuery = new graphql_1.GraphQLObjectType({
48
48
  words: { type: new graphql_1.GraphQLList(graphql_1.GraphQLString) },
49
49
  startDate: { type: graphql_1.GraphQLString },
50
50
  endDate: { type: graphql_1.GraphQLString },
51
+ sinceId: { type: graphql_1.GraphQLString },
51
52
  quoted: { type: graphql_1.GraphQLString },
52
53
  links: { type: graphql_1.GraphQLBoolean, defaultValue: false },
53
- count: { type: graphql_1.GraphQLInt, defaultValue: 20 },
54
+ count: { type: graphql_1.GraphQLInt, defaultValue: 10 },
54
55
  cursor: { type: graphql_1.GraphQLString, defaultValue: '' }
55
56
  },
56
57
  resolve: function (parent, args, context) { return new TweetResolver_1["default"](context).resolveTweets(args, args.count, args.cursor); }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RootQuery.js","sourceRoot":"","sources":["../../../src/graphql/queries/RootQuery.ts"],"names":[],"mappings":";;;;;;AAAA,UAAU;AACV,mCAAmG;AAEnG,QAAQ;AACR,gDAA0C;AAC1C,kDAAuD;AAGvD,YAAY;AACZ,2EAAqD;AACrD,6EAAuD;AACvD,iFAA2D;AAE9C,QAAA,SAAS,GAAG,IAAI,2BAAiB,CAAC;IAC3C,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE;QACJ,IAAI,EAAE;YACF,IAAI,EAAE,uBAAa;YACnB,OAAO,EAAE,cAAM,OAAA,gBAAgB,EAAhB,CAAgB;SAClC;QACD,IAAI,EAAE;YACF,IAAI,EAAE,gBAAI;YACV,WAAW,EA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BAAa,EAAE;gBAChC,MAAM,EAAE,EAAE,IAAI,EAAE,uBAAa,EAAE;gBAC/B,KAAK,EAAE,EAAE,IAAI,EAAE,wBAAc,EAAE,YAAY,EAAE,KAAK,EAAE;gBACpD,KAAK,EAAE,EAAE,IAAI,EAAE,oBAAU,EAAE,YAAY,EAAE,EAAE,EAAE;gBAC7C,MAAM,EAAE,EAAE,IAAI,EAAE,uBAAa,EAAE,YAAY,EAAE,EAAE,EAAE;aACpD;YACD,OAAO,EAAE,UAAC,MAAM,EAAE,IAAI,EAAE,OAAO,IAAK,OAAA,IAAI,0BAAa,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,IAAmB,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAtF,CAAsF;SAC7H;QACD,KAAK,EAAE;YACH,IAAI,EAAE,uBAAa;YACnB,WAAW,EAAE,iEAAiE;YAC9E,IAAI,EAAE;gBACF,KAAK,EAAE,EAAE,IAAI,EAAE,uBAAa,EAAE;gBAC9B,QAAQ,EAAE,EAAE,IAAI,EAAE,uBAAa,EAAE;gBACjC,QAAQ,EAAE,EAAE,IAAI,EAAE,uBAAa,EAAE;aACpC;YACD,OAAO,EAAE,UAAC,MAAM,EAAE,IAAI,EAAE,OAAO,IAAK,OAAA,IAAI,4BAAe,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAnF,CAAmF;SAC1H;KACJ;CACJ,CAAC,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import ResolverBase from './ResolverBase';
2
- import { DataContext } from '../types/Service';
2
+ import { DataContext } from '../../types/data/Service';
3
3
  export default class AccountResolver extends ResolverBase {
4
4
  constructor(context: DataContext);
5
5
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountResolver.js","sourceRoot":"","sources":["../../../src/graphql/resolvers/AccountResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAY;AACZ,gEAA0C;AAK1C;IAA6C,mCAAY;IACrD,iBAAiB;IACjB,yBAAY,OAAoB;eAC5B,kBAAM,OAAO,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACG,sCAAY,GAAlB,UAAmB,KAAa,EAAE,QAAgB,EAAE,QAAgB;;;;4BACzD,qBAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAA;4BAAlE,sBAAO,SAA2D,EAAC;;;;KACtE;IACL,sBAAC;AAAD,CAAC,AAfD,CAA6C,yBAAY,GAexD"}
@@ -1,4 +1,4 @@
1
- import { DataContext } from '../types/Service';
1
+ import { DataContext } from '../../types/data/Service';
2
2
  export default class ResolverBase {
3
3
  protected context: DataContext;
4
4
  constructor(context: DataContext);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResolverBase.js","sourceRoot":"","sources":["../../../src/graphql/resolvers/ResolverBase.ts"],"names":[],"mappings":";;AAGA;IAII,iBAAiB;IACjB,sBAAY,OAAoB;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IACL,mBAAC;AAAD,CAAC,AARD,IAQC"}
@@ -1,7 +1,8 @@
1
1
  import ResolverBase from './ResolverBase';
2
- import { TweetFilter } from '../types/Tweet';
3
- import { DataContext } from '../types/Service';
2
+ import { TweetFilter } from '../../types/data/Tweet';
3
+ import { DataContext } from '../../types/data/Service';
4
4
  export default class TweetResolver extends ResolverBase {
5
+ private batchSize;
5
6
  constructor(context: DataContext);
6
7
  /**
7
8
  * @returns The details of the tweet with the given id
@@ -11,14 +12,14 @@ export default class TweetResolver extends ResolverBase {
11
12
  /**
12
13
  * @returns The list of tweets matching the given filter
13
14
  * @param filter The filter to be used for fetching matching tweets
14
- * @param count The number of tweets to fetch
15
+ * @param count The number of tweets to fetch, must be >= 1
15
16
  * @param cursor The cursor to the batch of tweets to fetch
16
17
  */
17
- resolveTweets(filter: TweetFilter, count: number, cursor: string): Promise<any[]>;
18
+ resolveTweets(filter: TweetFilter, count: number, cursor: string): Promise<any>;
18
19
  /**
19
20
  * @returns The list of quotes of the given tweet
20
21
  * @param id The id of the tweet whose quotes are to be fetched
21
- * @param count The number of quotes to be fetched
22
+ * @param count The number of quotes to be fetched, must be >= 1 (when no cursor if provided)
22
23
  * @param all Whether to fetch all quotes or not
23
24
  * @param cursor The cursor to the batch of tweet quotes to fetch
24
25
  * @param quoteCount The total number of quotes of the given tweet
@@ -27,21 +28,21 @@ export default class TweetResolver extends ResolverBase {
27
28
  /**
28
29
  * @returns The list of likers of the given tweet
29
30
  * @param id The id of the tweet whose likers are to be fetched
30
- * @param count The total number of likers to fetch
31
+ * @param count The total number of likers to fetch, must be >= 10 (when no cursor if provided)
31
32
  * @param all Whether to fetch all the likers of the tweet
32
33
  * @param cursor The cursor to the batch of likers to fetch
33
34
  * @param likesCount The total number of like of the tweet
34
35
  */
35
- resolveTweetLikers(id: string, count: number, all: boolean, cursor: string, likesCount: number): Promise<any[]>;
36
+ resolveTweetLikers(id: string, count: number, all: boolean, cursor: string, likesCount: number): Promise<any>;
36
37
  /**
37
38
  * @returns The list of retweeters of the given tweet
38
39
  * @param id The id of the tweet whose retweeters are to be fetched
39
- * @param count The total number of retweeters to fetch
40
+ * @param count The total number of retweeters to fetch, must be >= 10 (when no cursor if provided)
40
41
  * @param all Whether to fetch all retweeters
41
42
  * @param cursor The cursor to the batch of retweeters to fetch
42
43
  * @param retweetsCount The total number of retweets of the
43
44
  */
44
- resolveTweetRetweeters(id: string, count: number, all: boolean, cursor: string, retweetsCount: number): Promise<any[]>;
45
+ resolveTweetRetweeters(id: string, count: number, all: boolean, cursor: string, retweetsCount: number): Promise<any>;
45
46
  /**
46
47
  * @returns The list of replies of the given tweet
47
48
  * @param id The id of the tweet whose replies are to be fetched
@@ -56,14 +56,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
56
56
  exports.__esModule = true;
57
57
  // RESOLVERS
58
58
  var ResolverBase_1 = __importDefault(require("./ResolverBase"));
59
- var Service_1 = require("../types/Service");
60
- // HELPERS
61
- var Errors_1 = require("../types/graphql/Errors");
59
+ var Service_1 = require("../../types/data/Service");
60
+ var Errors_1 = require("../../types/data/Errors");
62
61
  var TweetResolver = /** @class */ (function (_super) {
63
62
  __extends(TweetResolver, _super);
64
63
  // MEMBER METHODS
65
64
  function TweetResolver(context) {
66
- return _super.call(this, context) || this;
65
+ var _this = _super.call(this, context) || this;
66
+ _this.batchSize = 20;
67
+ return _this;
67
68
  }
68
69
  /**
69
70
  * @returns The details of the tweet with the given id
@@ -86,32 +87,30 @@ var TweetResolver = /** @class */ (function (_super) {
86
87
  /**
87
88
  * @returns The list of tweets matching the given filter
88
89
  * @param filter The filter to be used for fetching matching tweets
89
- * @param count The number of tweets to fetch
90
+ * @param count The number of tweets to fetch, must be >= 1
90
91
  * @param cursor The cursor to the batch of tweets to fetch
91
92
  */
92
93
  TweetResolver.prototype.resolveTweets = function (filter, count, cursor) {
93
94
  var _a;
94
95
  return __awaiter(this, void 0, void 0, function () {
95
- var tweets, next, total, batchSize, res;
96
+ var tweets, next, total, res;
96
97
  return __generator(this, function (_b) {
97
98
  switch (_b.label) {
98
99
  case 0:
99
100
  tweets = [];
100
101
  next = new Service_1.Cursor(cursor);
101
102
  total = 0;
102
- batchSize = 20;
103
103
  // Checking if the given tweet filter is valid or not
104
104
  if (!(filter.fromUsers || filter.toUsers || filter.words || filter.hashtags || filter.mentions || filter.quoted)) {
105
105
  throw new Error(Errors_1.ValidationErrors.InvalidTweetFilter);
106
106
  }
107
107
  // If required count less than batch size, setting batch size to required count
108
- batchSize = (count < batchSize) ? count : batchSize;
108
+ this.batchSize = (count < this.batchSize) ? count : this.batchSize;
109
109
  _b.label = 1;
110
110
  case 1:
111
- if (!(total < count)) return [3 /*break*/, 3];
112
111
  // If this is the last batch, change batch size to number of remaining tweets
113
- batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
114
- return [4 /*yield*/, this.context.tweets.getTweets(filter, count, next.value)];
112
+ this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
113
+ return [4 /*yield*/, this.context.tweets.getTweets(filter, this.batchSize, next.value)];
115
114
  case 2:
116
115
  res = _b.sent();
117
116
  // If data is available
@@ -125,10 +124,17 @@ var TweetResolver = /** @class */ (function (_super) {
125
124
  }
126
125
  // If no more data is available
127
126
  else {
128
- return [3 /*break*/, 3];
127
+ return [3 /*break*/, 4];
129
128
  }
130
- return [3 /*break*/, 1];
129
+ _b.label = 3;
131
130
  case 3:
131
+ if (total < count) return [3 /*break*/, 1];
132
+ _b.label = 4;
133
+ case 4:
134
+ // If no tweets found
135
+ if (!tweets.length) {
136
+ return [2 /*return*/, new Error(Errors_1.DataErrors.NoTweetsFound)];
137
+ }
132
138
  // Adding the cursor to the end of list of data
133
139
  tweets.push(next);
134
140
  return [2 /*return*/, tweets];
@@ -139,7 +145,7 @@ var TweetResolver = /** @class */ (function (_super) {
139
145
  /**
140
146
  * @returns The list of quotes of the given tweet
141
147
  * @param id The id of the tweet whose quotes are to be fetched
142
- * @param count The number of quotes to be fetched
148
+ * @param count The number of quotes to be fetched, must be >= 1 (when no cursor if provided)
143
149
  * @param all Whether to fetch all quotes or not
144
150
  * @param cursor The cursor to the batch of tweet quotes to fetch
145
151
  * @param quoteCount The total number of quotes of the given tweet
@@ -152,7 +158,7 @@ var TweetResolver = /** @class */ (function (_super) {
152
158
  case 0:
153
159
  quotes = [];
154
160
  // If all tweets are to be fetched
155
- count = (all || count > quoteCount) ? quoteCount : count;
161
+ count = all ? quoteCount : count;
156
162
  filter = {
157
163
  words: [],
158
164
  hashtags: [],
@@ -175,7 +181,7 @@ var TweetResolver = /** @class */ (function (_super) {
175
181
  /**
176
182
  * @returns The list of likers of the given tweet
177
183
  * @param id The id of the tweet whose likers are to be fetched
178
- * @param count The total number of likers to fetch
184
+ * @param count The total number of likers to fetch, must be >= 10 (when no cursor if provided)
179
185
  * @param all Whether to fetch all the likers of the tweet
180
186
  * @param cursor The cursor to the batch of likers to fetch
181
187
  * @param likesCount The total number of like of the tweet
@@ -183,24 +189,22 @@ var TweetResolver = /** @class */ (function (_super) {
183
189
  TweetResolver.prototype.resolveTweetLikers = function (id, count, all, cursor, likesCount) {
184
190
  var _a;
185
191
  return __awaiter(this, void 0, void 0, function () {
186
- var likers, next, total, batchSize, res;
192
+ var likers, next, total, res;
187
193
  return __generator(this, function (_b) {
188
194
  switch (_b.label) {
189
195
  case 0:
190
196
  likers = [];
191
197
  next = new Service_1.Cursor(cursor);
192
198
  total = 0;
193
- batchSize = 20;
194
199
  // If all likers are to be fetched
195
- count = (all || count > likesCount) ? likesCount : count;
200
+ count = all ? likesCount : count;
196
201
  // If required count less than batch size, setting batch size to required count
197
- batchSize = (count < batchSize) ? count : batchSize;
202
+ this.batchSize = (count < this.batchSize) ? count : this.batchSize;
198
203
  _b.label = 1;
199
204
  case 1:
200
- if (!(total < count)) return [3 /*break*/, 3];
201
205
  // If this is the last batch, change batch size to number of remaining likers
202
- batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
203
- return [4 /*yield*/, this.context.tweets.getTweetLikers(id, count, next.value)];
206
+ this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
207
+ return [4 /*yield*/, this.context.tweets.getTweetLikers(id, this.batchSize, next.value)];
204
208
  case 2:
205
209
  res = _b.sent();
206
210
  // If data is available
@@ -214,10 +218,17 @@ var TweetResolver = /** @class */ (function (_super) {
214
218
  }
215
219
  // If no more data is available
216
220
  else {
217
- return [3 /*break*/, 3];
221
+ return [3 /*break*/, 4];
218
222
  }
219
- return [3 /*break*/, 1];
223
+ _b.label = 3;
220
224
  case 3:
225
+ if (total < count) return [3 /*break*/, 1];
226
+ _b.label = 4;
227
+ case 4:
228
+ // If no likers found
229
+ if (!likers.length) {
230
+ return [2 /*return*/, new Error(Errors_1.DataErrors.NoLikersFound)];
231
+ }
221
232
  // Adding the cursor to the end of list of data
222
233
  likers.push(next);
223
234
  return [2 /*return*/, likers];
@@ -228,7 +239,7 @@ var TweetResolver = /** @class */ (function (_super) {
228
239
  /**
229
240
  * @returns The list of retweeters of the given tweet
230
241
  * @param id The id of the tweet whose retweeters are to be fetched
231
- * @param count The total number of retweeters to fetch
242
+ * @param count The total number of retweeters to fetch, must be >= 10 (when no cursor if provided)
232
243
  * @param all Whether to fetch all retweeters
233
244
  * @param cursor The cursor to the batch of retweeters to fetch
234
245
  * @param retweetsCount The total number of retweets of the
@@ -236,24 +247,22 @@ var TweetResolver = /** @class */ (function (_super) {
236
247
  TweetResolver.prototype.resolveTweetRetweeters = function (id, count, all, cursor, retweetsCount) {
237
248
  var _a;
238
249
  return __awaiter(this, void 0, void 0, function () {
239
- var retweeters, next, total, batchSize, res;
250
+ var retweeters, next, total, res;
240
251
  return __generator(this, function (_b) {
241
252
  switch (_b.label) {
242
253
  case 0:
243
254
  retweeters = [];
244
255
  next = new Service_1.Cursor(cursor);
245
256
  total = 0;
246
- batchSize = 20;
247
257
  // If all retweeters are to be fetched
248
- count = (all || count > retweetsCount) ? retweetsCount : count;
258
+ count = all ? retweetsCount : count;
249
259
  // If required count less than batch size, setting batch size to required count
250
- batchSize = (count < batchSize) ? count : batchSize;
260
+ this.batchSize = (count < this.batchSize) ? count : this.batchSize;
251
261
  _b.label = 1;
252
262
  case 1:
253
- if (!(total < count)) return [3 /*break*/, 3];
254
263
  // If this is the last batch, change batch size to number of remaining retweeters
255
- batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
256
- return [4 /*yield*/, this.context.tweets.getTweetRetweeters(id, count, next.value)];
264
+ this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
265
+ return [4 /*yield*/, this.context.tweets.getTweetRetweeters(id, this.batchSize, next.value)];
257
266
  case 2:
258
267
  res = _b.sent();
259
268
  // If data is available
@@ -267,10 +276,17 @@ var TweetResolver = /** @class */ (function (_super) {
267
276
  }
268
277
  // If no more data is available
269
278
  else {
270
- return [3 /*break*/, 3];
279
+ return [3 /*break*/, 4];
271
280
  }
272
- return [3 /*break*/, 1];
281
+ _b.label = 3;
273
282
  case 3:
283
+ if (total < count) return [3 /*break*/, 1];
284
+ _b.label = 4;
285
+ case 4:
286
+ // If no retweeters found
287
+ if (!retweeters.length) {
288
+ return [2 /*return*/, new Error(Errors_1.DataErrors.NoRetweetersFound)];
289
+ }
274
290
  // Adding the cursor to the end of list of data
275
291
  retweeters.push(next);
276
292
  return [2 /*return*/, retweeters];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TweetResolver.js","sourceRoot":"","sources":["../../../src/graphql/resolvers/TweetResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAY;AACZ,gEAA0C;AAI1C,oDAA+D;AAC/D,kDAAuE;AAEvE;IAA2C,iCAAY;IAGnD,iBAAiB;IACjB,uBAAY,OAAoB;QAAhC,YACI,kBAAM,OAAO,CAAC,SAEjB;QADG,KAAI,CAAC,SAAS,GAAG,EAAE,CAAC;;IACxB,CAAC;IAED;;;OAGG;IACG,oCAAY,GAAlB,UAAmB,EAAU;;;;;4BAEf,qBAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,EAAA;;wBAAhD,GAAG,GAAG,SAA0C;wBAEpD,sBAAsB;wBACtB,sBAAO,GAAG,EAAC;;;;KACd;IAED;;;;;OAKG;IACG,qCAAa,GAAnB,UAAoB,MAAmB,EAAE,KAAa,EAAE,MAAc;;;;;;;wBAC9D,MAAM,GAAU,EAAE,CAAC;wBACnB,IAAI,GAAW,IAAI,gBAAM,CAAC,MAAM,CAAC,CAAC;wBAClC,KAAK,GAAW,CAAC,CAAC;wBAEtB,qDAAqD;wBACrD,IAAI,CAAC,CAAC,MAAM,CAAC,SA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E,GAAY,EAAE,MAAc,EAAE,YAAoB;;;;;;;wBAC/F,OAAO,GAAU,EAAE,CAAC;wBACpB,IAAI,GAAW,IAAI,gBAAM,CAAC,MAAM,CAAC,CAAC;wBAClC,KAAK,GAAW,CAAC,CAAC;wBAEtB,mCAAmC;wBACnC,KAAK,GAAG,CAAC,GAAG,IAAI,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC;;;6BAGtD,CAAA,KAAK,GAAG,KAAK,CAAA;wBAEJ,qBAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,EAAA;;wBAA/D,GAAG,GAAG,SAAyD;wBAErE,uBAAuB;wBACvB,IAAI,MAAA,GAAG,CAAC,IAAI,0CAAE,MAAM,EAAE;4BAClB,4CAA4C;4BAC5C,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;4BAEnC,iCAAiC;4BACjC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;4BAEvB,+BAA+B;4BAC/B,IAAI,GAAG,GAAG,CAAC,IAAc,CAAC;yBAC7B;wBACD,+BAA+B;6BAC1B;4BACD,wBAAM;yBACT;;;wBAGL,+CAA+C;wBAC/C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBAEnB,sBAAO,OAAO,EAAC;;;;KAClB;IACL,oBAAC;AAAD,CAAC,AArQD,CAA2C,yBAAY,GAqQtD"}
@@ -1,6 +1,7 @@
1
1
  import ResolverBase from './ResolverBase';
2
- import { DataContext } from '../types/Service';
2
+ import { DataContext } from '../../types/data/Service';
3
3
  export default class UserResolver extends ResolverBase {
4
+ private batchSize;
4
5
  constructor(context: DataContext);
5
6
  /**
6
7
  * @returns The details of the target twitter user
@@ -11,7 +12,7 @@ export default class UserResolver extends ResolverBase {
11
12
  /**
12
13
  * @returns The list of tweets liked by the given user
13
14
  * @param id The id of the user whose likes are to be fetched
14
- * @param count The number of likes to fetch
15
+ * @param count The number of likes to fetch, must be >= 40
15
16
  * @param all Whether to fetch list of all tweets liked by user
16
17
  * @param cursor The cursor to the batch of likes to fetch
17
18
  * @param favouritesCount The total number of tweets liked by target user
@@ -20,7 +21,7 @@ export default class UserResolver extends ResolverBase {
20
21
  /**
21
22
  * @returns The list of followers of the given twiiter user
22
23
  * @param id The id of the user whose followers are to be fetched
23
- * @param count The number of followers to fetch
24
+ * @param count The number of followers to fetch, must be >= 40 when no cursor is provided
24
25
  * @param all Whether to fetch all followers list
25
26
  * @param cursor The cursor to the batch of followers to fetch
26
27
  * @param followerCount The total number of followers of the target user
@@ -29,7 +30,7 @@ export default class UserResolver extends ResolverBase {
29
30
  /**
30
31
  * @returns The list of following of the given twiiter user
31
32
  * @param id The id of the user whose followings are to be fetched
32
- * @param count The number of following to fetch
33
+ * @param count The number of following to fetch, should be >= 40 when no cursor is provided
33
34
  * @param all Whether to fetch list of all followings
34
35
  * @param cursor The cursor to the batch of followings to fetch
35
36
  * @param followingsCount The total number of followings of the target user
@@ -57,14 +57,15 @@ exports.__esModule = true;
57
57
  // RESOLVERS
58
58
  var ResolverBase_1 = __importDefault(require("./ResolverBase"));
59
59
  // TYPES
60
- var Service_1 = require("../types/Service");
61
- // HELPERS
62
- var Errors_1 = require("../types/graphql/Errors");
60
+ var Service_1 = require("../../types/data/Service");
61
+ var Errors_1 = require("../../types/data/Errors");
63
62
  var UserResolver = /** @class */ (function (_super) {
64
63
  __extends(UserResolver, _super);
65
64
  // MEMBER METHODS
66
65
  function UserResolver(context) {
67
- return _super.call(this, context) || this;
66
+ var _this = _super.call(this, context) || this;
67
+ _this.batchSize = 40;
68
+ return _this;
68
69
  }
69
70
  /**
70
71
  * @returns The details of the target twitter user
@@ -77,11 +78,11 @@ var UserResolver = /** @class */ (function (_super) {
77
78
  switch (_a.label) {
78
79
  case 0:
79
80
  if (!userName) return [3 /*break*/, 2];
80
- return [4 /*yield*/, this.context.users.getUserAccountDetails(userName)];
81
+ return [4 /*yield*/, this.context.users.getUserDetails(userName)];
81
82
  case 1: return [2 /*return*/, _a.sent()];
82
83
  case 2:
83
84
  if (!id) return [3 /*break*/, 4];
84
- return [4 /*yield*/, this.context.users.getUserAccountDetailsById(id)];
85
+ return [4 /*yield*/, this.context.users.getUserDetailsById(id)];
85
86
  case 3: return [2 /*return*/, _a.sent()];
86
87
  case 4: throw new Error(Errors_1.ValidationErrors.NoUserIdentification);
87
88
  }
@@ -91,7 +92,7 @@ var UserResolver = /** @class */ (function (_super) {
91
92
  /**
92
93
  * @returns The list of tweets liked by the given user
93
94
  * @param id The id of the user whose likes are to be fetched
94
- * @param count The number of likes to fetch
95
+ * @param count The number of likes to fetch, must be >= 40
95
96
  * @param all Whether to fetch list of all tweets liked by user
96
97
  * @param cursor The cursor to the batch of likes to fetch
97
98
  * @param favouritesCount The total number of tweets liked by target user
@@ -99,24 +100,22 @@ var UserResolver = /** @class */ (function (_super) {
99
100
  UserResolver.prototype.resolveUserLikes = function (id, count, all, cursor, favouritesCount) {
100
101
  var _a;
101
102
  return __awaiter(this, void 0, void 0, function () {
102
- var likes, next, total, batchSize, res;
103
+ var likes, next, total, res;
103
104
  return __generator(this, function (_b) {
104
105
  switch (_b.label) {
105
106
  case 0:
106
107
  likes = [];
107
108
  next = new Service_1.Cursor(cursor);
108
109
  total = 0;
109
- batchSize = 20;
110
110
  // If all liked tweets are to be fetched
111
111
  count = all ? favouritesCount : count;
112
112
  // If required count less than batch size, setting batch size to required count
113
- batchSize = (count < batchSize) ? count : batchSize;
113
+ this.batchSize = (count < this.batchSize) ? count : this.batchSize;
114
114
  _b.label = 1;
115
115
  case 1:
116
- if (!(total < count)) return [3 /*break*/, 3];
117
116
  // If this is the last batch, change batch size to number of remaining tweets
118
- batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
119
- return [4 /*yield*/, this.context.users.getUserLikes(id, count, next.value)];
117
+ this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
118
+ return [4 /*yield*/, this.context.users.getUserLikes(id, this.batchSize, next.value)];
120
119
  case 2:
121
120
  res = _b.sent();
122
121
  // If data is available
@@ -130,10 +129,17 @@ var UserResolver = /** @class */ (function (_super) {
130
129
  }
131
130
  // If no more data is available
132
131
  else {
133
- return [3 /*break*/, 3];
132
+ return [3 /*break*/, 4];
134
133
  }
135
- return [3 /*break*/, 1];
134
+ _b.label = 3;
136
135
  case 3:
136
+ if (total < count) return [3 /*break*/, 1];
137
+ _b.label = 4;
138
+ case 4:
139
+ // If no likes found
140
+ if (!likes.length) {
141
+ return [2 /*return*/, new Error(Errors_1.DataErrors.NoLikedTweetsFound)];
142
+ }
137
143
  // Adding the cursor to the end of list of data
138
144
  likes.push(next);
139
145
  return [2 /*return*/, likes];
@@ -144,7 +150,7 @@ var UserResolver = /** @class */ (function (_super) {
144
150
  /**
145
151
  * @returns The list of followers of the given twiiter user
146
152
  * @param id The id of the user whose followers are to be fetched
147
- * @param count The number of followers to fetch
153
+ * @param count The number of followers to fetch, must be >= 40 when no cursor is provided
148
154
  * @param all Whether to fetch all followers list
149
155
  * @param cursor The cursor to the batch of followers to fetch
150
156
  * @param followerCount The total number of followers of the target user
@@ -152,24 +158,22 @@ var UserResolver = /** @class */ (function (_super) {
152
158
  UserResolver.prototype.resolveUserFollowers = function (id, count, all, cursor, followersCount) {
153
159
  var _a;
154
160
  return __awaiter(this, void 0, void 0, function () {
155
- var followers, next, total, batchSize, res;
161
+ var followers, next, total, res;
156
162
  return __generator(this, function (_b) {
157
163
  switch (_b.label) {
158
164
  case 0:
159
165
  followers = [];
160
166
  next = new Service_1.Cursor(cursor);
161
167
  total = 0;
162
- batchSize = 20;
163
168
  // If all followers are to be fetched
164
- count = (all || count > followersCount) ? followersCount : count;
169
+ count = all ? followersCount : count;
165
170
  // If required count less than batch size, setting batch size to required count
166
- batchSize = (count < batchSize) ? count : batchSize;
171
+ this.batchSize = (count < this.batchSize) ? count : this.batchSize;
167
172
  _b.label = 1;
168
173
  case 1:
169
- if (!(total < count)) return [3 /*break*/, 3];
170
174
  // If this is the last batch, change batch size to number of remaining followers
171
- batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
172
- return [4 /*yield*/, this.context.users.getUserFollowers(id, count, next.value)];
175
+ this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
176
+ return [4 /*yield*/, this.context.users.getUserFollowers(id, this.batchSize, next.value)];
173
177
  case 2:
174
178
  res = _b.sent();
175
179
  // If data is available
@@ -183,10 +187,17 @@ var UserResolver = /** @class */ (function (_super) {
183
187
  }
184
188
  // If no more data is available
185
189
  else {
186
- return [3 /*break*/, 3];
190
+ return [3 /*break*/, 4];
187
191
  }
188
- return [3 /*break*/, 1];
192
+ _b.label = 3;
189
193
  case 3:
194
+ if (total < count) return [3 /*break*/, 1];
195
+ _b.label = 4;
196
+ case 4:
197
+ // If no followers found
198
+ if (!followers.length) {
199
+ return [2 /*return*/, new Error(Errors_1.DataErrors.NoFollowsFound)];
200
+ }
190
201
  // Adding the cursor to the end of list of data
191
202
  followers.push(next);
192
203
  return [2 /*return*/, followers];
@@ -197,7 +208,7 @@ var UserResolver = /** @class */ (function (_super) {
197
208
  /**
198
209
  * @returns The list of following of the given twiiter user
199
210
  * @param id The id of the user whose followings are to be fetched
200
- * @param count The number of following to fetch
211
+ * @param count The number of following to fetch, should be >= 40 when no cursor is provided
201
212
  * @param all Whether to fetch list of all followings
202
213
  * @param cursor The cursor to the batch of followings to fetch
203
214
  * @param followingsCount The total number of followings of the target user
@@ -205,24 +216,22 @@ var UserResolver = /** @class */ (function (_super) {
205
216
  UserResolver.prototype.resolveUserFollowing = function (id, count, all, cursor, followingsCount) {
206
217
  var _a;
207
218
  return __awaiter(this, void 0, void 0, function () {
208
- var following, next, total, batchSize, res;
219
+ var following, next, total, res;
209
220
  return __generator(this, function (_b) {
210
221
  switch (_b.label) {
211
222
  case 0:
212
223
  following = [];
213
224
  next = new Service_1.Cursor(cursor);
214
225
  total = 0;
215
- batchSize = 20;
216
226
  // If all followings are to be fetched
217
- count = (all || count > followingsCount) ? followingsCount : count;
227
+ count = all ? followingsCount : count;
218
228
  // If required count less than batch size, setting batch size to required count
219
- batchSize = (count < batchSize) ? count : batchSize;
229
+ this.batchSize = (count < this.batchSize) ? count : this.batchSize;
220
230
  _b.label = 1;
221
231
  case 1:
222
- if (!(total < count)) return [3 /*break*/, 3];
223
232
  // If this is the last batch, change batch size to number of remaining following
224
- batchSize = ((count - total) < batchSize) ? (count - total) : batchSize;
225
- return [4 /*yield*/, this.context.users.getUserFollowing(id, count, next.value)];
233
+ this.batchSize = ((count - total) < this.batchSize) ? (count - total) : this.batchSize;
234
+ return [4 /*yield*/, this.context.users.getUserFollowing(id, this.batchSize, next.value)];
226
235
  case 2:
227
236
  res = _b.sent();
228
237
  // If data is available
@@ -236,10 +245,17 @@ var UserResolver = /** @class */ (function (_super) {
236
245
  }
237
246
  // If no more data is available
238
247
  else {
239
- return [3 /*break*/, 3];
248
+ return [3 /*break*/, 4];
240
249
  }
241
- return [3 /*break*/, 1];
250
+ _b.label = 3;
242
251
  case 3:
252
+ if (total < count) return [3 /*break*/, 1];
253
+ _b.label = 4;
254
+ case 4:
255
+ // If no following found
256
+ if (!following.length) {
257
+ return [2 /*return*/, new Error(Errors_1.DataErrors.NoFollowsFound)];
258
+ }
243
259
  // Adding the cursor to the end of list of data
244
260
  following.push(next);
245
261
  return [2 /*return*/, following];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserResolver.js","sourceRoot":"","sources":["../../../src/graphql/resolvers/UserResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAY;AACZ,gEAA0C;AAE1C,QAAQ;AACR,oDAA+D;AAC/D,kDAAuE;AAEvE;IAA0C,gCAAY;IAIlD,iBAAiB;IACjB,sBAAY,OAAoB;QAAhC,YACI,kBAAM,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"Global.js","sourceRoot":"","sources":["../../../src/graphql/types/Global.ts"],"names":[],"mappings":";;;AAAA,UAAU;AACV,mCAA4D;AAE/C,QAAA,MAAM,GAAG,IAAI,2BAAiB,CAAC;IACxC,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,6CAA6C;IAC1D,MAAM,EAAE,cAAM,OAAA,CAAC;QACX,KAAK,EAAE,EAAE,IAAI,EAAE,uBAAa,EAAE;KACjC,CAAC,EAFY,CAEZ;CACL,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { GraphQLList, GraphQLObjectType, GraphQLType } from "graphql";
2
+ export declare const TweetTokens: GraphQLObjectType;
3
+ export declare const Tweet: GraphQLObjectType;
4
+ export declare const TweetList: GraphQLList<GraphQLType>;