rettiwt-api 5.0.0-alpha.1 → 5.0.0-alpha.2

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 (406) hide show
  1. package/dist/Rettiwt.d.ts +10 -3
  2. package/dist/Rettiwt.js +19 -7
  3. package/dist/Rettiwt.js.map +1 -1
  4. package/dist/collections/Extractors.d.ts +35 -2
  5. package/dist/collections/Extractors.js +3 -0
  6. package/dist/collections/Extractors.js.map +1 -1
  7. package/dist/collections/Groups.js +3 -0
  8. package/dist/collections/Groups.js.map +1 -1
  9. package/dist/collections/Requests.js +41 -41
  10. package/dist/collections/Requests.js.map +1 -1
  11. package/dist/commands/Tweet.js +33 -7
  12. package/dist/commands/Tweet.js.map +1 -1
  13. package/dist/commands/User.js +12 -2
  14. package/dist/commands/User.js.map +1 -1
  15. package/dist/enums/Authentication.d.ts +2 -10
  16. package/dist/enums/Authentication.js +3 -12
  17. package/dist/enums/Authentication.js.map +1 -1
  18. package/dist/enums/Data.d.ts +3 -15
  19. package/dist/enums/Data.js +4 -17
  20. package/dist/enums/Data.js.map +1 -1
  21. package/dist/enums/Media.d.ts +10 -0
  22. package/dist/enums/Media.js +15 -0
  23. package/dist/enums/Media.js.map +1 -0
  24. package/dist/enums/Notification.d.ts +12 -0
  25. package/dist/enums/Notification.js +17 -0
  26. package/dist/enums/Notification.js.map +1 -0
  27. package/dist/enums/Resource.d.ts +3 -0
  28. package/dist/enums/Resource.js +3 -0
  29. package/dist/enums/Resource.js.map +1 -1
  30. package/dist/enums/raw/Analytics.d.ts +28 -0
  31. package/dist/enums/raw/Analytics.js +34 -0
  32. package/dist/enums/raw/Analytics.js.map +1 -0
  33. package/dist/enums/raw/Media.d.ts +10 -0
  34. package/dist/enums/raw/Media.js +15 -0
  35. package/dist/enums/raw/Media.js.map +1 -0
  36. package/dist/enums/raw/Notification.d.ts +11 -0
  37. package/dist/enums/raw/Notification.js +16 -0
  38. package/dist/enums/raw/Notification.js.map +1 -0
  39. package/dist/enums/raw/Tweet.d.ts +9 -0
  40. package/dist/enums/raw/Tweet.js +14 -0
  41. package/dist/enums/raw/Tweet.js.map +1 -0
  42. package/dist/helper/TidUtils.d.ts +2 -0
  43. package/dist/helper/TidUtils.js +162 -0
  44. package/dist/helper/TidUtils.js.map +1 -0
  45. package/dist/index.d.ts +75 -4
  46. package/dist/index.js +26 -5
  47. package/dist/index.js.map +1 -1
  48. package/dist/models/RettiwtConfig.d.ts +28 -0
  49. package/dist/models/RettiwtConfig.js +55 -0
  50. package/dist/models/RettiwtConfig.js.map +1 -0
  51. package/dist/models/args/FetchArgs.d.ts +46 -3
  52. package/dist/models/args/FetchArgs.js +107 -5
  53. package/dist/models/args/FetchArgs.js.map +1 -1
  54. package/dist/models/args/PostArgs.d.ts +44 -16
  55. package/dist/models/args/PostArgs.js +61 -22
  56. package/dist/models/args/PostArgs.js.map +1 -1
  57. package/dist/models/auth/AuthCookie.d.ts +2 -0
  58. package/dist/models/auth/AuthCookie.js +2 -0
  59. package/dist/models/auth/AuthCookie.js.map +1 -1
  60. package/dist/models/auth/AuthCredential.d.ts +2 -0
  61. package/dist/models/auth/AuthCredential.js +2 -0
  62. package/dist/models/auth/AuthCredential.js.map +1 -1
  63. package/dist/models/data/CursoredData.d.ts +4 -13
  64. package/dist/models/data/CursoredData.js +16 -23
  65. package/dist/models/data/CursoredData.js.map +1 -1
  66. package/dist/models/data/List.d.ts +5 -1
  67. package/dist/models/data/List.js +14 -0
  68. package/dist/models/data/List.js.map +1 -1
  69. package/dist/models/data/Notification.d.ts +7 -5
  70. package/dist/models/data/Notification.js +19 -8
  71. package/dist/models/data/Notification.js.map +1 -1
  72. package/dist/models/data/Tweet.d.ts +29 -9
  73. package/dist/models/data/Tweet.js +103 -25
  74. package/dist/models/data/Tweet.js.map +1 -1
  75. package/dist/models/data/User.d.ts +17 -8
  76. package/dist/models/data/User.js +63 -13
  77. package/dist/models/data/User.js.map +1 -1
  78. package/dist/models/errors/RettiwtError.d.ts +3 -2
  79. package/dist/models/errors/RettiwtError.js +3 -2
  80. package/dist/models/errors/RettiwtError.js.map +1 -1
  81. package/dist/models/params/Variables.d.ts +41 -0
  82. package/dist/models/params/Variables.js +61 -0
  83. package/dist/models/params/Variables.js.map +1 -0
  84. package/dist/requests/List.d.ts +24 -0
  85. package/dist/requests/List.js +122 -0
  86. package/dist/requests/List.js.map +1 -0
  87. package/dist/requests/Media.d.ts +21 -0
  88. package/dist/requests/Media.js +70 -0
  89. package/dist/requests/Media.js.map +1 -0
  90. package/dist/requests/Tweet.d.ts +75 -0
  91. package/dist/requests/Tweet.js +480 -0
  92. package/dist/requests/Tweet.js.map +1 -0
  93. package/dist/requests/User.d.ts +111 -0
  94. package/dist/requests/User.js +762 -0
  95. package/dist/requests/User.js.map +1 -0
  96. package/dist/services/internal/AuthService.d.ts +3 -5
  97. package/dist/services/internal/AuthService.js +5 -8
  98. package/dist/services/internal/AuthService.js.map +1 -1
  99. package/dist/services/internal/TidService.d.ts +44 -0
  100. package/dist/services/internal/TidService.js +162 -0
  101. package/dist/services/internal/TidService.js.map +1 -0
  102. package/dist/services/public/FetcherService.d.ts +20 -19
  103. package/dist/services/public/FetcherService.js +67 -49
  104. package/dist/services/public/FetcherService.js.map +1 -1
  105. package/dist/services/public/ListService.d.ts +2 -2
  106. package/dist/services/public/ListService.js.map +1 -1
  107. package/dist/services/public/TweetService.d.ts +35 -7
  108. package/dist/services/public/TweetService.js +54 -8
  109. package/dist/services/public/TweetService.js.map +1 -1
  110. package/dist/services/public/UserService.d.ts +4 -4
  111. package/dist/services/public/UserService.js +25 -13
  112. package/dist/services/public/UserService.js.map +1 -1
  113. package/dist/types/RettiwtConfig.d.ts +9 -10
  114. package/dist/types/args/FetchArgs.d.ts +71 -7
  115. package/dist/types/args/PostArgs.d.ts +62 -18
  116. package/dist/types/auth/AuthCookie.d.ts +2 -0
  117. package/dist/types/auth/AuthCredential.d.ts +2 -0
  118. package/dist/types/auth/TidDynamicArgs.d.ts +10 -0
  119. package/dist/types/auth/{AccountCredential.js → TidDynamicArgs.js} +1 -1
  120. package/dist/types/auth/TidDynamicArgs.js.map +1 -0
  121. package/dist/types/auth/TidHeader.d.ts +8 -0
  122. package/dist/types/{ReturnTypes.js → auth/TidHeader.js} +1 -1
  123. package/dist/types/auth/TidHeader.js.map +1 -0
  124. package/dist/types/auth/TidParams.d.ts +27 -0
  125. package/dist/types/auth/TidParams.js +3 -0
  126. package/dist/types/auth/TidParams.js.map +1 -0
  127. package/dist/types/auth/TidProvider.d.ts +18 -0
  128. package/dist/types/auth/TidProvider.js +3 -0
  129. package/dist/types/auth/TidProvider.js.map +1 -0
  130. package/dist/types/data/CursoredData.d.ts +1 -10
  131. package/dist/types/data/Notification.d.ts +2 -2
  132. package/dist/types/data/Tweet.d.ts +2 -2
  133. package/dist/types/params/Variables.d.ts +27 -0
  134. package/dist/types/params/Variables.js +3 -0
  135. package/dist/types/params/Variables.js.map +1 -0
  136. package/dist/types/raw/base/Analytic.d.ts +21 -0
  137. package/dist/types/raw/base/Analytic.js +4 -0
  138. package/dist/types/raw/base/Analytic.js.map +1 -0
  139. package/dist/types/raw/base/Cursor.d.ts +11 -0
  140. package/dist/types/raw/base/Cursor.js +4 -0
  141. package/dist/types/raw/base/Cursor.js.map +1 -0
  142. package/dist/types/raw/base/LimitedVisibilityTweet.d.ts +32 -0
  143. package/dist/types/raw/base/LimitedVisibilityTweet.js +4 -0
  144. package/dist/types/raw/base/LimitedVisibilityTweet.js.map +1 -0
  145. package/dist/types/raw/base/List.d.ts +43 -0
  146. package/dist/types/raw/base/List.js +4 -0
  147. package/dist/types/raw/base/List.js.map +1 -0
  148. package/dist/types/raw/base/Media.d.ts +43 -0
  149. package/dist/types/raw/base/Media.js +4 -0
  150. package/dist/types/raw/base/Media.js.map +1 -0
  151. package/dist/types/raw/base/Notification.d.ts +53 -0
  152. package/dist/types/raw/base/Notification.js +4 -0
  153. package/dist/types/raw/base/Notification.js.map +1 -0
  154. package/dist/types/raw/base/Space.d.ts +32 -0
  155. package/dist/types/raw/base/Space.js +4 -0
  156. package/dist/types/raw/base/Space.js.map +1 -0
  157. package/dist/types/raw/base/Tweet.d.ts +119 -0
  158. package/dist/types/raw/base/Tweet.js +4 -0
  159. package/dist/types/raw/base/Tweet.js.map +1 -0
  160. package/dist/types/raw/base/User.d.ts +140 -0
  161. package/dist/types/raw/base/User.js +4 -0
  162. package/dist/types/raw/base/User.js.map +1 -0
  163. package/dist/types/raw/composite/DataResult.d.ts +8 -0
  164. package/dist/types/raw/composite/DataResult.js +3 -0
  165. package/dist/types/raw/composite/DataResult.js.map +1 -0
  166. package/dist/types/raw/composite/TimelineTweet.d.ts +11 -0
  167. package/dist/types/raw/composite/TimelineTweet.js +4 -0
  168. package/dist/types/raw/composite/TimelineTweet.js.map +1 -0
  169. package/dist/types/raw/composite/TimelineUser.d.ts +10 -0
  170. package/dist/types/raw/composite/TimelineUser.js +4 -0
  171. package/dist/types/raw/composite/TimelineUser.js.map +1 -0
  172. package/dist/types/raw/generic/Error.d.ts +30 -0
  173. package/dist/types/raw/generic/Error.js +3 -0
  174. package/dist/types/raw/generic/Error.js.map +1 -0
  175. package/dist/types/raw/generic/Response.d.ts +12 -0
  176. package/dist/types/raw/generic/Response.js +3 -0
  177. package/dist/types/raw/generic/Response.js.map +1 -0
  178. package/dist/types/raw/list/Details.d.ts +122 -0
  179. package/dist/types/raw/list/Details.js +4 -0
  180. package/dist/types/raw/list/Details.js.map +1 -0
  181. package/dist/types/raw/list/Members.d.ts +134 -0
  182. package/dist/types/raw/list/Members.js +4 -0
  183. package/dist/types/raw/list/Members.js.map +1 -0
  184. package/dist/types/raw/list/Tweets.d.ts +1968 -0
  185. package/dist/types/raw/list/Tweets.js +4 -0
  186. package/dist/types/raw/list/Tweets.js.map +1 -0
  187. package/dist/types/raw/media/FinalizeUpload.d.ts +18 -0
  188. package/dist/types/raw/media/FinalizeUpload.js +4 -0
  189. package/dist/types/raw/media/FinalizeUpload.js.map +1 -0
  190. package/dist/types/raw/media/InitalizeUpload.d.ts +10 -0
  191. package/dist/types/raw/media/InitalizeUpload.js +4 -0
  192. package/dist/types/raw/media/InitalizeUpload.js.map +1 -0
  193. package/dist/types/raw/media/LiveVideoStream.d.ts +19 -0
  194. package/dist/types/raw/media/LiveVideoStream.js +4 -0
  195. package/dist/types/raw/media/LiveVideoStream.js.map +1 -0
  196. package/dist/types/raw/space/Details.d.ts +315 -0
  197. package/dist/types/raw/space/Details.js +4 -0
  198. package/dist/types/raw/space/Details.js.map +1 -0
  199. package/dist/types/raw/tweet/Details.d.ts +183 -0
  200. package/dist/types/raw/tweet/Details.js +4 -0
  201. package/dist/types/raw/tweet/Details.js.map +1 -0
  202. package/dist/types/raw/tweet/Like.d.ts +12 -0
  203. package/dist/types/raw/tweet/Like.js +4 -0
  204. package/dist/types/raw/tweet/Like.js.map +1 -0
  205. package/dist/types/raw/tweet/Likers.d.ts +170 -0
  206. package/dist/types/raw/tweet/Likers.js +4 -0
  207. package/dist/types/raw/tweet/Likers.js.map +1 -0
  208. package/dist/types/raw/tweet/Post.d.ts +133 -0
  209. package/dist/types/raw/tweet/Post.js +4 -0
  210. package/dist/types/raw/tweet/Post.js.map +1 -0
  211. package/dist/types/raw/tweet/Replies.d.ts +465 -0
  212. package/dist/types/raw/tweet/Replies.js +4 -0
  213. package/dist/types/raw/tweet/Replies.js.map +1 -0
  214. package/dist/types/raw/tweet/Retweet.d.ts +25 -0
  215. package/dist/types/raw/tweet/Retweet.js +4 -0
  216. package/dist/types/raw/tweet/Retweet.js.map +1 -0
  217. package/dist/types/raw/tweet/Retweeters.d.ts +177 -0
  218. package/dist/types/raw/tweet/Retweeters.js +4 -0
  219. package/dist/types/raw/tweet/Retweeters.js.map +1 -0
  220. package/dist/types/raw/tweet/Schedule.d.ts +15 -0
  221. package/dist/types/raw/tweet/Schedule.js +4 -0
  222. package/dist/types/raw/tweet/Schedule.js.map +1 -0
  223. package/dist/types/raw/tweet/Search.d.ts +518 -0
  224. package/dist/types/raw/tweet/Search.js +4 -0
  225. package/dist/types/raw/tweet/Search.js.map +1 -0
  226. package/dist/types/raw/tweet/Unlike.d.ts +12 -0
  227. package/dist/types/raw/tweet/Unlike.js +4 -0
  228. package/dist/types/raw/tweet/Unlike.js.map +1 -0
  229. package/dist/types/raw/tweet/Unpost.d.ts +17 -0
  230. package/dist/types/raw/tweet/Unpost.js +4 -0
  231. package/dist/types/raw/tweet/Unpost.js.map +1 -0
  232. package/dist/types/raw/tweet/Unretweet.d.ts +25 -0
  233. package/dist/types/raw/tweet/Unretweet.js +4 -0
  234. package/dist/types/raw/tweet/Unretweet.js.map +1 -0
  235. package/dist/types/raw/tweet/Unschedule.d.ts +12 -0
  236. package/dist/types/raw/tweet/Unschedule.js +4 -0
  237. package/dist/types/raw/tweet/Unschedule.js.map +1 -0
  238. package/dist/types/raw/user/Affiliates.d.ts +154 -0
  239. package/dist/types/raw/user/Affiliates.js +4 -0
  240. package/dist/types/raw/user/Affiliates.js.map +1 -0
  241. package/dist/types/raw/user/Analytics.d.ts +32 -0
  242. package/dist/types/raw/user/Analytics.js +4 -0
  243. package/dist/types/raw/user/Analytics.js.map +1 -0
  244. package/dist/types/raw/user/Bookmarks.d.ts +550 -0
  245. package/dist/types/raw/user/Bookmarks.js +4 -0
  246. package/dist/types/raw/user/Bookmarks.js.map +1 -0
  247. package/dist/types/raw/user/Details.d.ts +157 -0
  248. package/dist/types/raw/user/Details.js +4 -0
  249. package/dist/types/raw/user/Details.js.map +1 -0
  250. package/dist/types/raw/user/Follow.d.ts +248 -0
  251. package/dist/types/raw/user/Follow.js +4 -0
  252. package/dist/types/raw/user/Follow.js.map +1 -0
  253. package/dist/types/raw/user/Followed.d.ts +1666 -0
  254. package/dist/types/raw/user/Followed.js +4 -0
  255. package/dist/types/raw/user/Followed.js.map +1 -0
  256. package/dist/types/raw/user/Followers.d.ts +182 -0
  257. package/dist/types/raw/user/Followers.js +4 -0
  258. package/dist/types/raw/user/Followers.js.map +1 -0
  259. package/dist/types/raw/user/Following.d.ts +182 -0
  260. package/dist/types/raw/user/Following.js +4 -0
  261. package/dist/types/raw/user/Following.js.map +1 -0
  262. package/dist/types/raw/user/Highlights.d.ts +1106 -0
  263. package/dist/types/raw/user/Highlights.js +4 -0
  264. package/dist/types/raw/user/Highlights.js.map +1 -0
  265. package/dist/types/raw/user/Likes.d.ts +1065 -0
  266. package/dist/types/raw/user/Likes.js +4 -0
  267. package/dist/types/raw/user/Likes.js.map +1 -0
  268. package/dist/types/raw/user/Media.d.ts +1492 -0
  269. package/dist/types/raw/user/Media.js +4 -0
  270. package/dist/types/raw/user/Media.js.map +1 -0
  271. package/dist/types/raw/user/Notifications.d.ts +142 -0
  272. package/dist/types/raw/user/Notifications.js +4 -0
  273. package/dist/types/raw/user/Notifications.js.map +1 -0
  274. package/dist/types/raw/user/Recommended.d.ts +1991 -0
  275. package/dist/types/raw/user/Recommended.js +4 -0
  276. package/dist/types/raw/user/Recommended.js.map +1 -0
  277. package/dist/types/raw/user/Scheduled.d.ts +31 -0
  278. package/dist/types/raw/user/Scheduled.js +4 -0
  279. package/dist/types/raw/user/Scheduled.js.map +1 -0
  280. package/dist/types/raw/user/Subscriptions.d.ts +151 -0
  281. package/dist/types/raw/user/Subscriptions.js +4 -0
  282. package/dist/types/raw/user/Subscriptions.js.map +1 -0
  283. package/dist/types/raw/user/Tweets.d.ts +1065 -0
  284. package/dist/types/raw/user/Tweets.js +4 -0
  285. package/dist/types/raw/user/Tweets.js.map +1 -0
  286. package/dist/types/raw/user/TweetsAndReplies.d.ts +1065 -0
  287. package/dist/types/raw/user/TweetsAndReplies.js +4 -0
  288. package/dist/types/raw/user/TweetsAndReplies.js.map +1 -0
  289. package/dist/types/raw/user/Unfollow.d.ts +248 -0
  290. package/dist/types/raw/user/Unfollow.js +4 -0
  291. package/dist/types/raw/user/Unfollow.js.map +1 -0
  292. package/package.json +3 -3
  293. package/src/Rettiwt.ts +22 -7
  294. package/src/collections/Extractors.ts +38 -34
  295. package/src/collections/Groups.ts +3 -0
  296. package/src/collections/Requests.ts +43 -42
  297. package/src/commands/Tweet.ts +35 -7
  298. package/src/commands/User.ts +13 -2
  299. package/src/enums/Authentication.ts +2 -11
  300. package/src/enums/Data.ts +3 -16
  301. package/src/enums/Media.ts +10 -0
  302. package/src/enums/Notification.ts +12 -0
  303. package/src/enums/Resource.ts +3 -0
  304. package/src/enums/raw/Analytics.ts +29 -0
  305. package/src/enums/raw/Media.ts +10 -0
  306. package/src/enums/raw/Notification.ts +11 -0
  307. package/src/enums/raw/Tweet.ts +9 -0
  308. package/src/helper/TidUtils.ts +189 -0
  309. package/src/index.ts +78 -43
  310. package/src/models/RettiwtConfig.ts +64 -0
  311. package/src/models/args/FetchArgs.ts +121 -5
  312. package/src/models/args/PostArgs.ts +61 -21
  313. package/src/models/auth/AuthCookie.ts +2 -0
  314. package/src/models/auth/AuthCredential.ts +2 -0
  315. package/src/models/data/CursoredData.ts +16 -24
  316. package/src/models/data/List.ts +16 -2
  317. package/src/models/data/Notification.ts +21 -12
  318. package/src/models/data/Tweet.ts +120 -39
  319. package/src/models/data/User.ts +71 -15
  320. package/src/models/errors/RettiwtError.ts +3 -2
  321. package/src/models/params/Variables.ts +62 -0
  322. package/src/requests/List.ts +121 -0
  323. package/src/requests/Media.ts +67 -0
  324. package/src/requests/Tweet.ts +496 -0
  325. package/src/requests/User.ts +783 -0
  326. package/src/services/internal/AuthService.ts +6 -11
  327. package/src/services/internal/TidService.ts +147 -0
  328. package/src/services/public/FetcherService.ts +78 -58
  329. package/src/services/public/ListService.ts +4 -4
  330. package/src/services/public/TweetService.ts +87 -40
  331. package/src/services/public/UserService.ts +47 -35
  332. package/src/types/RettiwtConfig.ts +11 -12
  333. package/src/types/args/FetchArgs.ts +92 -8
  334. package/src/types/args/PostArgs.ts +72 -22
  335. package/src/types/auth/AuthCookie.ts +2 -0
  336. package/src/types/auth/AuthCredential.ts +2 -0
  337. package/src/types/auth/TidDynamicArgs.ts +10 -0
  338. package/src/types/auth/TidHeader.ts +12 -0
  339. package/src/types/auth/TidParams.ts +36 -0
  340. package/src/types/auth/TidProvider.ts +19 -0
  341. package/src/types/data/CursoredData.ts +1 -11
  342. package/src/types/data/Notification.ts +2 -2
  343. package/src/types/data/Tweet.ts +2 -2
  344. package/src/types/params/Variables.ts +41 -0
  345. package/src/types/raw/base/Analytic.ts +26 -0
  346. package/src/types/raw/base/Cursor.ts +13 -0
  347. package/src/types/raw/base/LimitedVisibilityTweet.ts +40 -0
  348. package/src/types/raw/base/List.ts +50 -0
  349. package/src/types/raw/base/Media.ts +53 -0
  350. package/src/types/raw/base/Notification.ts +67 -0
  351. package/src/types/raw/base/Space.ts +35 -0
  352. package/src/types/raw/base/Tweet.ts +139 -0
  353. package/src/types/raw/base/User.ts +164 -0
  354. package/src/types/raw/composite/DataResult.ts +8 -0
  355. package/src/types/raw/composite/TimelineTweet.ts +14 -0
  356. package/src/types/raw/composite/TimelineUser.ts +13 -0
  357. package/src/types/raw/generic/Error.ts +35 -0
  358. package/src/types/raw/generic/Response.ts +13 -0
  359. package/src/types/raw/list/Details.ts +137 -0
  360. package/src/types/raw/list/Members.ts +154 -0
  361. package/src/types/raw/list/Tweets.ts +2296 -0
  362. package/src/types/raw/media/FinalizeUpload.ts +20 -0
  363. package/src/types/raw/media/InitalizeUpload.ts +12 -0
  364. package/src/types/raw/media/LiveVideoStream.ts +21 -0
  365. package/src/types/raw/space/Details.ts +359 -0
  366. package/src/types/raw/tweet/Details.ts +210 -0
  367. package/src/types/raw/tweet/Like.ts +14 -0
  368. package/src/types/raw/tweet/Likers.ts +200 -0
  369. package/src/types/raw/tweet/Post.ts +150 -0
  370. package/src/types/raw/tweet/Replies.ts +539 -0
  371. package/src/types/raw/tweet/Retweet.ts +31 -0
  372. package/src/types/raw/tweet/Retweeters.ts +208 -0
  373. package/src/types/raw/tweet/Schedule.ts +18 -0
  374. package/src/types/raw/tweet/Search.ts +597 -0
  375. package/src/types/raw/tweet/Unlike.ts +14 -0
  376. package/src/types/raw/tweet/Unpost.ts +20 -0
  377. package/src/types/raw/tweet/Unretweet.ts +31 -0
  378. package/src/types/raw/tweet/Unschedule.ts +14 -0
  379. package/src/types/raw/user/Affiliates.ts +179 -0
  380. package/src/types/raw/user/Analytics.ts +39 -0
  381. package/src/types/raw/user/Bookmarks.ts +637 -0
  382. package/src/types/raw/user/Details.ts +185 -0
  383. package/src/types/raw/user/Follow.ts +280 -0
  384. package/src/types/raw/user/Followed.ts +1942 -0
  385. package/src/types/raw/user/Followers.ts +215 -0
  386. package/src/types/raw/user/Following.ts +215 -0
  387. package/src/types/raw/user/Highlights.ts +1287 -0
  388. package/src/types/raw/user/Likes.ts +1254 -0
  389. package/src/types/raw/user/Media.ts +1738 -0
  390. package/src/types/raw/user/Notifications.ts +175 -0
  391. package/src/types/raw/user/Recommended.ts +2319 -0
  392. package/src/types/raw/user/Scheduled.ts +37 -0
  393. package/src/types/raw/user/Subscriptions.ts +176 -0
  394. package/src/types/raw/user/Tweets.ts +1254 -0
  395. package/src/types/raw/user/TweetsAndReplies.ts +1254 -0
  396. package/src/types/raw/user/Unfollow.ts +280 -0
  397. package/dist/models/auth/AccountCredential.d.ts +0 -13
  398. package/dist/models/auth/AccountCredential.js +0 -21
  399. package/dist/models/auth/AccountCredential.js.map +0 -1
  400. package/dist/types/ReturnTypes.d.ts +0 -21
  401. package/dist/types/ReturnTypes.js.map +0 -1
  402. package/dist/types/auth/AccountCredential.d.ts +0 -11
  403. package/dist/types/auth/AccountCredential.js.map +0 -1
  404. package/src/models/auth/AccountCredential.ts +0 -19
  405. package/src/types/ReturnTypes.ts +0 -24
  406. package/src/types/auth/AccountCredential.ts +0 -13
