fxtwitter 1.0.0 → 2.0.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 +90 -31
- 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 +9 -1
- package/dist/v1-BKUGwGbc.d.cts +0 -267
- package/dist/v1-BKUGwGbc.d.mts +0 -267
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { n as FxTwitterError, t as HttpClient } from "./http-BTdKgEdX.mjs";
|
|
2
|
+
//#region src/deprecation.ts
|
|
3
|
+
const emitted = /* @__PURE__ */ new Set();
|
|
4
|
+
/**
|
|
5
|
+
* Emits a deprecation warning once per process, the way Node's own deprecated
|
|
6
|
+
* APIs (and libraries such as discord.js) do — so `--no-deprecation` and
|
|
7
|
+
* `--throw-deprecation` apply, and repeated construction doesn't spam the
|
|
8
|
+
* console. Falls back to `console.warn` in runtimes without
|
|
9
|
+
* `process.emitWarning`.
|
|
10
|
+
*/
|
|
11
|
+
function emitDeprecationWarning(code, message) {
|
|
12
|
+
if (emitted.has(code)) return;
|
|
13
|
+
emitted.add(code);
|
|
14
|
+
const proc = globalThis.process;
|
|
15
|
+
if (typeof proc?.emitWarning === "function") {
|
|
16
|
+
proc.emitWarning(message, {
|
|
17
|
+
type: "DeprecationWarning",
|
|
18
|
+
code
|
|
19
|
+
});
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
console.warn(`DeprecationWarning [${code}]: ${message}`);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/v1.ts
|
|
26
|
+
/**
|
|
27
|
+
* The API resolves a status from the first 2-20 digit run in the path segment,
|
|
28
|
+
* and answers anything else with its embed HTML at HTTP 200 rather than JSON.
|
|
29
|
+
*/
|
|
30
|
+
const STATUS_ID_PATTERN = /^\d{2,20}$/;
|
|
31
|
+
/**
|
|
32
|
+
* Handles are matched as `\w{1,15}` upstream; anything else is redirected to
|
|
33
|
+
* the project's GitHub page instead of returning JSON.
|
|
34
|
+
*/
|
|
35
|
+
const HANDLE_PATTERN = /^\w{1,15}$/;
|
|
36
|
+
const DEPRECATION_MESSAGE = "FxTwitterV1 targets the legacy FxTwitter v1 API, which is kept only for backwards compatibility and does not receive new features. Use FxTwitterV2 (import from \"fxtwitter/v2\") instead.";
|
|
37
|
+
/**
|
|
38
|
+
* Client for the legacy FxTwitter v1 API.
|
|
39
|
+
*
|
|
40
|
+
* @deprecated Use {@link import("./v2").FxTwitterV2} instead. v1 is kept only
|
|
41
|
+
* for backwards compatibility and does not receive new features.
|
|
42
|
+
*/
|
|
43
|
+
var FxTwitterV1 = class {
|
|
44
|
+
http;
|
|
45
|
+
constructor(options = {}) {
|
|
46
|
+
if (!options.silenceDeprecationWarning) emitDeprecationWarning("FXTWITTER_V1_DEPRECATED", DEPRECATION_MESSAGE);
|
|
47
|
+
this.http = new HttpClient(options);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Fetches a single status by its snowflake ID.
|
|
51
|
+
*
|
|
52
|
+
* `GET /status/:id`, `GET /status/:id/:language`,
|
|
53
|
+
* `GET /:handle/status/:id`, `GET /:handle/status/:id/:language`
|
|
54
|
+
*/
|
|
55
|
+
async getStatus(id, options = {}) {
|
|
56
|
+
if (!STATUS_ID_PATTERN.test(id)) throw new FxTwitterError(`Invalid status ID ${JSON.stringify(id)}: expected 2-20 digits`);
|
|
57
|
+
if (options.screenName !== void 0 && options.screenName.trim() === "") throw new FxTwitterError("screenName must not be empty");
|
|
58
|
+
const segments = [
|
|
59
|
+
options.screenName,
|
|
60
|
+
"status",
|
|
61
|
+
id,
|
|
62
|
+
options.translateTo
|
|
63
|
+
].filter((segment) => segment !== void 0);
|
|
64
|
+
return requireBody(await this.http.get({
|
|
65
|
+
path: `/${segments.map(encodeURIComponent).join("/")}`,
|
|
66
|
+
signal: options.signal
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
/** Fetches a user profile by handle (`GET /:handle`). */
|
|
70
|
+
async getUser(screenName, options = {}) {
|
|
71
|
+
assertHandle(screenName);
|
|
72
|
+
return requireBody(await this.http.get({
|
|
73
|
+
path: `/${encodeURIComponent(screenName)}`,
|
|
74
|
+
signal: options.signal
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
function assertHandle(handle) {
|
|
79
|
+
if (!HANDLE_PATTERN.test(handle)) throw new FxTwitterError(`Invalid handle ${JSON.stringify(handle)}: expected 1-15 letters, digits or underscores, without a leading @`);
|
|
80
|
+
}
|
|
81
|
+
/** v1 never answers 204, so an empty body here means something went wrong. */
|
|
82
|
+
function requireBody(body) {
|
|
83
|
+
if (body === null) throw new FxTwitterError("The API returned an empty response");
|
|
84
|
+
return body;
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { FxTwitterV1 as t };
|
package/dist/v1.cjs
CHANGED
package/dist/v1.d.cts
CHANGED
|
@@ -1,2 +1,253 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as ClientOptions } from "./http-CidaL0TV.cjs";
|
|
2
|
+
//#region src/types/v1.d.ts
|
|
3
|
+
interface Facet {
|
|
4
|
+
/** e.g. `url`, `mention`, `hashtag`, `media`. */
|
|
5
|
+
type: string;
|
|
6
|
+
/** Start/end UTF-16 indices. */
|
|
7
|
+
indices: [number, number];
|
|
8
|
+
original?: string;
|
|
9
|
+
replacement?: string;
|
|
10
|
+
display?: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
}
|
|
13
|
+
interface RawText {
|
|
14
|
+
text: string;
|
|
15
|
+
facets: Facet[];
|
|
16
|
+
}
|
|
17
|
+
interface StatusRawText extends RawText {
|
|
18
|
+
display_text_range: [number, number];
|
|
19
|
+
}
|
|
20
|
+
interface Website {
|
|
21
|
+
url: string;
|
|
22
|
+
display_url: string;
|
|
23
|
+
}
|
|
24
|
+
type VerificationType = "organization" | "government" | "individual" | null;
|
|
25
|
+
interface Verification {
|
|
26
|
+
verified: boolean;
|
|
27
|
+
type: VerificationType;
|
|
28
|
+
verified_at?: string | null;
|
|
29
|
+
identity_verified?: boolean;
|
|
30
|
+
verified_by?: string;
|
|
31
|
+
}
|
|
32
|
+
/** The author embedded in a status. Same shape as {@link User}, plus `avatar_color`. */
|
|
33
|
+
interface Author {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
screen_name: string;
|
|
37
|
+
url: string;
|
|
38
|
+
description: string;
|
|
39
|
+
raw_description: RawText;
|
|
40
|
+
location: string;
|
|
41
|
+
avatar_url: string | null;
|
|
42
|
+
banner_url: string | null;
|
|
43
|
+
/** @deprecated Always `null` upstream. */
|
|
44
|
+
avatar_color?: string | null;
|
|
45
|
+
followers: number;
|
|
46
|
+
following: number;
|
|
47
|
+
likes: number;
|
|
48
|
+
media_count: number;
|
|
49
|
+
joined: string;
|
|
50
|
+
protected: boolean;
|
|
51
|
+
website: Website | null;
|
|
52
|
+
verification?: Verification;
|
|
53
|
+
}
|
|
54
|
+
/** The user returned by `GET /:screen_name`. Uses `tweets` where v2 uses `statuses`. */
|
|
55
|
+
interface User extends Author {
|
|
56
|
+
/** Status count. Named `statuses` in the v2 API. */
|
|
57
|
+
tweets: number;
|
|
58
|
+
}
|
|
59
|
+
interface Translation {
|
|
60
|
+
text: string;
|
|
61
|
+
source_lang: string;
|
|
62
|
+
source_lang_en: string;
|
|
63
|
+
target_lang: string;
|
|
64
|
+
provider: string;
|
|
65
|
+
}
|
|
66
|
+
interface PollChoice {
|
|
67
|
+
label: string;
|
|
68
|
+
count: number;
|
|
69
|
+
/** 0-100. */
|
|
70
|
+
percentage: number;
|
|
71
|
+
}
|
|
72
|
+
interface Poll {
|
|
73
|
+
choices: PollChoice[];
|
|
74
|
+
total_votes: number;
|
|
75
|
+
ends_at: string;
|
|
76
|
+
time_left_en: string;
|
|
77
|
+
}
|
|
78
|
+
interface VideoFormat {
|
|
79
|
+
container?: "mp4" | "webm" | "m3u8";
|
|
80
|
+
codec?: "h264" | "hevc" | "vp9" | "av1";
|
|
81
|
+
bitrate?: number;
|
|
82
|
+
url: string;
|
|
83
|
+
size?: number;
|
|
84
|
+
height?: number;
|
|
85
|
+
width?: number;
|
|
86
|
+
}
|
|
87
|
+
interface Photo {
|
|
88
|
+
id?: string;
|
|
89
|
+
/** MIME type, e.g. `image/jpeg`. */
|
|
90
|
+
format?: string;
|
|
91
|
+
type: "photo" | "gif";
|
|
92
|
+
url: string;
|
|
93
|
+
width: number;
|
|
94
|
+
height: number;
|
|
95
|
+
transcode_url?: string | null;
|
|
96
|
+
altText?: string;
|
|
97
|
+
}
|
|
98
|
+
interface Video {
|
|
99
|
+
id?: string;
|
|
100
|
+
/** MIME type, e.g. `video/mp4`. */
|
|
101
|
+
format?: string;
|
|
102
|
+
type: "video" | "gif";
|
|
103
|
+
url: string;
|
|
104
|
+
width: number;
|
|
105
|
+
height: number;
|
|
106
|
+
thumbnail_url?: string | null;
|
|
107
|
+
transcode_url?: string | null;
|
|
108
|
+
duration: number;
|
|
109
|
+
filesize?: number;
|
|
110
|
+
formats?: VideoFormat[];
|
|
111
|
+
}
|
|
112
|
+
interface MosaicPhoto {
|
|
113
|
+
id?: string;
|
|
114
|
+
type: "mosaic_photo";
|
|
115
|
+
url?: string;
|
|
116
|
+
width: number;
|
|
117
|
+
height: number;
|
|
118
|
+
formats: {
|
|
119
|
+
webp: string;
|
|
120
|
+
jpeg: string;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
interface ExternalMedia {
|
|
124
|
+
/** Currently always `video`. */
|
|
125
|
+
type: string;
|
|
126
|
+
url: string;
|
|
127
|
+
thumbnail_url?: string;
|
|
128
|
+
height?: number;
|
|
129
|
+
width?: number;
|
|
130
|
+
duration?: number;
|
|
131
|
+
}
|
|
132
|
+
type AnyMedia = Photo | Video | MosaicPhoto;
|
|
133
|
+
interface StatusMedia {
|
|
134
|
+
/** Preserves the original ordering across photos and videos. */
|
|
135
|
+
all?: AnyMedia[];
|
|
136
|
+
external?: ExternalMedia;
|
|
137
|
+
photos?: Photo[];
|
|
138
|
+
videos?: Video[];
|
|
139
|
+
mosaic?: MosaicPhoto;
|
|
140
|
+
}
|
|
141
|
+
interface CommunityNote {
|
|
142
|
+
text: string;
|
|
143
|
+
facets: Facet[];
|
|
144
|
+
}
|
|
145
|
+
interface RepostedBy {
|
|
146
|
+
id: string;
|
|
147
|
+
name: string;
|
|
148
|
+
screen_name: string;
|
|
149
|
+
avatar_url?: string | null;
|
|
150
|
+
url?: string;
|
|
151
|
+
}
|
|
152
|
+
type TwitterCard = "tweet" | "summary" | "summary_large_image" | "player";
|
|
153
|
+
interface Tweet {
|
|
154
|
+
id: string;
|
|
155
|
+
url: string;
|
|
156
|
+
text: string;
|
|
157
|
+
raw_text: StatusRawText;
|
|
158
|
+
created_at: string;
|
|
159
|
+
created_timestamp: number;
|
|
160
|
+
author: Author;
|
|
161
|
+
likes: number;
|
|
162
|
+
/** Named `reposts` in the v2 API. */
|
|
163
|
+
retweets: number;
|
|
164
|
+
replies: number;
|
|
165
|
+
quotes: number;
|
|
166
|
+
views: number | null;
|
|
167
|
+
bookmarks?: number | null;
|
|
168
|
+
lang: string | null;
|
|
169
|
+
/** Screen name of the account being replied to. An object in the v2 API. */
|
|
170
|
+
replying_to: string | null;
|
|
171
|
+
/** Status ID being replied to. Folded into `replying_to` in the v2 API. */
|
|
172
|
+
replying_to_status: string | null;
|
|
173
|
+
source: string | null;
|
|
174
|
+
/** Named `embed_card` in the v2 API. */
|
|
175
|
+
twitter_card: TwitterCard;
|
|
176
|
+
provider?: string;
|
|
177
|
+
possibly_sensitive?: boolean;
|
|
178
|
+
is_note_tweet: boolean;
|
|
179
|
+
community_note: CommunityNote | null;
|
|
180
|
+
reposted_by: RepostedBy | null;
|
|
181
|
+
/** @deprecated Always `null` upstream. */
|
|
182
|
+
color?: string | null;
|
|
183
|
+
quote?: Tweet;
|
|
184
|
+
poll?: Poll;
|
|
185
|
+
/** Only present when a translation target was requested. */
|
|
186
|
+
translation?: Translation;
|
|
187
|
+
media?: StatusMedia;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* `message` values the API maps onto its status codes: 200, 401, 404, 503
|
|
191
|
+
* and 500 respectively.
|
|
192
|
+
*/
|
|
193
|
+
type StatusMessage = "OK" | "PRIVATE_TWEET" | "NOT_FOUND" | "UPSTREAM_UNAVAILABLE" | "API_FAIL";
|
|
194
|
+
interface StatusResponse {
|
|
195
|
+
/** Mirrors the HTTP status code. */
|
|
196
|
+
code: number;
|
|
197
|
+
message: StatusMessage | string;
|
|
198
|
+
/** `null` when the status could not be retrieved. */
|
|
199
|
+
tweet: Tweet | null;
|
|
200
|
+
}
|
|
201
|
+
interface UserResponse {
|
|
202
|
+
/** Mirrors the HTTP status code. */
|
|
203
|
+
code: number;
|
|
204
|
+
message: string;
|
|
205
|
+
/** Omitted entirely when the user could not be retrieved. */
|
|
206
|
+
user?: User;
|
|
207
|
+
/** Set to `suspended` when the account is suspended. */
|
|
208
|
+
reason?: "suspended";
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/v1.d.ts
|
|
212
|
+
type FxTwitterV1Options = ClientOptions & {
|
|
213
|
+
/** Suppresses the one-time deprecation warning emitted on construction. */
|
|
214
|
+
silenceDeprecationWarning?: boolean;
|
|
215
|
+
};
|
|
216
|
+
interface GetStatusOptions {
|
|
217
|
+
/**
|
|
218
|
+
* Included in the URL for readability only. The API resolves the status from
|
|
219
|
+
* `id` alone and never validates this, so a wrong handle still succeeds.
|
|
220
|
+
*/
|
|
221
|
+
screenName?: string;
|
|
222
|
+
/**
|
|
223
|
+
* Language to translate the status into, as an ISO 639-1 code (`es`) or a
|
|
224
|
+
* locale (`zh-cn`). Adds a `translation` object to the returned status.
|
|
225
|
+
*/
|
|
226
|
+
translateTo?: string;
|
|
227
|
+
/** Per-call cancellation, composed with the client-level `timeout`. */
|
|
228
|
+
signal?: AbortSignal;
|
|
229
|
+
}
|
|
230
|
+
interface GetUserOptions {
|
|
231
|
+
signal?: AbortSignal;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Client for the legacy FxTwitter v1 API.
|
|
235
|
+
*
|
|
236
|
+
* @deprecated Use {@link import("./v2").FxTwitterV2} instead. v1 is kept only
|
|
237
|
+
* for backwards compatibility and does not receive new features.
|
|
238
|
+
*/
|
|
239
|
+
declare class FxTwitterV1 {
|
|
240
|
+
private readonly http;
|
|
241
|
+
constructor(options?: FxTwitterV1Options);
|
|
242
|
+
/**
|
|
243
|
+
* Fetches a single status by its snowflake ID.
|
|
244
|
+
*
|
|
245
|
+
* `GET /status/:id`, `GET /status/:id/:language`,
|
|
246
|
+
* `GET /:handle/status/:id`, `GET /:handle/status/:id/:language`
|
|
247
|
+
*/
|
|
248
|
+
getStatus(id: string, options?: GetStatusOptions): Promise<StatusResponse>;
|
|
249
|
+
/** Fetches a user profile by handle (`GET /:handle`). */
|
|
250
|
+
getUser(screenName: string, options?: GetUserOptions): Promise<UserResponse>;
|
|
251
|
+
}
|
|
252
|
+
//#endregion
|
|
2
253
|
export { type AnyMedia, type Author, type CommunityNote, type ExternalMedia, type Facet, FxTwitterV1, FxTwitterV1Options, GetStatusOptions, GetUserOptions, type MosaicPhoto, type Photo, type Poll, type PollChoice, type RawText, type RepostedBy, type StatusMedia, type StatusMessage, type StatusRawText, type StatusResponse, type Translation, type Tweet, type TwitterCard, type User, type UserResponse, type Verification, type VerificationType, type Video, type VideoFormat, type Website };
|
package/dist/v1.d.mts
CHANGED
|
@@ -1,2 +1,253 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as ClientOptions } from "./http-CidaL0TV.mjs";
|
|
2
|
+
//#region src/types/v1.d.ts
|
|
3
|
+
interface Facet {
|
|
4
|
+
/** e.g. `url`, `mention`, `hashtag`, `media`. */
|
|
5
|
+
type: string;
|
|
6
|
+
/** Start/end UTF-16 indices. */
|
|
7
|
+
indices: [number, number];
|
|
8
|
+
original?: string;
|
|
9
|
+
replacement?: string;
|
|
10
|
+
display?: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
}
|
|
13
|
+
interface RawText {
|
|
14
|
+
text: string;
|
|
15
|
+
facets: Facet[];
|
|
16
|
+
}
|
|
17
|
+
interface StatusRawText extends RawText {
|
|
18
|
+
display_text_range: [number, number];
|
|
19
|
+
}
|
|
20
|
+
interface Website {
|
|
21
|
+
url: string;
|
|
22
|
+
display_url: string;
|
|
23
|
+
}
|
|
24
|
+
type VerificationType = "organization" | "government" | "individual" | null;
|
|
25
|
+
interface Verification {
|
|
26
|
+
verified: boolean;
|
|
27
|
+
type: VerificationType;
|
|
28
|
+
verified_at?: string | null;
|
|
29
|
+
identity_verified?: boolean;
|
|
30
|
+
verified_by?: string;
|
|
31
|
+
}
|
|
32
|
+
/** The author embedded in a status. Same shape as {@link User}, plus `avatar_color`. */
|
|
33
|
+
interface Author {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
screen_name: string;
|
|
37
|
+
url: string;
|
|
38
|
+
description: string;
|
|
39
|
+
raw_description: RawText;
|
|
40
|
+
location: string;
|
|
41
|
+
avatar_url: string | null;
|
|
42
|
+
banner_url: string | null;
|
|
43
|
+
/** @deprecated Always `null` upstream. */
|
|
44
|
+
avatar_color?: string | null;
|
|
45
|
+
followers: number;
|
|
46
|
+
following: number;
|
|
47
|
+
likes: number;
|
|
48
|
+
media_count: number;
|
|
49
|
+
joined: string;
|
|
50
|
+
protected: boolean;
|
|
51
|
+
website: Website | null;
|
|
52
|
+
verification?: Verification;
|
|
53
|
+
}
|
|
54
|
+
/** The user returned by `GET /:screen_name`. Uses `tweets` where v2 uses `statuses`. */
|
|
55
|
+
interface User extends Author {
|
|
56
|
+
/** Status count. Named `statuses` in the v2 API. */
|
|
57
|
+
tweets: number;
|
|
58
|
+
}
|
|
59
|
+
interface Translation {
|
|
60
|
+
text: string;
|
|
61
|
+
source_lang: string;
|
|
62
|
+
source_lang_en: string;
|
|
63
|
+
target_lang: string;
|
|
64
|
+
provider: string;
|
|
65
|
+
}
|
|
66
|
+
interface PollChoice {
|
|
67
|
+
label: string;
|
|
68
|
+
count: number;
|
|
69
|
+
/** 0-100. */
|
|
70
|
+
percentage: number;
|
|
71
|
+
}
|
|
72
|
+
interface Poll {
|
|
73
|
+
choices: PollChoice[];
|
|
74
|
+
total_votes: number;
|
|
75
|
+
ends_at: string;
|
|
76
|
+
time_left_en: string;
|
|
77
|
+
}
|
|
78
|
+
interface VideoFormat {
|
|
79
|
+
container?: "mp4" | "webm" | "m3u8";
|
|
80
|
+
codec?: "h264" | "hevc" | "vp9" | "av1";
|
|
81
|
+
bitrate?: number;
|
|
82
|
+
url: string;
|
|
83
|
+
size?: number;
|
|
84
|
+
height?: number;
|
|
85
|
+
width?: number;
|
|
86
|
+
}
|
|
87
|
+
interface Photo {
|
|
88
|
+
id?: string;
|
|
89
|
+
/** MIME type, e.g. `image/jpeg`. */
|
|
90
|
+
format?: string;
|
|
91
|
+
type: "photo" | "gif";
|
|
92
|
+
url: string;
|
|
93
|
+
width: number;
|
|
94
|
+
height: number;
|
|
95
|
+
transcode_url?: string | null;
|
|
96
|
+
altText?: string;
|
|
97
|
+
}
|
|
98
|
+
interface Video {
|
|
99
|
+
id?: string;
|
|
100
|
+
/** MIME type, e.g. `video/mp4`. */
|
|
101
|
+
format?: string;
|
|
102
|
+
type: "video" | "gif";
|
|
103
|
+
url: string;
|
|
104
|
+
width: number;
|
|
105
|
+
height: number;
|
|
106
|
+
thumbnail_url?: string | null;
|
|
107
|
+
transcode_url?: string | null;
|
|
108
|
+
duration: number;
|
|
109
|
+
filesize?: number;
|
|
110
|
+
formats?: VideoFormat[];
|
|
111
|
+
}
|
|
112
|
+
interface MosaicPhoto {
|
|
113
|
+
id?: string;
|
|
114
|
+
type: "mosaic_photo";
|
|
115
|
+
url?: string;
|
|
116
|
+
width: number;
|
|
117
|
+
height: number;
|
|
118
|
+
formats: {
|
|
119
|
+
webp: string;
|
|
120
|
+
jpeg: string;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
interface ExternalMedia {
|
|
124
|
+
/** Currently always `video`. */
|
|
125
|
+
type: string;
|
|
126
|
+
url: string;
|
|
127
|
+
thumbnail_url?: string;
|
|
128
|
+
height?: number;
|
|
129
|
+
width?: number;
|
|
130
|
+
duration?: number;
|
|
131
|
+
}
|
|
132
|
+
type AnyMedia = Photo | Video | MosaicPhoto;
|
|
133
|
+
interface StatusMedia {
|
|
134
|
+
/** Preserves the original ordering across photos and videos. */
|
|
135
|
+
all?: AnyMedia[];
|
|
136
|
+
external?: ExternalMedia;
|
|
137
|
+
photos?: Photo[];
|
|
138
|
+
videos?: Video[];
|
|
139
|
+
mosaic?: MosaicPhoto;
|
|
140
|
+
}
|
|
141
|
+
interface CommunityNote {
|
|
142
|
+
text: string;
|
|
143
|
+
facets: Facet[];
|
|
144
|
+
}
|
|
145
|
+
interface RepostedBy {
|
|
146
|
+
id: string;
|
|
147
|
+
name: string;
|
|
148
|
+
screen_name: string;
|
|
149
|
+
avatar_url?: string | null;
|
|
150
|
+
url?: string;
|
|
151
|
+
}
|
|
152
|
+
type TwitterCard = "tweet" | "summary" | "summary_large_image" | "player";
|
|
153
|
+
interface Tweet {
|
|
154
|
+
id: string;
|
|
155
|
+
url: string;
|
|
156
|
+
text: string;
|
|
157
|
+
raw_text: StatusRawText;
|
|
158
|
+
created_at: string;
|
|
159
|
+
created_timestamp: number;
|
|
160
|
+
author: Author;
|
|
161
|
+
likes: number;
|
|
162
|
+
/** Named `reposts` in the v2 API. */
|
|
163
|
+
retweets: number;
|
|
164
|
+
replies: number;
|
|
165
|
+
quotes: number;
|
|
166
|
+
views: number | null;
|
|
167
|
+
bookmarks?: number | null;
|
|
168
|
+
lang: string | null;
|
|
169
|
+
/** Screen name of the account being replied to. An object in the v2 API. */
|
|
170
|
+
replying_to: string | null;
|
|
171
|
+
/** Status ID being replied to. Folded into `replying_to` in the v2 API. */
|
|
172
|
+
replying_to_status: string | null;
|
|
173
|
+
source: string | null;
|
|
174
|
+
/** Named `embed_card` in the v2 API. */
|
|
175
|
+
twitter_card: TwitterCard;
|
|
176
|
+
provider?: string;
|
|
177
|
+
possibly_sensitive?: boolean;
|
|
178
|
+
is_note_tweet: boolean;
|
|
179
|
+
community_note: CommunityNote | null;
|
|
180
|
+
reposted_by: RepostedBy | null;
|
|
181
|
+
/** @deprecated Always `null` upstream. */
|
|
182
|
+
color?: string | null;
|
|
183
|
+
quote?: Tweet;
|
|
184
|
+
poll?: Poll;
|
|
185
|
+
/** Only present when a translation target was requested. */
|
|
186
|
+
translation?: Translation;
|
|
187
|
+
media?: StatusMedia;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* `message` values the API maps onto its status codes: 200, 401, 404, 503
|
|
191
|
+
* and 500 respectively.
|
|
192
|
+
*/
|
|
193
|
+
type StatusMessage = "OK" | "PRIVATE_TWEET" | "NOT_FOUND" | "UPSTREAM_UNAVAILABLE" | "API_FAIL";
|
|
194
|
+
interface StatusResponse {
|
|
195
|
+
/** Mirrors the HTTP status code. */
|
|
196
|
+
code: number;
|
|
197
|
+
message: StatusMessage | string;
|
|
198
|
+
/** `null` when the status could not be retrieved. */
|
|
199
|
+
tweet: Tweet | null;
|
|
200
|
+
}
|
|
201
|
+
interface UserResponse {
|
|
202
|
+
/** Mirrors the HTTP status code. */
|
|
203
|
+
code: number;
|
|
204
|
+
message: string;
|
|
205
|
+
/** Omitted entirely when the user could not be retrieved. */
|
|
206
|
+
user?: User;
|
|
207
|
+
/** Set to `suspended` when the account is suspended. */
|
|
208
|
+
reason?: "suspended";
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/v1.d.ts
|
|
212
|
+
type FxTwitterV1Options = ClientOptions & {
|
|
213
|
+
/** Suppresses the one-time deprecation warning emitted on construction. */
|
|
214
|
+
silenceDeprecationWarning?: boolean;
|
|
215
|
+
};
|
|
216
|
+
interface GetStatusOptions {
|
|
217
|
+
/**
|
|
218
|
+
* Included in the URL for readability only. The API resolves the status from
|
|
219
|
+
* `id` alone and never validates this, so a wrong handle still succeeds.
|
|
220
|
+
*/
|
|
221
|
+
screenName?: string;
|
|
222
|
+
/**
|
|
223
|
+
* Language to translate the status into, as an ISO 639-1 code (`es`) or a
|
|
224
|
+
* locale (`zh-cn`). Adds a `translation` object to the returned status.
|
|
225
|
+
*/
|
|
226
|
+
translateTo?: string;
|
|
227
|
+
/** Per-call cancellation, composed with the client-level `timeout`. */
|
|
228
|
+
signal?: AbortSignal;
|
|
229
|
+
}
|
|
230
|
+
interface GetUserOptions {
|
|
231
|
+
signal?: AbortSignal;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Client for the legacy FxTwitter v1 API.
|
|
235
|
+
*
|
|
236
|
+
* @deprecated Use {@link import("./v2").FxTwitterV2} instead. v1 is kept only
|
|
237
|
+
* for backwards compatibility and does not receive new features.
|
|
238
|
+
*/
|
|
239
|
+
declare class FxTwitterV1 {
|
|
240
|
+
private readonly http;
|
|
241
|
+
constructor(options?: FxTwitterV1Options);
|
|
242
|
+
/**
|
|
243
|
+
* Fetches a single status by its snowflake ID.
|
|
244
|
+
*
|
|
245
|
+
* `GET /status/:id`, `GET /status/:id/:language`,
|
|
246
|
+
* `GET /:handle/status/:id`, `GET /:handle/status/:id/:language`
|
|
247
|
+
*/
|
|
248
|
+
getStatus(id: string, options?: GetStatusOptions): Promise<StatusResponse>;
|
|
249
|
+
/** Fetches a user profile by handle (`GET /:handle`). */
|
|
250
|
+
getUser(screenName: string, options?: GetUserOptions): Promise<UserResponse>;
|
|
251
|
+
}
|
|
252
|
+
//#endregion
|
|
2
253
|
export { type AnyMedia, type Author, type CommunityNote, type ExternalMedia, type Facet, FxTwitterV1, FxTwitterV1Options, GetStatusOptions, GetUserOptions, type MosaicPhoto, type Photo, type Poll, type PollChoice, type RawText, type RepostedBy, type StatusMedia, type StatusMessage, type StatusRawText, type StatusResponse, type Translation, type Tweet, type TwitterCard, type User, type UserResponse, type Verification, type VerificationType, type Video, type VideoFormat, type Website };
|
package/dist/v1.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as FxTwitterV1 } from "./v1-
|
|
1
|
+
import { t as FxTwitterV1 } from "./v1-ByqsBlpO.mjs";
|
|
2
2
|
export { FxTwitterV1 };
|