rettiwt-api 1.4.0 → 2.0.0

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 (232) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc.js +54 -0
  3. package/.github/workflows/documentation.yml +29 -9
  4. package/.github/workflows/publish.yml +8 -3
  5. package/.prettierignore +3 -0
  6. package/.prettierrc +13 -0
  7. package/README.md +59 -61
  8. package/dist/Rettiwt.d.ts +19 -0
  9. package/dist/Rettiwt.js +30 -0
  10. package/dist/Rettiwt.js.map +1 -0
  11. package/dist/enums/ApiErrors.d.ts +30 -0
  12. package/dist/enums/ApiErrors.js +35 -0
  13. package/dist/enums/ApiErrors.js.map +1 -0
  14. package/dist/enums/HTTP.d.ts +11 -11
  15. package/dist/enums/HTTP.js +15 -16
  16. package/dist/enums/HTTP.js.map +1 -1
  17. package/dist/helper/JsonUtils.d.ts +26 -0
  18. package/dist/helper/JsonUtils.js +88 -0
  19. package/dist/helper/JsonUtils.js.map +1 -0
  20. package/dist/index.d.ts +10 -43
  21. package/dist/index.js +16 -55
  22. package/dist/index.js.map +1 -1
  23. package/dist/models/CursoredData.d.ts +37 -0
  24. package/dist/models/CursoredData.js +59 -0
  25. package/dist/models/CursoredData.js.map +1 -0
  26. package/dist/models/{data/Tweet.d.ts → Tweet.d.ts} +4 -4
  27. package/dist/models/{data/Tweet.js → Tweet.js} +7 -32
  28. package/dist/models/Tweet.js.map +1 -0
  29. package/dist/models/{data/User.d.ts → User.d.ts} +3 -3
  30. package/dist/models/{data/User.js → User.js} +3 -3
  31. package/dist/models/User.js.map +1 -0
  32. package/dist/services/FetcherService.d.ts +66 -0
  33. package/dist/services/FetcherService.js +207 -0
  34. package/dist/services/FetcherService.js.map +1 -0
  35. package/dist/services/TweetService.d.ts +88 -0
  36. package/dist/services/TweetService.js +244 -0
  37. package/dist/services/TweetService.js.map +1 -0
  38. package/dist/services/UserService.d.ts +60 -0
  39. package/dist/services/UserService.js +188 -0
  40. package/dist/services/UserService.js.map +1 -0
  41. package/dist/types/{Service.d.ts → CursoredData.d.ts} +3 -3
  42. package/dist/types/CursoredData.js +3 -0
  43. package/dist/types/CursoredData.js.map +1 -0
  44. package/dist/types/Tweet.js +1 -1
  45. package/dist/types/User.js +1 -1
  46. package/package.json +15 -19
  47. package/src/Rettiwt.ts +33 -0
  48. package/src/enums/ApiErrors.ts +30 -0
  49. package/src/enums/HTTP.ts +12 -12
  50. package/src/helper/JsonUtils.ts +86 -0
  51. package/src/index.ts +14 -57
  52. package/src/models/CursoredData.ts +64 -0
  53. package/src/models/Tweet.ts +116 -0
  54. package/src/models/User.ts +72 -0
  55. package/src/services/FetcherService.ts +183 -0
  56. package/src/services/TweetService.ts +153 -0
  57. package/src/services/UserService.ts +117 -0
  58. package/src/types/CursoredData.ts +24 -0
  59. package/src/types/Tweet.ts +35 -35
  60. package/src/types/User.ts +30 -30
  61. package/tsconfig.json +9 -9
  62. package/dist/config/env.d.ts +0 -5
  63. package/dist/config/env.js +0 -9
  64. package/dist/config/env.js.map +0 -1
  65. package/dist/enums/Errors.d.ts +0 -21
  66. package/dist/enums/Errors.js +0 -29
  67. package/dist/enums/Errors.js.map +0 -1
  68. package/dist/graphql/enums/Errors.d.ts +0 -21
  69. package/dist/graphql/enums/Errors.js +0 -29
  70. package/dist/graphql/enums/Errors.js.map +0 -1
  71. package/dist/graphql/queries/RootQuery.d.ts +0 -4
  72. package/dist/graphql/queries/RootQuery.js +0 -83
  73. package/dist/graphql/queries/RootQuery.js.map +0 -1
  74. package/dist/graphql/resolvers/AccountResolver.d.ts +0 -12
  75. package/dist/graphql/resolvers/AccountResolver.js +0 -84
  76. package/dist/graphql/resolvers/AccountResolver.js.map +0 -1
  77. package/dist/graphql/resolvers/ResolverBase.d.ts +0 -16
  78. package/dist/graphql/resolvers/ResolverBase.js +0 -23
  79. package/dist/graphql/resolvers/ResolverBase.js.map +0 -1
  80. package/dist/graphql/resolvers/TweetResolver.d.ts +0 -46
  81. package/dist/graphql/resolvers/TweetResolver.js +0 -302
  82. package/dist/graphql/resolvers/TweetResolver.js.map +0 -1
  83. package/dist/graphql/resolvers/UserResolver.d.ts +0 -48
  84. package/dist/graphql/resolvers/UserResolver.js +0 -334
  85. package/dist/graphql/resolvers/UserResolver.js.map +0 -1
  86. package/dist/graphql/types/Global.d.ts +0 -4
  87. package/dist/graphql/types/Global.js +0 -13
  88. package/dist/graphql/types/Global.js.map +0 -1
  89. package/dist/graphql/types/TweetTypes.d.ts +0 -4
  90. package/dist/graphql/types/TweetTypes.js +0 -160
  91. package/dist/graphql/types/TweetTypes.js.map +0 -1
  92. package/dist/graphql/types/UserTypes.d.ts +0 -3
  93. package/dist/graphql/types/UserTypes.js +0 -137
  94. package/dist/graphql/types/UserTypes.js.map +0 -1
  95. package/dist/models/args/TweetListArgs.d.ts +0 -21
  96. package/dist/models/args/TweetListArgs.js +0 -54
  97. package/dist/models/args/TweetListArgs.js.map +0 -1
  98. package/dist/models/args/UserListArgs.d.ts +0 -21
  99. package/dist/models/args/UserListArgs.js +0 -54
  100. package/dist/models/args/UserListArgs.js.map +0 -1
  101. package/dist/models/auth/AuthCookie.d.ts +0 -21
  102. package/dist/models/auth/AuthCookie.js +0 -33
  103. package/dist/models/auth/AuthCookie.js.map +0 -1
  104. package/dist/models/data/CursoredData.d.ts +0 -34
  105. package/dist/models/data/CursoredData.js +0 -42
  106. package/dist/models/data/CursoredData.js.map +0 -1
  107. package/dist/models/data/Tweet.js.map +0 -1
  108. package/dist/models/data/User.js.map +0 -1
  109. package/dist/server.d.ts +0 -1
  110. package/dist/server.js +0 -76
  111. package/dist/server.js.map +0 -1
  112. package/dist/services/auth/AccountService.d.ts +0 -83
  113. package/dist/services/auth/AccountService.js +0 -412
  114. package/dist/services/auth/AccountService.js.map +0 -1
  115. package/dist/services/auth/AuthService.d.ts +0 -31
  116. package/dist/services/auth/AuthService.js +0 -118
  117. package/dist/services/auth/AuthService.js.map +0 -1
  118. package/dist/services/data/TweetService.d.ts +0 -60
  119. package/dist/services/data/TweetService.js +0 -250
  120. package/dist/services/data/TweetService.js.map +0 -1
  121. package/dist/services/data/UserService.d.ts +0 -71
  122. package/dist/services/data/UserService.js +0 -278
  123. package/dist/services/data/UserService.js.map +0 -1
  124. package/dist/services/helper/Headers.d.ts +0 -19
  125. package/dist/services/helper/Headers.js +0 -62
  126. package/dist/services/helper/Headers.js.map +0 -1
  127. package/dist/services/helper/Parser.d.ts +0 -22
  128. package/dist/services/helper/Parser.js +0 -84
  129. package/dist/services/helper/Parser.js.map +0 -1
  130. package/dist/services/helper/extractors/Tweets.d.ts +0 -23
  131. package/dist/services/helper/extractors/Tweets.js +0 -200
  132. package/dist/services/helper/extractors/Tweets.js.map +0 -1
  133. package/dist/services/helper/extractors/Users.d.ts +0 -17
  134. package/dist/services/helper/extractors/Users.js +0 -151
  135. package/dist/services/helper/extractors/Users.js.map +0 -1
  136. package/dist/services/helper/payloads/LoginFlows.d.ts +0 -77
  137. package/dist/services/helper/payloads/LoginFlows.js +0 -92
  138. package/dist/services/helper/payloads/LoginFlows.js.map +0 -1
  139. package/dist/services/helper/urls/Authentication.d.ts +0 -4
  140. package/dist/services/helper/urls/Authentication.js +0 -11
  141. package/dist/services/helper/urls/Authentication.js.map +0 -1
  142. package/dist/services/util/CacheService.d.ts +0 -33
  143. package/dist/services/util/CacheService.js +0 -96
  144. package/dist/services/util/CacheService.js.map +0 -1
  145. package/dist/services/util/FetcherService.d.ts +0 -65
  146. package/dist/services/util/FetcherService.js +0 -202
  147. package/dist/services/util/FetcherService.js.map +0 -1
  148. package/dist/types/Args.d.ts +0 -11
  149. package/dist/types/Args.js +0 -4
  150. package/dist/types/Args.js.map +0 -1
  151. package/dist/types/Authentication.d.ts +0 -55
  152. package/dist/types/Authentication.js +0 -6
  153. package/dist/types/Authentication.js.map +0 -1
  154. package/dist/types/Resolvers.d.ts +0 -15
  155. package/dist/types/Resolvers.js +0 -3
  156. package/dist/types/Resolvers.js.map +0 -1
  157. package/dist/types/Rettiwt.d.ts +0 -16
  158. package/dist/types/Rettiwt.js +0 -3
  159. package/dist/types/Rettiwt.js.map +0 -1
  160. package/dist/types/Service.js +0 -5
  161. package/dist/types/Service.js.map +0 -1
  162. package/docs/.nojekyll +0 -1
  163. package/docs/assets/highlight.css +0 -64
  164. package/docs/assets/main.js +0 -58
  165. package/docs/assets/search.js +0 -1
  166. package/docs/assets/style.css +0 -1280
  167. package/docs/classes/AccountService.html +0 -286
  168. package/docs/classes/AuthCookie.html +0 -146
  169. package/docs/classes/AuthService.html +0 -147
  170. package/docs/classes/CacheService.html +0 -157
  171. package/docs/classes/Cursor.html +0 -102
  172. package/docs/classes/CursoredData.html +0 -126
  173. package/docs/classes/DataValidationError.html +0 -120
  174. package/docs/classes/FetcherService.html +0 -225
  175. package/docs/classes/Tweet.html +0 -210
  176. package/docs/classes/TweetEntities.html +0 -128
  177. package/docs/classes/TweetFilter.html +0 -233
  178. package/docs/classes/TweetListArgs.html +0 -118
  179. package/docs/classes/TweetService.html +0 -319
  180. package/docs/classes/User.html +0 -230
  181. package/docs/classes/UserListArgs.html +0 -118
  182. package/docs/classes/UserService.html +0 -355
  183. package/docs/enums/HttpMethods.html +0 -74
  184. package/docs/functions/Rettiwt.html +0 -100
  185. package/docs/index.html +0 -159
  186. package/docs/interfaces/IAuthCookie.html +0 -104
  187. package/docs/interfaces/ICursor.html +0 -77
  188. package/docs/interfaces/ICursoredData.html +0 -93
  189. package/docs/interfaces/IDataContext.html +0 -91
  190. package/docs/interfaces/IDataValidationError.html +0 -109
  191. package/docs/interfaces/IListArgs.html +0 -87
  192. package/docs/interfaces/ITweet.html +0 -176
  193. package/docs/interfaces/ITweetEntities.html +0 -104
  194. package/docs/interfaces/ITweetFilter.html +0 -158
  195. package/docs/interfaces/IUser.html +0 -194
  196. package/docs/modules.html +0 -111
  197. package/environment.d.ts +0 -11
  198. package/src/config/env.ts +0 -5
  199. package/src/enums/Errors.ts +0 -22
  200. package/src/graphql/enums/Errors.ts +0 -22
  201. package/src/graphql/queries/RootQuery.ts +0 -81
  202. package/src/graphql/resolvers/AccountResolver.ts +0 -22
  203. package/src/graphql/resolvers/ResolverBase.ts +0 -26
  204. package/src/graphql/resolvers/TweetResolver.ts +0 -225
  205. package/src/graphql/resolvers/UserResolver.ts +0 -257
  206. package/src/graphql/types/Global.ts +0 -10
  207. package/src/graphql/types/TweetTypes.ts +0 -158
  208. package/src/graphql/types/UserTypes.ts +0 -134
  209. package/src/models/args/TweetListArgs.ts +0 -47
  210. package/src/models/args/UserListArgs.ts +0 -47
  211. package/src/models/auth/AuthCookie.ts +0 -43
  212. package/src/models/data/CursoredData.ts +0 -45
  213. package/src/models/data/Tweet.ts +0 -118
  214. package/src/models/data/User.ts +0 -72
  215. package/src/server.ts +0 -37
  216. package/src/services/auth/AccountService.ts +0 -283
  217. package/src/services/auth/AuthService.ts +0 -81
  218. package/src/services/data/TweetService.ts +0 -197
  219. package/src/services/data/UserService.ts +0 -221
  220. package/src/services/helper/Headers.ts +0 -60
  221. package/src/services/helper/Parser.ts +0 -89
  222. package/src/services/helper/extractors/Tweets.ts +0 -190
  223. package/src/services/helper/extractors/Users.ts +0 -141
  224. package/src/services/helper/payloads/LoginFlows.ts +0 -90
  225. package/src/services/helper/urls/Authentication.ts +0 -6
  226. package/src/services/util/CacheService.ts +0 -76
  227. package/src/services/util/FetcherService.ts +0 -143
  228. package/src/types/Args.ts +0 -12
  229. package/src/types/Authentication.ts +0 -63
  230. package/src/types/Resolvers.ts +0 -18
  231. package/src/types/Rettiwt.ts +0 -20
  232. package/src/types/Service.ts +0 -24