@@ -1,19 +1,10 @@
1
1
  /**
2
2
  * The different types of authentication for authenticating against Twitter.
3
+ *
4
+ * @public
3
5
  */
4
6
  export enum EAuthenticationType {
5
7
  GUEST = 'GUEST',
6
8
  USER = 'USER',
7
9
  LOGIN = 'LOGIN',
8
10
  }
9
-
10
- /**
11
- * Different types of error messages related to authentication returned by services.
12
- */
13
- export enum EAuthenticationErrors {
14
- NOT_AUTHENTICATED = 'Cannot fetch this data without authentication',
15
- INVALID_EMAIL = 'No Twitter account found for the given email address',
16
- INVALID_USERNAME = 'Incorrect username given for the given Twitter account',
17
- INVALID_PASSWORD = 'Incorrect password given for the given Twitter account',
18
- AUTHENTICATION_FAILED = 'Failed to authenticate using the given account Credentials',
19
- }
package/src/enums/Data.ts CHANGED
@@ -4,20 +4,7 @@
4
4
  * @internal
5
5
  */
6
6
  export enum EBaseType {
7
- NOTIFICATION = 'Notification',
8
- TWEET = 'Tweet',
9
- USER = 'User',
10
- }
11
-
12
- /**
13
- * The different types of notifications.
14
- *
15
- * @public
16
- */
17
- export enum ENotificationType {
18
- RECOMMENDATION = 'RECOMMENDATION',
19
- INFORMATION = 'INFORMATION',
20
- LIVE = 'LIVE',
21
- ALERT = 'ALERT',
22
- UNDEFINED = 'UNDEFINED',
7
+ NOTIFICATION = 'NOTIFICATION',
8
+ TWEET = 'TWEET',
9
+ USER = 'USER',
23
10
  }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The different types of media items.
