rettiwt-api 4.0.0 → 4.1.0-alpha.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.
- package/.github/workflows/publish-alpha.yml +29 -0
- package/dist/collections/Extractors.d.ts +3 -1
- package/dist/collections/Extractors.js +3 -0
- package/dist/collections/Extractors.js.map +1 -1
- package/dist/collections/Groups.js +1 -0
- package/dist/collections/Groups.js.map +1 -1
- package/dist/collections/Requests.js +1 -0
- package/dist/collections/Requests.js.map +1 -1
- package/dist/commands/User.js +39 -15
- package/dist/commands/User.js.map +1 -1
- package/dist/enums/Data.d.ts +1 -0
- package/dist/enums/Data.js +1 -0
- package/dist/enums/Data.js.map +1 -1
- package/dist/enums/Resource.d.ts +1 -0
- package/dist/enums/Resource.js +1 -0
- package/dist/enums/Resource.js.map +1 -1
- package/dist/helper/JsonUtils.js +1 -1
- package/dist/helper/JsonUtils.js.map +1 -1
- package/dist/models/args/FetchArgs.js +13 -1
- package/dist/models/args/FetchArgs.js.map +1 -1
- package/dist/models/data/CursoredData.d.ts +3 -3
- package/dist/models/data/CursoredData.js +5 -1
- package/dist/models/data/CursoredData.js.map +1 -1
- package/dist/models/data/Notification.d.ts +46 -0
- package/dist/models/data/Notification.js +69 -0
- package/dist/models/data/Notification.js.map +1 -0
- package/dist/models/data/Tweet.d.ts +3 -3
- package/dist/models/data/Tweet.js.map +1 -1
- package/dist/models/data/User.d.ts +3 -3
- package/dist/models/data/User.js.map +1 -1
- package/dist/services/public/UserService.d.ts +28 -1
- package/dist/services/public/UserService.js +47 -1
- package/dist/services/public/UserService.js.map +1 -1
- package/package.json +2 -2
- package/src/collections/Extractors.ts +4 -0
- package/src/collections/Groups.ts +1 -0
- package/src/collections/Requests.ts +1 -0
- package/src/commands/User.ts +14 -0
- package/src/enums/Data.ts +1 -0
- package/src/enums/Resource.ts +1 -0
- package/src/helper/JsonUtils.ts +1 -1
- package/src/models/args/FetchArgs.ts +13 -1
- package/src/models/data/CursoredData.ts +7 -4
- package/src/models/data/Notification.ts +91 -0
- package/src/models/data/Tweet.ts +2 -3
- package/src/models/data/User.ts +3 -3
- package/src/services/public/UserService.ts +46 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EMediaType, IExtendedMedia as IRawExtendedMedia, ITweet as IRawTweet, IEntities as IRawTweetEntities
|
|
1
|
+
import { EMediaType, IExtendedMedia as IRawExtendedMedia, ITweet as IRawTweet, IEntities as IRawTweetEntities } from 'rettiwt-core';
|
|
2
2
|
import { User } from './User';
|
|
3
3
|
/**
|
|
4
4
|
* The details of a single tweet.
|
|
@@ -51,7 +51,7 @@ export declare class Tweet {
|
|
|
51
51
|
*
|
|
52
52
|
* @internal
|
|
53
53
|
*/
|
|
54
|
-
static list(response:
|
|
54
|
+
static list(response: NonNullable<unknown>): Tweet[];
|
|
55
55
|
/**
|
|
56
56
|
* Extracts and deserializes a single target tweet from the given raw response data.
|
|
57
57
|
*
|
|
@@ -62,7 +62,7 @@ export declare class Tweet {
|
|
|
62
62
|
*
|
|
63
63
|
* @internal
|
|
64
64
|
*/
|
|
65
|
-
static single(response:
|
|
65
|
+
static single(response: NonNullable<unknown>, id: string): Tweet | undefined;
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* The different types parsed entities like urls, media, mentions, hashtags, etc.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tweet.js","sourceRoot":"","sources":["../../../src/models/data/Tweet.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Tweet.js","sourceRoot":"","sources":["../../../src/models/data/Tweet.ts"],"names":[],"mappings":";;;AAAA,6CAOsB;AAEtB,+CAAkD;AAClD,oDAAsD;AAEtD,iEAAgE;AAEhE,+BAA8B;AAE9B;;;;GAIG;AACH;IAiDC;;OAEG;IACH,eAAmB,KAAgB;;QAClC,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC;QACxB,IAAI,CAAC,SAA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eAEG;YACH,MAAA,KAAK,CAAC,UAAU,0CAAE,QAAQ,CAAC,OAAO,CAAC,UAAC,OAAO;gBAC1C,IAAI,OAAO,CAAC,OAAO,GAAG,aAAW,EAAE;oBAClC,aAAW,GAAG,OAAO,CAAC,OAAO,CAAC;oBAC9B,KAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;iBACvB;YACF,CAAC,CAAC,CAAC;SACH;IACF,CAAC;IACF,iBAAC;AAAD,CAAC,AArCD,IAqCC;AArCY,gCAAU"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IUser as IRawUser
|
|
1
|
+
import { IUser as IRawUser } from 'rettiwt-core';
|
|
2
2
|
/**
|
|
3
3
|
* The details of a single user.
|
|
4
4
|
*
|
|
@@ -46,7 +46,7 @@ export declare class User {
|
|
|
46
46
|
*
|
|
47
47
|
* @internal
|
|
48
48
|
*/
|
|
49
|
-
static list(response:
|
|
49
|
+
static list(response: NonNullable<unknown>): User[];
|
|
50
50
|
/**
|
|
51
51
|
* Extracts and deserializes a single target user from the given raw response data.
|
|
52
52
|
*
|
|
@@ -56,5 +56,5 @@ export declare class User {
|
|
|
56
56
|
*
|
|
57
57
|
* @internal
|
|
58
58
|
*/
|
|
59
|
-
static single(response:
|
|
59
|
+
static single(response: NonNullable<unknown>): User | undefined;
|
|
60
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../src/models/data/User.ts"],"names":[],"mappings":";;;AAEA,+CAAkD;AAClD,oDAAsD;AACtD,iEAAgE;AAEhE;;;;GAIG;AACH;IA2CC;;OAEG;IACH,cAAmB,IAAc;QAChC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QACjC,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W,CAAC,OAAO,EAAE;oBACnC,MAAM,EAAE,qBAAW,CAAC,WAAW;oBAC/B,OAAO,EAAE,0BAA0B;iBACnC,CAAC,CAAC;aACH;SACD;QAED,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5C,CAAC;IACF,WAAC;AAAD,CAAC,AAlID,IAkIC;AAlIY,oBAAI"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CursoredData } from '../../models/data/CursoredData';
|
|
2
|
+
import { Notification } from '../../models/data/Notification';
|
|
2
3
|
import { Tweet } from '../../models/data/Tweet';
|
|
3
4
|
import { User } from '../../models/data/User';
|
|
4
5
|
import { IRettiwtConfig } from '../../types/RettiwtConfig';
|
|
@@ -223,7 +224,7 @@ export declare class UserService extends FetcherService {
|
|
|
223
224
|
*/
|
|
224
225
|
likes(count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
225
226
|
/**
|
|
226
|
-
* Get the media timeline of a user
|
|
227
|
+
* Get the media timeline of a user.
|
|
227
228
|
*
|
|
228
229
|
* @param id - The id of the target user.
|
|
229
230
|
* @param count - The number of media to fetch, must be \<= 100.
|
|
@@ -249,6 +250,32 @@ export declare class UserService extends FetcherService {
|
|
|
249
250
|
* ```
|
|
250
251
|
*/
|
|
251
252
|
media(id: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
|
|
253
|
+
/**
|
|
254
|
+
* Get the list of notifications of the logged in user.
|
|
255
|
+
*
|
|
256
|
+
* @param count - The number of notifications to fetch, must be \<= 40.
|
|
257
|
+
* @param cursor - The cursor to the batch of notifications to fetch
|
|
258
|
+
*
|
|
259
|
+
* @returns The list of notifications of the target user.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```
|
|
263
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
264
|
+
*
|
|
265
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
266
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
267
|
+
*
|
|
268
|
+
* // Fetching the recent 40 Notifications of the logged in user
|
|
269
|
+
* rettiwt.user.notifications(40)
|
|
270
|
+
* .then(res => {
|
|
271
|
+
* console.log(res);
|
|
272
|
+
* })
|
|
273
|
+
* .catch(err => {
|
|
274
|
+
* console.log(err);
|
|
275
|
+
* });
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
notifications(count?: number, cursor?: string): Promise<CursoredData<Notification>>;
|
|
252
279
|
/**
|
|
253
280
|
* Get the recommended feed of the logged in user.
|
|
254
281
|
*
|
|
@@ -409,7 +409,7 @@ var UserService = /** @class */ (function (_super) {
|
|
|
409
409
|
});
|
|
410
410
|
};
|
|
411
411
|
/**
|
|
412
|
-
* Get the media timeline of a user
|
|
412
|
+
* Get the media timeline of a user.
|
|
413
413
|
*
|
|
414
414
|
* @param id - The id of the target user.
|
|
415
415
|
* @param count - The number of media to fetch, must be \<= 100.
|
|
@@ -454,6 +454,52 @@ var UserService = /** @class */ (function (_super) {
|
|
|
454
454
|
});
|
|
455
455
|
});
|
|
456
456
|
};
|
|
457
|
+
/**
|
|
458
|
+
* Get the list of notifications of the logged in user.
|
|
459
|
+
*
|
|
460
|
+
* @param count - The number of notifications to fetch, must be \<= 40.
|
|
461
|
+
* @param cursor - The cursor to the batch of notifications to fetch
|
|
462
|
+
*
|
|
463
|
+
* @returns The list of notifications of the target user.
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* ```
|
|
467
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
468
|
+
*
|
|
469
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
470
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
471
|
+
*
|
|
472
|
+
* // Fetching the recent 40 Notifications of the logged in user
|
|
473
|
+
* rettiwt.user.notifications(40)
|
|
474
|
+
* .then(res => {
|
|
475
|
+
* console.log(res);
|
|
476
|
+
* })
|
|
477
|
+
* .catch(err => {
|
|
478
|
+
* console.log(err);
|
|
479
|
+
* });
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
UserService.prototype.notifications = function (count, cursor) {
|
|
483
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
484
|
+
var resource, response, data;
|
|
485
|
+
return __generator(this, function (_a) {
|
|
486
|
+
switch (_a.label) {
|
|
487
|
+
case 0:
|
|
488
|
+
resource = Resource_1.EResourceType.USER_NOTIFICATIONS;
|
|
489
|
+
return [4 /*yield*/, this.request(resource, {
|
|
490
|
+
count: count,
|
|
491
|
+
cursor: cursor,
|
|
492
|
+
})];
|
|
493
|
+
case 1:
|
|
494
|
+
response = _a.sent();
|
|
495
|
+
data = Extractors_1.extractors[resource](response);
|
|
496
|
+
// Sorting the notifications by time, from recent to oldest
|
|
497
|
+
data.list.sort(function (a, b) { return new Date(b.receivedAt).valueOf() - new Date(a.receivedAt).valueOf(); });
|
|
498
|
+
return [2 /*return*/, data];
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
});
|
|
502
|
+
};
|
|
457
503
|
/**
|
|
458
504
|
* Get the recommended feed of the logged in user.
|
|
459
505
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../../src/services/public/UserService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../../src/services/public/UserService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,2DAA0D;AAC1D,iDAAqD;AAOrD,mDAAkD;AAElD;;;;GAIG;AACH;IAAiC,+BAAc;IAC9C;;;;OAIG;IACH,qBAAmB,MAAuB;eACzC,kBAAM,MAAM,CAAC;IACd,CAAC;IAED;;;;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;;KACZ;IACF,kBAAC;AAAD,CAAC,AAvmBD,CAAiC,+BAAc,GAumB9C;AAvmBY,kCAAW"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rettiwt-api",
|
|
3
|
-
"version": "4.0.0",
|
|
3
|
+
"version": "4.1.0-alpha.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"description": "An API for fetching data from TwitterAPI, without any rate limits!",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"commander": "11.1.0",
|
|
37
37
|
"https-proxy-agent": "7.0.2",
|
|
38
38
|
"rettiwt-auth": "2.1.0",
|
|
39
|
-
"rettiwt-core": "4.
|
|
39
|
+
"rettiwt-core": "4.3.0-alpha.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "20.4.1",
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
IUserHighlightsResponse,
|
|
22
22
|
IUserLikesResponse,
|
|
23
23
|
IUserMediaResponse,
|
|
24
|
+
IUserNotifications as IUserNotificationsResponse,
|
|
24
25
|
IUserRecommendedResponse,
|
|
25
26
|
IUserSubscriptionsResponse,
|
|
26
27
|
IUserTweetsAndRepliesResponse,
|
|
@@ -30,6 +31,7 @@ import {
|
|
|
30
31
|
|
|
31
32
|
import { EBaseType } from '../enums/Data';
|
|
32
33
|
import { CursoredData } from '../models/data/CursoredData';
|
|
34
|
+
import { Notification } from '../models/data/Notification';
|
|
33
35
|
import { Tweet } from '../models/data/Tweet';
|
|
34
36
|
import { User } from '../models/data/User';
|
|
35
37
|
|
|
@@ -82,6 +84,8 @@ export const extractors = {
|
|
|
82
84
|
new CursoredData<Tweet>(response, EBaseType.TWEET),
|
|
83
85
|
USER_MEDIA: (response: IUserMediaResponse): CursoredData<Tweet> =>
|
|
84
86
|
new CursoredData<Tweet>(response, EBaseType.TWEET),
|
|
87
|
+
USER_NOTIFICATIONS: (response: IUserNotificationsResponse): CursoredData<Notification> =>
|
|
88
|
+
new CursoredData<Notification>(response, EBaseType.NOTIFICATION),
|
|
85
89
|
USER_SUBSCRIPTIONS: (response: IUserSubscriptionsResponse): CursoredData<User> =>
|
|
86
90
|
new CursoredData<User>(response, EBaseType.USER),
|
|
87
91
|
USER_TIMELINE: (response: IUserTweetsResponse): CursoredData<Tweet> =>
|
|
@@ -31,6 +31,7 @@ export const fetchResources = [
|
|
|
31
31
|
EResourceType.USER_HIGHLIGHTS,
|
|
32
32
|
EResourceType.USER_LIKES,
|
|
33
33
|
EResourceType.USER_MEDIA,
|
|
34
|
+
EResourceType.USER_NOTIFICATIONS,
|
|
34
35
|
EResourceType.USER_SUBSCRIPTIONS,
|
|
35
36
|
EResourceType.USER_TIMELINE,
|
|
36
37
|
EResourceType.USER_TIMELINE_AND_REPLIES,
|
|
@@ -48,6 +48,7 @@ export const requests: { [key in keyof typeof EResourceType]: (args: FetchArgs |
|
|
|
48
48
|
USER_HIGHLIGHTS: (args: FetchArgs) => request.user.highlights(args.id!, args.count, args.cursor),
|
|
49
49
|
USER_LIKES: (args: FetchArgs) => request.user.likes(args.id!, args.count, args.cursor),
|
|
50
50
|
USER_MEDIA: (args: FetchArgs) => request.user.media(args.id!, args.count, args.cursor),
|
|
51
|
+
USER_NOTIFICATIONS: (args: FetchArgs) => request.user.notifications(args.count, args.cursor),
|
|
51
52
|
USER_SUBSCRIPTIONS: (args: FetchArgs) => request.user.subscriptions(args.id!, args.count, args.cursor),
|
|
52
53
|
USER_TIMELINE: (args: FetchArgs) => request.user.tweets(args.id!, args.count, args.cursor),
|
|
53
54
|
USER_TIMELINE_AND_REPLIES: (args: FetchArgs) => request.user.tweetsAndReplies(args.id!, args.count, args.cursor),
|
package/src/commands/User.ts
CHANGED
|
@@ -126,6 +126,20 @@ function createUserCommand(rettiwt: Rettiwt): Command {
|
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
+
// Notifications
|
|
130
|
+
user.command('notifications')
|
|
131
|
+
.description('Fetch you list of notifications')
|
|
132
|
+
.argument('[count]', 'The number of notifications to fetch')
|
|
133
|
+
.argument('[cursor]', 'The cursor to the batch of notifications to fetch')
|
|
134
|
+
.action(async (count?: string, cursor?: string) => {
|
|
135
|
+
try {
|
|
136
|
+
const notifications = await rettiwt.user.notifications(count ? parseInt(count) : undefined, cursor);
|
|
137
|
+
output(notifications);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
output(error);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
129
143
|
// Recommended
|
|
130
144
|
user.command('recommended')
|
|
131
145
|
.description('Fetch your recommended feed')
|
package/src/enums/Data.ts
CHANGED
package/src/enums/Resource.ts
CHANGED
|
@@ -37,6 +37,7 @@ export enum EResourceType {
|
|
|
37
37
|
USER_HIGHLIGHTS = 'USER_HIGHLIGHTS',
|
|
38
38
|
USER_LIKES = 'USER_LIKES',
|
|
39
39
|
USER_MEDIA = 'USER_MEDIA',
|
|
40
|
+
USER_NOTIFICATIONS = 'USER_NOTIFICATIONS',
|
|
40
41
|
USER_SUBSCRIPTIONS = 'USER_SUBSCRIPTIONS',
|
|
41
42
|
USER_TIMELINE = 'USER_TIMELINE',
|
|
42
43
|
USER_TIMELINE_AND_REPLIES = 'USER_TIMELINE_AND_REPLIES',
|
package/src/helper/JsonUtils.ts
CHANGED
|
@@ -27,7 +27,7 @@ export function findByFilter<T>(data: NonNullable<unknown>, key: string, value:
|
|
|
27
27
|
res = res.concat(...data.map((item) => findByFilter<T>(item as NonNullable<unknown>, key, value)));
|
|
28
28
|
}
|
|
29
29
|
// If the data is an object
|
|
30
|
-
else if (typeof data == 'object') {
|
|
30
|
+
else if (data != null && typeof data == 'object') {
|
|
31
31
|
/**
|
|
32
32
|
* If the object includes the key and the value specified by the key matches the filter, add it to the result.
|
|
33
33
|
*/
|
|
@@ -60,6 +60,7 @@ export class FetchArgs {
|
|
|
60
60
|
EResourceType.USER_HIGHLIGHTS,
|
|
61
61
|
EResourceType.USER_LIKES,
|
|
62
62
|
EResourceType.USER_MEDIA,
|
|
63
|
+
EResourceType.USER_NOTIFICATIONS,
|
|
63
64
|
EResourceType.USER_SUBSCRIPTIONS,
|
|
64
65
|
EResourceType.USER_TIMELINE,
|
|
65
66
|
EResourceType.USER_TIMELINE_AND_REPLIES,
|
|
@@ -75,6 +76,7 @@ export class FetchArgs {
|
|
|
75
76
|
EResourceType.USER_HIGHLIGHTS,
|
|
76
77
|
EResourceType.USER_LIKES,
|
|
77
78
|
EResourceType.USER_MEDIA,
|
|
79
|
+
EResourceType.USER_NOTIFICATIONS,
|
|
78
80
|
EResourceType.USER_SUBSCRIPTIONS,
|
|
79
81
|
EResourceType.USER_TIMELINE,
|
|
80
82
|
EResourceType.USER_TIMELINE_AND_REPLIES,
|
|
@@ -92,6 +94,9 @@ export class FetchArgs {
|
|
|
92
94
|
EResourceType.USER_SUBSCRIPTIONS,
|
|
93
95
|
],
|
|
94
96
|
})
|
|
97
|
+
@Max(40, {
|
|
98
|
+
groups: [EResourceType.USER_NOTIFICATIONS],
|
|
99
|
+
})
|
|
95
100
|
@Max(20, {
|
|
96
101
|
groups: [EResourceType.TWEET_SEARCH, EResourceType.USER_TIMELINE, EResourceType.USER_TIMELINE_AND_REPLIES],
|
|
97
102
|
})
|
|
@@ -124,6 +129,7 @@ export class FetchArgs {
|
|
|
124
129
|
EResourceType.USER_HIGHLIGHTS,
|
|
125
130
|
EResourceType.USER_LIKES,
|
|
126
131
|
EResourceType.USER_MEDIA,
|
|
132
|
+
EResourceType.USER_NOTIFICATIONS,
|
|
127
133
|
EResourceType.USER_SUBSCRIPTIONS,
|
|
128
134
|
EResourceType.USER_TIMELINE,
|
|
129
135
|
EResourceType.USER_TIMELINE_AND_REPLIES,
|
|
@@ -141,6 +147,7 @@ export class FetchArgs {
|
|
|
141
147
|
EResourceType.USER_HIGHLIGHTS,
|
|
142
148
|
EResourceType.USER_LIKES,
|
|
143
149
|
EResourceType.USER_MEDIA,
|
|
150
|
+
EResourceType.USER_NOTIFICATIONS,
|
|
144
151
|
EResourceType.USER_SUBSCRIPTIONS,
|
|
145
152
|
EResourceType.USER_TIMELINE,
|
|
146
153
|
EResourceType.USER_TIMELINE_AND_REPLIES,
|
|
@@ -169,6 +176,7 @@ export class FetchArgs {
|
|
|
169
176
|
EResourceType.USER_HIGHLIGHTS,
|
|
170
177
|
EResourceType.USER_LIKES,
|
|
171
178
|
EResourceType.USER_MEDIA,
|
|
179
|
+
EResourceType.USER_NOTIFICATIONS,
|
|
172
180
|
EResourceType.USER_SUBSCRIPTIONS,
|
|
173
181
|
EResourceType.USER_TIMELINE,
|
|
174
182
|
EResourceType.USER_TIMELINE_AND_REPLIES,
|
|
@@ -186,7 +194,11 @@ export class FetchArgs {
|
|
|
186
194
|
* - For {@link EResourceType.USER_DETAILS_BY_USERNAME}, can be alphanumeric, while for others, is strictly numeric.
|
|
187
195
|
*/
|
|
188
196
|
@IsEmpty({
|
|
189
|
-
groups: [
|
|
197
|
+
groups: [
|
|
198
|
+
EResourceType.USER_FEED_FOLLOWED,
|
|
199
|
+
EResourceType.USER_FEED_RECOMMENDED,
|
|
200
|
+
EResourceType.USER_NOTIFICATIONS,
|
|
201
|
+
],
|
|
190
202
|
})
|
|
191
203
|
@IsNotEmpty({
|
|
192
204
|
groups: [
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ICursor
|
|
1
|
+
import { ICursor } from 'rettiwt-core';
|
|
2
2
|
|
|
3
3
|
import { EBaseType } from '../../enums/Data';
|
|
4
4
|
|
|
5
5
|
import { findByFilter } from '../../helper/JsonUtils';
|
|
6
6
|
|
|
7
|
+
import { Notification } from './Notification';
|
|
7
8
|
import { Tweet } from './Tweet';
|
|
8
9
|
import { User } from './User';
|
|
9
10
|
|
|
@@ -14,7 +15,7 @@ import { User } from './User';
|
|
|
14
15
|
*
|
|
15
16
|
* @public
|
|
16
17
|
*/
|
|
17
|
-
export class CursoredData<T extends Tweet | User> {
|
|
18
|
+
export class CursoredData<T extends Notification | Tweet | User> {
|
|
18
19
|
/** The batch of data of the given type. */
|
|
19
20
|
public list: T[] = [];
|
|
20
21
|
|
|
@@ -25,11 +26,13 @@ export class CursoredData<T extends Tweet | User> {
|
|
|
25
26
|
* @param response - The raw response.
|
|
26
27
|
* @param type - The base type of the data included in the batch.
|
|
27
28
|
*/
|
|
28
|
-
public constructor(response:
|
|
29
|
+
public constructor(response: NonNullable<unknown>, type: EBaseType) {
|
|
29
30
|
if (type == EBaseType.TWEET) {
|
|
30
31
|
this.list = Tweet.list(response) as T[];
|
|
31
|
-
} else {
|
|
32
|
+
} else if (type == EBaseType.USER) {
|
|
32
33
|
this.list = User.list(response) as T[];
|
|
34
|
+
} else if (type == EBaseType.NOTIFICATION) {
|
|
35
|
+
this.list = Notification.list(response) as T[];
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
this.next = new Cursor(findByFilter<ICursor>(response, 'cursorType', 'Bottom')[0]?.value ?? '');
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ENotificationType as ENotificationTypeOriginal,
|
|
3
|
+
INotification,
|
|
4
|
+
IUserNotifications as IUserNotificationsResponse,
|
|
5
|
+
} from 'rettiwt-core';
|
|
6
|
+
|
|
7
|
+
import { findKeyByValue } from '../../helper/JsonUtils';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The different types of notifications.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export enum ENotificationType {
|
|
15
|
+
RECOMMENDATION = 'RECOMMENDATION',
|
|
16
|
+
INFORMATION = 'INFORMATION',
|
|
17
|
+
LIVE = 'LIVE',
|
|
18
|
+
ALERT = 'ALERT',
|
|
19
|
+
UNDEFINED = 'UNDEFINED',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The details of a single notification.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export class Notification {
|
|
28
|
+
/** The list of id of the users from whom the notification was received. */
|
|
29
|
+
public from: string[];
|
|
30
|
+
|
|
31
|
+
/** The id of the notification. */
|
|
32
|
+
public id: string;
|
|
33
|
+
|
|
34
|
+
/** The text contents of the notification. */
|
|
35
|
+
public message: string;
|
|
36
|
+
|
|
37
|
+
/** The date/time at which the notification was received. */
|
|
38
|
+
public receivedAt: Date;
|
|
39
|
+
|
|
40
|
+
/** The list of id of the target tweet(s) of the notification. */
|
|
41
|
+
public target: string[];
|
|
42
|
+
|
|
43
|
+
/** The type of notification. */
|
|
44
|
+
public type?: ENotificationType;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @param notification - The raw notification details.
|
|
48
|
+
*/
|
|
49
|
+
public constructor(notification: INotification) {
|
|
50
|
+
// Getting the original notification type
|
|
51
|
+
const notificationType: string | undefined = findKeyByValue(ENotificationTypeOriginal, notification.icon.id);
|
|
52
|
+
|
|
53
|
+
this.from = notification.template?.aggregateUserActionsV1?.fromUsers
|
|
54
|
+
? notification.template.aggregateUserActionsV1.fromUsers.map((item) => item.user.id)
|
|
55
|
+
: [];
|
|
56
|
+
this.id = notification.id;
|
|
57
|
+
this.message = notification.message.text;
|
|
58
|
+
this.receivedAt = new Date(Number(notification.timestampMs));
|
|
59
|
+
this.target = notification.template?.aggregateUserActionsV1?.targetObjects
|
|
60
|
+
? notification.template.aggregateUserActionsV1.targetObjects.map((item) => item.tweet.id)
|
|
61
|
+
: [];
|
|
62
|
+
this.type = notificationType
|
|
63
|
+
? ENotificationType[notificationType as keyof typeof ENotificationType]
|
|
64
|
+
: ENotificationType.UNDEFINED;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Extracts and deserializes the list of notifications from the given raw response data.
|
|
69
|
+
*
|
|
70
|
+
* @param response - The raw response data.
|
|
71
|
+
*
|
|
72
|
+
* @returns The deserialized list of notifications.
|
|
73
|
+
*
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
public static list(response: NonNullable<unknown>): Notification[] {
|
|
77
|
+
const notifications: Notification[] = [];
|
|
78
|
+
|
|
79
|
+
// Extracting notifications
|
|
80
|
+
if ((response as IUserNotificationsResponse).globalObjects.notifications) {
|
|
81
|
+
// Iterating over the raw list of notifications
|
|
82
|
+
for (const [, value] of Object.entries(
|
|
83
|
+
(response as IUserNotificationsResponse).globalObjects.notifications,
|
|
84
|
+
)) {
|
|
85
|
+
notifications.push(new Notification(value as INotification));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return notifications;
|
|
90
|
+
}
|
|
91
|
+
}
|
package/src/models/data/Tweet.ts
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
IExtendedMedia as IRawExtendedMedia,
|
|
4
4
|
ITweet as IRawTweet,
|
|
5
5
|
IEntities as IRawTweetEntities,
|
|
6
|
-
IResponse,
|
|
7
6
|
ITimelineTweet,
|
|
8
7
|
ITweet,
|
|
9
8
|
} from 'rettiwt-core';
|
|
@@ -102,7 +101,7 @@ export class Tweet {
|
|
|
102
101
|
*
|
|
103
102
|
* @internal
|
|
104
103
|
*/
|
|
105
|
-
public static list(response:
|
|
104
|
+
public static list(response: NonNullable<unknown>): Tweet[] {
|
|
106
105
|
const tweets: Tweet[] = [];
|
|
107
106
|
|
|
108
107
|
// Extracting the matching data
|
|
@@ -137,7 +136,7 @@ export class Tweet {
|
|
|
137
136
|
*
|
|
138
137
|
* @internal
|
|
139
138
|
*/
|
|
140
|
-
public static single(response:
|
|
139
|
+
public static single(response: NonNullable<unknown>, id: string): Tweet | undefined {
|
|
141
140
|
const tweets: Tweet[] = [];
|
|
142
141
|
|
|
143
142
|
// Extracting the matching data
|
package/src/models/data/User.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IUser as IRawUser,
|
|
1
|
+
import { IUser as IRawUser, ITimelineUser, IUser } from 'rettiwt-core';
|
|
2
2
|
|
|
3
3
|
import { ELogActions } from '../../enums/Logging';
|
|
4
4
|
import { findByFilter } from '../../helper/JsonUtils';
|
|
@@ -81,7 +81,7 @@ export class User {
|
|
|
81
81
|
*
|
|
82
82
|
* @internal
|
|
83
83
|
*/
|
|
84
|
-
public static list(response:
|
|
84
|
+
public static list(response: NonNullable<unknown>): User[] {
|
|
85
85
|
const users: User[] = [];
|
|
86
86
|
|
|
87
87
|
// Extracting the matching data
|
|
@@ -115,7 +115,7 @@ export class User {
|
|
|
115
115
|
*
|
|
116
116
|
* @internal
|
|
117
117
|
*/
|
|
118
|
-
public static single(response:
|
|
118
|
+
public static single(response: NonNullable<unknown>): User | undefined {
|
|
119
119
|
const users: User[] = [];
|
|
120
120
|
|
|
121
121
|
// Extracting the matching data
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
IUserHighlightsResponse,
|
|
8
8
|
IUserLikesResponse,
|
|
9
9
|
IUserMediaResponse,
|
|
10
|
+
IUserNotifications as IUserNotificationsResponse,
|
|
10
11
|
IUserRecommendedResponse,
|
|
11
12
|
IUserSubscriptionsResponse,
|
|
12
13
|
IUserTweetsAndRepliesResponse,
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
import { extractors } from '../../collections/Extractors';
|
|
18
19
|
import { EResourceType } from '../../enums/Resource';
|
|
19
20
|
import { CursoredData } from '../../models/data/CursoredData';
|
|
21
|
+
import { Notification } from '../../models/data/Notification';
|
|
20
22
|
import { Tweet } from '../../models/data/Tweet';
|
|
21
23
|
import { User } from '../../models/data/User';
|
|
22
24
|
import { IRettiwtConfig } from '../../types/RettiwtConfig';
|
|
@@ -350,7 +352,7 @@ export class UserService extends FetcherService {
|
|
|
350
352
|
}
|
|
351
353
|
|
|
352
354
|
/**
|
|
353
|
-
* Get the media timeline of a user
|
|
355
|
+
* Get the media timeline of a user.
|
|
354
356
|
*
|
|
355
357
|
* @param id - The id of the target user.
|
|
356
358
|
* @param count - The number of media to fetch, must be \<= 100.
|
|
@@ -391,6 +393,49 @@ export class UserService extends FetcherService {
|
|
|
391
393
|
return data;
|
|
392
394
|
}
|
|
393
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Get the list of notifications of the logged in user.
|
|
398
|
+
*
|
|
399
|
+
* @param count - The number of notifications to fetch, must be \<= 40.
|
|
400
|
+
* @param cursor - The cursor to the batch of notifications to fetch
|
|
401
|
+
*
|
|
402
|
+
* @returns The list of notifications of the target user.
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```
|
|
406
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
407
|
+
*
|
|
408
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
409
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
410
|
+
*
|
|
411
|
+
* // Fetching the recent 40 Notifications of the logged in user
|
|
412
|
+
* rettiwt.user.notifications(40)
|
|
413
|
+
* .then(res => {
|
|
414
|
+
* console.log(res);
|
|
415
|
+
* })
|
|
416
|
+
* .catch(err => {
|
|
417
|
+
* console.log(err);
|
|
418
|
+
* });
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
public async notifications(count?: number, cursor?: string): Promise<CursoredData<Notification>> {
|
|
422
|
+
const resource = EResourceType.USER_NOTIFICATIONS;
|
|
423
|
+
|
|
424
|
+
// Fetching raw list of notifications
|
|
425
|
+
const response = await this.request<IUserNotificationsResponse>(resource, {
|
|
426
|
+
count: count,
|
|
427
|
+
cursor: cursor,
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
// Deserializing response
|
|
431
|
+
const data = extractors[resource](response);
|
|
432
|
+
|
|
433
|
+
// Sorting the notifications by time, from recent to oldest
|
|
434
|
+
data.list.sort((a, b) => new Date(b.receivedAt).valueOf() - new Date(a.receivedAt).valueOf());
|
|
435
|
+
|
|
436
|
+
return data;
|
|
437
|
+
}
|
|
438
|
+
|
|
394
439
|
/**
|
|
395
440
|
* Get the recommended feed of the logged in user.
|
|
396
441
|
*
|