@@ -1,134 +0,0 @@
1
- // PACKAGE
2
- import { GraphQLBoolean, GraphQLObjectType, GraphQLString, GraphQLInt, GraphQLList, GraphQLUnionType, GraphQLType } from 'graphql';
3
-
4
- // TYPES
5
- import { Tweet, TweetList } from './TweetTypes'
6
- import { Cursor } from './Global';
7
-
8
- // RESOLVERS
9
- import UserResolver from '../resolvers/UserResolver';
10
- import TweetResolver from '../resolvers/TweetResolver';
11
-
12
- export const User: GraphQLObjectType = new GraphQLObjectType({
13
- name: 'User',
14
- description: 'The details of a single target twitter user',
15
- fields: () => ({
16
- id: { type: GraphQLString },
17
- userName: { type: GraphQLString },
18
- fullName: { type: GraphQLString },
19
- createdAt: { type: GraphQLString },
20
- description: { type: GraphQLString },
21
- isVerified: { type: GraphQLBoolean },
22
- location: { type: GraphQLString },
23
- pinnedTweet: {
24
- type: Tweet,
25
- resolve: (parent, args, context) => (parent.pinnedTweet) ? new TweetResolver(context).resolveTweet(parent.pinnedTweet) : undefined
26
- },
27
- profileBanner: { type: GraphQLString },
28
- profileImage: { type: GraphQLString },
29
- favouritesCount: { type: GraphQLInt },
30
- likes: {
31
- type: TweetList,
32
- args: {
33
- count: {
34
- description: "The number of liked tweets to fetch, must be >= 40 (when no cursor if provided)",
35
- type: GraphQLInt,
36
- defaultValue: 10
37
- },
38
- all: {
39
- description: "Whether to fetch all tweets liked by user",
40
- type: GraphQLBoolean,
41
- defaultValue: false
42
- },
43
- cursor: {
44
- type: GraphQLString,
45
- description: 'The cursor to the batch of likes list to fetch',
46
- defaultValue: ''
47
- }
48
- },
49
- resolve: (parent, args, context) => new UserResolver(context).resolveUserLikes(parent.id, args.count, args.all, args.cursor, parent.favouritesCount)
50
- },
51
- followersCount: { type: GraphQLInt },
52
- followers: {
53
- type: UserList,
54
- args: {
55
- count: {
56
- description: "The number of followers to fetch, must be >= 40 (when no cursor is provided)",
57
- type: GraphQLInt,
58
- defaultValue: 40
59
- },
60
- all: {
61
- description: "Whether to fetch all followers list",
62
- type: GraphQLBoolean,
63
- defaultValue: false
64
- },
65
- cursor: {
66
- type: GraphQLString,
67
- description: 'The cursor to the batch of followers list to fetch',
68
- defaultValue: ''
69
- }
70
- },
71
- resolve: (parent, args, context) => new UserResolver(context).resolveUserFollowers(parent.id, args.count, args.all, args.cursor, parent.followersCount)
72
- },
73
- followingsCount: { type: GraphQLInt },
74
- following: {
75
- type: UserList,
76
- args: {
77
- count: {
78
- type: GraphQLInt,
79
- description: "The number of followings to fetch, must be >= 40 (when no cursor is provided)",
80
- defaultValue: 40
81
- },
82
- all: {
83
- description: "Whether to fetch all followings list",
84
- type: GraphQLBoolean,
85
- defaultValue: false
86
- },
87
- cursor: {
88
- type: GraphQLString,
89
- description: 'The cursor to the batch of followers list to fetch',
90
- defaultValue: ''
91
- }
92
- },
93
- resolve: (parent, args, context) => new UserResolver(context).resolveUserFollowing(parent.id, args.count, args.all, args.cursor, parent.followingsCount)
94
- },
95
- statusesCount: { type: GraphQLInt },
96
- tweets: {
97
- type: TweetList,
98
- args: {
99
- count: {
100
- description: "The number of tweets to fetch, must be >= 1",
101
- type: GraphQLInt,
102
- defaultValue: 10
103
- },
104
- all: {
105
- description: "Whether to fetch all tweets made by user",
106
- type: GraphQLBoolean,
107
- defaultValue: false
108
- },
109
- cursor: {
110
- type: GraphQLString,
111
- description: 'The cursor to the batch of tweets list to fetch',
112
- defaultValue: ''
113
- }
114
- },
115
- resolve: (parent, args, context) => new UserResolver(context).resolveUserTweets(parent.userName, args.count, args.all, args.cursor, parent.statusesCount)
116
- }
117
- })
118
- });
119
-
120
- export const UserList: GraphQLList<GraphQLType> = new GraphQLList(new GraphQLUnionType({
121
- name: 'UserCursorUnion',
122
- description: 'A union type which can either be a User or a Cursor, used in cursored User lists',
123
- types: [User, Cursor],
124
- resolveType: (data) => {
125
- // If it has a userName field => this is a User object
126
- if (data.userName) {
127
- return User;
128
- }
129
- // If it has a value field => this is a Cursor object
130
- else if (data.value) {
131
- return Cursor;
132
- }
133
- }
134
- }));
@@ -1,47 +0,0 @@
1
- // PACKAGES
2
- import { IsInt, IsString, IsOptional, Min, validateSync, Max, ValidateIf } from 'class-validator';
3
- import { DataValidationError } from 'rettiwt-core';
4
-
5
- // TYPES
6
- import { IListArgs } from '../../types/Args';
7
-
8
- /**
9
- * The arguments for fetching cursored list in TweetService.
10
- *
11
- * @internal
12
- */
13
- export class TweetListArgs implements IListArgs {
14
- /** The number of data items to fetch.
15
- *
16
- * @defaultValue 10
17
- * @remarks Must be >= 10 and <= 100
18
- */
19
- @IsInt()
20
- @IsOptional()
21
- @Max(100)
22
- @ValidateIf(ob => ob.cursor.length == 0)
23
- @Min(10)
24
- count: number;
25
-
26
- /** The cursor to the batch of data to fetch. */
27
- @IsString()
28
- @IsOptional()
29
- cursor: string;
30
-
31
- /**
32
- * @param count The number of data items to fetch.
33
- * @param cursor The cursor to the batch of data to fetch.
34
- */
35
- constructor(count: number = 10, cursor: string = '') {
36
- this.count = count;
37
- this.cursor = cursor;
38
-
39
- // Validating the arguments
40
- const validationResult = validateSync(this);
41
-
42
- // If valiation error occured
43
- if (validationResult.length) {
44
- throw new DataValidationError(validationResult);
45
- }
46
- }
47
- }
@@ -1,47 +0,0 @@
1
- // PACKAGES
2
- import { IsInt, IsString, IsOptional, Min, validateSync, Max, ValidateIf } from 'class-validator';
3
- import { DataValidationError } from 'rettiwt-core';
4
-
5
- // TYPES
6
- import { IListArgs } from '../../types/Args';
7
-
8
- /**
9
- * The arguments for fetching cursored list in TweetService.
10
- *
11
- * @internal
12
- */
13
- export class UserListArgs implements IListArgs {
14
- /** The number of data items to fetch.
15
- *
16
- * @defaultValue 40
17
- * @remarks Must be >= 40 and <= 100
18
- */
19
- @IsInt()
20
- @IsOptional()
21
- @Max(100)
22
- @ValidateIf(ob => ob.cursor.length == 0)
23
- @Min(40)
24
- count: number;
25
-
26
- /** The cursor to the batch of data to fetch. */
27
- @IsString()
28
- @IsOptional()
29
- cursor: string;
30
-
31
- /**
32
- * @param count The number of data items to fetch.
33
- * @param cursor The cursor to the batch of data to fetch.
34
- */
35
- constructor(count: number = 40, cursor: string = '') {
36
- this.count = count;
37
- this.cursor = cursor;
38
-
39
- // Validating the arguments
40
- const validationResult = validateSync(this);
41
-
42
- // If valiation error occured
43
- if (validationResult.length) {
44
- throw new DataValidationError(validationResult);
45
- }
46
- }
47
- }
@@ -1,43 +0,0 @@
1
- // TYPES
2
- import { IAuthCookie } from '../../types/Authentication';
3
-
4
- /**
5
- * The cookie containing the tokens that are used to authenticate against Twitter.
6
- *
7
- * @internal
8
- */
9
- export class AuthCookie implements IAuthCookie {
10
- /** Token used to authenticate a device. */
11
- kdt: string;
12
-
13
- /** Token used to authenticate a user using a Twitter ID. */
14
- twid: string;
15
-
16
- /** The CSRF token of the session. */
17
- ct0: string;
18
-
19
- /** The authentication token used while logging in to the account. */
20
- auth_token: string;
21
-
22
- constructor(cookie?: IAuthCookie) {
23
- this.auth_token = cookie?.auth_token ?? '';
24
- this.ct0 = cookie?.ct0 ?? '';
25
- this.kdt = cookie?.kdt ?? '';
26
- this.twid = cookie?.twid ?? '';
27
- }
28
-
29
- /**
30
- * @returns The string respresentation of this cookie in the valid cookie string format.
31
- */
32
- toString(): string {
33
- /** The string representation of this cookie. */
34
- let cookieString: string = '';
35
-
36
- // Iterating through the (key, value) pairs of this cookie
37
- for (let [key, value] of Object.entries(this)) {
38
- cookieString += `${key}=${value};`;
39
- }
40
-
41
- return cookieString;
42
- }
43
- }
@@ -1,45 +0,0 @@
1
- // TYPES
2
- import { ICursor,ICursoredData } from "../../types/Service";
3
-
4
- /**
5
- * The cursor to the batch of data to be fetched.
6
- *
7
- * @internal
8
- */
9
- export class Cursor implements ICursor {
10
- /** The cursor string. */
11
- value: string;
12
-
13
- /**
14
- * Initializes a new cursor from the given cursor string.
15
- *
16
- * @param cursorStr The string representation of the cursor.
17
- */
18
- constructor(cursorStr: string) {
19
- this.value = cursorStr;
20
- }
21
- }
22
-
23
- /**
24
- * The data that us fetched batch-wise along with a cursor.
25
- *
26
- * @internal
27
- *
28
- * @typeParam Type - The type of data present in the list.
29
- */
30
- export class CursoredData<T> implements ICursoredData<T> {
31
- /** The list of data of the given type. */
32
- list: T[];
33
-
34
- /** The cursor to the next batch of data. */
35
- next: Cursor;
36
-
37
- /**
38
- * @param list The list of data item to store.
39
- * @param next The cursor to the next batch of data.
40
- */
41
- constructor(list: T[] = [], next: string = '') {
42
- this.list = list;
43
- this.next = new Cursor(next);
44
- }
45
- }
@@ -1,118 +0,0 @@
1
- // TYPES
2
- import { ITweet, ITweetEntities } from '../../types/Tweet';
3
- import { ITweet as IRawTweet, IEntities as IRawTweetEntities } from 'rettiwt-core';
4
-
5
- // PARSERS
6
- import * as Parsers from '../../services/helper/Parser';
7
-
8
- /**
9
- * The different types parsed entities like urls, media, mentions, hashtags, etc.
10
- *
11
- * @internal
12
- */
13
- export class TweetEntities implements ITweetEntities {
14
- // MEMBER DATA
15
- /** The list of hashtags mentioned in the tweet. */
16
- hashtags: string[] = [];
17
-
18
- /** The list of urls mentioned in the tweet. */
19
- urls: string[] = [];
20
-
21
- /** The list of IDs of users mentioned in the tweet. */
22
- mentionedUsers: string[] = [];
23
-
24
- /** The list of urls to various media mentioned in the tweet. */
25
- media: string[] = [];
26
-
27
- // MEMBER METHODS
28
- constructor(entities: IRawTweetEntities) {
29
- // Extracting user mentions
30
- if (entities.user_mentions) {
31
- for (let user of entities.user_mentions) {
32
- this.mentionedUsers.push(user.id_str);
33
- }
34
- }
35
-
36
- // Extracting urls
37
- if (entities.urls) {
38
- for (let url of entities.urls) {
39
- this.urls.push(url.expanded_url);
40
- }
41
- }
42
-
43
- // Extracting hashtags
44
- if (entities.hashtags) {
45
- for (let hashtag of entities.hashtags) {
46
- this.hashtags.push(hashtag.text);
47
- }
48
- }
49
-
50
- // Extracting media urls (if any)
51
- if (entities.media) {
52
- for (const media of entities.media) {
53
- this.media.push(media.media_url_https);
54
- }
55
- }
56
- }
57
- }
58
-
59
- /**
60
- * The details of a single Tweet.
61
- *
62
- * @internal
63
- */
64
- export class Tweet implements ITweet {
65
- /** The rest id of the tweet. */
66
- id: string;
67
-
68
- /** The rest id of the user who made the tweet. */
69
- tweetBy: string;
70
-
71
- /** The date and time of creation of the tweet, in UTC string format. */
72
- createdAt: string;
73
-
74
- /** Additional tweet entities like urls, mentions, etc. */
75
- entities: TweetEntities;
76
-
77
- /** The rest id of the tweet which is quoted in the tweet. */
78
- quoted: string;
79
-
80
- /** The full text content of the tweet. */
81
- fullText: string;
82
-
83
- /** The rest id of the user to which the tweet is a reply. */
84
- replyTo: string;
85
-
86
- /** The language in which the tweet is written. */
87
- lang: string;
88
-
89
- /** The number of quotes of the tweet. */
90
- quoteCount: number;
91
-
92
- /** The number of replies to the tweet. */
93
- replyCount: number;
94
-
95
- /** The number of retweets of the tweet. */
96
- retweetCount: number;
97
-
98
- /** The number of likes of the tweet. */
99
- likeCount: number;
100
-
101
- /**
102
- * @param tweet The raw tweet data.
103
- */
104
- constructor(tweet: IRawTweet) {
105
- this.id = tweet.rest_id;
106
- this.createdAt = tweet.legacy.created_at;
107
- this.tweetBy = tweet.legacy.user_id_str;
108
- this.entities = new TweetEntities(tweet.legacy.entities);
109
- this.quoted = tweet.legacy.quoted_status_id_str;
110
- this.fullText = Parsers.normalizeText(tweet.legacy.full_text);
111
- this.replyTo = tweet.legacy.in_reply_to_status_id_str;
112
- this.lang = tweet.legacy.lang;
113
- this.quoteCount = tweet.legacy.quote_count;
114
- this.replyCount = tweet.legacy.reply_count;
115
- this.retweetCount = tweet.legacy.retweet_count;
116
- this.likeCount = tweet.legacy.favorite_count;
117
- }
118
- }
@@ -1,72 +0,0 @@
1
- // TYPES
2
- import { IUser } from '../../types/User';
3
- import { IUser as IRawUser } from 'rettiwt-core';
4
-
5
- /**
6
- * The details of a single user.
7
- *
8
- * @internal
9
- */
10
- export class User implements IUser {
11
- /** The rest id of the user. */
12
- id: string;
13
-
14
- /** The username/screenname of the user. */
15
- userName: string;
16
-
17
- /** The full name of the user. */
18
- fullName: string;
19
-
20
- /** The creation date of user's account. */
21
- createdAt: string;
22
-
23
- /** The user's description. */
24
- description: string;
25
-
26
- /** Whether the account is verified or not. */
27
- isVerified: boolean;
28
-
29
- /** The number of tweets liked by the user. */
30
- favouritesCount: number;
31
-
32
- /** The number of followers of the user. */
33
- followersCount: number;
34
-
35
- /** The number of following of the user. */
36
- followingsCount: number;
37
-
38
- /** The number of tweets made by the user. */
39
- statusesCount: number;
40
-
41
- /** The location of user as provided by user. */
42
- location: string;
43
-
44
- /** The rest id of the tweet pinned in the user's profile. */
45
- pinnedTweet: string;
46
-
47
- /** The url of the profile banner image. */
48
- profileBanner: string;
49
-
50
- /** The url of the profile image. */
51
- profileImage: string;
52
-
53
- /**
54
- * @param user The raw user data.
55
- */
56
- constructor(user: IRawUser) {
57
- this.id = user.rest_id;
58
- this.userName = user.legacy.screen_name;
59
- this.fullName = user.legacy.name;
60
- this.createdAt = user.legacy.created_at;
61
- this.description = user.legacy.description;
62
- this.isVerified = user.legacy.verified;
63
- this.favouritesCount = user.legacy.favourites_count;
64
- this.followersCount = user.legacy.followers_count;
65
- this.followingsCount = user.legacy.friends_count;
66
- this.statusesCount = user.legacy.statuses_count;
67
- this.location = user.legacy.location;
68
- this.pinnedTweet = user.legacy.pinned_tweet_ids_str[0];
69
- this.profileBanner = user.legacy.profile_banner_url;
70
- this.profileImage = user.legacy.profile_image_url_https;
71
- }
72
- }
package/src/server.ts DELETED
@@ -1,37 +0,0 @@
1
- // PACKAGE
2
- import express from 'express';
3
- import { graphqlHTTP } from 'express-graphql';
4
- import { GraphQLSchema } from 'graphql';
5
- import 'reflect-metadata';
6
-
7
- // SERVICES
8
- import { Rettiwt } from '.';
9
-
10
- // SCHEMA
11
- import { rootQuery } from './graphql/queries/RootQuery';
12
-
13
- // CONFIGS
14
- import { config } from './config/env';
15
-
16
- // Initialising express instance
17
- const app = express();
18
-
19
- // Setting up graphql endpoint
20
- app.use('/graphql', graphqlHTTP(req => ({
21
- schema: new GraphQLSchema({
22
- query: rootQuery
23
- }),
24
- context: Rettiwt({
25
- auth_token: req.headers['auth_token'] as string,
26
- ct0: req.headers['ct0'] as string,
27
- kdt: req.headers['kdt'] as string,
28
- twid: req.headers['twid'] as string,
29
- }),
30
- // If app is running in development environment, enable graphiql
31
- graphiql: config.is_development
32
- })));
33
-
34
- // Setting up express server
35
- app.listen(config.port, async () => {
36
- console.log(`Listening on port ${config.port}`);
37
- });