rettiwt-api 5.0.0-alpha.4 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/documentation.yml +3 -3
- package/README.md +160 -87
- package/dist/collections/Requests.d.ts +1 -1
- package/dist/collections/Requests.js +3 -2
- package/dist/collections/Requests.js.map +1 -1
- package/dist/collections/Tweet.d.ts +10 -0
- package/dist/collections/Tweet.js +17 -0
- package/dist/collections/Tweet.js.map +1 -0
- package/dist/commands/Tweet.js +0 -16
- package/dist/commands/Tweet.js.map +1 -1
- package/dist/commands/User.js +0 -15
- package/dist/commands/User.js.map +1 -1
- package/dist/enums/Tweet.d.ts +8 -0
- package/dist/enums/Tweet.js +13 -0
- package/dist/enums/Tweet.js.map +1 -0
- package/dist/enums/raw/Tweet.d.ts +11 -1
- package/dist/enums/raw/Tweet.js +13 -2
- package/dist/enums/raw/Tweet.js.map +1 -1
- package/dist/helper/TidUtils.d.ts +2 -0
- package/dist/helper/TidUtils.js +10 -1
- package/dist/helper/TidUtils.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/models/RettiwtConfig.d.ts +27 -3
- package/dist/models/RettiwtConfig.js +37 -4
- package/dist/models/RettiwtConfig.js.map +1 -1
- package/dist/models/args/FetchArgs.d.ts +3 -3
- package/dist/models/args/FetchArgs.js +3 -2
- package/dist/models/args/FetchArgs.js.map +1 -1
- package/dist/models/args/PostArgs.d.ts +2 -3
- package/dist/models/args/PostArgs.js +3 -3
- package/dist/models/args/PostArgs.js.map +1 -1
- package/dist/models/auth/AuthCookie.d.ts +1 -1
- package/dist/models/auth/AuthCookie.js +1 -1
- package/dist/models/auth/AuthCredential.d.ts +1 -1
- package/dist/models/auth/AuthCredential.js +1 -1
- package/dist/models/data/List.d.ts +1 -1
- package/dist/models/data/List.js +1 -1
- package/dist/models/data/List.js.map +1 -1
- package/dist/models/data/Notification.d.ts +1 -1
- package/dist/models/data/Notification.js +1 -1
- package/dist/models/data/Notification.js.map +1 -1
- package/dist/models/data/Tweet.d.ts +1 -1
- package/dist/models/data/Tweet.js +1 -1
- package/dist/models/data/Tweet.js.map +1 -1
- package/dist/models/data/User.d.ts +1 -1
- package/dist/models/data/User.js +1 -1
- package/dist/models/data/User.js.map +1 -1
- package/dist/requests/Tweet.d.ts +2 -1
- package/dist/requests/Tweet.js +3 -4
- package/dist/requests/Tweet.js.map +1 -1
- package/dist/services/internal/AuthService.d.ts +1 -1
- package/dist/services/internal/AuthService.js +1 -1
- package/dist/services/internal/TidService.d.ts +0 -1
- package/dist/services/internal/TidService.js +10 -15
- package/dist/services/internal/TidService.js.map +1 -1
- package/dist/services/public/FetcherService.d.ts +4 -3
- package/dist/services/public/FetcherService.js +6 -5
- package/dist/services/public/FetcherService.js.map +1 -1
- package/dist/services/public/ListService.d.ts +6 -4
- package/dist/services/public/ListService.js +6 -4
- package/dist/services/public/ListService.js.map +1 -1
- package/dist/services/public/TweetService.d.ts +96 -74
- package/dist/services/public/TweetService.js +97 -87
- package/dist/services/public/TweetService.js.map +1 -1
- package/dist/services/public/UserService.d.ts +80 -39
- package/dist/services/public/UserService.js +84 -43
- package/dist/services/public/UserService.js.map +1 -1
- package/dist/types/args/FetchArgs.d.ts +8 -0
- package/package.json +1 -1
- package/src/collections/Requests.ts +5 -2
- package/src/collections/Tweet.ts +17 -0
- package/src/commands/Tweet.ts +0 -16
- package/src/commands/User.ts +0 -15
- package/src/enums/Tweet.ts +8 -0
- package/src/enums/raw/Tweet.ts +12 -1
- package/src/helper/TidUtils.ts +10 -1
- package/src/index.ts +1 -0
- package/src/models/RettiwtConfig.ts +43 -4
- package/src/models/args/FetchArgs.ts +4 -3
- package/src/models/args/PostArgs.ts +3 -4
- package/src/models/auth/AuthCookie.ts +1 -1
- package/src/models/auth/AuthCredential.ts +1 -1
- package/src/models/data/List.ts +1 -1
- package/src/models/data/Notification.ts +1 -1
- package/src/models/data/Tweet.ts +1 -1
- package/src/models/data/User.ts +1 -1
- package/src/requests/Tweet.ts +4 -5
- package/src/services/internal/AuthService.ts +1 -1
- package/src/services/internal/TidService.ts +12 -18
- package/src/services/public/FetcherService.ts +6 -5
- package/src/services/public/ListService.ts +6 -4
- package/src/services/public/TweetService.ts +101 -93
- package/src/services/public/UserService.ts +88 -47
- package/src/types/args/FetchArgs.ts +10 -0
|
@@ -21,14 +21,15 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
21
21
|
/**
|
|
22
22
|
* Get the list affiliates of a user.
|
|
23
23
|
*
|
|
24
|
-
* @param id - The
|
|
24
|
+
* @param id - The ID of the target user. If no id is provided, the logged-in user's id is used.
|
|
25
25
|
* @param count - The number of affiliates to fetch, must be \<= 100.
|
|
26
26
|
* @param cursor - The cursor to the batch of affiliates to fetch.
|
|
27
27
|
*
|
|
28
28
|
* @returns The list of users affiliated to the target user.
|
|
29
29
|
*
|
|
30
30
|
* @example
|
|
31
|
-
*
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
32
33
|
* import { Rettiwt } from 'rettiwt-api';
|
|
33
34
|
*
|
|
34
35
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -48,7 +49,7 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
48
49
|
const resource = Resource_1.EResourceType.USER_AFFILIATES;
|
|
49
50
|
// Fetching raw list of affiliates
|
|
50
51
|
const response = await this.request(resource, {
|
|
51
|
-
id: id,
|
|
52
|
+
id: id ?? this.config.userId,
|
|
52
53
|
count: count,
|
|
53
54
|
cursor: cursor,
|
|
54
55
|
});
|
|
@@ -65,7 +66,8 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
65
66
|
* @returns The list of tweets bookmarked by the target user.
|
|
66
67
|
*
|
|
67
68
|
* @example
|
|
68
|
-
*
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
69
71
|
* import { Rettiwt } from 'rettiwt-api';
|
|
70
72
|
*
|
|
71
73
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -95,15 +97,19 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
95
97
|
/**
|
|
96
98
|
* Get the details of a user.
|
|
97
99
|
*
|
|
98
|
-
* @param id - The username/
|
|
100
|
+
* @param id - The username/ID/IDs of the target user/users. If no ID is provided, the logged-in user's ID is used.
|
|
99
101
|
*
|
|
100
102
|
* @returns
|
|
101
103
|
* The details of the given user.
|
|
104
|
+
*
|
|
105
|
+
* If more than one ID is provided, returns a list.
|
|
106
|
+
*
|
|
102
107
|
* If no user matches the given id, returns `undefined`.
|
|
103
108
|
*
|
|
104
109
|
* @example
|
|
105
|
-
*
|
|
106
|
-
*
|
|
110
|
+
*
|
|
111
|
+
* #### Fetching the details of a single user using username
|
|
112
|
+
* ```ts
|
|
107
113
|
* import { Rettiwt } from 'rettiwt-api';
|
|
108
114
|
*
|
|
109
115
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -120,8 +126,9 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
120
126
|
* ```
|
|
121
127
|
*
|
|
122
128
|
* @example
|
|
123
|
-
*
|
|
124
|
-
*
|
|
129
|
+
*
|
|
130
|
+
* #### Fetching the details of a single user using ID
|
|
131
|
+
* ```ts
|
|
125
132
|
* import { Rettiwt } from 'rettiwt-api';
|
|
126
133
|
*
|
|
127
134
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -130,7 +137,25 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
130
137
|
* // Fetching the details of the User with id '1234567890'
|
|
131
138
|
* rettiwt.user.details('1234567890')
|
|
132
139
|
* .then(res => {
|
|
133
|
-
* console.log(res);
|
|
140
|
+
* console.log(res); # 'res' is a single tweet
|
|
141
|
+
* })
|
|
142
|
+
* .catch(err => {
|
|
143
|
+
* console.log(err);
|
|
144
|
+
* });
|
|
145
|
+
* ```
|
|
146
|
+
* * @example
|
|
147
|
+
*
|
|
148
|
+
* #### Fetching the details of multiple users
|
|
149
|
+
* ```ts
|
|
150
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
151
|
+
*
|
|
152
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
153
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
154
|
+
*
|
|
155
|
+
* // Fetching the details of the users with IDs '123', '456', '789'
|
|
156
|
+
* rettiwt.user.details(['123', '456', '789'])
|
|
157
|
+
* .then(res => {
|
|
158
|
+
* console.log(res); # 'res' is an array of users
|
|
134
159
|
* })
|
|
135
160
|
* .catch(err => {
|
|
136
161
|
* console.log(err);
|
|
@@ -172,14 +197,15 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
172
197
|
/**
|
|
173
198
|
* Follow a user.
|
|
174
199
|
*
|
|
175
|
-
* @param id - The
|
|
200
|
+
* @param id - The ID the user to be followed.
|
|
176
201
|
*
|
|
177
202
|
* @returns Whether following was successful or not.
|
|
178
203
|
*
|
|
179
204
|
* @throws Code 108 if given user id is invalid.
|
|
180
205
|
*
|
|
181
206
|
* @example
|
|
182
|
-
*
|
|
207
|
+
*
|
|
208
|
+
* ```ts
|
|
183
209
|
* import { Rettiwt } from 'rettiwt-api';
|
|
184
210
|
*
|
|
185
211
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -211,7 +237,8 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
211
237
|
* @returns - The followed feed of the logged-in user.
|
|
212
238
|
*
|
|
213
239
|
* @example
|
|
214
|
-
*
|
|
240
|
+
*
|
|
241
|
+
* ```ts
|
|
215
242
|
* import { Rettiwt } from 'rettiwt-api';
|
|
216
243
|
*
|
|
217
244
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -242,14 +269,15 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
242
269
|
/**
|
|
243
270
|
* Get the list followers of a user.
|
|
244
271
|
*
|
|
245
|
-
* @param id - The
|
|
272
|
+
* @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used.
|
|
246
273
|
* @param count - The number of followers to fetch, must be \<= 100.
|
|
247
274
|
* @param cursor - The cursor to the batch of followers to fetch.
|
|
248
275
|
*
|
|
249
276
|
* @returns The list of users following the target user.
|
|
250
277
|
*
|
|
251
278
|
* @example
|
|
252
|
-
*
|
|
279
|
+
*
|
|
280
|
+
* ```ts
|
|
253
281
|
* import { Rettiwt } from 'rettiwt-api';
|
|
254
282
|
*
|
|
255
283
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -269,7 +297,7 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
269
297
|
const resource = Resource_1.EResourceType.USER_FOLLOWERS;
|
|
270
298
|
// Fetching raw list of followers
|
|
271
299
|
const response = await this.request(resource, {
|
|
272
|
-
id: id,
|
|
300
|
+
id: id ?? this.config.userId,
|
|
273
301
|
count: count,
|
|
274
302
|
cursor: cursor,
|
|
275
303
|
});
|
|
@@ -280,14 +308,15 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
280
308
|
/**
|
|
281
309
|
* Get the list of users who are followed by a user.
|
|
282
310
|
*
|
|
283
|
-
* @param id - The
|
|
311
|
+
* @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used.
|
|
284
312
|
* @param count - The number of following to fetch, must be \<= 100.
|
|
285
313
|
* @param cursor - The cursor to the batch of following to fetch.
|
|
286
314
|
*
|
|
287
315
|
* @returns The list of users followed by the target user.
|
|
288
316
|
*
|
|
289
317
|
* @example
|
|
290
|
-
*
|
|
318
|
+
*
|
|
319
|
+
* ```ts
|
|
291
320
|
* import { Rettiwt } from 'rettiwt-api';
|
|
292
321
|
*
|
|
293
322
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -307,7 +336,7 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
307
336
|
const resource = Resource_1.EResourceType.USER_FOLLOWING;
|
|
308
337
|
// Fetching raw list of following
|
|
309
338
|
const response = await this.request(resource, {
|
|
310
|
-
id: id,
|
|
339
|
+
id: id ?? this.config.userId,
|
|
311
340
|
count: count,
|
|
312
341
|
cursor: cursor,
|
|
313
342
|
});
|
|
@@ -318,14 +347,15 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
318
347
|
/**
|
|
319
348
|
* Get the highlighted tweets of a user.
|
|
320
349
|
*
|
|
321
|
-
* @param id - The
|
|
350
|
+
* @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used.
|
|
322
351
|
* @param count - The number of followers to fetch, must be \<= 100.
|
|
323
352
|
* @param cursor - The cursor to the batch of followers to fetch.
|
|
324
353
|
*
|
|
325
354
|
* @returns The list of highlighted tweets of the target user.
|
|
326
355
|
*
|
|
327
356
|
* @example
|
|
328
|
-
*
|
|
357
|
+
*
|
|
358
|
+
* ```ts
|
|
329
359
|
* import { Rettiwt } from 'rettiwt-api';
|
|
330
360
|
*
|
|
331
361
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -345,7 +375,7 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
345
375
|
const resource = Resource_1.EResourceType.USER_HIGHLIGHTS;
|
|
346
376
|
// Fetching raw list of highlights
|
|
347
377
|
const response = await this.request(resource, {
|
|
348
|
-
id: id,
|
|
378
|
+
id: id ?? this.config.userId,
|
|
349
379
|
count: count,
|
|
350
380
|
cursor: cursor,
|
|
351
381
|
});
|
|
@@ -362,7 +392,8 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
362
392
|
* @returns The list of tweets liked by the target user.
|
|
363
393
|
*
|
|
364
394
|
* @example
|
|
365
|
-
*
|
|
395
|
+
*
|
|
396
|
+
* ```ts
|
|
366
397
|
* import { Rettiwt } from 'rettiwt-api';
|
|
367
398
|
*
|
|
368
399
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -393,14 +424,15 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
393
424
|
/**
|
|
394
425
|
* Get the media timeline of a user.
|
|
395
426
|
*
|
|
396
|
-
* @param id - The
|
|
427
|
+
* @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used.
|
|
397
428
|
* @param count - The number of media to fetch, must be \<= 100.
|
|
398
429
|
* @param cursor - The cursor to the batch of media to fetch
|
|
399
430
|
*
|
|
400
431
|
* @returns The media timeline of the target user.
|
|
401
432
|
*
|
|
402
433
|
* @example
|
|
403
|
-
*
|
|
434
|
+
*
|
|
435
|
+
* ```ts
|
|
404
436
|
* import { Rettiwt } from 'rettiwt-api';
|
|
405
437
|
*
|
|
406
438
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -420,7 +452,7 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
420
452
|
const resource = Resource_1.EResourceType.USER_MEDIA;
|
|
421
453
|
// Fetching raw list of media
|
|
422
454
|
const response = await this.request(resource, {
|
|
423
|
-
id: id,
|
|
455
|
+
id: id ?? this.config.userId,
|
|
424
456
|
count: count,
|
|
425
457
|
cursor: cursor,
|
|
426
458
|
});
|
|
@@ -436,7 +468,8 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
436
468
|
* @returns An async generator that yields new notifications as they are received.
|
|
437
469
|
*
|
|
438
470
|
* @example
|
|
439
|
-
*
|
|
471
|
+
*
|
|
472
|
+
* ```ts
|
|
440
473
|
* import { Rettiwt } from 'rettiwt-api';
|
|
441
474
|
*
|
|
442
475
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -446,7 +479,7 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
446
479
|
* async function streamNotifications() {
|
|
447
480
|
* try {
|
|
448
481
|
* // Awaiting for the notifications returned by the AsyncGenerator returned by the method
|
|
449
|
-
* for await (const notification of rettiwt.user.notifications(
|
|
482
|
+
* for await (const notification of rettiwt.user.notifications(5000)) {
|
|
450
483
|
* console.log(notification.message);
|
|
451
484
|
* }
|
|
452
485
|
* }
|
|
@@ -499,7 +532,8 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
499
532
|
* @returns - The recommended feed of the logged-in user.
|
|
500
533
|
*
|
|
501
534
|
* @example
|
|
502
|
-
*
|
|
535
|
+
*
|
|
536
|
+
* ```ts
|
|
503
537
|
* import { Rettiwt } from 'rettiwt-api';
|
|
504
538
|
*
|
|
505
539
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -530,14 +564,15 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
530
564
|
/**
|
|
531
565
|
* Get the reply timeline of a user.
|
|
532
566
|
*
|
|
533
|
-
* @param id - The
|
|
567
|
+
* @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used.
|
|
534
568
|
* @param count - The number of replies to fetch, must be \<= 20.
|
|
535
569
|
* @param cursor - The cursor to the batch of replies to fetch.
|
|
536
570
|
*
|
|
537
571
|
* @returns The reply timeline of the target user.
|
|
538
572
|
*
|
|
539
573
|
* @example
|
|
540
|
-
*
|
|
574
|
+
*
|
|
575
|
+
* ```ts
|
|
541
576
|
* import { Rettiwt } from 'rettiwt-api';
|
|
542
577
|
*
|
|
543
578
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -553,13 +588,15 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
553
588
|
* });
|
|
554
589
|
* ```
|
|
555
590
|
*
|
|
556
|
-
* @remarks
|
|
591
|
+
* @remarks
|
|
592
|
+
*
|
|
593
|
+
* If the target user has a pinned tweet, the returned reply timeline has one item extra and this is always the pinned tweet.
|
|
557
594
|
*/
|
|
558
595
|
async replies(id, count, cursor) {
|
|
559
596
|
const resource = Resource_1.EResourceType.USER_TIMELINE_AND_REPLIES;
|
|
560
597
|
// Fetching raw list of replies
|
|
561
598
|
const response = await this.request(resource, {
|
|
562
|
-
id: id,
|
|
599
|
+
id: id ?? this.config.userId,
|
|
563
600
|
count: count,
|
|
564
601
|
cursor: cursor,
|
|
565
602
|
});
|
|
@@ -570,14 +607,17 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
570
607
|
/**
|
|
571
608
|
* Get the list of subscriptions of a user.
|
|
572
609
|
*
|
|
573
|
-
* @
|
|
610
|
+
* @deprecated Currently not working.
|
|
611
|
+
*
|
|
612
|
+
* @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used.
|
|
574
613
|
* @param count - The number of subscriptions to fetch, must be \<= 100.
|
|
575
614
|
* @param cursor - The cursor to the batch of subscriptions to fetch.
|
|
576
615
|
*
|
|
577
616
|
* @returns The list of subscriptions by the target user.
|
|
578
617
|
*
|
|
579
618
|
* @example
|
|
580
|
-
*
|
|
619
|
+
*
|
|
620
|
+
* ```ts
|
|
581
621
|
* import { Rettiwt } from 'rettiwt-api';
|
|
582
622
|
*
|
|
583
623
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -597,7 +637,7 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
597
637
|
const resource = Resource_1.EResourceType.USER_SUBSCRIPTIONS;
|
|
598
638
|
// Fetching raw list of subscriptions
|
|
599
639
|
const response = await this.request(resource, {
|
|
600
|
-
id: id,
|
|
640
|
+
id: id ?? this.config.userId,
|
|
601
641
|
count: count,
|
|
602
642
|
cursor: cursor,
|
|
603
643
|
});
|
|
@@ -608,14 +648,15 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
608
648
|
/**
|
|
609
649
|
* Get the tweet timeline of a user.
|
|
610
650
|
*
|
|
611
|
-
* @param id - The
|
|
651
|
+
* @param id - The ID of the target user. If no ID is provided, the logged-in user's ID is used.
|
|
612
652
|
* @param count - The number of timeline items to fetch, must be \<= 20.
|
|
613
653
|
* @param cursor - The cursor to the batch of timeline items to fetch.
|
|
614
654
|
*
|
|
615
655
|
* @returns The timeline of the target user.
|
|
616
656
|
*
|
|
617
657
|
* @example
|
|
618
|
-
*
|
|
658
|
+
*
|
|
659
|
+
* ```ts
|
|
619
660
|
* import { Rettiwt } from 'rettiwt-api';
|
|
620
661
|
*
|
|
621
662
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -632,6 +673,7 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
632
673
|
* ```
|
|
633
674
|
*
|
|
634
675
|
* @remarks
|
|
676
|
+
*
|
|
635
677
|
* - If the target user has a pinned tweet, the returned timeline has one item extra and this is always the pinned tweet.
|
|
636
678
|
* - If timeline is fetched without authenticating, then the most popular tweets of the target user are returned instead.
|
|
637
679
|
*/
|
|
@@ -639,7 +681,7 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
639
681
|
const resource = Resource_1.EResourceType.USER_TIMELINE;
|
|
640
682
|
// Fetching raw list of tweets
|
|
641
683
|
const response = await this.request(resource, {
|
|
642
|
-
id: id,
|
|
684
|
+
id: id ?? this.config.userId,
|
|
643
685
|
count: count,
|
|
644
686
|
cursor: cursor,
|
|
645
687
|
});
|
|
@@ -650,14 +692,13 @@ class UserService extends FetcherService_1.FetcherService {
|
|
|
650
692
|
/**
|
|
651
693
|
* Unfollow a user.
|
|
652
694
|
*
|
|
653
|
-
* @param id - The
|
|
695
|
+
* @param id - The ID the user to be unfollowed.
|
|
654
696
|
*
|
|
655
697
|
* @returns Whether unfollowing was successful or not.
|
|
656
698
|
*
|
|
657
|
-
* @throws Code 34 if given user id is invalid.
|
|
658
|
-
*
|
|
659
699
|
* @example
|
|
660
|
-
*
|
|
700
|
+
*
|
|
701
|
+
* ```ts
|
|
661
702
|
* import { Rettiwt } from 'rettiwt-api';
|
|
662
703
|
*
|
|
663
704
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../../src/services/public/UserService.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAC1D,mDAAqD;AAwBrD,qDAAkD;AAElD;;;;GAIG;AACH,MAAa,WAAY,SAAQ,+BAAc;IAC9C;;;;OAIG;IACH,YAAmB,MAAqB;QACvC,KAAK,CAAC,MAAM,CAAC,CAAC;IACf,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"UserService.js","source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,CAAC;QAE5C,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACI,KAAK,CAAC,QAAQ,CAAC,EAAU;QAC/B,MAAM,QAAQ,GAAG,wBAAa,CAAC,aAAa,CAAC;QAE7C,uBAAuB;QACvB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAwB,wBAAa,CAAC,aAAa,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAEpG,6BAA6B;QAC7B,MAAM,IAAI,GAAG,uBAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC;QAErD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AArxBD,kCAqxBC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ETweetRepliesSortType } from '../../enums/Tweet';
|
|
1
2
|
/**
|
|
2
3
|
* Options specifying the data that is to be fetched.
|
|
3
4
|
*
|
|
@@ -51,6 +52,13 @@ export interface IFetchArgs {
|
|
|
51
52
|
* - Required only for {@link EResourceType.TWEET_DETAILS_BULK} and {@link EResourceType.USER_DETAILS_BY_IDS_BULK}.
|
|
52
53
|
*/
|
|
53
54
|
ids?: string[];
|
|
55
|
+
/**
|
|
56
|
+
* The sorting to use for tweet results.
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* - Only works for {@link EResourceType.TWEET_REPLIES}.
|
|
60
|
+
*/
|
|
61
|
+
sortBy?: ETweetRepliesSortType;
|
|
54
62
|
}
|
|
55
63
|
/**
|
|
56
64
|
* The filter to be used for searching tweets.
|
package/package.json
CHANGED
|
@@ -8,8 +8,10 @@ import { UserRequests } from '../requests/User';
|
|
|
8
8
|
import { IFetchArgs } from '../types/args/FetchArgs';
|
|
9
9
|
import { IPostArgs } from '../types/args/PostArgs';
|
|
10
10
|
|
|
11
|
+
import { rawTweetRepliesSortType } from './Tweet';
|
|
12
|
+
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
14
|
+
* Collection of requests to various resources.
|
|
13
15
|
*
|
|
14
16
|
* @internal
|
|
15
17
|
*/
|
|
@@ -29,7 +31,8 @@ export const requests: { [key in keyof typeof EResourceType]: (args: IFetchArgs
|
|
|
29
31
|
TWEET_LIKE: (args: IPostArgs) => TweetRequests.like(args.id!),
|
|
30
32
|
TWEET_LIKERS: (args: IFetchArgs) => TweetRequests.likers(args.id!, args.count, args.cursor),
|
|
31
33
|
TWEET_POST: (args: IPostArgs) => TweetRequests.post(args.tweet!),
|
|
32
|
-
TWEET_REPLIES: (args: IFetchArgs) =>
|
|
34
|
+
TWEET_REPLIES: (args: IFetchArgs) =>
|
|
35
|
+
TweetRequests.replies(args.id!, args.cursor, args.sortBy ? rawTweetRepliesSortType[args.sortBy] : undefined),
|
|
33
36
|
TWEET_RETWEET: (args: IPostArgs) => TweetRequests.retweet(args.id!),
|
|
34
37
|
TWEET_RETWEETERS: (args: IFetchArgs) => TweetRequests.retweeters(args.id!, args.count, args.cursor),
|
|
35
38
|
TWEET_SCHEDULE: (args: IPostArgs) => TweetRequests.schedule(args.tweet!),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ERawTweetRepliesSortType } from '../enums/raw/Tweet';
|
|
2
|
+
import { ETweetRepliesSortType } from '../enums/Tweet';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Collection of mapping from parsed reply sort type to raw reply sort type.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export const rawTweetRepliesSortType: { [key in keyof typeof ETweetRepliesSortType]: ERawTweetRepliesSortType } = {
|
|
10
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
11
|
+
|
|
12
|
+
LATEST: ERawTweetRepliesSortType.LATEST,
|
|
13
|
+
LIKES: ERawTweetRepliesSortType.LIKES,
|
|
14
|
+
RELEVANCE: ERawTweetRepliesSortType.RELEVACE,
|
|
15
|
+
|
|
16
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
17
|
+
};
|
package/src/commands/Tweet.ts
CHANGED
|
@@ -70,22 +70,6 @@ function createTweetCommand(rettiwt: Rettiwt): Command {
|
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
// List
|
|
74
|
-
tweet
|
|
75
|
-
.command('list')
|
|
76
|
-
.description('Fetch the list of tweets in the tweet list with the given id')
|
|
77
|
-
.argument('<id>', 'The id of the tweet list')
|
|
78
|
-
.argument('[count]', 'The number of tweets to fetch')
|
|
79
|
-
.argument('[cursor]', 'The cursor to the batch of tweets to fetch')
|
|
80
|
-
.action(async (id: string, count?: string, cursor?: string) => {
|
|
81
|
-
try {
|
|
82
|
-
const tweets = await rettiwt.tweet.list(id, count ? parseInt(count) : undefined, cursor);
|
|
83
|
-
output(tweets);
|
|
84
|
-
} catch (error) {
|
|
85
|
-
output(error);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
73
|
// Post
|
|
90
74
|
tweet
|
|
91
75
|
.command('post')
|
package/src/commands/User.ts
CHANGED
|
@@ -193,21 +193,6 @@ function createUserCommand(rettiwt: Rettiwt): Command {
|
|
|
193
193
|
}
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
-
// Subscriptions
|
|
197
|
-
user.command('subscriptions')
|
|
198
|
-
.description('Fetch the list of users who are subscribed by the given user')
|
|
199
|
-
.argument('<id>', 'The id of the user')
|
|
200
|
-
.argument('[count]', 'The number of subscriptions to fetch')
|
|
201
|
-
.argument('[cursor]', 'The cursor to the batch of subscriptions to fetch')
|
|
202
|
-
.action(async (id: string, count?: string, cursor?: string) => {
|
|
203
|
-
try {
|
|
204
|
-
const users = await rettiwt.user.subscriptions(id, count ? parseInt(count) : undefined, cursor);
|
|
205
|
-
output(users);
|
|
206
|
-
} catch (error) {
|
|
207
|
-
output(error);
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
|
|
211
196
|
// Timeline
|
|
212
197
|
user.command('timeline')
|
|
213
198
|
.description('Fetch the tweets timeline the given user')
|
package/src/enums/raw/Tweet.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The different types of search results when searching for
|
|
2
|
+
* The different types of search results when searching for tweets.
|
|
3
3
|
*
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
@@ -7,3 +7,14 @@ export enum ERawTweetSearchResultType {
|
|
|
7
7
|
LATEST = 'Latest',
|
|
8
8
|
TOP = 'Top',
|
|
9
9
|
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The different types of sorting options when fetching replies to tweets.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export enum ERawTweetRepliesSortType {
|
|
17
|
+
RELEVACE = 'Relevance',
|
|
18
|
+
LATEST = 'Recency',
|
|
19
|
+
LIKES = 'Likes',
|
|
20
|
+
}
|
package/src/helper/TidUtils.ts
CHANGED
|
@@ -2,8 +2,17 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
|
|
3
3
|
import { ITidParams } from '../types/auth/TidParams';
|
|
4
4
|
|
|
5
|
+
export function getUnixTime(): number {
|
|
6
|
+
const [seconds, nanoseconds] = process.hrtime();
|
|
7
|
+
return Date.now() / 1000 + seconds + nanoseconds / 1e9;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getNanosecondPrecisionTime(): number {
|
|
11
|
+
return Number(((BigInt(Date.now()) * 1000000n + process.hrtime.bigint()) * 1000n) / BigInt(1000000)) / 1000000;
|
|
12
|
+
}
|
|
13
|
+
|
|
5
14
|
export function calculateClientTransactionIdHeader(args: ITidParams): string {
|
|
6
|
-
const time = Math.floor(((args.time ||
|
|
15
|
+
const time = Math.floor(((args.time || getUnixTime()) * 1000 - 1682924400 * 1000) / 1000);
|
|
7
16
|
const timeBuffer = new Uint8Array(new Uint32Array([time]).buffer);
|
|
8
17
|
|
|
9
18
|
const keyBytes = Array.from(Buffer.from(args.verificationKey, 'base64'));
|
package/src/index.ts
CHANGED