x-twitter-scraper 0.4.1 → 0.5.1
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/CHANGELOG.md +21 -0
- package/README.md +1 -0
- package/client.d.mts +1 -1
- package/client.d.ts +1 -1
- package/client.js +1 -1
- package/client.mjs +1 -1
- package/package.json +1 -1
- package/resources/account.d.mts +2 -2
- package/resources/account.d.ts +2 -2
- package/resources/compose.d.mts +186 -65
- package/resources/compose.d.mts.map +1 -1
- package/resources/compose.d.ts +186 -65
- package/resources/compose.d.ts.map +1 -1
- package/resources/compose.js +5 -2
- package/resources/compose.js.map +1 -1
- package/resources/compose.mjs +5 -2
- package/resources/compose.mjs.map +1 -1
- package/resources/credits.d.mts +1 -1
- package/resources/credits.d.ts +1 -1
- package/resources/extractions.d.mts +4 -4
- package/resources/extractions.d.ts +4 -4
- package/resources/guest-wallets.d.mts +2 -2
- package/resources/guest-wallets.d.ts +2 -2
- package/resources/monitors/keywords.d.mts +4 -4
- package/resources/monitors/keywords.d.ts +4 -4
- package/resources/monitors/keywords.js +4 -4
- package/resources/monitors/keywords.mjs +4 -4
- package/resources/monitors/monitors.d.mts +5 -4
- package/resources/monitors/monitors.d.mts.map +1 -1
- package/resources/monitors/monitors.d.ts +5 -4
- package/resources/monitors/monitors.d.ts.map +1 -1
- package/resources/monitors/monitors.js +5 -4
- package/resources/monitors/monitors.js.map +1 -1
- package/resources/monitors/monitors.mjs +5 -4
- package/resources/monitors/monitors.mjs.map +1 -1
- package/resources/shared.d.mts +24 -8
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +24 -8
- package/resources/shared.d.ts.map +1 -1
- package/resources/support/tickets.d.mts +67 -4
- package/resources/support/tickets.d.mts.map +1 -1
- package/resources/support/tickets.d.ts +67 -4
- package/resources/support/tickets.d.ts.map +1 -1
- package/resources/support/tickets.js +22 -4
- package/resources/support/tickets.js.map +1 -1
- package/resources/support/tickets.mjs +22 -4
- package/resources/support/tickets.mjs.map +1 -1
- package/resources/x/account-connection-challenges.d.mts +1 -1
- package/resources/x/account-connection-challenges.d.ts +1 -1
- package/resources/x/account-connection-challenges.js +1 -1
- package/resources/x/account-connection-challenges.mjs +1 -1
- package/resources/x/accounts.d.mts +9 -6
- package/resources/x/accounts.d.mts.map +1 -1
- package/resources/x/accounts.d.ts +9 -6
- package/resources/x/accounts.d.ts.map +1 -1
- package/resources/x/accounts.js +4 -2
- package/resources/x/accounts.js.map +1 -1
- package/resources/x/accounts.mjs +4 -2
- package/resources/x/accounts.mjs.map +1 -1
- package/resources/x/communities/communities.d.mts +360 -10
- package/resources/x/communities/communities.d.mts.map +1 -1
- package/resources/x/communities/communities.d.ts +360 -10
- package/resources/x/communities/communities.d.ts.map +1 -1
- package/resources/x/communities/communities.js +17 -4
- package/resources/x/communities/communities.js.map +1 -1
- package/resources/x/communities/communities.mjs +17 -4
- package/resources/x/communities/communities.mjs.map +1 -1
- package/resources/x/communities/join.d.mts +361 -7
- package/resources/x/communities/join.d.mts.map +1 -1
- package/resources/x/communities/join.d.ts +361 -7
- package/resources/x/communities/join.d.ts.map +1 -1
- package/resources/x/communities/join.js +20 -5
- package/resources/x/communities/join.js.map +1 -1
- package/resources/x/communities/join.mjs +20 -5
- package/resources/x/communities/join.mjs.map +1 -1
- package/resources/x/dm.d.mts +183 -5
- package/resources/x/dm.d.mts.map +1 -1
- package/resources/x/dm.d.ts +183 -5
- package/resources/x/dm.d.ts.map +1 -1
- package/resources/x/dm.js +9 -2
- package/resources/x/dm.js.map +1 -1
- package/resources/x/dm.mjs +9 -2
- package/resources/x/dm.mjs.map +1 -1
- package/resources/x/media.d.mts +178 -10
- package/resources/x/media.d.mts.map +1 -1
- package/resources/x/media.d.ts +178 -10
- package/resources/x/media.d.ts.map +1 -1
- package/resources/x/media.js +9 -5
- package/resources/x/media.js.map +1 -1
- package/resources/x/media.mjs +9 -5
- package/resources/x/media.mjs.map +1 -1
- package/resources/x/profile.d.mts +545 -14
- package/resources/x/profile.d.mts.map +1 -1
- package/resources/x/profile.d.ts +545 -14
- package/resources/x/profile.d.ts.map +1 -1
- package/resources/x/profile.js +25 -6
- package/resources/x/profile.js.map +1 -1
- package/resources/x/profile.mjs +25 -6
- package/resources/x/profile.mjs.map +1 -1
- package/resources/x/tweets/like.d.mts +358 -6
- package/resources/x/tweets/like.d.mts.map +1 -1
- package/resources/x/tweets/like.d.ts +358 -6
- package/resources/x/tweets/like.d.ts.map +1 -1
- package/resources/x/tweets/like.js +17 -4
- package/resources/x/tweets/like.js.map +1 -1
- package/resources/x/tweets/like.mjs +17 -4
- package/resources/x/tweets/like.mjs.map +1 -1
- package/resources/x/tweets/retweet.d.mts +358 -6
- package/resources/x/tweets/retweet.d.mts.map +1 -1
- package/resources/x/tweets/retweet.d.ts +358 -6
- package/resources/x/tweets/retweet.d.ts.map +1 -1
- package/resources/x/tweets/retweet.js +17 -4
- package/resources/x/tweets/retweet.js.map +1 -1
- package/resources/x/tweets/retweet.mjs +17 -4
- package/resources/x/tweets/retweet.mjs.map +1 -1
- package/resources/x/tweets/tweets.d.mts +376 -18
- package/resources/x/tweets/tweets.d.mts.map +1 -1
- package/resources/x/tweets/tweets.d.ts +376 -18
- package/resources/x/tweets/tweets.d.ts.map +1 -1
- package/resources/x/tweets/tweets.js +25 -6
- package/resources/x/tweets/tweets.js.map +1 -1
- package/resources/x/tweets/tweets.mjs +25 -6
- package/resources/x/tweets/tweets.mjs.map +1 -1
- package/resources/x/users/follow.d.mts +361 -7
- package/resources/x/users/follow.d.mts.map +1 -1
- package/resources/x/users/follow.d.ts +361 -7
- package/resources/x/users/follow.d.ts.map +1 -1
- package/resources/x/users/follow.js +20 -5
- package/resources/x/users/follow.js.map +1 -1
- package/resources/x/users/follow.mjs +20 -5
- package/resources/x/users/follow.mjs.map +1 -1
- package/resources/x/users/users.d.mts +181 -5
- package/resources/x/users/users.d.mts.map +1 -1
- package/resources/x/users/users.d.ts +181 -5
- package/resources/x/users/users.d.ts.map +1 -1
- package/resources/x/users/users.js +9 -2
- package/resources/x/users/users.js.map +1 -1
- package/resources/x/users/users.mjs +9 -2
- package/resources/x/users/users.mjs.map +1 -1
- package/resources/x/write-actions.d.mts +155 -12
- package/resources/x/write-actions.d.mts.map +1 -1
- package/resources/x/write-actions.d.ts +155 -12
- package/resources/x/write-actions.d.ts.map +1 -1
- package/src/client.ts +1 -1
- package/src/resources/account.ts +2 -2
- package/src/resources/compose.ts +232 -65
- package/src/resources/credits.ts +1 -1
- package/src/resources/extractions.ts +4 -4
- package/src/resources/guest-wallets.ts +2 -2
- package/src/resources/monitors/keywords.ts +4 -4
- package/src/resources/monitors/monitors.ts +5 -4
- package/src/resources/shared.ts +93 -9
- package/src/resources/support/tickets.ts +122 -6
- package/src/resources/x/account-connection-challenges.ts +1 -1
- package/src/resources/x/accounts.ts +9 -6
- package/src/resources/x/communities/communities.ts +515 -12
- package/src/resources/x/communities/join.ts +518 -9
- package/src/resources/x/dm.ts +261 -6
- package/src/resources/x/media.ts +258 -11
- package/src/resources/x/profile.ts +786 -17
- package/src/resources/x/tweets/like.ts +515 -8
- package/src/resources/x/tweets/retweet.ts +523 -8
- package/src/resources/x/tweets/tweets.ts +529 -23
- package/src/resources/x/users/follow.ts +518 -9
- package/src/resources/x/users/users.ts +260 -6
- package/src/resources/x/write-actions.ts +207 -14
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/resources/x/dm.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../../core/resource';
|
|
4
4
|
import { APIPromise } from '../../core/api-promise';
|
|
5
|
+
import { buildHeaders } from '../../internal/headers';
|
|
5
6
|
import { RequestOptions } from '../../internal/request-options';
|
|
6
7
|
import { path } from '../../internal/utils/path';
|
|
7
8
|
|
|
@@ -33,12 +34,18 @@ export class Dm extends APIResource {
|
|
|
33
34
|
* const response = await client.x.dm.send('userId', {
|
|
34
35
|
* account: '@elonmusk',
|
|
35
36
|
* text: 'Example text content',
|
|
37
|
+
* 'Idempotency-Key': 'Idempotency-Key',
|
|
36
38
|
* media_ids: ['1234567890123456789'],
|
|
37
39
|
* });
|
|
38
40
|
* ```
|
|
39
41
|
*/
|
|
40
|
-
send(userID: string,
|
|
41
|
-
|
|
42
|
+
send(userID: string, params: DmSendParams, options?: RequestOptions): APIPromise<DmSendResponse> {
|
|
43
|
+
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
|
|
44
|
+
return this._client.post(path`/x/dm/${userID}`, {
|
|
45
|
+
body,
|
|
46
|
+
...options,
|
|
47
|
+
headers: buildHeaders([{ 'Idempotency-Key': idempotencyKey }, options?.headers]),
|
|
48
|
+
});
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
51
|
|
|
@@ -70,10 +77,247 @@ export namespace DmRetrieveHistoryResponse {
|
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Durable write lifecycle record. Poll statusUrl until terminal is true. Reusing
|
|
82
|
+
* the original Idempotency-Key returns this same record. Submit a new write only
|
|
83
|
+
* when safeToRetry is true, using a new key.
|
|
84
|
+
*/
|
|
73
85
|
export interface DmSendResponse {
|
|
74
|
-
|
|
86
|
+
id: string;
|
|
75
87
|
|
|
76
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Connected account selected for the write.
|
|
90
|
+
*/
|
|
91
|
+
account: DmSendResponse.Account | null;
|
|
92
|
+
|
|
93
|
+
action:
|
|
94
|
+
| 'create_tweet'
|
|
95
|
+
| 'delete_tweet'
|
|
96
|
+
| 'like'
|
|
97
|
+
| 'unlike'
|
|
98
|
+
| 'retweet'
|
|
99
|
+
| 'unretweet'
|
|
100
|
+
| 'follow'
|
|
101
|
+
| 'unfollow'
|
|
102
|
+
| 'remove_follower'
|
|
103
|
+
| 'send_dm'
|
|
104
|
+
| 'upload_media'
|
|
105
|
+
| 'update_profile'
|
|
106
|
+
| 'update_avatar'
|
|
107
|
+
| 'update_banner'
|
|
108
|
+
| 'create_community'
|
|
109
|
+
| 'delete_community'
|
|
110
|
+
| 'join_community'
|
|
111
|
+
| 'leave_community';
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* plannedCredits is the approved maximum. chargedCredits comes from the settled
|
|
115
|
+
* credit ledger. Pending or failed writes are not charged.
|
|
116
|
+
*/
|
|
117
|
+
billing: DmSendResponse.Billing;
|
|
118
|
+
|
|
119
|
+
charged: boolean;
|
|
120
|
+
|
|
121
|
+
chargedCredits: string;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Exact follow-up an API client or agent should perform.
|
|
125
|
+
*/
|
|
126
|
+
nextAction: DmSendResponse.NextAction | null;
|
|
127
|
+
|
|
128
|
+
object: 'x_write_action';
|
|
129
|
+
|
|
130
|
+
pollAfterMs: number | null;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Stable fingerprint and sanitized payload for replay checks.
|
|
134
|
+
*/
|
|
135
|
+
request: DmSendResponse.Request;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Confirmed result produced by the write, when available.
|
|
139
|
+
*/
|
|
140
|
+
result: DmSendResponse.Result | null;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* True only when a new attempt can reasonably succeed.
|
|
144
|
+
*/
|
|
145
|
+
retryable: boolean;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* True only when no write was dispatched and a new idempotency key may be used.
|
|
149
|
+
*/
|
|
150
|
+
safeToRetry: boolean;
|
|
151
|
+
|
|
152
|
+
sendDispatched: boolean;
|
|
153
|
+
|
|
154
|
+
status: 'accepted' | 'dispatching' | 'pending_confirmation' | 'success' | 'failed' | 'expired';
|
|
155
|
+
|
|
156
|
+
statusUrl: string;
|
|
157
|
+
|
|
158
|
+
success: boolean;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Existing X resource targeted by the write, when applicable.
|
|
162
|
+
*/
|
|
163
|
+
target: DmSendResponse.Target | null;
|
|
164
|
+
|
|
165
|
+
targetId: string | null;
|
|
166
|
+
|
|
167
|
+
terminal: boolean;
|
|
168
|
+
|
|
169
|
+
writeActionId: string;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Compatibility field for a confirmed community ID.
|
|
173
|
+
*/
|
|
174
|
+
communityId?: string;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Confirmed community name when available.
|
|
178
|
+
*/
|
|
179
|
+
communityName?: string;
|
|
180
|
+
|
|
181
|
+
completedAt?: string;
|
|
182
|
+
|
|
183
|
+
confirmationAttempts?: number;
|
|
184
|
+
|
|
185
|
+
confirmationCheckedAt?: string;
|
|
186
|
+
|
|
187
|
+
confirmedAt?: string;
|
|
188
|
+
|
|
189
|
+
createdAt?: string;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Structured recovery context for a failed write.
|
|
193
|
+
*/
|
|
194
|
+
details?: { [key: string]: unknown };
|
|
195
|
+
|
|
196
|
+
error?: string;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Deadline for resolving a non-terminal write. This is not the Idempotency-Key
|
|
200
|
+
* retention deadline.
|
|
201
|
+
*/
|
|
202
|
+
expiresAt?: string;
|
|
203
|
+
|
|
204
|
+
idempotent?: boolean;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Media count, kind, size, and billing details when used.
|
|
208
|
+
*/
|
|
209
|
+
media?: { [key: string]: unknown };
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Compatibility field for a confirmed media upload ID.
|
|
213
|
+
*/
|
|
214
|
+
mediaId?: string;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Public media URL when the upload creates one.
|
|
218
|
+
*/
|
|
219
|
+
mediaUrl?: string;
|
|
220
|
+
|
|
221
|
+
message?: string;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Compatibility field for a confirmed direct message ID.
|
|
225
|
+
*/
|
|
226
|
+
messageId?: string;
|
|
227
|
+
|
|
228
|
+
requestHash?: string;
|
|
229
|
+
|
|
230
|
+
requestId?: string;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Compatibility result ID for other write actions.
|
|
234
|
+
*/
|
|
235
|
+
resultId?: string;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Dispatch timestamp when the write reached execution.
|
|
239
|
+
*/
|
|
240
|
+
sendDispatchedAt?: string;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Compatibility field for a confirmed tweet result ID.
|
|
244
|
+
*/
|
|
245
|
+
tweetId?: string;
|
|
246
|
+
|
|
247
|
+
updatedAt?: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export namespace DmSendResponse {
|
|
251
|
+
/**
|
|
252
|
+
* Connected account selected for the write.
|
|
253
|
+
*/
|
|
254
|
+
export interface Account {
|
|
255
|
+
id: string;
|
|
256
|
+
|
|
257
|
+
username: string;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* plannedCredits is the approved maximum. chargedCredits comes from the settled
|
|
262
|
+
* credit ledger. Pending or failed writes are not charged.
|
|
263
|
+
*/
|
|
264
|
+
export interface Billing {
|
|
265
|
+
charged: boolean;
|
|
266
|
+
|
|
267
|
+
chargedCredits: string;
|
|
268
|
+
|
|
269
|
+
plannedCredits: string;
|
|
270
|
+
|
|
271
|
+
status: 'not_charged' | 'pending' | 'charged' | 'charge_failed' | 'refunded';
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Exact follow-up an API client or agent should perform.
|
|
276
|
+
*/
|
|
277
|
+
export interface NextAction {
|
|
278
|
+
type: 'poll' | 'retry' | 'verify_result' | 'fix_request';
|
|
279
|
+
|
|
280
|
+
afterMs?: number;
|
|
281
|
+
|
|
282
|
+
requiresNewIdempotencyKey?: boolean;
|
|
283
|
+
|
|
284
|
+
url?: string;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Stable fingerprint and sanitized payload for replay checks.
|
|
289
|
+
*/
|
|
290
|
+
export interface Request {
|
|
291
|
+
/**
|
|
292
|
+
* Stable hash of account, action, target, and payload.
|
|
293
|
+
*/
|
|
294
|
+
hash: string | null;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Exact sanitized payload dispatched for this action.
|
|
298
|
+
*/
|
|
299
|
+
payload: { [key: string]: unknown } | null;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Confirmed result produced by the write, when available.
|
|
304
|
+
*/
|
|
305
|
+
export interface Result {
|
|
306
|
+
id?: string;
|
|
307
|
+
|
|
308
|
+
state?: string;
|
|
309
|
+
|
|
310
|
+
type?: 'tweet' | 'direct_message' | 'media' | 'community' | 'state_change';
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Existing X resource targeted by the write, when applicable.
|
|
315
|
+
*/
|
|
316
|
+
export interface Target {
|
|
317
|
+
id: string;
|
|
318
|
+
|
|
319
|
+
type: 'tweet' | 'user' | 'community';
|
|
320
|
+
}
|
|
77
321
|
}
|
|
78
322
|
|
|
79
323
|
export interface DmRetrieveHistoryParams {
|
|
@@ -96,14 +340,25 @@ export interface DmRetrieveHistoryParams {
|
|
|
96
340
|
|
|
97
341
|
export interface DmSendParams {
|
|
98
342
|
/**
|
|
99
|
-
* X account (@username or ID) sending the DM
|
|
343
|
+
* Body param: X account (@username or ID) sending the DM
|
|
100
344
|
*/
|
|
101
345
|
account: string;
|
|
102
346
|
|
|
347
|
+
/**
|
|
348
|
+
* Body param
|
|
349
|
+
*/
|
|
103
350
|
text: string;
|
|
104
351
|
|
|
105
352
|
/**
|
|
106
|
-
*
|
|
353
|
+
* Header param: Generate one unique value for each intended write. Reuse it only
|
|
354
|
+
* when retrying the exact same account, action, target, and payload. A reused key
|
|
355
|
+
* returns the original action. Reusing it with different input returns 409. Replay
|
|
356
|
+
* protection remains active for at least 90 days.
|
|
357
|
+
*/
|
|
358
|
+
'Idempotency-Key': string;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Body param: Optional array containing exactly 1 uploaded media ID.
|
|
107
362
|
*/
|
|
108
363
|
media_ids?: Array<string>;
|
|
109
364
|
}
|
package/src/resources/x/media.ts
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../../core/resource';
|
|
4
4
|
import { APIPromise } from '../../core/api-promise';
|
|
5
|
+
import { buildHeaders } from '../../internal/headers';
|
|
5
6
|
import { RequestOptions } from '../../internal/request-options';
|
|
6
7
|
import { maybeMultipartFormRequestOptions } from '../../internal/uploads';
|
|
7
8
|
|
|
8
|
-
/**
|
|
9
|
-
* Media upload and download
|
|
10
|
-
*/
|
|
11
9
|
export class Media extends APIResource {
|
|
12
10
|
/**
|
|
13
11
|
* Download images and videos from tweets
|
|
@@ -31,13 +29,22 @@ export class Media extends APIResource {
|
|
|
31
29
|
* const response = await client.x.media.upload({
|
|
32
30
|
* account: '@elonmusk',
|
|
33
31
|
* url: 'https://example.com/image.png',
|
|
32
|
+
* 'Idempotency-Key': 'Idempotency-Key',
|
|
34
33
|
* });
|
|
35
34
|
* ```
|
|
36
35
|
*/
|
|
37
|
-
upload(
|
|
36
|
+
upload(params: MediaUploadParams, options?: RequestOptions): APIPromise<MediaUploadResponse> {
|
|
37
|
+
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
|
|
38
38
|
return this._client.post(
|
|
39
39
|
'/x/media',
|
|
40
|
-
maybeMultipartFormRequestOptions(
|
|
40
|
+
maybeMultipartFormRequestOptions(
|
|
41
|
+
{
|
|
42
|
+
body,
|
|
43
|
+
...options,
|
|
44
|
+
headers: buildHeaders([{ 'Idempotency-Key': idempotencyKey }, options?.headers]),
|
|
45
|
+
},
|
|
46
|
+
this._client,
|
|
47
|
+
),
|
|
41
48
|
);
|
|
42
49
|
}
|
|
43
50
|
}
|
|
@@ -54,15 +61,247 @@ export interface MediaDownloadResponse {
|
|
|
54
61
|
tweetId?: string;
|
|
55
62
|
}
|
|
56
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Durable write lifecycle record. Poll statusUrl until terminal is true. Reusing
|
|
66
|
+
* the original Idempotency-Key returns this same record. Submit a new write only
|
|
67
|
+
* when safeToRetry is true, using a new key.
|
|
68
|
+
*/
|
|
57
69
|
export interface MediaUploadResponse {
|
|
58
|
-
|
|
70
|
+
id: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Connected account selected for the write.
|
|
74
|
+
*/
|
|
75
|
+
account: MediaUploadResponse.Account | null;
|
|
76
|
+
|
|
77
|
+
action:
|
|
78
|
+
| 'create_tweet'
|
|
79
|
+
| 'delete_tweet'
|
|
80
|
+
| 'like'
|
|
81
|
+
| 'unlike'
|
|
82
|
+
| 'retweet'
|
|
83
|
+
| 'unretweet'
|
|
84
|
+
| 'follow'
|
|
85
|
+
| 'unfollow'
|
|
86
|
+
| 'remove_follower'
|
|
87
|
+
| 'send_dm'
|
|
88
|
+
| 'upload_media'
|
|
89
|
+
| 'update_profile'
|
|
90
|
+
| 'update_avatar'
|
|
91
|
+
| 'update_banner'
|
|
92
|
+
| 'create_community'
|
|
93
|
+
| 'delete_community'
|
|
94
|
+
| 'join_community'
|
|
95
|
+
| 'leave_community';
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* plannedCredits is the approved maximum. chargedCredits comes from the settled
|
|
99
|
+
* credit ledger. Pending or failed writes are not charged.
|
|
100
|
+
*/
|
|
101
|
+
billing: MediaUploadResponse.Billing;
|
|
102
|
+
|
|
103
|
+
charged: boolean;
|
|
104
|
+
|
|
105
|
+
chargedCredits: string;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Exact follow-up an API client or agent should perform.
|
|
109
|
+
*/
|
|
110
|
+
nextAction: MediaUploadResponse.NextAction | null;
|
|
111
|
+
|
|
112
|
+
object: 'x_write_action';
|
|
113
|
+
|
|
114
|
+
pollAfterMs: number | null;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Stable fingerprint and sanitized payload for replay checks.
|
|
118
|
+
*/
|
|
119
|
+
request: MediaUploadResponse.Request;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Confirmed result produced by the write, when available.
|
|
123
|
+
*/
|
|
124
|
+
result: MediaUploadResponse.Result | null;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* True only when a new attempt can reasonably succeed.
|
|
128
|
+
*/
|
|
129
|
+
retryable: boolean;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* True only when no write was dispatched and a new idempotency key may be used.
|
|
133
|
+
*/
|
|
134
|
+
safeToRetry: boolean;
|
|
135
|
+
|
|
136
|
+
sendDispatched: boolean;
|
|
137
|
+
|
|
138
|
+
status: 'accepted' | 'dispatching' | 'pending_confirmation' | 'success' | 'failed' | 'expired';
|
|
139
|
+
|
|
140
|
+
statusUrl: string;
|
|
141
|
+
|
|
142
|
+
success: boolean;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Existing X resource targeted by the write, when applicable.
|
|
146
|
+
*/
|
|
147
|
+
target: MediaUploadResponse.Target | null;
|
|
148
|
+
|
|
149
|
+
targetId: string | null;
|
|
150
|
+
|
|
151
|
+
terminal: boolean;
|
|
152
|
+
|
|
153
|
+
writeActionId: string;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Compatibility field for a confirmed community ID.
|
|
157
|
+
*/
|
|
158
|
+
communityId?: string;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Confirmed community name when available.
|
|
162
|
+
*/
|
|
163
|
+
communityName?: string;
|
|
164
|
+
|
|
165
|
+
completedAt?: string;
|
|
166
|
+
|
|
167
|
+
confirmationAttempts?: number;
|
|
168
|
+
|
|
169
|
+
confirmationCheckedAt?: string;
|
|
170
|
+
|
|
171
|
+
confirmedAt?: string;
|
|
172
|
+
|
|
173
|
+
createdAt?: string;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Structured recovery context for a failed write.
|
|
177
|
+
*/
|
|
178
|
+
details?: { [key: string]: unknown };
|
|
179
|
+
|
|
180
|
+
error?: string;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Deadline for resolving a non-terminal write. This is not the Idempotency-Key
|
|
184
|
+
* retention deadline.
|
|
185
|
+
*/
|
|
186
|
+
expiresAt?: string;
|
|
187
|
+
|
|
188
|
+
idempotent?: boolean;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Media count, kind, size, and billing details when used.
|
|
192
|
+
*/
|
|
193
|
+
media?: { [key: string]: unknown };
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Compatibility field for a confirmed media upload ID.
|
|
197
|
+
*/
|
|
198
|
+
mediaId?: string;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Public media URL when the upload creates one.
|
|
202
|
+
*/
|
|
203
|
+
mediaUrl?: string;
|
|
204
|
+
|
|
205
|
+
message?: string;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Compatibility field for a confirmed direct message ID.
|
|
209
|
+
*/
|
|
210
|
+
messageId?: string;
|
|
211
|
+
|
|
212
|
+
requestHash?: string;
|
|
213
|
+
|
|
214
|
+
requestId?: string;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Compatibility result ID for other write actions.
|
|
218
|
+
*/
|
|
219
|
+
resultId?: string;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Dispatch timestamp when the write reached execution.
|
|
223
|
+
*/
|
|
224
|
+
sendDispatchedAt?: string;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Compatibility field for a confirmed tweet result ID.
|
|
228
|
+
*/
|
|
229
|
+
tweetId?: string;
|
|
230
|
+
|
|
231
|
+
updatedAt?: string;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export namespace MediaUploadResponse {
|
|
235
|
+
/**
|
|
236
|
+
* Connected account selected for the write.
|
|
237
|
+
*/
|
|
238
|
+
export interface Account {
|
|
239
|
+
id: string;
|
|
240
|
+
|
|
241
|
+
username: string;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* plannedCredits is the approved maximum. chargedCredits comes from the settled
|
|
246
|
+
* credit ledger. Pending or failed writes are not charged.
|
|
247
|
+
*/
|
|
248
|
+
export interface Billing {
|
|
249
|
+
charged: boolean;
|
|
250
|
+
|
|
251
|
+
chargedCredits: string;
|
|
252
|
+
|
|
253
|
+
plannedCredits: string;
|
|
254
|
+
|
|
255
|
+
status: 'not_charged' | 'pending' | 'charged' | 'charge_failed' | 'refunded';
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Exact follow-up an API client or agent should perform.
|
|
260
|
+
*/
|
|
261
|
+
export interface NextAction {
|
|
262
|
+
type: 'poll' | 'retry' | 'verify_result' | 'fix_request';
|
|
263
|
+
|
|
264
|
+
afterMs?: number;
|
|
265
|
+
|
|
266
|
+
requiresNewIdempotencyKey?: boolean;
|
|
267
|
+
|
|
268
|
+
url?: string;
|
|
269
|
+
}
|
|
59
270
|
|
|
60
271
|
/**
|
|
61
|
-
*
|
|
272
|
+
* Stable fingerprint and sanitized payload for replay checks.
|
|
62
273
|
*/
|
|
63
|
-
|
|
274
|
+
export interface Request {
|
|
275
|
+
/**
|
|
276
|
+
* Stable hash of account, action, target, and payload.
|
|
277
|
+
*/
|
|
278
|
+
hash: string | null;
|
|
64
279
|
|
|
65
|
-
|
|
280
|
+
/**
|
|
281
|
+
* Exact sanitized payload dispatched for this action.
|
|
282
|
+
*/
|
|
283
|
+
payload: { [key: string]: unknown } | null;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Confirmed result produced by the write, when available.
|
|
288
|
+
*/
|
|
289
|
+
export interface Result {
|
|
290
|
+
id?: string;
|
|
291
|
+
|
|
292
|
+
state?: string;
|
|
293
|
+
|
|
294
|
+
type?: 'tweet' | 'direct_message' | 'media' | 'community' | 'state_change';
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Existing X resource targeted by the write, when applicable.
|
|
299
|
+
*/
|
|
300
|
+
export interface Target {
|
|
301
|
+
id: string;
|
|
302
|
+
|
|
303
|
+
type: 'tweet' | 'user' | 'community';
|
|
304
|
+
}
|
|
66
305
|
}
|
|
67
306
|
|
|
68
307
|
export interface MediaDownloadParams {
|
|
@@ -89,14 +328,22 @@ export interface MediaDownloadParams {
|
|
|
89
328
|
|
|
90
329
|
export interface MediaUploadParams {
|
|
91
330
|
/**
|
|
92
|
-
* X account (@username or ID) uploading media from URL
|
|
331
|
+
* Body param: X account (@username or ID) uploading media from URL
|
|
93
332
|
*/
|
|
94
333
|
account: string;
|
|
95
334
|
|
|
96
335
|
/**
|
|
97
|
-
* HTTPS URL to download and upload as media
|
|
336
|
+
* Body param: HTTPS URL to download and upload as media
|
|
98
337
|
*/
|
|
99
338
|
url: string;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Header param: Generate one unique value for each intended write. Reuse it only
|
|
342
|
+
* when retrying the exact same account, action, target, and payload. A reused key
|
|
343
|
+
* returns the original action. Reusing it with different input returns 409. Replay
|
|
344
|
+
* protection remains active for at least 90 days.
|
|
345
|
+
*/
|
|
346
|
+
'Idempotency-Key': string;
|
|
100
347
|
}
|
|
101
348
|
|
|
102
349
|
export declare namespace Media {
|