rettiwt-api 1.0.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 (156) hide show
  1. package/.dockerignore +2 -0
  2. package/.gitattributes +3 -0
  3. package/Dockerfile +9 -0
  4. package/README.md +38 -0
  5. package/dist/config/env.d.ts +5 -0
  6. package/dist/config/env.js +9 -0
  7. package/dist/config/env.js.map +1 -0
  8. package/dist/index.d.ts +10 -0
  9. package/dist/index.js +23 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/models/graphql/Global.d.ts +4 -0
  12. package/dist/models/graphql/Global.js +13 -0
  13. package/dist/models/graphql/Global.js.map +1 -0
  14. package/dist/models/graphql/TweetTypes.d.ts +6 -0
  15. package/dist/models/graphql/TweetTypes.js +156 -0
  16. package/dist/models/graphql/TweetTypes.js.map +1 -0
  17. package/dist/models/graphql/UserTypes.d.ts +3 -0
  18. package/dist/models/graphql/UserTypes.js +139 -0
  19. package/dist/models/graphql/UserTypes.js.map +1 -0
  20. package/dist/queries/RootQuery.d.ts +4 -0
  21. package/dist/queries/RootQuery.js +59 -0
  22. package/dist/queries/RootQuery.js.map +1 -0
  23. package/dist/resolvers/ResolverBase.d.ts +5 -0
  24. package/dist/resolvers/ResolverBase.js +11 -0
  25. package/dist/resolvers/ResolverBase.js.map +1 -0
  26. package/dist/resolvers/TweetResolver.d.ts +54 -0
  27. package/dist/resolvers/TweetResolver.js +328 -0
  28. package/dist/resolvers/TweetResolver.js.map +1 -0
  29. package/dist/resolvers/UserResolver.d.ts +47 -0
  30. package/dist/resolvers/UserResolver.js +302 -0
  31. package/dist/resolvers/UserResolver.js.map +1 -0
  32. package/dist/server.d.ts +1 -0
  33. package/dist/server.js +75 -0
  34. package/dist/server.js.map +1 -0
  35. package/dist/services/AuthService.d.ts +17 -0
  36. package/dist/services/AuthService.js +103 -0
  37. package/dist/services/AuthService.js.map +1 -0
  38. package/dist/services/CacheService.d.ts +25 -0
  39. package/dist/services/CacheService.js +141 -0
  40. package/dist/services/CacheService.js.map +1 -0
  41. package/dist/services/FetcherService.d.ts +30 -0
  42. package/dist/services/FetcherService.js +171 -0
  43. package/dist/services/FetcherService.js.map +1 -0
  44. package/dist/services/data/TweetService.d.ts +43 -0
  45. package/dist/services/data/TweetService.js +229 -0
  46. package/dist/services/data/TweetService.js.map +1 -0
  47. package/dist/services/data/UserAccountService.d.ts +49 -0
  48. package/dist/services/data/UserAccountService.js +250 -0
  49. package/dist/services/data/UserAccountService.js.map +1 -0
  50. package/dist/services/helper/Deserializers.d.ts +19 -0
  51. package/dist/services/helper/Deserializers.js +115 -0
  52. package/dist/services/helper/Deserializers.js.map +1 -0
  53. package/dist/services/helper/Extractors.d.ts +101 -0
  54. package/dist/services/helper/Extractors.js +409 -0
  55. package/dist/services/helper/Extractors.js.map +1 -0
  56. package/dist/services/helper/Headers.d.ts +9 -0
  57. package/dist/services/helper/Headers.js +47 -0
  58. package/dist/services/helper/Headers.js.map +1 -0
  59. package/dist/services/helper/Parser.d.ts +28 -0
  60. package/dist/services/helper/Parser.js +104 -0
  61. package/dist/services/helper/Parser.js.map +1 -0
  62. package/dist/services/helper/Urls.d.ts +74 -0
  63. package/dist/services/helper/Urls.js +114 -0
  64. package/dist/services/helper/Urls.js.map +1 -0
  65. package/dist/test/Test.js +2 -0
  66. package/dist/test/Test.js.map +1 -0
  67. package/dist/types/Authentication.d.ts +15 -0
  68. package/dist/types/Authentication.js +5 -0
  69. package/dist/types/Authentication.js.map +1 -0
  70. package/dist/types/HTTP.d.ts +22 -0
  71. package/dist/types/HTTP.js +30 -0
  72. package/dist/types/HTTP.js.map +1 -0
  73. package/dist/types/Service.d.ts +27 -0
  74. package/dist/types/Service.js +19 -0
  75. package/dist/types/Service.js.map +1 -0
  76. package/dist/types/Tweet.d.ts +40 -0
  77. package/dist/types/Tweet.js +5 -0
  78. package/dist/types/Tweet.js.map +1 -0
  79. package/dist/types/UserAccount.d.ts +19 -0
  80. package/dist/types/UserAccount.js +4 -0
  81. package/dist/types/UserAccount.js.map +1 -0
  82. package/dist/types/graphql/Errors.d.ts +15 -0
  83. package/dist/types/graphql/Errors.js +23 -0
  84. package/dist/types/graphql/Errors.js.map +1 -0
  85. package/dist/types/raw/auth/Cookie.d.ts +16 -0
  86. package/dist/types/raw/auth/Cookie.js +3 -0
  87. package/dist/types/raw/auth/Cookie.js.map +1 -0
  88. package/dist/types/raw/tweet/Favouriters.d.ts +164 -0
  89. package/dist/types/raw/tweet/Favouriters.js +3 -0
  90. package/dist/types/raw/tweet/Favouriters.js.map +1 -0
  91. package/dist/types/raw/tweet/Retweeters.d.ts +171 -0
  92. package/dist/types/raw/tweet/Retweeters.js +3 -0
  93. package/dist/types/raw/tweet/Retweeters.js.map +1 -0
  94. package/dist/types/raw/tweet/Tweet.d.ts +746 -0
  95. package/dist/types/raw/tweet/Tweet.js +3 -0
  96. package/dist/types/raw/tweet/Tweet.js.map +1 -0
  97. package/dist/types/raw/tweet/Tweets.d.ts +386 -0
  98. package/dist/types/raw/tweet/Tweets.js +3 -0
  99. package/dist/types/raw/tweet/Tweets.js.map +1 -0
  100. package/dist/types/raw/user/Followers.d.ts +176 -0
  101. package/dist/types/raw/user/Followers.js +3 -0
  102. package/dist/types/raw/user/Followers.js.map +1 -0
  103. package/dist/types/raw/user/Following.d.ts +176 -0
  104. package/dist/types/raw/user/Following.js +3 -0
  105. package/dist/types/raw/user/Following.js.map +1 -0
  106. package/dist/types/raw/user/Likes.d.ts +1059 -0
  107. package/dist/types/raw/user/Likes.js +3 -0
  108. package/dist/types/raw/user/Likes.js.map +1 -0
  109. package/dist/types/raw/user/Tweets.d.ts +2428 -0
  110. package/dist/types/raw/user/Tweets.js +3 -0
  111. package/dist/types/raw/user/Tweets.js.map +1 -0
  112. package/dist/types/raw/user/User.d.ts +117 -0
  113. package/dist/types/raw/user/User.js +3 -0
  114. package/dist/types/raw/user/User.js.map +1 -0
  115. package/dist/types/raw/user/Users.d.ts +120 -0
  116. package/dist/types/raw/user/Users.js +3 -0
  117. package/dist/types/raw/user/Users.js.map +1 -0
  118. package/environment.d.ts +11 -0
  119. package/package.json +40 -0
  120. package/src/config/env.ts +5 -0
  121. package/src/index.ts +19 -0
  122. package/src/models/graphql/Global.ts +10 -0
  123. package/src/models/graphql/TweetTypes.ts +154 -0
  124. package/src/models/graphql/UserTypes.ts +137 -0
  125. package/src/queries/RootQuery.ts +56 -0
  126. package/src/resolvers/ResolverBase.ts +12 -0
  127. package/src/resolvers/TweetResolver.ts +257 -0
  128. package/src/resolvers/UserResolver.ts +239 -0
  129. package/src/server.ts +36 -0
  130. package/src/services/AuthService.ts +58 -0
  131. package/src/services/CacheService.ts +70 -0
  132. package/src/services/FetcherService.ts +84 -0
  133. package/src/services/data/TweetService.ts +163 -0
  134. package/src/services/data/UserAccountService.ts +187 -0
  135. package/src/services/helper/Deserializers.ts +95 -0
  136. package/src/services/helper/Extractors.ts +455 -0
  137. package/src/services/helper/Headers.ts +45 -0
  138. package/src/services/helper/Parser.ts +108 -0
  139. package/src/services/helper/Urls.ts +109 -0
  140. package/src/types/Authentication.ts +16 -0
  141. package/src/types/HTTP.ts +23 -0
  142. package/src/types/Service.ts +36 -0
  143. package/src/types/Tweet.ts +44 -0
  144. package/src/types/UserAccount.ts +21 -0
  145. package/src/types/graphql/Errors.ts +16 -0
  146. package/src/types/raw/auth/Cookie.ts +16 -0
  147. package/src/types/raw/tweet/Favouriters.ts +193 -0
  148. package/src/types/raw/tweet/Retweeters.ts +201 -0
  149. package/src/types/raw/tweet/Tweet.ts +882 -0
  150. package/src/types/raw/tweet/Tweets.ts +444 -0
  151. package/src/types/raw/user/Followers.ts +208 -0
  152. package/src/types/raw/user/Following.ts +208 -0
  153. package/src/types/raw/user/Likes.ts +1247 -0
  154. package/src/types/raw/user/Tweets.ts +2847 -0
  155. package/src/types/raw/user/User.ts +135 -0
  156. package/tsconfig.json +95 -0
