@spectratools/xapi-cli 0.4.0 → 0.5.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.
Files changed (2) hide show
  1. package/dist/cli.js +70 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -189,6 +189,15 @@ function createXApiClient(bearerToken) {
189
189
  function likePost(userId, tweetId) {
190
190
  return post(`/users/${userId}/likes`, { tweet_id: tweetId });
191
191
  }
192
+ function unlikePost(userId, tweetId) {
193
+ return del(`/users/${userId}/likes/${tweetId}`);
194
+ }
195
+ function bookmarkPost(userId, tweetId) {
196
+ return post(`/users/${userId}/bookmarks`, { tweet_id: tweetId });
197
+ }
198
+ function unbookmarkPost(userId, tweetId) {
199
+ return del(`/users/${userId}/bookmarks/${tweetId}`);
200
+ }
192
201
  function retweetPost(userId, tweetId) {
193
202
  return post(`/users/${userId}/retweets`, { tweet_id: tweetId });
194
203
  }
@@ -225,6 +234,22 @@ function createXApiClient(bearerToken) {
225
234
  function unfollowUser(sourceUserId, targetUserId) {
226
235
  return del(`/users/${sourceUserId}/following/${targetUserId}`);
227
236
  }
237
+ function blockUser(sourceUserId, targetUserId) {
238
+ return post(`/users/${sourceUserId}/blocking`, {
239
+ target_user_id: targetUserId
240
+ });
241
+ }
242
+ function unblockUser(sourceUserId, targetUserId) {
243
+ return del(`/users/${sourceUserId}/blocking/${targetUserId}`);
244
+ }
245
+ function muteUser(sourceUserId, targetUserId) {
246
+ return post(`/users/${sourceUserId}/muting`, {
247
+ target_user_id: targetUserId
248
+ });
249
+ }
250
+ function unmuteUser(sourceUserId, targetUserId) {
251
+ return del(`/users/${sourceUserId}/muting/${targetUserId}`);
252
+ }
228
253
  function getUserPosts(id, maxResults, nextToken) {
229
254
  return get(`/users/${id}/tweets`, {
230
255
  max_results: maxResults,
@@ -280,6 +305,24 @@ function createXApiClient(bearerToken) {
280
305
  ...nextToken ? { pagination_token: nextToken } : {}
281
306
  });
282
307
  }
308
+ function createList(name, description, isPrivate) {
309
+ return post("/lists", {
310
+ name,
311
+ ...description ? { description } : {},
312
+ ...isPrivate !== void 0 ? { private: isPrivate } : {}
313
+ });
314
+ }
315
+ function deleteList(id) {
316
+ return del(`/lists/${id}`);
317
+ }
318
+ function addListMember(id, userId) {
319
+ return post(`/lists/${id}/members`, {
320
+ user_id: userId
321
+ });
322
+ }
323
+ function removeListMember(id, userId) {
324
+ return del(`/lists/${id}/members/${userId}`);
325
+ }
283
326
  function getTrendingPlaces() {
284
327
  return getV1_1(
285
328
  "/trends/available.json"
@@ -318,6 +361,9 @@ function createXApiClient(bearerToken) {
318
361
  getPostLikes,
319
362
  getPostRetweets,
320
363
  likePost,
364
+ unlikePost,
365
+ bookmarkPost,
366
+ unbookmarkPost,
321
367
  retweetPost,
322
368
  getUserByUsername,
323
369
  getUserById,
@@ -325,6 +371,10 @@ function createXApiClient(bearerToken) {
325
371
  getUserFollowing,
326
372
  followUser,
327
373
  unfollowUser,
374
+ blockUser,
375
+ unblockUser,
376
+ muteUser,
377
+ unmuteUser,
328
378
  getUserPosts,
329
379
  getUserMentions,
330
380
  searchUsers,
@@ -333,6 +383,10 @@ function createXApiClient(bearerToken) {
333
383
  getList,
334
384
  getListMembers,
335
385
  getListPosts,
386
+ createList,
387
+ deleteList,
388
+ addListMember,
389
+ removeListMember,
336
390
  getTrendingPlaces,
337
391
  getTrendsByLocation,
338
392
  getDmConversations,
@@ -935,6 +989,7 @@ timeline.command("home", {
935
989
  description: "View your home timeline.",
936
990
  options: z5.object({
937
991
  maxResults: z5.number().default(25).describe("Maximum posts to return (5\u2013100)"),
992
+ sinceId: z5.string().optional().describe("Only return posts newer than this post ID"),
938
993
  verbose: z5.boolean().optional().describe("Show full text without truncation")
939
994
  }),
940
995
  alias: { maxResults: "n" },
@@ -954,14 +1009,18 @@ timeline.command("home", {
954
1009
  }),
955
1010
  examples: [
956
1011
  { description: "View your home timeline" },
957
- { options: { maxResults: 50 }, description: "View 50 posts" }
1012
+ { options: { maxResults: 50 }, description: "View 50 posts" },
1013
+ {
1014
+ options: { sinceId: "1900123456789012345" },
1015
+ description: "Resume from last-seen post ID"
1016
+ }
958
1017
  ],
959
1018
  async run(c) {
960
1019
  const client = createXApiClient(readAuthToken(c.env));
961
1020
  const meRes = await client.getMe();
962
1021
  const userId = meRes.data.id;
963
1022
  const allPosts = await collectPaged(
964
- (limit, cursor) => client.getHomeTimeline(userId, limit, cursor),
1023
+ (limit, cursor) => client.getHomeTimeline(userId, limit, cursor, c.options.sinceId),
965
1024
  (post) => ({
966
1025
  id: post.id,
967
1026
  text: c.options.verbose ? post.text : truncateText(post.text),
@@ -994,6 +1053,7 @@ timeline.command("mentions", {
994
1053
  description: "View your recent mentions.",
995
1054
  options: z5.object({
996
1055
  maxResults: z5.number().default(25).describe("Maximum mentions to return"),
1056
+ sinceId: z5.string().optional().describe("Only return mentions newer than this post ID"),
997
1057
  verbose: z5.boolean().optional().describe("Show full text without truncation")
998
1058
  }),
999
1059
  alias: { maxResults: "n" },
@@ -1009,13 +1069,19 @@ timeline.command("mentions", {
1009
1069
  ),
1010
1070
  count: z5.number()
1011
1071
  }),
1012
- examples: [{ description: "View your recent mentions" }],
1072
+ examples: [
1073
+ { description: "View your recent mentions" },
1074
+ {
1075
+ options: { sinceId: "1900123456789012345" },
1076
+ description: "Resume mentions from last-seen post ID"
1077
+ }
1078
+ ],
1013
1079
  async run(c) {
1014
1080
  const client = createXApiClient(readAuthToken(c.env));
1015
1081
  const meRes = await client.getMe();
1016
1082
  const userId = meRes.data.id;
1017
1083
  const allPosts = await collectPaged(
1018
- (limit, cursor) => client.getMentionsTimeline(userId, limit, cursor),
1084
+ (limit, cursor) => client.getMentionsTimeline(userId, limit, cursor, c.options.sinceId),
1019
1085
  (post) => ({
1020
1086
  id: post.id,
1021
1087
  text: c.options.verbose ? post.text : truncateText(post.text),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectratools/xapi-cli",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "X (Twitter) API CLI for spectra-the-bot",
5
5
  "type": "module",
6
6
  "license": "MIT",