@glagan/rettiwt-api 7.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 (165) hide show
  1. package/.eslintrc.js +166 -0
  2. package/.gitattributes +3 -0
  3. package/.github/FUNDING.yml +4 -0
  4. package/.github/ISSUE_TEMPLATE/bug-report.yml +57 -0
  5. package/.github/ISSUE_TEMPLATE/feature-request.yml +20 -0
  6. package/.github/ISSUE_TEMPLATE/question.yml +15 -0
  7. package/.github/PULL_REQUEST_TEMPLATE.md +32 -0
  8. package/.github/workflows/ci.yml +32 -0
  9. package/.github/workflows/publish.yml +23 -0
  10. package/.nvmrc +1 -0
  11. package/.prettierignore +3 -0
  12. package/.prettierrc +13 -0
  13. package/LICENSE +21 -0
  14. package/README.md +566 -0
  15. package/dist/cli.js +43 -0
  16. package/eslint.config.mjs +17 -0
  17. package/package.json +50 -0
  18. package/src/Rettiwt.ts +97 -0
  19. package/src/cli.ts +48 -0
  20. package/src/collections/Extractors.ts +155 -0
  21. package/src/collections/Groups.ts +81 -0
  22. package/src/collections/Requests.ts +89 -0
  23. package/src/collections/Tweet.ts +17 -0
  24. package/src/commands/DirectMessage.ts +62 -0
  25. package/src/commands/List.ts +90 -0
  26. package/src/commands/Tweet.ts +437 -0
  27. package/src/commands/User.ts +367 -0
  28. package/src/enums/Api.ts +10 -0
  29. package/src/enums/Authentication.ts +10 -0
  30. package/src/enums/Data.ts +13 -0
  31. package/src/enums/Logging.ts +14 -0
  32. package/src/enums/Media.ts +10 -0
  33. package/src/enums/Notification.ts +12 -0
  34. package/src/enums/Resource.ts +69 -0
  35. package/src/enums/Tweet.ts +8 -0
  36. package/src/enums/raw/Analytics.ts +32 -0
  37. package/src/enums/raw/Media.ts +10 -0
  38. package/src/enums/raw/Notification.ts +11 -0
  39. package/src/enums/raw/Tweet.ts +20 -0
  40. package/src/helper/CliUtils.ts +17 -0
  41. package/src/helper/JsonUtils.ts +70 -0
  42. package/src/index.ts +128 -0
  43. package/src/models/RettiwtConfig.ts +101 -0
  44. package/src/models/args/FetchArgs.ts +169 -0
  45. package/src/models/args/PostArgs.ts +93 -0
  46. package/src/models/args/ProfileArgs.ts +68 -0
  47. package/src/models/auth/AuthCookie.ts +58 -0
  48. package/src/models/auth/AuthCredential.ts +83 -0
  49. package/src/models/data/Analytics.ts +97 -0
  50. package/src/models/data/BookmarkFolder.ts +73 -0
  51. package/src/models/data/Conversation.ts +344 -0
  52. package/src/models/data/CursoredData.ts +64 -0
  53. package/src/models/data/DirectMessage.ts +335 -0
  54. package/src/models/data/Inbox.ts +124 -0
  55. package/src/models/data/List.ts +113 -0
  56. package/src/models/data/Notification.ts +84 -0
  57. package/src/models/data/Tweet.ts +388 -0
  58. package/src/models/data/User.ts +187 -0
  59. package/src/models/errors/TwitterError.ts +65 -0
  60. package/src/models/params/Variables.ts +62 -0
  61. package/src/requests/DirectMessage.ts +229 -0
  62. package/src/requests/List.ts +203 -0
  63. package/src/requests/Media.ts +67 -0
  64. package/src/requests/Tweet.ts +607 -0
  65. package/src/requests/User.ts +1191 -0
  66. package/src/services/internal/AuthService.ts +115 -0
  67. package/src/services/internal/ErrorService.ts +41 -0
  68. package/src/services/internal/LogService.ts +34 -0
  69. package/src/services/public/DirectMessageService.ts +159 -0
  70. package/src/services/public/FetcherService.ts +366 -0
  71. package/src/services/public/ListService.ts +241 -0
  72. package/src/services/public/TweetService.ts +886 -0
  73. package/src/services/public/UserService.ts +1154 -0
  74. package/src/types/ErrorHandler.ts +13 -0
  75. package/src/types/Fetch.ts +3 -0
  76. package/src/types/RettiwtConfig.ts +48 -0
  77. package/src/types/args/FetchArgs.ts +233 -0
  78. package/src/types/args/PostArgs.ts +142 -0
  79. package/src/types/args/ProfileArgs.ts +33 -0
  80. package/src/types/auth/AuthCookie.ts +22 -0
  81. package/src/types/auth/AuthCredential.ts +28 -0
  82. package/src/types/auth/TransactionHeader.ts +8 -0
  83. package/src/types/data/Analytics.ts +58 -0
  84. package/src/types/data/BookmarkFolder.ts +12 -0
  85. package/src/types/data/Conversation.ts +44 -0
  86. package/src/types/data/CursoredData.ts +24 -0
  87. package/src/types/data/DirectMessage.ts +33 -0
  88. package/src/types/data/Inbox.ts +23 -0
  89. package/src/types/data/List.ts +33 -0
  90. package/src/types/data/Notification.ts +26 -0
  91. package/src/types/data/Tweet.ts +99 -0
  92. package/src/types/data/User.ts +54 -0
  93. package/src/types/errors/TwitterError.ts +37 -0
  94. package/src/types/params/Variables.ts +41 -0
  95. package/src/types/raw/base/Analytic.ts +32 -0
  96. package/src/types/raw/base/BookmarkFolder.ts +12 -0
  97. package/src/types/raw/base/Cursor.ts +13 -0
  98. package/src/types/raw/base/Error.ts +38 -0
  99. package/src/types/raw/base/LimitedVisibilityTweet.ts +40 -0
  100. package/src/types/raw/base/List.ts +50 -0
  101. package/src/types/raw/base/Media.ts +53 -0
  102. package/src/types/raw/base/Message.ts +22 -0
  103. package/src/types/raw/base/Notification.ts +66 -0
  104. package/src/types/raw/base/Space.ts +35 -0
  105. package/src/types/raw/base/Tweet.ts +139 -0
  106. package/src/types/raw/base/User.ts +182 -0
  107. package/src/types/raw/composite/DataResult.ts +8 -0
  108. package/src/types/raw/composite/TimelineList.ts +10 -0
  109. package/src/types/raw/composite/TimelineTweet.ts +14 -0
  110. package/src/types/raw/composite/TimelineUser.ts +13 -0
  111. package/src/types/raw/dm/Conversation.ts +59 -0
  112. package/src/types/raw/dm/InboxInitial.ts +155 -0
  113. package/src/types/raw/dm/InboxTimeline.ts +301 -0
  114. package/src/types/raw/dm/UserUpdates.ts +46 -0
  115. package/src/types/raw/generic/Response.ts +10 -0
  116. package/src/types/raw/list/AddMember.ts +175 -0
  117. package/src/types/raw/list/Details.ts +176 -0
  118. package/src/types/raw/list/Members.ts +154 -0
  119. package/src/types/raw/list/RemoveMember.ts +174 -0
  120. package/src/types/raw/list/Tweets.ts +2296 -0
  121. package/src/types/raw/media/FinalizeUpload.ts +20 -0
  122. package/src/types/raw/media/InitalizeUpload.ts +12 -0
  123. package/src/types/raw/media/LiveVideoStream.ts +21 -0
  124. package/src/types/raw/space/Details.ts +359 -0
  125. package/src/types/raw/tweet/Bookmark.ts +14 -0
  126. package/src/types/raw/tweet/Details.ts +210 -0
  127. package/src/types/raw/tweet/DetailsBulk.ts +338 -0
  128. package/src/types/raw/tweet/Like.ts +14 -0
  129. package/src/types/raw/tweet/Likers.ts +200 -0
  130. package/src/types/raw/tweet/Post.ts +150 -0
  131. package/src/types/raw/tweet/Replies.ts +539 -0
  132. package/src/types/raw/tweet/Retweet.ts +31 -0
  133. package/src/types/raw/tweet/Retweeters.ts +208 -0
  134. package/src/types/raw/tweet/Schedule.ts +18 -0
  135. package/src/types/raw/tweet/Search.ts +597 -0
  136. package/src/types/raw/tweet/Unbookmark.ts +14 -0
  137. package/src/types/raw/tweet/Unlike.ts +14 -0
  138. package/src/types/raw/tweet/Unpost.ts +20 -0
  139. package/src/types/raw/tweet/Unretweet.ts +31 -0
  140. package/src/types/raw/tweet/Unschedule.ts +14 -0
  141. package/src/types/raw/user/Affiliates.ts +179 -0
  142. package/src/types/raw/user/Analytics.ts +23 -0
  143. package/src/types/raw/user/BookmarkFolderTweets.ts +53 -0
  144. package/src/types/raw/user/BookmarkFolders.ts +41 -0
  145. package/src/types/raw/user/Bookmarks.ts +637 -0
  146. package/src/types/raw/user/Details.ts +185 -0
  147. package/src/types/raw/user/DetailsBulk.ts +104 -0
  148. package/src/types/raw/user/Follow.ts +280 -0
  149. package/src/types/raw/user/Followed.ts +1942 -0
  150. package/src/types/raw/user/Followers.ts +215 -0
  151. package/src/types/raw/user/Following.ts +215 -0
  152. package/src/types/raw/user/Highlights.ts +1287 -0
  153. package/src/types/raw/user/Likes.ts +1254 -0
  154. package/src/types/raw/user/Lists.ts +378 -0
  155. package/src/types/raw/user/Media.ts +1738 -0
  156. package/src/types/raw/user/Notifications.ts +499 -0
  157. package/src/types/raw/user/ProfileUpdate.ts +80 -0
  158. package/src/types/raw/user/Recommended.ts +2319 -0
  159. package/src/types/raw/user/Scheduled.ts +37 -0
  160. package/src/types/raw/user/Search.ts +230 -0
  161. package/src/types/raw/user/Subscriptions.ts +176 -0
  162. package/src/types/raw/user/Tweets.ts +1254 -0
  163. package/src/types/raw/user/TweetsAndReplies.ts +1254 -0
  164. package/src/types/raw/user/Unfollow.ts +280 -0
  165. package/tsconfig.json +97 -0
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Defines the error handler that processes API/HTTP errors in the responses.
3
+ *
4
+ * @public
5
+ */
6
+ export interface IErrorHandler {
7
+ /**
8
+ * The method called when an error response is received from Twitter API.
9
+ *
10
+ * @param error - The error caught while making request to Twitter API.
11
+ */
12
+ handle(error: unknown): void;
13
+ }
@@ -0,0 +1,3 @@
1
+ import { FetchOptions } from 'ofetch';
2
+
3
+ export type FetchConfig = FetchOptions & { url: string };
@@ -0,0 +1,48 @@
1
+ import { IErrorHandler } from './ErrorHandler';
2
+
3
+ /**
4
+ * The configuration for initializing a new Rettiwt instance.
5
+ *
6
+ * @public
7
+ */
8
+ export interface IRettiwtConfig {
9
+ /** The apiKey (cookie) to use for authenticating Rettiwt against Twitter API. */
10
+ apiKey?: string;
11
+
12
+ /**
13
+ * Optional URL to proxy server to use for requests to Twitter API.
14
+ *
15
+ * @remarks When deploying to cloud platforms, if setting {@link IRettiwtConfig.authProxyUrl} does not resolve Error 429, then this might be required.
16
+ */
17
+ proxyUrl?: URL;
18
+
19
+ /** The max wait time (in milli-seconds) for a response; if not set, Twitter server timeout is used. */
20
+ timeout?: number;
21
+
22
+ /** Whether to write logs to console or not. */
23
+ logging?: boolean;
24
+
25
+ /** Optional custom error handler to define error conditions and process API/HTTP errors in responses. */
26
+ errorHandler?: IErrorHandler;
27
+
28
+ /**
29
+ * Optional custom HTTP headers to add to all requests to Twitter API.
30
+ *
31
+ * @remarks Custom headers can be useful for proxies, avoiding rate limits, etc.
32
+ */
33
+ headers?: { [key: string]: string };
34
+
35
+ /**
36
+ * The delay (in ms) to use between concurrent request.
37
+ *
38
+ * Can either be a number or a function that returns a number synchronously or asynchronously.
39
+ */
40
+ delay?: number | (() => number | Promise<number>);
41
+
42
+ /**
43
+ * The maximum number of retries to use.
44
+ *
45
+ * @remarks Recommended to use a value of 5 combined with a `delay` of 1000 to prevent error 404.
46
+ */
47
+ maxRetries?: number;
48
+ }
@@ -0,0 +1,233 @@
1
+ import { RawAnalyticsGranularity, RawAnalyticsMetric } from '../../enums/raw/Analytics';
2
+ import { TweetRepliesSortType } from '../../enums/Tweet';
3
+
4
+ /**
5
+ * Options specifying the data that is to be fetched.
6
+ *
7
+ * @public
8
+ */
9
+ export interface IFetchArgs {
10
+ /**
11
+ * The id of the active conversation.
12
+ *
13
+ * @remarks
14
+ * - Required only for {@link ResourceType.DM_USER_UPDATES}.
15
+ */
16
+ activeConversationId?: string;
17
+
18
+ /**
19
+ * The maximum id of the data to fetch.
20
+ *
21
+ * @remarks
22
+ * - May be used for {@link ResourceType.DM_INBOX_TIMELINE} and {@link ResourceType.DM_CONVERSATION}.
23
+ */
24
+ maxId?: string;
25
+
26
+ /**
27
+ * The id of the conversation to fetch.
28
+ *
29
+ * @remarks
30
+ * - Required only for {@link ResourceType.DM_CONVERSATION} and {@link ResourceType.DM_DELETE_CONVERSATION}.
31
+ */
32
+ conversationId?: string;
33
+
34
+ /**
35
+ * The number of data items to fetch.
36
+ *
37
+ * @remarks
38
+ * - Works only for cursored resources.
39
+ * - Does not work for {@link ResourceType.TWEET_REPLIES}.
40
+ * - Must be \<= 20 for:
41
+ * - {@link ResourceType.USER_TIMELINE}
42
+ * - {@link ResourceType.USER_TIMELINE}
43
+ * - {@link ResourceType.USER_TIMELINE_AND_REPLIES}
44
+ * - Must be \<= 100 for all other cursored resources.
45
+ * - Due a bug on Twitter's end, count does not work for {@link ResourceType.USER_FOLLOWERS} and {@link ResourceType.USER_FOLLOWING}.
46
+ * - Has not effect for:
47
+ * - {@link ResourceType.USER_FEED_FOLLOWED}
48
+ * - {@link ResourceType.USER_FEED_RECOMMENDED}
49
+ */
50
+ count?: number;
51
+
52
+ /**
53
+ * The cursor to the batch of data to fetch.
54
+ *
55
+ * @remarks
56
+ * - May be used for cursored resources.
57
+ * - Has no effect for other resources.
58
+ */
59
+ cursor?: string;
60
+
61
+ /**
62
+ * The filter for searching tweets.
63
+ *
64
+ * @remarks
65
+ * Required when searching for tweets using {@link ResourceType.TWEET_SEARCH}.
66
+ */
67
+ filter?: ITweetFilter;
68
+
69
+ /**
70
+ * The id of the target resource.
71
+ *
72
+ * @remarks
73
+ * - Required for all resources except {@link ResourceType.TWEET_SEARCH} and {@link ResourceType.USER_TIMELINE_RECOMMENDED}.
74
+ * - For {@link ResourceType.USER_DETAILS_BY_USERNAME} and {@link ResourceType.USER_SEARCH}, can be alphanumeric, while for others, is strictly numeric.
75
+ */
76
+ id?: string;
77
+
78
+ /**
79
+ * The IDs of the target resources.
80
+ *
81
+ * @remarks
82
+ * - Required only for {@link ResourceType.TWEET_DETAILS_BULK} and {@link ResourceType.USER_DETAILS_BY_IDS_BULK}.
83
+ */
84
+ ids?: string[];
85
+
86
+ /**
87
+ * The sorting to use for tweet results.
88
+ *
89
+ * @remarks
90
+ * - Only works for {@link ResourceType.TWEET_REPLIES}.
91
+ */
92
+ sortBy?: TweetRepliesSortType;
93
+
94
+ /**
95
+ * The date to start fetching data from.
96
+ *
97
+ * @remarks
98
+ * - Only works for {@link EResourceType.USER_ANALYTICS}.
99
+ */
100
+ fromTime?: Date;
101
+
102
+ /**
103
+ * The date to end fetching data at.
104
+ *
105
+ * @remarks
106
+ * - Only works for {@link EResourceType.USER_ANALYTICS}.
107
+ */
108
+ toTime?: Date;
109
+
110
+ /**
111
+ * The granularity of the data to fetch.
112
+ *
113
+ * @remarks
114
+ * - Only works for {@link EResourceType.USER_ANALYTICS}.
115
+ */
116
+ granularity?: RawAnalyticsGranularity;
117
+
118
+ /**
119
+ * The metrics to fetch.
120
+ *
121
+ * @remarks
122
+ * - Only works for {@link EResourceType.USER_ANALYTICS}.
123
+ */
124
+ metrics?: RawAnalyticsMetric[];
125
+
126
+ /**
127
+ * Show the verified follower count and relationship counts in the response.
128
+ *
129
+ * @remarks
130
+ * - Only works for {@link EResourceType.USER_ANALYTICS}.
131
+ */
132
+ showVerifiedFollowers?: boolean;
133
+ }
134
+
135
+ /**
136
+ * The filter to be used for searching tweets.
137
+ *
138
+ * @public
139
+ */
140
+ export interface ITweetFilter {
141
+ /** The date upto which tweets are to be searched. */
142
+ endDate?: Date;
143
+
144
+ /** The list of words to exclude from search. */
145
+ excludeWords?: string[];
146
+
147
+ /**
148
+ * The list of usernames whose tweets are to be searched.
149
+ *
150
+ * @remarks
151
+ * '\@' must be excluded from the username!
152
+ */
153
+ fromUsers?: string[];
154
+
155
+ /**
156
+ * The list of hashtags to search.
157
+ *
158
+ * @remarks
159
+ * '#' must be excluded from the hashtag!
160
+ */
161
+ hashtags?: string[];
162
+
163
+ /** The exact phrase to search. */
164
+ includePhrase?: string;
165
+
166
+ /** The list of words to search. */
167
+ includeWords?: string[];
168
+
169
+ /** The language of the tweets to search. */
170
+ language?: string;
171
+
172
+ /** The list from which tweets are to be searched. */
173
+ list?: string;
174
+
175
+ /** The id of the tweet, before which the tweets are to be searched. */
176
+ maxId?: string;
177
+
178
+ /**
179
+ * The list of username mentioned in the tweets to search.
180
+ *
181
+ * @remarks
182
+ * '\@' must be excluded from the username!
183
+ */
184
+ mentions?: string[];
185
+
186
+ /** The minimun number of likes to search by. */
187
+ minLikes?: number;
188
+
189
+ /** The minimum number of replies to search by. */
190
+ minReplies?: number;
191
+
192
+ /** The minimum number of retweets to search by. */
193
+ minRetweets?: number;
194
+
195
+ /**
196
+ * Whether to search only posts that contain links.
197
+ *
198
+ * @remarks 'links' includes things like media, quotes, retweets, etc.
199
+ */
200
+ onlyLinks?: boolean;
201
+
202
+ /** Whether to search only original posts. */
203
+ onlyOriginal?: boolean;
204
+
205
+ /** Whether to search only replies */
206
+ onlyReplies?: boolean;
207
+
208
+ /** Whether to search posts that only contain text. */
209
+ onlyText?: boolean;
210
+
211
+ /** The optional words to search. */
212
+ optionalWords?: string[];
213
+
214
+ /** The id of the tweet which is quoted in the tweets to search. */
215
+ quoted?: string;
216
+
217
+ /** The id of the tweet, after which the tweets are to be searched. */
218
+ sinceId?: string;
219
+
220
+ /** The date starting from which tweets are to be searched. */
221
+ startDate?: Date;
222
+
223
+ /**
224
+ * The list of username to whom the tweets to be searched, are adressed.
225
+ *
226
+ * @remarks
227
+ * '\@' must be excluded from the username!
228
+ */
229
+ toUsers?: string[];
230
+
231
+ /** Whether to fetch top tweets or not. */
232
+ top?: boolean;
233
+ }
@@ -0,0 +1,142 @@
1
+ import { IProfileUpdateOptions } from './ProfileArgs';
2
+
3
+ /**
4
+ * Options specifying the data that is to be posted.
5
+ *
6
+ * @public
7
+ */
8
+ export interface IPostArgs {
9
+ /**
10
+ * The id of the target resource.
11
+ *
12
+ * @remarks
13
+ * Required only when posting using the following resources:
14
+ * - {@link ResourceType.TWEET_BOOKMARK}
15
+ * - {@link ResourceType.TWEET_LIKE}
16
+ * - {@link ResourceType.TWEET_RETWEET}
17
+ * - {@link ResourceType.TWEET_UNBOOKMARK}
18
+ * - {@link ResourceType.TWEET_UNLIKE}
19
+ * - {@link ResourceType.TWEET_UNPOST}
20
+ * - {@link ResourceType.TWEET_UNRETWEET}
21
+ * - {@link ResourceType.USER_FOLLOW}
22
+ * - {@link ResourceType.USER_UNFOLLOW}
23
+ */
24
+ id?: string;
25
+
26
+ /**
27
+ * The tweet that is to be posted.
28
+ *
29
+ * @remarks
30
+ * Required only when posting a tweet using {@link ResourceType.TWEET_POST}
31
+ */
32
+ tweet?: INewTweet;
33
+
34
+ /**
35
+ * The media file to be uploaded.
36
+ *
37
+ * @remarks
38
+ * Required only when uploading a media using the following resources:
39
+ * - {@link ResourceType.MEDIA_UPLOAD_APPEND}
40
+ * - {@link ResourceType.MEDIA_UPLOAD_FINALIZE}
41
+ * - {@link ResourceType.MEDIA_UPLOAD_INITIALIZE}
42
+ */
43
+ upload?: IUploadArgs;
44
+
45
+ /**
46
+ * The id of the target user.
47
+ *
48
+ * @remarks
49
+ * Required only for the following resources:
50
+ * - {@link ResourceType.LIST_MEMBER_ADD}
51
+ * - {@link ResourceType.LIST_MEMBER_REMOVE}
52
+ */
53
+ userId?: string;
54
+
55
+ /**
56
+ * The id of the conversation to delete.
57
+ *
58
+ * @remarks
59
+ * Required only when deleting a conversation using {@link ResourceType.DM_DELETE_CONVERSATION}
60
+ */
61
+ conversationId?: string;
62
+
63
+ /**
64
+ * Profile update options.
65
+ *
66
+ * @remarks
67
+ * Required only when updating user profile using {@link ResourceType.USER_PROFILE_UPDATE}
68
+ */
69
+ profileOptions?: IProfileUpdateOptions;
70
+ }
71
+
72
+ /**
73
+ * Configuration for the new tweet to be posted.
74
+ *
75
+ * @public
76
+ */
77
+ export interface INewTweet {
78
+ /**
79
+ * The list of media to be uploaded.
80
+ *
81
+ * @remarks
82
+ * - The media first needs to be uploaded.
83
+ * - After uploading, the returned id(s) can be used to reference the media here.
84
+ * - Maximum number of media items that can be posted is 4.
85
+ */
86
+ media?: INewTweetMedia[];
87
+
88
+ /** The id of the tweet to quote. */
89
+ quote?: string;
90
+
91
+ /** The id of the Tweet to which the given Tweet must be a reply. */
92
+ replyTo?: string;
93
+
94
+ /** The date/time at which the tweet is to be scheduled for posting. */
95
+ scheduleFor?: Date;
96
+
97
+ /**
98
+ * The text for the tweet to be created.
99
+ *
100
+ * @remarks
101
+ * Length of the tweet must be \<= 280 characters.
102
+ */
103
+ text?: string;
104
+ }
105
+
106
+ /**
107
+ * Configuration for the media to be uploaded.
108
+ *
109
+ * @public
110
+ */
111
+ export interface INewTweetMedia {
112
+ /** The id of the media to upload. */
113
+ id: string;
114
+
115
+ /**
116
+ * The list of id of the users to tag in the media.
117
+ *
118
+ * @remarks
119
+ * Maximum number of users that can be tagged is 10.
120
+ */
121
+ tags?: string[];
122
+ }
123
+
124
+ /**
125
+ * Options specifying the media file to be uploaded.
126
+ *
127
+ * @public
128
+ */
129
+ export interface IUploadArgs {
130
+ /** The id allocated to the media file to be uploaded. */
131
+ id?: string;
132
+
133
+ /** The media file to be uploaded. */
134
+ media?: string | ArrayBuffer;
135
+
136
+ /**
137
+ * The size (in bytes) of the media file to be uploaded.
138
+ *
139
+ * @remarks The size must be \<= 5242880 bytes.
140
+ */
141
+ size?: number;
142
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Profile update options.
3
+ *
4
+ * @public
5
+ */
6
+ export interface IProfileUpdateOptions {
7
+ /**
8
+ * Bio/description of the user (max 160 characters).
9
+ */
10
+ description?: string;
11
+
12
+ /**
13
+ * Location of the user (max 30 characters).
14
+ */
15
+ location?: string;
16
+
17
+ /**
18
+ * Display name (max 50 characters).
19
+ *
20
+ * @remarks
21
+ * The name field represents the user's display name shown on their profile.
22
+ * This is different from the username (screen_name/handle).
23
+ */
24
+ name?: string;
25
+
26
+ /**
27
+ * URL associated with the profile.
28
+ *
29
+ * @remarks
30
+ * Will be prepended with http:// if not present.
31
+ */
32
+ url?: string;
33
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The cookie containing the tokens that are used to authenticate against Twitter.
3
+ *
4
+ * @public
5
+ */
6
+ export interface IAuthCookie {
7
+ /* eslint-disable @typescript-eslint/naming-convention */
8
+
9
+ /** The bearer token from twitter.com. */
10
+ auth_token: string;
11
+
12
+ /** The CSRF token for the session. */
13
+ ct0: string;
14
+
15
+ /** Token used to authenticate a device. */
16
+ kdt: string;
17
+
18
+ /** Token used to authenticate a user using a Twitter ID. */
19
+ twid: string;
20
+
21
+ /* eslint-enable @typescript-eslint/naming-convention */
22
+ }
@@ -0,0 +1,28 @@
1
+ import { AuthenticationType } from '../../enums/Authentication';
2
+
3
+ /**
4
+ * The credentials for authenticating against Twitter.
5
+ *
6
+ * Depending on which tokens are present, the authentication type is determined as follows:
7
+ * - authToken, guestToken =\> Guest authentication.
8
+ * - authToken, csrfToken, cookie =\> User authentication.
9
+ * - authToken, guestToken, cookie =\> Guest authentication while logging in.
10
+ *
11
+ * @public
12
+ */
13
+ export interface IAuthCredential {
14
+ /** The bearer token from twitter.com. */
15
+ authToken?: string;
16
+
17
+ /** The type of authentication. */
18
+ authenticationType?: AuthenticationType;
19
+
20
+ /** The cookie of the twitter account, which is used to authenticate against twitter. */
21
+ cookies?: string;
22
+
23
+ /** The CSRF token for the session. */
24
+ csrfToken?: string;
25
+
26
+ /** The guest token provided by Twitter API. */
27
+ guestToken?: string;
28
+ }
@@ -0,0 +1,8 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+
3
+ /**
4
+ * The transaction information for Twitter.
5
+ */
6
+ export interface ITransactionHeader {
7
+ 'x-client-transaction-id': string;
8
+ }
@@ -0,0 +1,58 @@
1
+ import type { IAnalyticsMetric } from '../../types/raw/base/Analytic';
2
+ /**
3
+ * The details of the analytic result of the connected User.
4
+ *
5
+ * @public
6
+ */
7
+ export interface IAnalytics {
8
+ /** The creation date of user's account. */
9
+ createdAt: string;
10
+
11
+ /** Total followers number */
12
+ followers: number;
13
+
14
+ /** Total verified followers */
15
+ verifiedFollowers: number;
16
+
17
+ /** Total impressions on the given period */
18
+ impressions: number;
19
+
20
+ /** Total profile visits on the given period */
21
+ profileVisits: number;
22
+
23
+ /** Total Engagements on the given period */
24
+ engagements: number;
25
+
26
+ /** Total Follows on the given period */
27
+ follows: number;
28
+
29
+ /** Total Replies on the given period */
30
+ replies: number;
31
+
32
+ /** Total Likes on the given period */
33
+ likes: number;
34
+
35
+ /** Total Retweets on the given period */
36
+ retweets: number;
37
+
38
+ /** Total Bookmark on the given period */
39
+ bookmarks: number;
40
+
41
+ /** Total Shares on the given period */
42
+ shares: number;
43
+
44
+ /** Total CreateTweets on the given period */
45
+ createTweets: number;
46
+
47
+ /** Total CreateQuote on the given period */
48
+ createQuote: number;
49
+
50
+ /** Total Unfollows on the given period */
51
+ unfollows: number;
52
+
53
+ /** Total CreateReply on the given period */
54
+ createReply: number;
55
+
56
+ /** Organic metrics times series */
57
+ organicMetricsTimeSeries: IAnalyticsMetric[];
58
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The details of a single Bookmark Folder.
3
+ *
4
+ * @public
5
+ */
6
+ export interface IBookmarkFolder {
7
+ /** The unique identifier for the folder. */
8
+ id: string;
9
+
10
+ /** The display name of the folder. */
11
+ name: string;
12
+ }
@@ -0,0 +1,44 @@
1
+ import { IDirectMessage } from './DirectMessage';
2
+
3
+ /**
4
+ * The details of a single conversation.
5
+ *
6
+ * @public
7
+ */
8
+ export interface IConversation {
9
+ /** The unique identifier of the conversation. */
10
+ id: string;
11
+
12
+ /** The type of conversation (ONE_TO_ONE or GROUP_DM). */
13
+ type: 'ONE_TO_ONE' | 'GROUP_DM';
14
+
15
+ /** Array of participant user IDs. */
16
+ participants: string[];
17
+
18
+ /** The name of the conversation (for group DMs). */
19
+ name?: string;
20
+
21
+ /** URL to the conversation avatar (for group DMs). */
22
+ avatarUrl?: string;
23
+
24
+ /** Whether the conversation is trusted. */
25
+ trusted: boolean;
26
+
27
+ /** Whether the conversation is muted. */
28
+ muted: boolean;
29
+
30
+ /** Whether notifications are disabled. */
31
+ notificationsDisabled: boolean;
32
+
33
+ /** The timestamp of the last activity (ISO 8601 format). */
34
+ lastActivityAt: string;
35
+
36
+ /** The ID of the last message. */
37
+ lastMessageId?: string;
38
+
39
+ /** Whether there are more messages to load. */
40
+ hasMore: boolean;
41
+
42
+ /** Array of messages in this conversation. */
43
+ messages: IDirectMessage[];
44
+ }
@@ -0,0 +1,24 @@
1
+ import { IBookmarkFolder } from './BookmarkFolder';
2
+ import { IConversation } from './Conversation';
3
+ import { IDirectMessage } from './DirectMessage';
4
+ import { IList } from './List';
5
+ import { INotification } from './Notification';
6
+ import { ITweet } from './Tweet';
7
+ import { IUser } from './User';
8
+
9
+ /**
10
+ * The data that is fetched batch-wise using a cursor.
11
+ *
12
+ * @typeParam T - Type of data to be stored.
13
+ *
14
+ * @public
15
+ */
16
+ export interface ICursoredData<
17
+ T extends IDirectMessage | IConversation | INotification | ITweet | IUser | IList | IBookmarkFolder,
18
+ > {
19
+ /** The batch of data of the given type. */
20
+ list: T[];
21
+
22
+ /** The cursor to the next batch of data. */
23
+ next: string;
24
+ }