blob: 9814cbf5ca8261fc72bf87b6663c5b5be0e8ee49 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
import type { Ship } from "./urbit";
import type { Content as TrillContent } from "@/types/trill";
export interface APITweet {
core: APITweetCore;
legacy: APITweetLegacy;
rest_id?: string; // number
__typename?: string;
card?: any;
quoted_status_result?: { result: APIQuoteTweet };
}
export interface APIQuoteTweet extends APITweet {
quotedRefResult: { result: { rest_id: string; __typename: string } };
}
export interface APITwitterPoll {
binding_values: any[];
card_platform: any;
name: string;
url: string;
user_refs_results: any[];
}
export interface UserEntities {
description: {
urls: any[];
};
url: {
urls: URLEntity[];
};
}
export interface TweetEntities {
user_mentions: UserMentionEntity[];
urls: URLEntity[];
hashtags: HashtagEntity[];
symbols: any[];
media?: MediaEntity[];
}
export interface UserMentionEntity {
id_str: string; // "144930676"
indices: [number, number];
name: string; // "Naninizhoni"
screen_name: string; // "naninizhoni"
}
export interface HashtagEntity {
indices: [number, number];
text: string;
}
export interface URLEntity {
url: string;
display_url: string;
expanded_url: string;
indices: [number, number];
}
export interface MediaEntity {
display_url: string; // "pic.twitter.com/0qkz8kpFPQ"
expanded_url: string; // "https://twitter.com/ThaiNewsReports/status/1476368702924898304/photo/1"
media_url_https: string; // "https://pbs.twimg.com/media/FH0dgqeXEAEHVgI.jpg"
url: string; // "https://t.co/0qkz8kpFPQ"
features: {
large: { faces: any[] };
medium: { faces: any[] };
orig: { faces: any[] };
small: { faces: any[] };
};
id_str: string;
indices: [number, number];
original_info: {
height: number;
width: number;
focus_rects?: { x: number; y: number; w: number; h: number }[];
};
sizes: {
large: MediaSize;
medium: MediaSize;
small: MediaSize;
thumb: MediaSize;
};
type: "photo"; //"photo" | ??
}
export interface ExtendedEntity {
media: ExtendedMediaEntity[] | VideoEntity[];
}
export interface ExtendedMediaEntity {
display_url: string; // "pic.twitter.com/0qkz8kpFPQ"
expanded_url: string; // "https://twitter.com/ThaiNewsReports/status/1476368702924898304/photo/1"
media_url_https: string; // "https://pbs.twimg.com/media/FH0dgqeXEAEHVgI.jpg"
url: string; // "https://t.co/0qkz8kpFPQ"
features: {
large: { faces: any[] };
medium: { faces: any[] };
orig: { faces: any[] };
small: { faces: any[] };
};
id_str: string;
media_key: string; // "3_1476368699842039809"
indices: [number, number];
original_info: {
height: number;
width: number;
focus_rects?: { x: number; y: number; w: number; h: number }[];
};
sizes: {
large: MediaSize;
medium: MediaSize;
small: MediaSize;
thumb: MediaSize;
};
type: "photo" | "video"; // ??
ext_media_availability: { status: string }; // "Available"
ext_media_color: {
palette: {
percentage: number;
rgb: { red: number; blue: number; green: number };
}[];
};
}
export interface VideoEntity extends ExtendedMediaEntity {
original_info: { height: number; width: number };
additional_media_info: { monetizable: boolean };
mediaStats: { viewCount: number };
video_info: {
aspect_ratio: [number, number];
duration_millis: number;
variants: VideoVariant[];
};
}
export interface VideoVariant {
bitrate?: number;
content_type: string; // "video/mp4" "application/x-mpegURL"
url: string; // "https://video.twimg.com/ext_tw_video/1476257027378888711/pu/vid/640x360/KwFE_5vWD7hAVtu4.mp4?tag=12"
}
export interface MediaSize {
h: number;
w: number;
resize: "crop" | "fit";
}
export interface APITweetLegacy {
conversation_id_str: string; // thread id
created_at: string; // "Wed Dec 15 14:02:32 +0000 2021"
display_text_range: [number, number]; // [0, 96]
entities: TweetEntities;
favorite_count: number;
favorited: boolean;
full_text: string; //
id_str: string; // "1471118482095943680"
is_quote_status: boolean;
lang: string; // "en"
possibly_sensitive: boolean;
possibly_sensitive_editable: boolean;
quote_count: number;
reply_count: number;
retweet_count: number;
retweeted: boolean;
source: string; // "<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Twitter Web App</a>"
user_id_str: string; // "368897808"
retweeted_status_result?: { result: APITweet };
quoted_status_id_str?: string;
quoted_status_permalink?: {
display: string; //"twitter.com/lijukic/status…"
expanded: string; //"https://twitter.com/lijukic/status/1476284640826736640"
url: string; //"https://t.co/1yLiM97600"
};
in_reply_to_screen_name?: string;
in_reply_to_status_id_str?: string;
in_reply_to_user_id_str?: string;
self_thread?: { id_str: string };
extended_entities?: ExtendedEntity;
}
export interface Tweet {
index: string; // number
parent: string | null; // number
thread: string; // number
time: number;
author: TweetAuthor;
contents: TwatterToken[];
text: string;
media: TweetMedia[];
poll: TwatterPoll | null;
rt_by: TweetAuthor | null;
rt_time: number | null;
language: string;
quoting: Tweet | null;
replies: number;
rts: number;
likes: number;
quotes: number;
}
export type TweetMedia = TweetPic | TweetVideo;
export interface TweetPic {
url: string; //url
thumbnail?: string; //url
}
export interface TweetVideo {
url: string; //url
thumbnail: string; //url
}
export interface TwatterPoll {
card_url: string;
api: string;
last_updated_datetime_utc: Date;
end_datetime_utc: Date;
counts_are_final: boolean;
choice1_label: string;
choice1_count: string;
choice2_label: string;
choice2_count: string;
choice3_label?: string;
choice3_count?: string;
choice4_label?: string;
choice4_count?: string;
}
export interface TweetAuthor {
suspended?: boolean;
username: string;
name: string;
id: string; // number
created: number; // date
bio: string;
avatar: string;
avatar_big: string;
cover_img: string;
following: number;
followers: number;
location: string;
url: string;
bluecheck: boolean;
locked: boolean;
withheld_in_countries: string[];
post_count: number;
media_count: number;
listed_count: number;
patp: Ship | null;
}
export type EntityType =
| "user_mentions"
| "hashtags"
| "urls"
| "media"
| "symbol";
export type tokenizerData = [string, taggedContent[]];
export type taggedContent = [string, TwatterToken];
export type TwatterToken = TwatterContent | EmojiContent | HashtagContent;
export type TwatterContent =
| { text: string }
| { mention: string }
| { url: string }
| { hashtag: string };
export interface EmojiContent {
emoji: string;
}
export interface HashtagContent {
hashtag: string;
}
export interface TwatterThread {
thread: TweetsWithCursor;
replyThreads: TweetsWithCursor[];
cursor: string;
}
export interface TweetsWithCursor {
tweets: Tweet[];
cursor: string;
cursorBottom?: string;
type?: string;
}
export interface APITweetCore {
user: APIUserProfile;
}
export interface APIUserProfile {
affiliates_highlighted_label?: any;
id?: string; // base64
rest_id: string; // number
legacy: {
created_at: string; // "Tue Sep 06 12:23:27 +0000 2011"
default_profile: boolean;
default_profile_image: boolean;
description: string;
entities: UserEntities;
fast_followers_count: number;
favourites_count: number;
followers_count: number;
friends_count: number;
has_custom_timelines: boolean;
is_translator: boolean;
listed_count: number;
location: string;
media_count: number;
name: string;
normal_followers_count: number;
pinned_tweet_ids_str: string[]; // ['1471118482095943680']
profile_banner_extensions: any; //{mediaColor: {…}}
profile_banner_url: string; // "https://pbs.twimg.com/profile_banners/368897808/1398230281"
profile_image_extensions: any; // {mediaColor: {…}}
profile_image_url_https: string; //"https://pbs.twimg.com/profile_images/1193225494994571264/So4axAeC_normal.jpg"
profile_interstitial_type: string; // ""
protected: boolean;
screen_name: string;
statuses_count: number;
translator_type: string; // "none"
url?: string; // "https://t.co/uaINnItg4d"
verified: boolean;
withheld_in_countries: string[];
};
}
// return types of our Urbit fetcher
export type NoCokiRes = { "no-coki": null };
export type BadRequestRes = { fail: string };
export type TwatterSearchRes = TwatterSearchResOK | NoCokiRes | BadRequestRes;
export type TwatterUserRes = TwatterUserResOK | NoCokiRes | BadRequestRes;
export type TwatterThreadRes = TwatterThreadResOK | NoCokiRes | BadRequestRes;
export type TwatterUserResOK = {
user: {
profile: string;
feed: string;
};
};
export type TwatterThreadResOK = TwatterLoggedThreadRes | TwatterLurkThreadRes;
export type TwatterLurkThreadRes = {
"thread-lurk": string;
};
export type TwatterLoggedThreadRes = {
thread: string;
};
export type TwatterSearchResOK = {
search: {
query: string;
data: string;
}
}
export type TwatterNotification = {
type: string;
user: string;
post?: string;
text: string;
}
|