fxtwitter 1.0.0 → 2.1.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/README.md +111 -31
- package/dist/LICENSE-citty +21 -0
- package/dist/THIRD-PARTY-LICENSES-citty.md +33 -0
- package/dist/cli.mjs +880 -0
- package/dist/{v1-KUPCoHD9.mjs → http-BTdKgEdX.mjs} +1 -56
- package/dist/http-CidaL0TV.d.cts +24 -0
- package/dist/http-CidaL0TV.d.mts +24 -0
- package/dist/{v1-Da3KbdIz.cjs → http-Cs4GJeg-.cjs} +2 -57
- package/dist/index.cjs +48 -2
- package/dist/index.d.cts +40 -2
- package/dist/index.d.mts +40 -2
- package/dist/index.mjs +45 -2
- package/dist/v1-BFKgLuJi.cjs +92 -0
- package/dist/v1-ByqsBlpO.mjs +87 -0
- package/dist/v1.cjs +1 -1
- package/dist/v1.d.cts +252 -1
- package/dist/v1.d.mts +252 -1
- package/dist/v1.mjs +1 -1
- package/dist/v2.cjs +183 -0
- package/dist/v2.d.cts +685 -0
- package/dist/v2.d.mts +685 -0
- package/dist/v2.mjs +181 -0
- package/package.json +13 -1
- package/dist/v1-BKUGwGbc.d.cts +0 -267
- package/dist/v1-BKUGwGbc.d.mts +0 -267
package/dist/v1-BKUGwGbc.d.mts
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
//#region src/http.d.ts
|
|
2
|
-
/** Options shared by every client, forwarded to ofetch. */
|
|
3
|
-
interface ClientOptions {
|
|
4
|
-
/** Overrides the API host. Defaults to `https://api.fxtwitter.com`. */
|
|
5
|
-
baseUrl?: string;
|
|
6
|
-
/** Custom fetch implementation (e.g. a mock, or undici in older runtimes). */
|
|
7
|
-
fetch?: typeof fetch;
|
|
8
|
-
/**
|
|
9
|
-
* Extra headers sent with every request.
|
|
10
|
-
*
|
|
11
|
-
* When no `User-Agent` is given, one describing the current runtime is
|
|
12
|
-
* added, because the API answers `401` to requests that do not identify
|
|
13
|
-
* themselves. Set your own here to override it.
|
|
14
|
-
*/
|
|
15
|
-
headers?: Record<string, string>;
|
|
16
|
-
/** Abort a request after this many milliseconds. Disabled by default. */
|
|
17
|
-
timeout?: number;
|
|
18
|
-
/** Retry count for failed requests. Defaults to ofetch's `1` for GET. */
|
|
19
|
-
retry?: number | false;
|
|
20
|
-
/** Delay between retries in milliseconds. Defaults to `0`. */
|
|
21
|
-
retryDelay?: number;
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/types/v1.d.ts
|
|
25
|
-
interface Facet {
|
|
26
|
-
/** e.g. `url`, `mention`, `hashtag`, `media`. */
|
|
27
|
-
type: string;
|
|
28
|
-
/** Start/end UTF-16 indices. */
|
|
29
|
-
indices: [number, number];
|
|
30
|
-
original?: string;
|
|
31
|
-
replacement?: string;
|
|
32
|
-
display?: string;
|
|
33
|
-
id?: string;
|
|
34
|
-
}
|
|
35
|
-
interface RawText {
|
|
36
|
-
text: string;
|
|
37
|
-
facets: Facet[];
|
|
38
|
-
}
|
|
39
|
-
interface StatusRawText extends RawText {
|
|
40
|
-
display_text_range: [number, number];
|
|
41
|
-
}
|
|
42
|
-
interface Website {
|
|
43
|
-
url: string;
|
|
44
|
-
display_url: string;
|
|
45
|
-
}
|
|
46
|
-
type VerificationType = "organization" | "government" | "individual" | null;
|
|
47
|
-
interface Verification {
|
|
48
|
-
verified: boolean;
|
|
49
|
-
type: VerificationType;
|
|
50
|
-
verified_at?: string | null;
|
|
51
|
-
identity_verified?: boolean;
|
|
52
|
-
verified_by?: string;
|
|
53
|
-
}
|
|
54
|
-
/** The author embedded in a status. Same shape as {@link User}, plus `avatar_color`. */
|
|
55
|
-
interface Author {
|
|
56
|
-
id: string;
|
|
57
|
-
name: string;
|
|
58
|
-
screen_name: string;
|
|
59
|
-
url: string;
|
|
60
|
-
description: string;
|
|
61
|
-
raw_description: RawText;
|
|
62
|
-
location: string;
|
|
63
|
-
avatar_url: string | null;
|
|
64
|
-
banner_url: string | null;
|
|
65
|
-
/** @deprecated Always `null` upstream. */
|
|
66
|
-
avatar_color?: string | null;
|
|
67
|
-
followers: number;
|
|
68
|
-
following: number;
|
|
69
|
-
likes: number;
|
|
70
|
-
media_count: number;
|
|
71
|
-
joined: string;
|
|
72
|
-
protected: boolean;
|
|
73
|
-
website: Website | null;
|
|
74
|
-
verification?: Verification;
|
|
75
|
-
}
|
|
76
|
-
/** The user returned by `GET /:screen_name`. Uses `tweets` where v2 uses `statuses`. */
|
|
77
|
-
interface User extends Author {
|
|
78
|
-
/** Status count. Named `statuses` in the v2 API. */
|
|
79
|
-
tweets: number;
|
|
80
|
-
}
|
|
81
|
-
interface Translation {
|
|
82
|
-
text: string;
|
|
83
|
-
source_lang: string;
|
|
84
|
-
source_lang_en: string;
|
|
85
|
-
target_lang: string;
|
|
86
|
-
provider: string;
|
|
87
|
-
}
|
|
88
|
-
interface PollChoice {
|
|
89
|
-
label: string;
|
|
90
|
-
count: number;
|
|
91
|
-
/** 0-100. */
|
|
92
|
-
percentage: number;
|
|
93
|
-
}
|
|
94
|
-
interface Poll {
|
|
95
|
-
choices: PollChoice[];
|
|
96
|
-
total_votes: number;
|
|
97
|
-
ends_at: string;
|
|
98
|
-
time_left_en: string;
|
|
99
|
-
}
|
|
100
|
-
interface VideoFormat {
|
|
101
|
-
container?: "mp4" | "webm" | "m3u8";
|
|
102
|
-
codec?: "h264" | "hevc" | "vp9" | "av1";
|
|
103
|
-
bitrate?: number;
|
|
104
|
-
url: string;
|
|
105
|
-
size?: number;
|
|
106
|
-
height?: number;
|
|
107
|
-
width?: number;
|
|
108
|
-
}
|
|
109
|
-
interface Photo {
|
|
110
|
-
id?: string;
|
|
111
|
-
/** MIME type, e.g. `image/jpeg`. */
|
|
112
|
-
format?: string;
|
|
113
|
-
type: "photo" | "gif";
|
|
114
|
-
url: string;
|
|
115
|
-
width: number;
|
|
116
|
-
height: number;
|
|
117
|
-
transcode_url?: string | null;
|
|
118
|
-
altText?: string;
|
|
119
|
-
}
|
|
120
|
-
interface Video {
|
|
121
|
-
id?: string;
|
|
122
|
-
/** MIME type, e.g. `video/mp4`. */
|
|
123
|
-
format?: string;
|
|
124
|
-
type: "video" | "gif";
|
|
125
|
-
url: string;
|
|
126
|
-
width: number;
|
|
127
|
-
height: number;
|
|
128
|
-
thumbnail_url?: string | null;
|
|
129
|
-
transcode_url?: string | null;
|
|
130
|
-
duration: number;
|
|
131
|
-
filesize?: number;
|
|
132
|
-
formats?: VideoFormat[];
|
|
133
|
-
}
|
|
134
|
-
interface MosaicPhoto {
|
|
135
|
-
id?: string;
|
|
136
|
-
type: "mosaic_photo";
|
|
137
|
-
url?: string;
|
|
138
|
-
width: number;
|
|
139
|
-
height: number;
|
|
140
|
-
formats: {
|
|
141
|
-
webp: string;
|
|
142
|
-
jpeg: string;
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
interface ExternalMedia {
|
|
146
|
-
/** Currently always `video`. */
|
|
147
|
-
type: string;
|
|
148
|
-
url: string;
|
|
149
|
-
thumbnail_url?: string;
|
|
150
|
-
height?: number;
|
|
151
|
-
width?: number;
|
|
152
|
-
duration?: number;
|
|
153
|
-
}
|
|
154
|
-
type AnyMedia = Photo | Video | MosaicPhoto;
|
|
155
|
-
interface StatusMedia {
|
|
156
|
-
/** Preserves the original ordering across photos and videos. */
|
|
157
|
-
all?: AnyMedia[];
|
|
158
|
-
external?: ExternalMedia;
|
|
159
|
-
photos?: Photo[];
|
|
160
|
-
videos?: Video[];
|
|
161
|
-
mosaic?: MosaicPhoto;
|
|
162
|
-
}
|
|
163
|
-
interface CommunityNote {
|
|
164
|
-
text: string;
|
|
165
|
-
facets: Facet[];
|
|
166
|
-
}
|
|
167
|
-
interface RepostedBy {
|
|
168
|
-
id: string;
|
|
169
|
-
name: string;
|
|
170
|
-
screen_name: string;
|
|
171
|
-
avatar_url?: string | null;
|
|
172
|
-
url?: string;
|
|
173
|
-
}
|
|
174
|
-
type TwitterCard = "tweet" | "summary" | "summary_large_image" | "player";
|
|
175
|
-
interface Tweet {
|
|
176
|
-
id: string;
|
|
177
|
-
url: string;
|
|
178
|
-
text: string;
|
|
179
|
-
raw_text: StatusRawText;
|
|
180
|
-
created_at: string;
|
|
181
|
-
created_timestamp: number;
|
|
182
|
-
author: Author;
|
|
183
|
-
likes: number;
|
|
184
|
-
/** Named `reposts` in the v2 API. */
|
|
185
|
-
retweets: number;
|
|
186
|
-
replies: number;
|
|
187
|
-
quotes: number;
|
|
188
|
-
views: number | null;
|
|
189
|
-
bookmarks?: number | null;
|
|
190
|
-
lang: string | null;
|
|
191
|
-
/** Screen name of the account being replied to. An object in the v2 API. */
|
|
192
|
-
replying_to: string | null;
|
|
193
|
-
/** Status ID being replied to. Folded into `replying_to` in the v2 API. */
|
|
194
|
-
replying_to_status: string | null;
|
|
195
|
-
source: string | null;
|
|
196
|
-
/** Named `embed_card` in the v2 API. */
|
|
197
|
-
twitter_card: TwitterCard;
|
|
198
|
-
provider?: string;
|
|
199
|
-
possibly_sensitive?: boolean;
|
|
200
|
-
is_note_tweet: boolean;
|
|
201
|
-
community_note: CommunityNote | null;
|
|
202
|
-
reposted_by: RepostedBy | null;
|
|
203
|
-
/** @deprecated Always `null` upstream. */
|
|
204
|
-
color?: string | null;
|
|
205
|
-
quote?: Tweet;
|
|
206
|
-
poll?: Poll;
|
|
207
|
-
/** Only present when a translation target was requested. */
|
|
208
|
-
translation?: Translation;
|
|
209
|
-
media?: StatusMedia;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* `message` values the API maps onto its status codes: 200, 401, 404, 503
|
|
213
|
-
* and 500 respectively.
|
|
214
|
-
*/
|
|
215
|
-
type StatusMessage = "OK" | "PRIVATE_TWEET" | "NOT_FOUND" | "UPSTREAM_UNAVAILABLE" | "API_FAIL";
|
|
216
|
-
interface StatusResponse {
|
|
217
|
-
/** Mirrors the HTTP status code. */
|
|
218
|
-
code: number;
|
|
219
|
-
message: StatusMessage | string;
|
|
220
|
-
/** `null` when the status could not be retrieved. */
|
|
221
|
-
tweet: Tweet | null;
|
|
222
|
-
}
|
|
223
|
-
interface UserResponse {
|
|
224
|
-
/** Mirrors the HTTP status code. */
|
|
225
|
-
code: number;
|
|
226
|
-
message: string;
|
|
227
|
-
/** Omitted entirely when the user could not be retrieved. */
|
|
228
|
-
user?: User;
|
|
229
|
-
/** Set to `suspended` when the account is suspended. */
|
|
230
|
-
reason?: "suspended";
|
|
231
|
-
}
|
|
232
|
-
//#endregion
|
|
233
|
-
//#region src/v1.d.ts
|
|
234
|
-
type FxTwitterV1Options = ClientOptions;
|
|
235
|
-
interface GetStatusOptions {
|
|
236
|
-
/**
|
|
237
|
-
* Included in the URL for readability only. The API resolves the status from
|
|
238
|
-
* `id` alone and never validates this, so a wrong handle still succeeds.
|
|
239
|
-
*/
|
|
240
|
-
screenName?: string;
|
|
241
|
-
/**
|
|
242
|
-
* Language to translate the status into, as an ISO 639-1 code (`es`) or a
|
|
243
|
-
* locale (`zh-cn`). Adds a `translation` object to the returned status.
|
|
244
|
-
*/
|
|
245
|
-
translateTo?: string;
|
|
246
|
-
/** Per-call cancellation, composed with the client-level `timeout`. */
|
|
247
|
-
signal?: AbortSignal;
|
|
248
|
-
}
|
|
249
|
-
interface GetUserOptions {
|
|
250
|
-
signal?: AbortSignal;
|
|
251
|
-
}
|
|
252
|
-
/** Client for the FxTwitter v1 API. */
|
|
253
|
-
declare class FxTwitterV1 {
|
|
254
|
-
private readonly http;
|
|
255
|
-
constructor(options?: FxTwitterV1Options);
|
|
256
|
-
/**
|
|
257
|
-
* Fetches a single status by its snowflake ID.
|
|
258
|
-
*
|
|
259
|
-
* `GET /status/:id`, `GET /status/:id/:language`,
|
|
260
|
-
* `GET /:handle/status/:id`, `GET /:handle/status/:id/:language`
|
|
261
|
-
*/
|
|
262
|
-
getStatus(id: string, options?: GetStatusOptions): Promise<StatusResponse>;
|
|
263
|
-
/** Fetches a user profile by handle (`GET /:handle`). */
|
|
264
|
-
getUser(screenName: string, options?: GetUserOptions): Promise<UserResponse>;
|
|
265
|
-
}
|
|
266
|
-
//#endregion
|
|
267
|
-
export { ClientOptions as A, User as C, Video as D, VerificationType as E, VideoFormat as O, TwitterCard as S, Verification as T, StatusMessage as _, AnyMedia as a, Translation as b, ExternalMedia as c, Photo as d, Poll as f, StatusMedia as g, RepostedBy as h, GetUserOptions as i, Website as k, Facet as l, RawText as m, FxTwitterV1Options as n, Author as o, PollChoice as p, GetStatusOptions as r, CommunityNote as s, FxTwitterV1 as t, MosaicPhoto as u, StatusRawText as v, UserResponse as w, Tweet as x, StatusResponse as y };
|