3
+ *
4
+ * @public
5
+ */
6
+ export enum EMediaType {
7
+ PHOTO = 'PHOTO',
8
+ VIDEO = 'VIDEO',
9
+ GIF = 'GIF',
10
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The different types of notifications.
3
+ *
4
+ * @public
5
+ */
6
+ export enum ENotificationType {
7
+ RECOMMENDATION = 'RECOMMENDATION',
8
+ INFORMATION = 'INFORMATION',
9
+ LIVE = 'LIVE',
10
+ ALERT = 'ALERT',
11
+ UNDEFINED = 'UNDEFINED',
12
+ }
@@ -16,7 +16,9 @@ export enum EResourceType {
16
16
  // TWEET
17
17
  TWEET_DETAILS = 'TWEET_DETAILS',
18
18
  TWEET_DETAILS_ALT = 'TWEET_DETAILS_ALT',
19
+ TWEET_DETAILS_BULK = 'TWEET_DETAILS_BULK',
19
20
  TWEET_LIKE = 'TWEET_LIKE',
21
+ TWEET_LIKERS = 'TWEET_LIKERS',
20
22
  TWEET_POST = 'TWEET_POST',
21
23
  TWEET_REPLIES = 'TWEET_REPLIES',
22
24
  TWEET_RETWEET = 'TWEET_RETWEET',
@@ -32,6 +34,7 @@ export enum EResourceType {
32
34
  USER_BOOKMARKS = 'USER_BOOKMARKS',
33
35
  USER_DETAILS_BY_USERNAME = 'USER_DETAILS_BY_USERNAME',
34
36
  USER_DETAILS_BY_ID = 'USER_DETAILS_BY_ID',
37
+ USER_DETAILS_BY_IDS_BULK = 'USER_DETAILS_BY_IDS_BULK',
35
38
  USER_FEED_FOLLOWED = 'USER_FEED_FOLLOWED',
36
39
  USER_FEED_RECOMMENDED = 'USER_FEED_RECOMMENDED',
37
40
  USER_FOLLOW = 'USER_FOLLOW',
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Granularity types for analytics.
3
+ *
4
+ * @public
5
+ */
6
+ export enum ERawAnalyticsGranularity {
7
+ DAILY = 'Daily',
8
+ WEEKLY = 'Weekly',
9
+ MONTHLY = 'Monthly',
10
+ }
11
+
12
+ /**
13
+ * The different types of metric someone can request.
14
+ *
15
+ * @public
16
+ */
17
+ export enum ERawAnalyticsMetric {
18
+ ENGAGEMENTS = 'Engagements',
19
+ IMPRESSIONS = 'Impressions',
20
+ PROFILE_VISITS = 'ProfileVisits',
21
+ FOLLOWS = 'Follows',
22
+ VIDEO_VIEWS = 'VideoViews',
23
+ REPLIES = 'Replies',
24
+ LIKES = 'Likes',
25
+ RETWEETS = 'Retweets',
26
+ MEDIA_VIEWS = 'MediaViews',
27
+ BOOKMARK = 'Bookmark',
28
+ SHARE = 'Share',
29
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The different types of media items.
3
+ *
4
+ * @public
5
+ */
6
+ export enum ERawMediaType {
7
+ PHOTO = 'photo',
8
+ VIDEO = 'video',
9
+ GIF = 'animated_gif',
10
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The different types of notifications.
3
+ *
4
+ * @public
5
+ */
6
+ export enum ERawNotificationType {
7
+ RECOMMENDATION = 'recommendation_icon',
8
+ INFORMATION = 'bird_icon',
9
+ LIVE = 'live_icon',
10
+ ALERT = 'bell_icon',
11
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The different types of search results when searching for Tweets.
3
+ *
4
+ * @public
5
+ */
6
+ export enum ERawTweetSearchResultType {
7
+ LATEST = 'Latest',
8
+ TOP = 'Top',
9
+ }
@@ -0,0 +1,189 @@
1
+ import { createHash } from 'node:crypto';
2
+
3
+ import { ITidParams } from '../types/auth/TidParams';
4
+
5
+ export function calculateClientTransactionIdHeader(args: ITidParams): string {
6
+ const time = Math.floor(((args.time || Date.now()) - 1682924400 * 1000) / 1000);
7
+ const timeBuffer = new Uint8Array(new Uint32Array([time]).buffer);
8
+
9
+ const keyBytes = Array.from(Buffer.from(args.verificationKey, 'base64'));
10
+ const animationKey = args.animationKey || getAnimationKey(keyBytes, args.frames, args.indices);
11
+
12
+ const value = [args.method, args.path, time].join('!') + args.keyword + animationKey;
13
+ const valueEncoded = new TextEncoder().encode(value);
14
+
15
+ const hash = createHash('sha-256').update(valueEncoded).digest();
16
+ const hashBytes = Array.from(new Uint8Array(hash));
17
+
18
+ const xorByte = args.xorByte || Math.floor(Math.random() * 256);
19
+
20
+ const bytes = new Uint8Array(keyBytes.concat(Array.from(timeBuffer), hashBytes.slice(0, 16), [args.extraByte]));
21
+ return encode(xor(xorByte, bytes));
22
+ }
23
+
24
+ function getAnimationKey(keyBytes: number[], frames: number[][][], indices: number[]): string {
25
+ const totalTime = 4096;
26
+ const rowIndex = keyBytes[indices[0]] % 16;
27
+ const frameTime = indices
28
+ .slice(1)
29
+ .map((idx) => keyBytes[idx] % 16)
30
+ .reduce((a, b) => a * b, 1);
31
+ const targetTime = frameTime / totalTime;
32
+ const frameRow = frames[keyBytes[5] % 4][rowIndex];
33
+ return animate(frameRow, targetTime);
34
+ }
35
+
36
+ function animate(frameRow: number[], targetTime: number): string {
37
+ const curves = frameRow.slice(7).map((v, i) => Number(a(v, b(i), 1).toFixed(2)));
38
+ const cubicValue = getCubicCurveValue(curves, targetTime);
39
+
40
+ const fromColor = [...frameRow.slice(0, 3), 1];
41
+ const toColor = [...frameRow.slice(3, 6), 1];
42
+ const color = interpolate(fromColor, toColor, cubicValue);
43
+
44
+ const fromRotation = [0];
45
+ const toRotation = [Math.floor(a(frameRow[6], 60, 360))];
46
+ const rotation = interpolate(fromRotation, toRotation, cubicValue);
47
+ const matrix = convertRotationToMatrix(rotation[0]);
48
+
49
+ const strArray: string[] = [];
50
+ for (let i = 0; i < color.length - 1; i++) {
51
+ strArray.push(Math.round(color[i]).toString(16));
52
+ }
53
+
54
+ for (let i = 0; i < matrix.length; i++) {
55
+ let rounded = Number(matrix[i].toFixed(2));
56
+ if (rounded < 0) {
57
+ rounded = -rounded;
58
+ }
59
+ const hexValue = floatToHex(rounded);
60
+ if (hexValue.startsWith('.')) {
61
+ strArray.push('0' + hexValue);
62
+ } else if (hexValue) {
63
+ strArray.push(hexValue);
64
+ } else {
65
+ strArray.push('0');
66
+ }
67
+ }
68
+
69
+ strArray.push('0', '0');
70
+ return strArray.join('').replace(/[.-]/g, '').toLowerCase();
71
+ }
72
+
73
+ function a(b: number, c: number, d: number): number {
74
+ return (b * (d - c)) / 255 + c;
75
+ }
76
+
77
+ function b(a: number): number {
78
+ return a % 2 === 1 ? -1 : 0;
79
+ }
80
+
81
+ function getCubicCurveValue(curves: number[], time: number): number {
82
+ let startGradient = 0;
83
+ let endGradient = 0;
84
+
85
+ if (time <= 0) {
86
+ if (curves[0] > 0) {
87
+ startGradient = curves[1] / curves[0];
88
+ } else if (curves[1] === 0 && curves[2] > 0) {
89
+ startGradient = curves[3] / curves[2];
90
+ }
91
+ return startGradient * time;
92
+ }
93
+
94
+ if (time >= 1) {
95
+ if (curves[2] < 1) {
96
+ endGradient = (curves[3] - 1) / (curves[2] - 1);
97
+ } else if (curves[2] === 1 && curves[0] < 1) {
98
+ endGradient = (curves[1] - 1) / (curves[0] - 1);
99
+ }
100
+ return 1 + endGradient * (time - 1);
101
+ }
102
+
103
+ let start = 0;
104
+ let end = 1;
105
+ let mid = 0;
106
+
107
+ while (start < end) {
108
+ mid = (start + end) / 2;
109
+ const xEst = calculateBezier(curves[0], curves[2], mid);
110
+ if (Math.abs(time - xEst) < 0.00001) {
111
+ return calculateBezier(curves[1], curves[3], mid);
112
+ }
113
+ if (xEst < time) {
114
+ start = mid;
115
+ } else {
116
+ end = mid;
117
+ }
118
+ }
119
+
120
+ return calculateBezier(curves[1], curves[3], mid);
121
+ }
122
+
123
+ function calculateBezier(a: number, b: number, m: number): number {
124
+ return 3 * a * (1 - m) * (1 - m) * m + 3 * b * (1 - m) * m * m + m * m * m;
125
+ }
126
+
127
+ function interpolate(from: number[], to: number[], f: number): number[] {
128
+ const out: number[] = [];
129
+ for (let i = 0; i < from.length; i++) {
130
+ out.push(from[i] * (1 - f) + to[i] * f);
131
+ }
132
+ return out;
133
+ }
134
+
135
+ function convertRotationToMatrix(degrees: number): number[] {
136
+ const radians = (degrees * Math.PI) / 180;
137
+ const c = Math.cos(radians);
138
+ const s = Math.sin(radians);
139
+ return [c, -s, s, c];
140
+ }
141
+
142
+ function floatToHex(x: number): string {
143
+ const result: string[] = [];
144
+ let quotient = Math.floor(x);
145
+ let fraction = x - quotient;
146
+
147
+ while (quotient > 0) {
148
+ const remainder = quotient % 16;
149
+ quotient = Math.floor(quotient / 16);
150
+
151
+ if (remainder > 9) {
152
+ result.unshift(String.fromCharCode(remainder + 55));
153
+ } else {
154
+ result.unshift(remainder.toString());
155
+ }
156
+ }
157
+
158
+ if (fraction === 0) {
159
+ return result.join('');
160
+ }
161
+
162
+ result.push('.');
163
+
164
+ while (fraction > 0) {
165
+ fraction *= 16;
166
+ const integer = Math.floor(fraction);
167
+ fraction -= integer;
168
+
169
+ if (integer > 9) {
170
+ result.push(String.fromCharCode(integer + 55));
171
+ } else {
172
+ result.push(integer.toString());
173
+ }
174
+ }
175
+
176
+ return result.join('');
177
+ }
178
+
179
+ function xor(xorByte: number, data: Uint8Array): Uint8Array {
180
+ return new Uint8Array([xorByte, ...data.map((v) => v ^ xorByte)]);
181
+ }
182
+
183
+ function encode(data: Uint8Array): string {
184
+ return btoa(
185
+ Array.from(data)
186
+ .map((v) => String.fromCharCode(v))
187
+ .join(''),
188
+ ).replaceAll('=', '');
189
+ }
package/src/index.ts CHANGED
@@ -2,69 +2,104 @@
2
2
  export * from './Rettiwt';
3
3
 
4
4
  // ENUMS
5
+ export * from './enums/raw/Analytics';
6
+ export * from './enums/raw/Media';
7
+ export * from './enums/raw/Notification';
8
+ export * from './enums/raw/Tweet';
5
9
  export * from './enums/Api';
10
+ export * from './enums/Authentication';
11
+ export * from './enums/Data';
6
12
  export * from './enums/Http';
13
+ export * from './enums/Logging';
14
+ export * from './enums/Media';
15
+ export * from './enums/Notification';
7
16
  export * from './enums/Resource';
8
17
 
9
- // ARG MODELS
18
+ // MODELS
10
19
  export * from './models/args/FetchArgs';
11
20
  export * from './models/args/PostArgs';
12
-
13
- // DATA MODELS
14
21
  export * from './models/data/CursoredData';
15
22
  export * from './models/data/List';
16
23
  export * from './models/data/Notification';
17
24
  export * from './models/data/Tweet';
18
25
  export * from './models/data/User';
19
-
20
- // ERROR MODELS
21
26
  export * from './models/errors/ApiError';
22
27
  export * from './models/errors/HttpError';
23
28
  export * from './models/errors/RettiwtError';
24
29
  export * from './models/errors/TimeoutError';
25
30
 
31
+ // REQUESTS
32
+ export * from './requests/List';
33
+ export * from './requests/Media';
34
+ export * from './requests/Tweet';
35
+ export * from './requests/User';
36
+
26
37
  // SERVICES
27
- export * from './services/internal/AuthService';
28
38
  export * from './services/public/FetcherService';
39
+ export * from './services/public/ListService';
29
40
  export * from './services/public/TweetService';
30
41
  export * from './services/public/UserService';
31
42
 
32
43
  // TYPES
33
- export * from './types/RettiwtConfig';
44
+ export * from './types/args/FetchArgs';
45
+ export * from './types/args/PostArgs';
46
+ export * from './types/auth/TidProvider';
47
+ export * from './types/data/CursoredData';
48
+ export * from './types/data/List';
49
+ export * from './types/data/Notification';
50
+ export * from './types/data/Tweet';
51
+ export * from './types/data/User';
52
+ export * from './types/params/Variables';
53
+ export { IAnalytics as IRawAnalytics } from './types/raw/base/Analytic';
54
+ export { ICursor as IRawCursor } from './types/raw/base/Cursor';
55
+ export { ILimitedVisibilityTweet as IRawLimitedVisibilityTweet } from './types/raw/base/LimitedVisibilityTweet';
56
+ export { IList as IRawList } from './types/raw/base/List';
57
+ export { IMedia as IRawMedia } from './types/raw/base/Media';
58
+ export { INotification as IRawNotification } from './types/raw/base/Notification';
59
+ export { ISpace as IRawSpace } from './types/raw/base/Space';
60
+ export { ITweet as IRawTweet } from './types/raw/base/Tweet';
61
+ export { IUser as IRawUser } from './types/raw/base/User';
62
+ export { IDataResult as IRawDataResult } from './types/raw/composite/DataResult';
63
+ export { ITimelineTweet as IRawTimelineTweet } from './types/raw/composite/TimelineTweet';
64
+ export { ITimelineUser as IRawTimelineUser } from './types/raw/composite/TimelineUser';
65
+ export { IError as IRawError } from './types/raw/generic/Error';
66
+ export { IResponse as IRawResponse } from './types/raw/generic/Response';
67
+ export { IListDetailsResponse as IRawListDetailsResponse } from './types/raw/list/Details';
68
+ export { IListMembersResponse as IRawListMembersResponse } from './types/raw/list/Members';
69
+ export { IListTweetsResponse as IRawListTweetsResponse } from './types/raw/list/Tweets';
70
+ export { IMediaFinalizeUploadResponse as IRawMediaFinalizeUploadResponse } from './types/raw/media/FinalizeUpload';
71
+ export { IMediaInitializeUploadResponse as IRawMediaInitializeUploadResponse } from './types/raw/media/InitalizeUpload';
72
+ export { IMediaLiveVideoStreamResponse as IRawMediaLiveVideoStreamResponse } from './types/raw/media/LiveVideoStream';
73
+ export { ITweetDetailsResponse as IRawTweetDetailsResponse } from './types/raw/tweet/Details';
74
+ export { ITweetLikeResponse as IRawTweetLikeResponse } from './types/raw/tweet/Like';
75
+ export { ITweetLikersResponse as IRawTweetLikersResponse } from './types/raw/tweet/Likers';
76
+ export { ITweetPostResponse as IRawTweetPostResponse } from './types/raw/tweet/Post';
77
+ export { ITweetRepliesResponse as IRawTweetRepliesResponse } from './types/raw/tweet/Replies';
78
+ export { ITweetRetweetResponse as IRawTweetRetweetResponse } from './types/raw/tweet/Retweet';
79
+ export { ITweetRetweetersResponse as IRawTweetRetweetersResponse } from './types/raw/tweet/Retweeters';
80
+ export { ITweetScheduleResponse as IRawTweetScheduleResponse } from './types/raw/tweet/Schedule';
81
+ export { ITweetSearchResponse as IRawTweetSearchResponse } from './types/raw/tweet/Search';
82
+ export { ITweetUnlikeResponse as IRawTweetUnlikeResponse } from './types/raw/tweet/Unlike';
83
+ export { ITweetUnpostResponse as IRawTweetUnpostResponse } from './types/raw/tweet/Unpost';
84
+ export { ITweetUnretweetResponse as IRawTweetUnretweetResponse } from './types/raw/tweet/Unretweet';
85
+ export { ITweetUnscheduleResponse as ITRawTweetUnscheduleResponse } from './types/raw/tweet/Unschedule';
86
+ export { IUserAffiliatesResponse as IRawUserAffiliatesResponse } from './types/raw/user/Affiliates';
87
+ export { IUserAnalyticsResponse as IRawUserAnalyticsResponse } from './types/raw/user/Analytics';
88
+ export { IUserBookmarksResponse as IRawUserBookmarksResponse } from './types/raw/user/Bookmarks';
89
+ export { IUserDetailsResponse as IRawUserDetailsResponse } from './types/raw/user/Details';
90
+ export { IUserFollowResponse as IRawUserFollowResponse } from './types/raw/user/Follow';
91
+ export { IUserFollowedResponse as IRawUserFollowedResponse } from './types/raw/user/Followed';
92
+ export { IUserFollowersResponse as IRawUserFollowersResponse } from './types/raw/user/Followers';
93
+ export { IUserFollowingResponse as IRawUserFollowingResponse } from './types/raw/user/Following';
94
+ export { IUserHighlightsResponse as IRawUserHighlightsResponse } from './types/raw/user/Highlights';
95
+ export { IUserLikesResponse as IRawUserLikesResponse } from './types/raw/user/Likes';
96
+ export { IUserMediaResponse as IRawUserMediaResponse } from './types/raw/user/Media';
97
+ export { IUserNotificationsResponse as IRawUserNotificationsResponse } from './types/raw/user/Notifications';
98
+ export { IUserRecommendedResponse as IRawUserRecommendedResponse } from './types/raw/user/Recommended';
99
+ export { IUserScheduledResponse as IRawUserScheduledResponse } from './types/raw/user/Scheduled';
100
+ export { IUserSubscriptionsResponse as IRawUserSubscriptionsResponse } from './types/raw/user/Subscriptions';
101
+ export { IUserTweetsResponse as IRawUserTweetsResponse } from './types/raw/user/Tweets';
102
+ export { IUserTweetsAndRepliesResponse as IRawUserTweetsAndRepliesResponse } from './types/raw/user/TweetsAndReplies';
103
+ export { IUserUnfollowResponse as IRawUserUnfollowResponse } from './types/raw/user/Unfollow';
34
104
  export * from './types/ErrorHandler';
35
-
36
- // RAW TYPES
37
- export {
38
- IInitializeMediaUploadResponse,
39
- IListMembersResponse,
40
- IListTweetsResponse,
41
- ITweetDetailsResponse,
42
- ITweetLikeResponse,
43
- ITweetPostResponse,
44
- ITweetRepliesResponse,
45
- ITweetRetweetersResponse,
46
- ITweetRetweetResponse,
47
- ITweetScheduleResponse,
48
- ITweetSearchResponse,
49
- ITweetUnlikeResponse,
50
- ITweetUnpostResponse,
51
- ITweetUnscheduleResponse,
52
- ITweetUnretweetResponse,
53
- } from 'rettiwt-core';
54
- export {
55
- IUserBookmarksResponse,
56
- IUserDetailsResponse,
57
- IUserFollowedResponse,
58
- IUserFollowersResponse,
59
- IUserFollowingResponse,
60
- IUserFollowResponse,
61
- IUserHighlightsResponse,
62
- IUserLikesResponse,
63
- IUserMediaResponse,
64
- IUserNotificationsResponse,
65
- IUserRecommendedResponse,
66
- IUserSubscriptionsResponse,
67
- IUserTweetsAndRepliesResponse,
68
- IUserTweetsResponse,
69
- IUserUnfollowResponse,
70
- } from 'rettiwt-core';
105
+ export * from './types/RettiwtConfig';
@@ -0,0 +1,64 @@
1
+ import { Agent } from 'https';
2
+
3
+ import { HttpsProxyAgent } from 'https-proxy-agent';
4
+
5
+ import { AuthService } from '../services/internal/AuthService';
6
+ import { ITidProvider } from '../types/auth/TidProvider';
7
+ import { IErrorHandler } from '../types/ErrorHandler';
8
+ import { IRettiwtConfig } from '../types/RettiwtConfig';
9
+
10
+ export class RettiwtConfig implements IRettiwtConfig {
11
+ // Parameters for internal use
12
+ private _apiKey?: string;
13
+ private _httpsAgent: Agent;
14
+ private _userId: string | undefined;
15
+
16
+ // Parameters that can be set once, upon initialization
17
+ public readonly delay?: number | (() => number | Promise<number>);
18
+ public readonly errorHandler?: IErrorHandler;
19
+ public readonly logging?: boolean;
20
+ public readonly tidProvider?: ITidProvider;
21
+ public readonly timeout?: number;
22
+
23
+ // Parameters that can be changed on the fly
24
+ public headers?: { [key: string]: string };
25
+
26
+ /**
27
+ * @param config - The config for Rettiwt of type {@link IRettiwtConfig}.
28
+ */
29
+ public constructor(config?: IRettiwtConfig) {
30
+ this._apiKey = config?.apiKey;
31
+ this._httpsAgent = config?.proxyUrl ? new HttpsProxyAgent(config?.proxyUrl) : new Agent();
32
+ this._userId = config?.apiKey ? AuthService.getUserId(config?.apiKey) : undefined;
33
+ this.delay = config?.delay;
34
+ this.errorHandler = config?.errorHandler;
35
+ this.logging = config?.logging;
36
+ this.tidProvider = config?.tidProvider;
37
+ this.timeout = config?.timeout;
38
+ this.apiKey = config?.apiKey;
39
+ this.headers = config?.headers;
40
+ }
41
+
42
+ public get apiKey(): string | undefined {
43
+ return this._apiKey;
44
+ }
45
+
46
+ /** The HTTPS agent instance to use. */
47
+ public get httpsAgent(): Agent {
48
+ return this._httpsAgent;
49
+ }
50
+
51
+ /** The ID of the user associated with the API key, if any. */
52
+ public get userId(): string | undefined {
53
+ return this._userId;
54
+ }
55
+
56
+ public set apiKey(apiKey: string | undefined) {
57
+ this._apiKey = apiKey;
58
+ this._userId = apiKey ? AuthService.getUserId(apiKey) : undefined;
59
+ }
60
+
61
+ public set proxyUrl(proxyUrl: URL | undefined) {
62
+ this._httpsAgent = proxyUrl ? new HttpsProxyAgent(proxyUrl) : new Agent();
63
+ }
64
+ }