rettiwt-api 6.1.0 → 6.1.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.
@@ -4,76 +4,33 @@
4
4
  * @public
5
5
  */
6
6
  export interface IUserNotificationsResponse {
7
- globalObjects: GlobalObjects;
8
- timeline: Timeline;
9
- }
10
- interface GlobalObjects {
11
- notifications: Notifications;
7
+ data: Data;
12
8
  }
13
- interface Notifications {
14
- [key: string]: Notification;
15
- }
16
- interface Notification {
17
- id: string;
18
- timestampMs: string;
19
- icon: Icon;
20
- message: Message;
21
- template: Template;
9
+ interface Data {
10
+ viewer_v2: ViewerV2;
22
11
  }
23
- interface Icon {
24
- id: string;
12
+ interface ViewerV2 {
13
+ user_results: UserResults;
25
14
  }
26
- interface Message {
27
- text: string;
28
- entities: Entity[];
29
- rtl: boolean;
30
- }
31
- interface Entity {
32
- fromIndex: number;
33
- toIndex: number;
34
- format: string;
35
- }
36
- interface Template {
37
- aggregateUserActionsV1: AggregateUserActionsV1;
15
+ interface UserResults {
16
+ result: Result;
38
17
  }
39
- interface AggregateUserActionsV1 {
40
- targetObjects: TargetObject[];
41
- fromUsers: FromUser[];
42
- additionalContext: AdditionalContext;
18
+ interface Result {
19
+ __typename: string;
20
+ rest_id: string;
21
+ notification_timeline: NotificationTimeline;
43
22
  }
44
- interface TargetObject {
45
- tweet: Tweet;
46
- }
47
- interface Tweet {
23
+ interface NotificationTimeline {
48
24
  id: string;
49
- }
50
- interface FromUser {
51
- user: User;
52
- }
53
- interface User {
54
- id: string;
55
- }
56
- interface AdditionalContext {
57
- contextText: ContextText;
58
- }
59
- interface ContextText {
60
- text: string;
61
- entities: any[];
25
+ timeline: Timeline;
62
26
  }
63
27
  interface Timeline {
64
- id: string;
65
28
  instructions: Instruction[];
66
29
  }
67
30
  interface Instruction {
68
- clearCache?: ClearCache;
69
- addEntries?: AddEntries;
70
- clearEntriesUnreadState?: ClearEntriesUnreadState;
71
- markEntriesUnreadGreaterThanSortIndex?: MarkEntriesUnreadGreaterThanSortIndex;
72
- }
73
- interface ClearCache {
74
- }
75
- interface AddEntries {
76
- entries: Entry[];
31
+ type: string;
32
+ entries?: Entry[];
33
+ sort_index?: string;
77
34
  }
78
35
  interface Entry {
79
36
  entryId: string;
@@ -81,38 +38,380 @@ interface Entry {
81
38
  content: Content;
82
39
  }
83
40
  interface Content {
84
- operation?: Operation;
85
- item?: Item;
41
+ entryType: string;
42
+ __typename: string;
43
+ value?: string;
44
+ cursorType?: string;
45
+ itemContent?: ItemContent;
46
+ clientEventInfo?: ClientEventInfo;
47
+ }
48
+ interface ItemContent {
49
+ itemType: string;
50
+ __typename: string;
51
+ id: string;
52
+ notification_icon: string;
53
+ rich_message: RichMessage;
54
+ notification_url: NotificationUrl;
55
+ template: Template;
56
+ timestamp_ms: string;
86
57
  }
87
- interface Operation {
88
- cursor: Cursor;
58
+ interface RichMessage {
59
+ rtl: boolean;
60
+ text: string;
61
+ entities: Entity[];
89
62
  }
90
- interface Cursor {
91
- value: string;
92
- cursorType: string;
63
+ interface Entity {
64
+ fromIndex: number;
65
+ toIndex: number;
66
+ ref: Ref;
93
67
  }
94
- interface Item {
95
- content: Content2;
96
- clientEventInfo: ClientEventInfo;
97
- feedbackInfo?: FeedbackInfo;
68
+ interface Ref {
69
+ type: string;
70
+ user_results: UserResults2;
98
71
  }
99
- interface Content2 {
100
- notification: Notification2;
72
+ interface UserResults2 {
73
+ result: Result2;
101
74
  }
102
- interface Notification2 {
75
+ interface Result2 {
76
+ __typename: string;
103
77
  id: string;
104
- url: Url;
105
- fromUsers: string[];
106
- targetTweets: string[];
107
- }
108
- interface Url {
109
- urlType: string;
78
+ rest_id: string;
79
+ affiliates_highlighted_label: AffiliatesHighlightedLabel;
80
+ avatar: Avatar;
81
+ core: Core;
82
+ dm_permissions: DmPermissions;
83
+ follow_request_sent: boolean;
84
+ has_graduated_access: boolean;
85
+ is_blue_verified: boolean;
86
+ legacy: Legacy;
87
+ location: Location;
88
+ media_permissions: MediaPermissions;
89
+ parody_commentary_fan_label: string;
90
+ profile_image_shape: string;
91
+ profile_bio: ProfileBio;
92
+ privacy: Privacy;
93
+ relationship_perspectives: RelationshipPerspectives;
94
+ tipjar_settings: TipjarSettings;
95
+ verification: Verification;
96
+ verified_phone_status: boolean;
97
+ }
98
+ interface AffiliatesHighlightedLabel {
99
+ }
100
+ interface Avatar {
101
+ image_url: string;
102
+ }
103
+ interface Core {
104
+ created_at: string;
105
+ name: string;
106
+ screen_name: string;
107
+ }
108
+ interface DmPermissions {
109
+ can_dm: boolean;
110
+ }
111
+ interface Legacy {
112
+ default_profile: boolean;
113
+ default_profile_image: boolean;
114
+ description: string;
115
+ entities: Entities;
116
+ fast_followers_count: number;
117
+ favourites_count: number;
118
+ followers_count: number;
119
+ friends_count: number;
120
+ has_custom_timelines: boolean;
121
+ is_translator: boolean;
122
+ listed_count: number;
123
+ media_count: number;
124
+ normal_followers_count: number;
125
+ notifications: boolean;
126
+ pinned_tweet_ids_str: any[];
127
+ possibly_sensitive: boolean;
128
+ profile_interstitial_type: string;
129
+ statuses_count: number;
130
+ translator_type: string;
131
+ want_retweets: boolean;
132
+ withheld_in_countries: any[];
133
+ }
134
+ interface Entities {
135
+ description: Description;
136
+ }
137
+ interface Description {
138
+ urls: any[];
139
+ }
140
+ interface Location {
141
+ location: string;
142
+ }
143
+ interface MediaPermissions {
144
+ can_media_tag: boolean;
145
+ }
146
+ interface ProfileBio {
147
+ description: string;
148
+ }
149
+ interface Privacy {
150
+ protected: boolean;
151
+ }
152
+ interface RelationshipPerspectives {
153
+ followed_by: boolean;
154
+ following: boolean;
155
+ }
156
+ interface TipjarSettings {
157
+ }
158
+ interface Verification {
159
+ verified: boolean;
160
+ }
161
+ interface NotificationUrl {
110
162
  url: string;
163
+ urlType: string;
111
164
  urtEndpointOptions?: UrtEndpointOptions;
112
165
  }
113
166
  interface UrtEndpointOptions {
114
- title: string;
115
167
  cacheId: string;
168
+ title: string;
169
+ }
170
+ interface Template {
171
+ __typename: string;
172
+ target_objects: TargetObject[];
173
+ from_users: FromUser[];
174
+ }
175
+ interface TargetObject {
176
+ __typename: string;
177
+ tweet_results: TweetResults;
178
+ }
179
+ interface TweetResults {
180
+ result: Result3;
181
+ }
182
+ interface Result3 {
183
+ __typename: string;
184
+ rest_id: string;
185
+ core: Core2;
186
+ unmention_data: UnmentionData;
187
+ edit_control: EditControl;
188
+ is_translatable: boolean;
189
+ views: Views;
190
+ source: string;
191
+ grok_analysis_button: boolean;
192
+ legacy: Legacy3;
193
+ }
194
+ interface Core2 {
195
+ user_results: UserResults3;
196
+ }
197
+ interface UserResults3 {
198
+ result: Result4;
199
+ }
200
+ interface Result4 {
201
+ __typename: string;
202
+ id: string;
203
+ rest_id: string;
204
+ affiliates_highlighted_label: AffiliatesHighlightedLabel2;
205
+ avatar: Avatar2;
206
+ core: Core3;
207
+ dm_permissions: DmPermissions2;
208
+ follow_request_sent: boolean;
209
+ has_graduated_access: boolean;
210
+ is_blue_verified: boolean;
211
+ legacy: Legacy2;
212
+ location: Location2;
213
+ media_permissions: MediaPermissions2;
214
+ parody_commentary_fan_label: string;
215
+ profile_image_shape: string;
216
+ profile_bio: ProfileBio2;
217
+ privacy: Privacy2;
218
+ relationship_perspectives: RelationshipPerspectives2;
219
+ tipjar_settings: TipjarSettings2;
220
+ verification: Verification2;
221
+ verified_phone_status: boolean;
222
+ }
223
+ interface AffiliatesHighlightedLabel2 {
224
+ }
225
+ interface Avatar2 {
226
+ image_url: string;
227
+ }
228
+ interface Core3 {
229
+ created_at: string;
230
+ name: string;
231
+ screen_name: string;
232
+ }
233
+ interface DmPermissions2 {
234
+ can_dm: boolean;
235
+ }
236
+ interface Legacy2 {
237
+ default_profile: boolean;
238
+ default_profile_image: boolean;
239
+ description: string;
240
+ entities: Entities2;
241
+ fast_followers_count: number;
242
+ favourites_count: number;
243
+ followers_count: number;
244
+ friends_count: number;
245
+ has_custom_timelines: boolean;
246
+ is_translator: boolean;
247
+ listed_count: number;
248
+ media_count: number;
249
+ needs_phone_verification: boolean;
250
+ normal_followers_count: number;
251
+ pinned_tweet_ids_str: any[];
252
+ possibly_sensitive: boolean;
253
+ profile_interstitial_type: string;
254
+ statuses_count: number;
255
+ translator_type: string;
256
+ want_retweets: boolean;
257
+ withheld_in_countries: any[];
258
+ }
259
+ interface Entities2 {
260
+ description: Description2;
261
+ }
262
+ interface Description2 {
263
+ urls: any[];
264
+ }
265
+ interface Location2 {
266
+ location: string;
267
+ }
268
+ interface MediaPermissions2 {
269
+ can_media_tag: boolean;
270
+ }
271
+ interface ProfileBio2 {
272
+ description: string;
273
+ }
274
+ interface Privacy2 {
275
+ protected: boolean;
276
+ }
277
+ interface RelationshipPerspectives2 {
278
+ following: boolean;
279
+ }
280
+ interface TipjarSettings2 {
281
+ }
282
+ interface Verification2 {
283
+ verified: boolean;
284
+ }
285
+ interface UnmentionData {
286
+ }
287
+ interface EditControl {
288
+ edit_tweet_ids: string[];
289
+ editable_until_msecs: string;
290
+ is_edit_eligible: boolean;
291
+ edits_remaining: string;
292
+ }
293
+ interface Views {
294
+ count: string;
295
+ state: string;
296
+ }
297
+ interface Legacy3 {
298
+ bookmark_count: number;
299
+ bookmarked: boolean;
300
+ created_at: string;
301
+ conversation_id_str: string;
302
+ display_text_range: number[];
303
+ entities: Entities3;
304
+ favorite_count: number;
305
+ favorited: boolean;
306
+ full_text: string;
307
+ is_quote_status: boolean;
308
+ lang: string;
309
+ quote_count: number;
310
+ reply_count: number;
311
+ retweet_count: number;
312
+ retweeted: boolean;
313
+ user_id_str: string;
314
+ id_str: string;
315
+ }
316
+ interface Entities3 {
317
+ hashtags: any[];
318
+ symbols: any[];
319
+ timestamps: any[];
320
+ urls: any[];
321
+ user_mentions: any[];
322
+ }
323
+ interface FromUser {
324
+ __typename: string;
325
+ user_results: UserResults4;
326
+ }
327
+ interface UserResults4 {
328
+ result: Result5;
329
+ }
330
+ interface Result5 {
331
+ __typename: string;
332
+ id: string;
333
+ rest_id: string;
334
+ affiliates_highlighted_label: AffiliatesHighlightedLabel3;
335
+ avatar: Avatar3;
336
+ core: Core4;
337
+ dm_permissions: DmPermissions3;
338
+ follow_request_sent: boolean;
339
+ has_graduated_access: boolean;
340
+ is_blue_verified: boolean;
341
+ legacy: Legacy4;
342
+ location: Location3;
343
+ media_permissions: MediaPermissions3;
344
+ parody_commentary_fan_label: string;
345
+ profile_image_shape: string;
346
+ profile_bio: ProfileBio3;
347
+ privacy: Privacy3;
348
+ relationship_perspectives: RelationshipPerspectives3;
349
+ tipjar_settings: TipjarSettings3;
350
+ verification: Verification3;
351
+ verified_phone_status: boolean;
352
+ }
353
+ interface AffiliatesHighlightedLabel3 {
354
+ }
355
+ interface Avatar3 {
356
+ image_url: string;
357
+ }
358
+ interface Core4 {
359
+ created_at: string;
360
+ name: string;
361
+ screen_name: string;
362
+ }
363
+ interface DmPermissions3 {
364
+ can_dm: boolean;
365
+ }
366
+ interface Legacy4 {
367
+ default_profile: boolean;
368
+ default_profile_image: boolean;
369
+ description: string;
370
+ entities: Entities4;
371
+ fast_followers_count: number;
372
+ favourites_count: number;
373
+ followers_count: number;
374
+ friends_count: number;
375
+ has_custom_timelines: boolean;
376
+ is_translator: boolean;
377
+ listed_count: number;
378
+ media_count: number;
379
+ normal_followers_count: number;
380
+ notifications: boolean;
381
+ pinned_tweet_ids_str: any[];
382
+ possibly_sensitive: boolean;
383
+ profile_interstitial_type: string;
384
+ statuses_count: number;
385
+ translator_type: string;
386
+ want_retweets: boolean;
387
+ withheld_in_countries: any[];
388
+ }
389
+ interface Entities4 {
390
+ description: Description3;
391
+ }
392
+ interface Description3 {
393
+ urls: any[];
394
+ }
395
+ interface Location3 {
396
+ location: string;
397
+ }
398
+ interface MediaPermissions3 {
399
+ can_media_tag: boolean;
400
+ }
401
+ interface ProfileBio3 {
402
+ description: string;
403
+ }
404
+ interface Privacy3 {
405
+ protected: boolean;
406
+ }
407
+ interface RelationshipPerspectives3 {
408
+ followed_by: boolean;
409
+ following: boolean;
410
+ }
411
+ interface TipjarSettings3 {
412
+ }
413
+ interface Verification3 {
414
+ verified: boolean;
116
415
  }
117
416
  interface ClientEventInfo {
118
417
  component: string;
@@ -126,17 +425,4 @@ interface NotificationDetails {
126
425
  impressionId: string;
127
426
  metadata: string;
128
427
  }
129
- interface FeedbackInfo {
130
- feedbackKeys: string[];
131
- feedbackMetadata: string;
132
- clientEventInfo: ClientEventInfo2;
133
- }
134
- interface ClientEventInfo2 {
135
- element: string;
136
- }
137
- interface ClearEntriesUnreadState {
138
- }
139
- interface MarkEntriesUnreadGreaterThanSortIndex {
140
- sortIndex: string;
141
- }
142
428
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rettiwt-api",
3
- "version": "6.1.0",
3
+ "version": "6.1.2",
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!",
@@ -54,7 +54,7 @@
54
54
  "https-proxy-agent": "^7.0.6",
55
55
  "jsdom": "^27.2.0",
56
56
  "node-html-parser": "^7.0.1",
57
- "x-client-transaction-id": "^0.1.8"
57
+ "x-client-transaction-id": "^0.1.9"
58
58
  },
59
59
  "workspaces": [
60
60
  "playground",
@@ -1,9 +1,7 @@
1
1
  import { NotificationType } from '../../enums/Notification';
2
- import { RawNotificationType } from '../../enums/raw/Notification';
3
- import { findKeyByValue } from '../../helper/JsonUtils';
2
+ import { findByFilter } from '../../helper/JsonUtils';
4
3
  import { INotification } from '../../types/data/Notification';
5
4
  import { INotification as IRawNotification } from '../../types/raw/base/Notification';
6
- import { IUserNotificationsResponse } from '../../types/raw/user/Notifications';
7
5
 
8
6
  /**
9
7
  * The details of a single notification.
@@ -28,16 +26,16 @@ export class Notification implements INotification {
28
26
  this._raw = { ...notification };
29
27
 
30
28
  // Getting the original notification type
31
- const notificationType: string | undefined = findKeyByValue(RawNotificationType, notification.icon.id);
29
+ const notificationType = notification.notification_icon.toString();
32
30
 
33
- this.from = notification.template?.aggregateUserActionsV1?.fromUsers
34
- ? notification.template.aggregateUserActionsV1.fromUsers.map((item) => item.user.id)
31
+ this.from = notification.template.from_users
32
+ ? notification.template.from_users.map((item) => item.user_results.result.rest_id)
35
33
  : [];
36
34
  this.id = notification.id;
37
- this.message = notification.message.text;
38
- this.receivedAt = new Date(Number(notification.timestampMs)).toISOString();
39
- this.target = notification.template?.aggregateUserActionsV1?.targetObjects
40
- ? notification.template.aggregateUserActionsV1.targetObjects.map((item) => item.tweet.id)
35
+ this.message = notification.rich_message.text;
36
+ this.receivedAt = new Date(notification.timestamp_ms).toISOString();
37
+ this.target = notification.template.target_objects
38
+ ? notification.template.target_objects.map((item) => item.tweet_results.result.rest_id)
41
39
  : [];
42
40
  this.type = notificationType
43
41
  ? NotificationType[notificationType as keyof typeof NotificationType]
@@ -59,14 +57,12 @@ export class Notification implements INotification {
59
57
  public static list(response: NonNullable<unknown>): Notification[] {
60
58
  const notifications: Notification[] = [];
61
59
 
62
- // Extracting notifications
63
- if ((response as IUserNotificationsResponse).globalObjects.notifications) {
64
- // Iterating over the raw list of notifications
65
- for (const [, value] of Object.entries(
66
- (response as IUserNotificationsResponse).globalObjects.notifications,
67
- )) {
68
- notifications.push(new Notification(value as IRawNotification));
69
- }
60
+ // Extracting the matching data
61
+ const extract = findByFilter<IRawNotification>(response, '__typename', 'TimelineNotification');
62
+
63
+ // Deserializing valid data
64
+ for (const item of extract) {
65
+ notifications.push(new Notification(item));
70
66
  }
71
67
 
72
68
  return notifications;
@@ -1,7 +1,7 @@
1
1
  import axios, { isAxiosError } from 'axios';
2
2
  import { Cookie } from 'cookiejar';
3
3
  import { JSDOM } from 'jsdom';
4
- import { ClientTransaction } from 'x-client-transaction-id-glacier';
4
+ import { ClientTransaction } from 'x-client-transaction-id';
5
5
 
6
6
  import { AllowGuestAuthenticationGroup, FetchResourcesGroup, PostResourcesGroup } from '../../collections/Groups';
7
7
  import { Requests } from '../../collections/Requests';
@@ -1,6 +1,9 @@
1
1
  /* eslint-disable */
2
2
 
3
3
  import { RawNotificationType } from '../../../enums/raw/Notification';
4
+ import { IDataResult } from '../composite/DataResult';
5
+ import { ITweet } from './Tweet';
6
+ import { IUser } from './User';
4
7
 
5
8
  /**
6
9
  * Represents the raw data of a single Notification.
@@ -8,60 +11,56 @@ import { RawNotificationType } from '../../../enums/raw/Notification';
8
11
  * @public
9
12
  */
10
13
  export interface INotification {
14
+ itemType: string;
15
+ __typename: string;
11
16
  id: string;
12
- timestampMs: string;
13
- icon: INotificationIcon;
14
- message: INotificationMessage;
15
- template: INotificationTemplate;
17
+ notification_icon: RawNotificationType;
18
+ rich_message: INotificationRichMessage;
19
+ notification_url: INotificationUrl;
20
+ template: INoticiationTemplate;
21
+ timestamp_ms: string;
16
22
  }
17
23
 
18
- export interface INotificationIcon {
19
- id: RawNotificationType;
20
- }
21
-
22
- export interface INotificationMessage {
23
- text: string;
24
- entities: INotificationMessageEntity[];
24
+ export interface INotificationRichMessage {
25
25
  rtl: boolean;
26
+ text: string;
27
+ entities: INotificationEntity[];
26
28
  }
27
29
 
28
- export interface INotificationMessageEntity {
30
+ export interface INotificationEntity {
29
31
  fromIndex: number;
30
32
  toIndex: number;
31
- format: string;
33
+ ref: INotificationEntityRef;
32
34
  }
33
35
 
34
- export interface INotificationTemplate {
35
- aggregateUserActionsV1: INotificationUserActions;
36
+ export interface INotificationEntityRef {
37
+ type: string;
38
+ user_results: IDataResult<IUser>;
36
39
  }
37
40
 
38
- export interface INotificationUserActions {
39
- targetObjects: INotificationTargetObject[];
40
- fromUsers: INotificationFromUser[];
41
- additionalContext: INotificationAdditionalContext;
41
+ export interface INotificationUrl {
42
+ url: string;
43
+ urlType: string;
44
+ urtEndpointOptions?: INotificationUrtEndpointOptions;
42
45
  }
43
46
 
44
- export interface INotificationTargetObject {
45
- tweet: INotificationTweet;
47
+ export interface INotificationUrtEndpointOptions {
48
+ cacheId: string;
49
+ title: string;
46
50
  }
47
51
 
48
- export interface INotificationTweet {
49
- id: string;
52
+ export interface INoticiationTemplate {
53
+ __typename: string;
54
+ target_objects: INotificationTargetObject[];
55
+ from_users: INotificationFromUser[];
50
56
  }
51
57
 
52
- export interface INotificationFromUser {
53
- user: INotificationUser;
54
- }
55
-
56
- export interface INotificationUser {
57
- id: string;
58
- }
59
-
60
- export interface INotificationAdditionalContext {
61
- contextText: INotificationContextText;
58
+ export interface INotificationTargetObject {
59
+ __typename: string;
60
+ tweet_results: IDataResult<ITweet>;
62
61
  }
63
62
 
64
- export interface INotificationContextText {
65
- text: string;
66
- entities: any[];
63
+ export interface INotificationFromUser {
64
+ __typename: string;
65
+ user_results: IDataResult<IUser>;
67
66
  }