package/.dockerignore ADDED
@@ -0,0 +1,2 @@
1
+ node_modules
2
+ dist
package/.gitattributes ADDED
@@ -0,0 +1,3 @@
1
+ * text=auto eol=lf
2
+ *.{cmd,[cC][mM][dD]} text eol=crlf
3
+ *.{bat,[bB][aA][tT]} text eol=crlf
package/Dockerfile ADDED
@@ -0,0 +1,9 @@
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
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Rettiwt-API
2
+ An API for fetching data from TwitterAPI, without any rate limits!
3
+
4
+ **The API can either be used as a GraphQL Server or as a standalone npm library**
5
+
6
+ ## 1. GraphQL Server
7
+ Using the API as a GraphQL enables complex nested queries to fetch data from twitter.
8
+ To use the API as a server,
9
+
10
+ 1. Clone the repo
11
+ 2. Build the project using 'npm run build'
12
+ 3. Set the environment variables:
13
+ - APP_PORT -> The port number where the server will listen to
14
+ - DEVELOPMENT -> Whether to run the server in development mode or not
15
+ 4. Start the server using 'npm run start'
16
+ 5. Make graphql requests to server listening on localhost:port/graphql
17
+
18
+ **You can go to localhost:port/graphql to see the graphql schema**
19
+
20
+ ## 2. NPM Package
21
+ The API can also be used as a standalone npm package.
22
+ The limitation is that, large number of data cannot be fetched automatically, and the data needs to fetched in batches, by using cursors.
23
+ Further nested queries are not possible.
24
+ To use the API as an npm package,
25
+
26
+ 1. In your node project, install the package using 'npm install --save rettiwt-api'.
27
+ 2. import { Rettiwt } from 'rettiwt-api'.
28
+ 3. const rettiwt = Rettiwt('[cookies_string_scraped_from_browser_with_twitter_logged_in]').
29
+ 4. Use the created Rettiwt instance to fetch data from Twitter.
30
+
31
+ ### **The API uses the cookie of a working Twitter account to authenticate against the Twitter APIs**
32
+ ### **So you first need to scrape the cookie of your own logged in Twitter account using your browser and retrieving the cookie from the headers of outgoing request, and pass it to Rettiwt-API**
33
+
34
+ - For GraphQL Server mode, pass the cookie in the header while making a request to the graphql server
35
+ - For npm library mode, pass the cookie to the constructor while creating instance of Rettiwt
36
+
37
+ If you dont want to use you account's cookie, you can also not supply the cookie at all. However, the functionality of the API is limited to just fetching Tweets and User details.
38
+ **No likes, followers, followings, retweets, replies, tweet likes, quotes can be fetched without using cookie!**
@@ -0,0 +1,5 @@
1
+ export declare const config: {
2
+ port: number;
3
+ is_development: boolean;
4
+ twitter_auth_token: string;
5
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.config = void 0;
4
+ exports.config = {
5
+ port: Number(process.env.APP_PORT),
6
+ is_development: (process.env.DEVELOPMENT == 'true'),
7
+ twitter_auth_token: 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA'
8
+ };
9
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClC,cAAc,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,MAAM,CAAC;IACnD,kBAAkB,EAAE,iHAAiH;CACxI,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { UserAccountService } from "./services/data/UserAccountService";
2
+ import { TweetService } from "./services/data/TweetService";
3
+ /**
4
+ * @param cookie The cookies string to use to fetch data
5
+ * @returns The API for fetching user and tweet data
6
+ */
7
+ export declare const Rettiwt: (cookie?: string) => {
8
+ users: UserAccountService;
9
+ tweets: TweetService;
10
+ };
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.Rettiwt = void 0;
4
+ // SERVICES
5
+ var AuthService_1 = require("./services/AuthService");
6
+ var UserAccountService_1 = require("./services/data/UserAccountService");
7
+ var TweetService_1 = require("./services/data/TweetService");
8
+ /**
9
+ * @param cookie The cookies string to use to fetch data
10
+ * @returns The API for fetching user and tweet data
11
+ */
12
+ var Rettiwt = function (cookie) {
13
+ if (cookie === void 0) { cookie = ''; }
14
+ // Creating new auth service instance using the given cookie string
15
+ var auth = new AuthService_1.AuthService(cookie);
16
+ // Using the auth service instance to create data services instances
17
+ return {
18
+ users: new UserAccountService_1.UserAccountService(auth),
19
+ tweets: new TweetService_1.TweetService(auth)
20
+ };
21
+ };
22
+ exports.Rettiwt = Rettiwt;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,WAAW;AACX,sDAAqD;AACrD,yEAAwE;AACxE,6DAA4D;AAE5D;;;GAGG;AACI,IAAM,OAAO,GAAG,UAAC,MAAmB;IAAnB,uBAAA,EAAA,WAAmB;IACvC,mEAAmE;IACnE,IAAM,IAAI,GAAgB,IAAI,yBAAW,CAAC,MAAM,CAAC,CAAC;IAElD,oEAAoE;IACpE,OAAO;QACH,KAAK,EAAE,IAAI,uCAAkB,CAAC,IAAI,CAAC;QACnC,MAAM,EAAE,IAAI,2BAAY,CAAC,IAAI,CAAC;KACjC,CAAC;AACN,CAAC,CAAA;AATY,QAAA,OAAO,WASnB"}
@@ -0,0 +1,4 @@
1
+ import { GraphQLObjectType } from "graphql";
2
+ export declare const Cursor: GraphQLObjectType<any, any, {
3
+ [key: string]: any;
4
+ }>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.Cursor = void 0;
4
+ // PACKAGE
5
+ var graphql_1 = require("graphql");
6
+ exports.Cursor = new graphql_1.GraphQLObjectType({
7
+ name: 'Cursor',
8
+ description: 'Cursor data for the next batch of list data',
9
+ fields: function () { return ({
10
+ value: { type: graphql_1.GraphQLString }
11
+ }); }
12
+ });
13
+ //# sourceMappingURL=Global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Global.js","sourceRoot":"","sources":["../../../src/models/graphql/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,6 @@
1
+ import { GraphQLList, GraphQLObjectType } from "graphql";
2
+ export declare const TweetTokens: GraphQLObjectType<any, any, {
3
+ [key: string]: any;
4
+ }>;
5
+ export declare const Tweet: any;
6
+ export declare const TweetList: GraphQLList<import("graphql").GraphQLType>;
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ exports.__esModule = true;
6
+ exports.TweetList = exports.Tweet = exports.TweetTokens = void 0;
7
+ // PACKAGE
8
+ var graphql_1 = require("graphql");
9
+ // TYPES
10
+ var UserTypes_1 = require("./UserTypes");
11
+ var Global_1 = require("./Global");
12
+ // RESOLVERS
13
+ var TweetResolver_1 = __importDefault(require("../../resolvers/TweetResolver"));
14
+ var UserResolver_1 = __importDefault(require("../../resolvers/UserResolver"));
15
+ //@ts-ignore
16
+ exports.TweetTokens = new graphql_1.GraphQLObjectType({
17
+ name: 'TweetTokens',
18
+ description: 'Additional extracted tokens from the tweet like mentions, hashtags, etc',
19
+ fields: function () { return ({
20
+ hashtags: { type: new graphql_1.GraphQLList(graphql_1.GraphQLString) },
21
+ urls: { type: new graphql_1.GraphQLList(graphql_1.GraphQLString) },
22
+ mentionedUsers: {
23
+ type: UserTypes_1.UserList,
24
+ resolve: function (parent, args, context) { return parent.mentionedUsers.map(function (user) { return new UserResolver_1["default"](context).resolveUserDetails('', user); }); }
25
+ },
26
+ media: { type: new graphql_1.GraphQLList(graphql_1.GraphQLString) }
27
+ }); }
28
+ });
29
+ //@ts-ignore
30
+ exports.Tweet = new graphql_1.GraphQLObjectType({
31
+ name: 'Tweet',
32
+ description: 'The details of single tweet',
33
+ fields: function () { return ({
34
+ id: { type: graphql_1.GraphQLString },
35
+ tweetBy: {
36
+ type: UserTypes_1.User,
37
+ resolve: function (parent, args, context) { return new UserResolver_1["default"](context).resolveUserDetails('', parent.tweetBy); }
38
+ },
39
+ createdAt: { type: graphql_1.GraphQLString },
40
+ entities: { type: exports.TweetTokens },
41
+ quoted: {
42
+ type: exports.Tweet,
43
+ resolve: function (parent, args, context) { return parent.quoted ? new TweetResolver_1["default"](context).resolveTweet(parent.quoted) : undefined; }
44
+ },
45
+ fullText: { type: graphql_1.GraphQLString },
46
+ replyTo: {
47
+ type: exports.Tweet,
48
+ resolve: function (parent, args, context) { return parent.replyTo ? new TweetResolver_1["default"](context).resolveTweet(parent.replyTo) : undefined; }
49
+ },
50
+ lang: { type: graphql_1.GraphQLString },
51
+ quoteCount: { type: graphql_1.GraphQLInt },
52
+ quotes: {
53
+ type: exports.TweetList,
54
+ args: {
55
+ count: {
56
+ type: graphql_1.GraphQLInt,
57
+ description: "The number of quotes to fetch",
58
+ defaultValue: 10
59
+ },
60
+ all: {
61
+ type: graphql_1.GraphQLBoolean,
62
+ description: "Whether to fetch all quotes",
63
+ defaultValue: false
64
+ },
65
+ cursor: {
66
+ type: graphql_1.GraphQLString,
67
+ description: 'The cursor to the batch of quotes list to fetch',
68
+ defaultValue: ''
69
+ }
70
+ },
71
+ resolve: function (parent, args, context) { return new TweetResolver_1["default"](context).resolveTweetQuotes(parent.id, args.count, args.all, args.cursor, parent.quoteCount); }
72
+ },
73
+ likeCount: { type: graphql_1.GraphQLInt },
74
+ likers: {
75
+ type: UserTypes_1.UserList,
76
+ args: {
77
+ count: {
78
+ type: graphql_1.GraphQLInt,
79
+ description: "The number of likers to fetch",
80
+ defaultValue: 10
81
+ },
82
+ all: {
83
+ type: graphql_1.GraphQLBoolean,
84
+ description: "Whether to fetch all likers",
85
+ defaultValue: false
86
+ },
87
+ cursor: {
88
+ type: graphql_1.GraphQLString,
89
+ description: 'The cursor to the batch of likers list to fetch',
90
+ defaultValue: ''
91
+ }
92
+ },
93
+ resolve: function (parent, args, context) { return new TweetResolver_1["default"](context).resolveTweetLikers(parent.id, args.count, args.all, args.cursor, parent.likeCount); }
94
+ },
95
+ retweetCount: { type: graphql_1.GraphQLInt },
96
+ retweeters: {
97
+ type: UserTypes_1.UserList,
98
+ args: {
99
+ count: {
100
+ type: graphql_1.GraphQLInt,
101
+ description: "The number of retweeters to fetch",
102
+ defaultValue: 10
103
+ },
104
+ all: {
105
+ type: graphql_1.GraphQLBoolean,
106
+ description: "Whether to fetch all likers",
107
+ defaultValue: false
108
+ },
109
+ cursor: {
110
+ type: graphql_1.GraphQLString,
111
+ description: 'The cursor to the batch of retweeters list to fetch',
112
+ defaultValue: ''
113
+ }
114
+ },
115
+ resolve: function (parent, args, context) { return new TweetResolver_1["default"](context).resolveTweetRetweeters(parent.id, args.count, args.all, args.cursor, parent.retweetCount); }
116
+ },
117
+ replyCount: { type: graphql_1.GraphQLInt },
118
+ replies: {
119
+ type: exports.TweetList,
120
+ args: {
121
+ count: {
122
+ type: graphql_1.GraphQLInt,
123
+ description: "The number of replies to fetch",
124
+ defaultValue: 10
125
+ },
126
+ all: {
127
+ type: graphql_1.GraphQLBoolean,
128
+ description: "Whether to fetch all replies",
129
+ defaultValue: false
130
+ },
131
+ cursor: {
132
+ type: graphql_1.GraphQLString,
133
+ description: 'The cursor to the batch of replies list to fetch',
134
+ defaultValue: ''
135
+ }
136
+ },
137
+ resolve: function (parent, args, context) { return new TweetResolver_1["default"](context).resolveTweetReplies(parent.id, args.count, args.all, args.cursor, parent.replyCount); }
138
+ }
139
+ }); }
140
+ });
141
+ exports.TweetList = new graphql_1.GraphQLList(new graphql_1.GraphQLUnionType({
142
+ name: 'TweetCursorUnion',
143
+ description: 'A union type which can either be a Tweet or a Cursor, used in cursored tweet lists',
144
+ types: [exports.Tweet, Global_1.Cursor],
145
+ resolveType: function (data) {
146
+ // If it has fullText field => this is a Tweet object
147
+ if (data.fullText) {
148
+ return exports.Tweet;
149
+ }
150
+ // If it has a value field => this is a cursor object
151
+ else if (data.value) {
152
+ return Global_1.Cursor;
153
+ }
154
+ }
155
+ }));
156
+ //# sourceMappingURL=TweetTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TweetTypes.js","sourceRoot":"","sources":["../../../src/models/graphql/TweetTypes.ts"],"names":[],"mappings":";;;;;;AAAA,UAAU;AACV,mCAAsH;AAEtH,QAAQ;AACR,yCAA6C;AAC7C,mCAAkC;AAElC,YAAY;AACZ,gFAA0D;AAC1D,8EAAwD;AAExD,YAAY;AACC,QAAA,WAAW,GAAG,IAAI,2BAAiB,CAAC;IAC7C,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,yEAAyE;IACtF,MAAM,EAAE,cAAM,OAAA,CAAC;QACX,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,qBAAW,CAAC,uBAAa,CAAC,EAAE;QAClD,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,qBAAW,CAAC,uBAAa,CAAC,EAAE;QAC9C,cAAc,EAAE;YACZ,IAAI,EAAE,oBAAQ;YACd,OAAO,EAAE,UAAC,MAAM,EAAE,IAAI,EAAE,OAAO,IAAK,OAAA,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,UAAC,IAAY,IAAK,OAAA,IAAI,yBAAY,CAAC,OAAO,CAAC,CAAC,kBAAkB,CAAC,EAAE,EAAE,IAAI,CAAC,EAAtD,CAAsD,CAAC,EAAnG,CAAmG;SAC1I;QACD,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,qBAAW,CAAC,uBAAa,CAAC,EAAE;KAClD,CAAC,EARY,CAQZ;C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AA,IAAI,0BAAa,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,EAA/G,CAA+G;SACtJ;KACJ,CAAC,EA1GY,CA0GZ;CACL,CAAC,CAAC;AAEU,QAAA,SAAS,GAAG,IAAI,qBAAW,CAAC,IAAI,0BAAgB,CAAC;IAC1D,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,oFAAoF;IACjG,KAAK,EAAE,CAAC,aAAK,EAAE,eAAM,CAAC;IACtB,WAAW,EAAE,UAAC,IAAI;QACd,qDAAqD;QACrD,IAAG,IAAI,CAAC,QAAQ,EAAE;YACd,OAAO,aAAK,CAAC;SAChB;QACD,qDAAqD;aAChD,IAAG,IAAI,CAAC,KAAK,EAAE;YAChB,OAAO,eAAM,CAAC;SACjB;IACL,CAAC;CACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { GraphQLList } from 'graphql';
2
+ export declare const User: any;
3
+ export declare const UserList: GraphQLList<import("graphql").GraphQLType>;
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ exports.__esModule = true;
6
+ exports.UserList = exports.User = void 0;
7
+ // PACKAGE
8
+ var graphql_1 = require("graphql");
9
+ // TYPES
10
+ var TweetTypes_1 = require("./TweetTypes");
11
+ var Global_1 = require("./Global");
12
+ // RESOLVERS
13
+ var UserResolver_1 = __importDefault(require("../../resolvers/UserResolver"));
14
+ var TweetResolver_1 = __importDefault(require("../../resolvers/TweetResolver"));
15
+ //@ts-ignore
16
+ exports.User = new graphql_1.GraphQLObjectType({
17
+ name: 'User',
18
+ description: 'The details of a single target twitter user',
19
+ fields: function () { return ({
20
+ id: { type: graphql_1.GraphQLString },
21
+ userName: { type: graphql_1.GraphQLString },
22
+ fullName: { type: graphql_1.GraphQLString },
23
+ createdAt: { type: graphql_1.GraphQLString },
24
+ description: { type: graphql_1.GraphQLString },
25
+ isVerified: { type: graphql_1.GraphQLBoolean },
26
+ location: { type: graphql_1.GraphQLString },
27
+ pinnedTweet: {
28
+ type: TweetTypes_1.Tweet,
29
+ resolve: function (parent, args, context) { return (parent.pinnedTweet) ? new TweetResolver_1["default"](context).resolveTweet(parent.pinnedTweet) : undefined; }
30
+ },
31
+ profileBanner: { type: graphql_1.GraphQLString },
32
+ profileImage: { type: graphql_1.GraphQLString },
33
+ favouritesCount: { type: graphql_1.GraphQLInt },
34
+ likes: {
35
+ type: TweetTypes_1.TweetList,
36
+ args: {
37
+ count: {
38
+ description: "The number of liked tweets to fetch",
39
+ type: graphql_1.GraphQLInt,
40
+ defaultValue: 10
41
+ },
42
+ all: {
43
+ description: "Whether to fetch all tweets liked by user",
44
+ type: graphql_1.GraphQLBoolean,
45
+ defaultValue: false
46
+ },
47
+ cursor: {
48
+ type: graphql_1.GraphQLString,
49
+ description: 'The cursor to the batch of likes list to fetch',
50
+ defaultValue: ''
51
+ }
52
+ },
53
+ resolve: function (parent, args, context) { return new UserResolver_1["default"](context).resolveUserLikes(parent.id, args.count, args.all, args.cursor, parent.favouritesCount); }
54
+ },
55
+ followersCount: { type: graphql_1.GraphQLInt },
56
+ followers: {
57
+ type: exports.UserList,
58
+ args: {
59
+ count: {
60
+ description: "The number of followers to fetch",
61
+ type: graphql_1.GraphQLInt,
62
+ defaultValue: 20
63
+ },
64
+ all: {
65
+ description: "Whether to fetch all followers list",
66
+ type: graphql_1.GraphQLBoolean,
67
+ defaultValue: false
68
+ },
69
+ cursor: {
70
+ type: graphql_1.GraphQLString,
71
+ description: 'The cursor to the batch of followers list to fetch',
72
+ defaultValue: ''
73
+ }
74
+ },
75
+ resolve: function (parent, args, context) { return new UserResolver_1["default"](context).resolveUserFollowers(parent.id, args.count, args.all, args.cursor, parent.followersCount); }
76
+ },
77
+ followingsCount: { type: graphql_1.GraphQLInt },
78
+ following: {
79
+ type: exports.UserList,
80
+ args: {
81
+ count: {
82
+ type: graphql_1.GraphQLInt,
83
+ description: "The number of followings to fetch",
84
+ defaultValue: 20
85
+ },
86
+ all: {
87
+ description: "Whether to fetch all followings list",
88
+ type: graphql_1.GraphQLBoolean,
89
+ defaultValue: false
90
+ },
91
+ cursor: {
92
+ type: graphql_1.GraphQLString,
93
+ description: 'The cursor to the batch of followers list to fetch',
94
+ defaultValue: ''
95
+ }
96
+ },
97
+ resolve: function (parent, args, context) { return new UserResolver_1["default"](context).resolveUserFollowing(parent.id, args.count, args.all, args.cursor, parent.followingsCount); }
98
+ },
99
+ statusesCount: { type: graphql_1.GraphQLInt },
100
+ tweets: {
101
+ type: TweetTypes_1.TweetList,
102
+ args: {
103
+ count: {
104
+ description: "The number of tweets to fetch",
105
+ type: graphql_1.GraphQLInt,
106
+ defaultValue: 10
107
+ },
108
+ all: {
109
+ description: "Whether to fetch all tweets made by user",
110
+ type: graphql_1.GraphQLBoolean,
111
+ defaultValue: false
112
+ },
113
+ cursor: {
114
+ type: graphql_1.GraphQLString,
115
+ description: 'The cursor to the batch of tweets list to fetch',
116
+ defaultValue: ''
117
+ }
118
+ },
119
+ resolve: function (parent, args, context) { return new TweetResolver_1["default"](context).resolveTweets({ fromUsers: [parent.userName] }, args.count, args.cursor); }
120
+ }
121
+ }); }
122
+ });
123
+ //@ts-ignore
124
+ exports.UserList = new graphql_1.GraphQLList(new graphql_1.GraphQLUnionType({
125
+ name: 'UserCursorUnion',
126
+ description: 'A union type which can either be a User or a Cursor, used in cursored User lists',
127
+ types: [exports.User, Global_1.Cursor],
128
+ resolveType: function (data) {
129
+ // If it has a userName field => this is a User object
130
+ if (data.userName) {
131
+ return exports.User;
132
+ }
133
+ // If it has a value field => this is a Cursor object
134
+ else if (data.value) {
135
+ return Global_1.Cursor;
136
+ }
137
+ }
138
+ }));
139
+ //# sourceMappingURL=UserTyp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AAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAiB,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAlH,CAAkH;SACzJ;KACJ,CAAC,EAtGY,CAsGZ;CACL,CAAC,CAAC;AAEH,YAAY;AACC,QAAA,QAAQ,GAAG,IAAI,qBAAW,CAAC,IAAI,0BAAgB,CAAC;IACzD,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,kFAAkF;IAC/F,KAAK,EAAE,CAAC,YAAI,EAAE,eAAM,CAAC;IACrB,WAAW,EAAE,UAAC,IAAI;QACd,sDAAsD;QACtD,IAAG,IAAI,CAAC,QAAQ,EAAE;YACd,OAAO,YAAI,CAAC;SACf;QACD,qDAAqD;aAChD,IAAG,IAAI,CAAC,KAAK,EAAE;YAChB,OAAO,eAAM,CAAC;SACjB;IACL,CAAC;CACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { GraphQLObjectType } from 'graphql';
2
+ export declare const rootQuery: GraphQLObjectType<any, any, {
3
+ [key: string]: any;
4
+ }>;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ exports.__esModule = true;
6
+ exports.rootQuery = void 0;
7
+ // PACKAGE
8
+ var graphql_1 = require("graphql");
9
+ // TYPES
10
+ var UserTypes_1 = require("../models/graphql/UserTypes");
11
+ var TweetTypes_1 = require("../models/graphql/TweetTypes");
12
+ // RESOLVERS
13
+ var UserResolver_1 = __importDefault(require("../resolvers/UserResolver"));
14
+ var TweetResolver_1 = __importDefault(require("../resolvers/TweetResolver"));
15
+ exports.rootQuery = new graphql_1.GraphQLObjectType({
16
+ name: 'Root',
17
+ fields: {
18
+ test: {
19
+ type: graphql_1.GraphQLString,
20
+ resolve: function () { return "GraphQL Works!"; }
21
+ },
22
+ User: {
23
+ type: UserTypes_1.User,
24
+ description: "Returns the details of the twitter user with given user name",
25
+ args: {
26
+ userName: { type: graphql_1.GraphQLString },
27
+ id: { type: graphql_1.GraphQLString }
28
+ },
29
+ resolve: function (parent, args, context) { return new UserResolver_1["default"](context).resolveUserDetails(args.userName, args.id); }
30
+ },
31
+ Tweet: {
32
+ type: TweetTypes_1.Tweet,
33
+ description: "Returns a single tweet given it's id",
34
+ args: {
35
+ id: { type: graphql_1.GraphQLString }
36
+ },
37
+ resolve: function (parent, args, context) { return new TweetResolver_1["default"](context).resolveTweet(args.id); }
38
+ },
39
+ Tweets: {
40
+ type: TweetTypes_1.TweetList,
41
+ description: "Returns the list of tweets matching the given criteria",
42
+ args: {
43
+ fromUsers: { type: new graphql_1.GraphQLList(graphql_1.GraphQLString) },
44
+ toUsers: { type: new graphql_1.GraphQLList(graphql_1.GraphQLString) },
45
+ mentions: { type: new graphql_1.GraphQLList(graphql_1.GraphQLString) },
46
+ hashtags: { type: new graphql_1.GraphQLList(graphql_1.GraphQLString) },
47
+ words: { type: new graphql_1.GraphQLList(graphql_1.GraphQLString) },
48
+ startDate: { type: graphql_1.GraphQLString },
49
+ endDate: { type: graphql_1.GraphQLString },
50
+ quoted: { type: graphql_1.GraphQLString },
51
+ links: { type: graphql_1.GraphQLBoolean, defaultValue: false },
52
+ count: { type: graphql_1.GraphQLInt, defaultValue: 20 },
53
+ cursor: { type: graphql_1.GraphQLString, defaultValue: '' }
54
+ },
55
+ resolve: function (parent, args, context) { return new TweetResolver_1["default"](context).resolveTweets(args, args.count, args.cursor); }
56
+ }
57
+ }
58
+ });
59
+ //# sourceMappingURL=RootQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RootQuery.js","sourceRoot":"","sources":["../../src/queries/RootQuery.ts"],"names":[],"mappings":";;;;;;AAAA,UAAU;AACV,mCAAmG;AAEnG,QAAQ;AACR,yDAAmD;AACnD,2DAAgE;AAGhE,YAAY;AACZ,2EAAqD;AACrD,6EAAuD;AAE1C,QAAA,SAAS,GAAG,IAAI,2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D,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,qBAAW,CAAC,uBAAa,CAAC,EAAE;gBAC/C,SAAS,EAAE,EAAE,IAAI,EAAE,uBAAa,EAAE;gBAClC,OAAO,EAAE,EAAE,IAAI,EAAE,uBAAa,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;KACJ;CACJ,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { DataContext } from '../types/Service';
2
+ export default class ResolverBase {
3
+ protected context: DataContext;
4
+ constructor(context: DataContext);
5
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var ResolverBase = /** @class */ (function () {
4
+ // MEMBER METHODS
5
+ function ResolverBase(context) {
6
+ this.context = context;
7
+ }
8
+ return ResolverBase;
9
+ }());
10
+ exports["default"] = ResolverBase;
11
+ //# sourceMappingURL=ResolverBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResolverBase.js","sourceRoot":"","sources":["../../src/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"}
@@ -0,0 +1,54 @@
1
+ import ResolverBase from './ResolverBase';
2
+ import { TweetFilter } from '../types/Tweet';
3
+ import { DataContext } from '../types/Service';
4
+ export default class TweetResolver extends ResolverBase {
5
+ constructor(context: DataContext);
6
+ /**
7
+ * @returns The details of the tweet with the given id
8
+ * @param id The id of the tweet which is to be fetched
9
+ */
10
+ resolveTweet(id: string): Promise<any>;
11
+ /**
12
+ * @returns The list of tweets matching the given filter
13
+ * @param filter The filter to be used for fetching matching tweets
14
+ * @param count The number of tweets to fetch
15
+ * @param cursor The cursor to the batch of tweets to fetch
16
+ */
17
+ resolveTweets(filter: TweetFilter, count: number, cursor: string): Promise<any[]>;
18
+ /**
19
+ * @returns The list of quotes of the given tweet
20
+ * @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 all Whether to fetch all quotes or not
23
+ * @param cursor The cursor to the batch of tweet quotes to fetch
24
+ * @param quoteCount The total number of quotes of the given tweet
25
+ */
26
+ resolveTweetQuotes(id: string, count: number, all: boolean, cursor: string, quoteCount: number): Promise<any[]>;
27
+ /**
28
+ * @returns The list of likers of the given tweet
29
+ * @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 all Whether to fetch all the likers of the tweet
32
+ * @param cursor The cursor to the batch of likers to fetch
33
+ * @param likesCount The total number of like of the tweet
34
+ */
35
+ resolveTweetLikers(id: string, count: number, all: boolean, cursor: string, likesCount: number): Promise<any[]>;
36
+ /**
37
+ * @returns The list of retweeters of the given tweet
38
+ * @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 all Whether to fetch all retweeters
41
+ * @param cursor The cursor to the batch of retweeters to fetch
42
+ * @param retweetsCount The total number of retweets of the
43
+ */
44
+ resolveTweetRetweeters(id: string, count: number, all: boolean, cursor: string, retweetsCount: number): Promise<any[]>;
45
+ /**
46
+ * @returns The list of replies of the given tweet
47
+ * @param id The id of the tweet whose replies are to be fetched
48
+ * @param count The total number of replies to fetch
49
+ * @param all Whether to fetch list of all replies
50
+ * @param cursor The cursor to the batch of replies to fetch
51
+ * @param repliesCount The total number of replies to the target tweet
52
+ */
53
+ resolveTweetReplies(id: string, count: number, all: boolean, cursor: string, repliesCount: number): Promise<any[]>;
54
+ }