corsair 0.1.36 → 0.1.37
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/dist/index.js +871 -640
- package/dist/plugins/index.js +870 -639
- package/dist/plugins/twitterapiio/endpoints/index.d.ts +95 -0
- package/dist/plugins/twitterapiio/endpoints/index.d.ts.map +1 -1
- package/dist/plugins/twitterapiio/endpoints/tweets.d.ts +1 -0
- package/dist/plugins/twitterapiio/endpoints/tweets.d.ts.map +1 -1
- package/dist/plugins/twitterapiio/endpoints/types.d.ts +646 -0
- package/dist/plugins/twitterapiio/endpoints/types.d.ts.map +1 -1
- package/dist/plugins/twitterapiio/index.d.ts +529 -0
- package/dist/plugins/twitterapiio/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39793,622 +39793,337 @@ var get59 = async (ctx, input) => {
|
|
|
39793
39793
|
return response;
|
|
39794
39794
|
};
|
|
39795
39795
|
|
|
39796
|
-
// plugins/twitterapiio/endpoints/
|
|
39797
|
-
|
|
39798
|
-
|
|
39799
|
-
|
|
39800
|
-
|
|
39801
|
-
|
|
39802
|
-
|
|
39803
|
-
|
|
39804
|
-
|
|
39805
|
-
|
|
39806
|
-
|
|
39807
|
-
|
|
39808
|
-
|
|
39809
|
-
|
|
39796
|
+
// plugins/twitterapiio/endpoints/types.ts
|
|
39797
|
+
import { z as z71 } from "zod";
|
|
39798
|
+
|
|
39799
|
+
// plugins/twitterapiio/schema/database.ts
|
|
39800
|
+
import { z as z70 } from "zod";
|
|
39801
|
+
var TwitterApiIOUser = z70.object({
|
|
39802
|
+
id: z70.string(),
|
|
39803
|
+
userName: z70.string(),
|
|
39804
|
+
name: z70.string(),
|
|
39805
|
+
followerCount: z70.number().optional(),
|
|
39806
|
+
followingCount: z70.number().optional(),
|
|
39807
|
+
profilePicture: z70.string().nullable().optional(),
|
|
39808
|
+
coverPicture: z70.string().nullable().optional(),
|
|
39809
|
+
description: z70.string().nullable().optional(),
|
|
39810
|
+
location: z70.string().nullable().optional(),
|
|
39811
|
+
isBlueVerified: z70.boolean().optional(),
|
|
39812
|
+
isGovernmentVerified: z70.boolean().optional(),
|
|
39813
|
+
favouritesCount: z70.number().optional(),
|
|
39814
|
+
statusesCount: z70.number().optional(),
|
|
39815
|
+
mediaCount: z70.number().optional(),
|
|
39816
|
+
createdAt: z70.string().optional(),
|
|
39817
|
+
isProtected: z70.boolean().optional(),
|
|
39818
|
+
isSuspended: z70.boolean().optional(),
|
|
39819
|
+
isUnavailable: z70.boolean().optional(),
|
|
39820
|
+
pinnedTweetIds: z70.array(z70.string()).optional(),
|
|
39821
|
+
website: z70.string().nullable().optional()
|
|
39822
|
+
});
|
|
39823
|
+
var TwitterApiIOTweetMedia = z70.object({
|
|
39824
|
+
type: z70.string().optional(),
|
|
39825
|
+
url: z70.string().optional(),
|
|
39826
|
+
mediaUrlHttps: z70.string().optional(),
|
|
39827
|
+
expandedUrl: z70.string().optional(),
|
|
39828
|
+
width: z70.number().optional(),
|
|
39829
|
+
height: z70.number().optional(),
|
|
39830
|
+
altText: z70.string().nullable().optional(),
|
|
39831
|
+
durationMs: z70.number().nullable().optional()
|
|
39832
|
+
});
|
|
39833
|
+
var TwitterApiIOTweet = z70.object({
|
|
39834
|
+
id: z70.string(),
|
|
39835
|
+
text: z70.string(),
|
|
39836
|
+
author: z70.string().optional(),
|
|
39837
|
+
createdAt: z70.string().optional(),
|
|
39838
|
+
likeCount: z70.number().optional(),
|
|
39839
|
+
retweetCount: z70.number().optional(),
|
|
39840
|
+
replyCount: z70.number().optional(),
|
|
39841
|
+
quoteCount: z70.number().optional(),
|
|
39842
|
+
viewCount: z70.number().nullable().optional(),
|
|
39843
|
+
bookmarkCount: z70.number().optional(),
|
|
39844
|
+
lang: z70.string().optional(),
|
|
39845
|
+
source: z70.string().optional(),
|
|
39846
|
+
isRetweet: z70.boolean().optional(),
|
|
39847
|
+
isQuote: z70.boolean().optional(),
|
|
39848
|
+
isPinned: z70.boolean().optional(),
|
|
39849
|
+
inReplyToStatusId: z70.string().nullable().optional(),
|
|
39850
|
+
inReplyToUserId: z70.string().nullable().optional(),
|
|
39851
|
+
quotedTweetId: z70.string().nullable().optional(),
|
|
39852
|
+
media: z70.array(TwitterApiIOTweetMedia).optional(),
|
|
39853
|
+
entities: z70.object({
|
|
39854
|
+
urls: z70.array(
|
|
39855
|
+
z70.object({
|
|
39856
|
+
url: z70.string().optional(),
|
|
39857
|
+
expandedUrl: z70.string().optional(),
|
|
39858
|
+
displayUrl: z70.string().optional()
|
|
39859
|
+
})
|
|
39860
|
+
).optional(),
|
|
39861
|
+
hashtags: z70.array(
|
|
39862
|
+
z70.object({
|
|
39863
|
+
text: z70.string().optional()
|
|
39864
|
+
})
|
|
39865
|
+
).optional(),
|
|
39866
|
+
userMentions: z70.array(
|
|
39867
|
+
z70.object({
|
|
39868
|
+
id: z70.string().optional(),
|
|
39869
|
+
name: z70.string().optional(),
|
|
39870
|
+
screenName: z70.string().optional()
|
|
39871
|
+
})
|
|
39872
|
+
).optional()
|
|
39873
|
+
}).optional(),
|
|
39874
|
+
conversationId: z70.string().optional()
|
|
39875
|
+
});
|
|
39876
|
+
var TwitterApiIOList = z70.object({
|
|
39877
|
+
id: z70.string(),
|
|
39878
|
+
name: z70.string(),
|
|
39879
|
+
description: z70.string().nullable().optional(),
|
|
39880
|
+
memberCount: z70.number().optional(),
|
|
39881
|
+
followerCount: z70.number().optional(),
|
|
39882
|
+
owner: TwitterApiIOUser.optional(),
|
|
39883
|
+
createdAt: z70.string().optional(),
|
|
39884
|
+
isPrivate: z70.boolean().optional()
|
|
39885
|
+
});
|
|
39886
|
+
var TwitterApiIOCommunity = z70.object({
|
|
39887
|
+
id: z70.string(),
|
|
39888
|
+
name: z70.string(),
|
|
39889
|
+
description: z70.string().nullable().optional(),
|
|
39890
|
+
memberCount: z70.number().optional(),
|
|
39891
|
+
role: z70.string().optional(),
|
|
39892
|
+
createdAt: z70.string().optional(),
|
|
39893
|
+
isNsfw: z70.boolean().optional(),
|
|
39894
|
+
adminResults: z70.array(z70.any()).optional(),
|
|
39895
|
+
moderatorResults: z70.array(z70.any()).optional(),
|
|
39896
|
+
rules: z70.array(z70.any()).optional(),
|
|
39897
|
+
primaryTopic: z70.any().optional()
|
|
39898
|
+
});
|
|
39899
|
+
var TwitterApiIOTrend = z70.object({
|
|
39900
|
+
name: z70.string(),
|
|
39901
|
+
tweetVolume: z70.number().nullable().optional(),
|
|
39902
|
+
url: z70.string().optional(),
|
|
39903
|
+
woeid: z70.number().optional(),
|
|
39904
|
+
trendingAt: z70.string().optional()
|
|
39905
|
+
});
|
|
39906
|
+
var RawApiTweet = TwitterApiIOTweet.extend({
|
|
39907
|
+
author: TwitterApiIOUser.optional()
|
|
39908
|
+
});
|
|
39909
|
+
|
|
39910
|
+
// plugins/twitterapiio/endpoints/types.ts
|
|
39911
|
+
var PaginatedTweetsResponseSchema = z71.object({
|
|
39912
|
+
status: z71.boolean().optional(),
|
|
39913
|
+
tweets: z71.array(RawApiTweet).optional(),
|
|
39914
|
+
next_cursor: z71.string().nullable().optional(),
|
|
39915
|
+
has_next_page: z71.boolean().optional()
|
|
39916
|
+
});
|
|
39917
|
+
var PaginatedUsersResponseSchema = z71.object({
|
|
39918
|
+
status: z71.boolean().optional(),
|
|
39919
|
+
users: z71.array(TwitterApiIOUser).optional(),
|
|
39920
|
+
next_cursor: z71.string().nullable().optional(),
|
|
39921
|
+
has_next_page: z71.boolean().optional()
|
|
39922
|
+
});
|
|
39923
|
+
var ActionResponseSchema = z71.object({
|
|
39924
|
+
status: z71.boolean().optional(),
|
|
39925
|
+
message: z71.string().optional()
|
|
39926
|
+
});
|
|
39927
|
+
var TweetsGetByIdsInputSchema = z71.object({
|
|
39928
|
+
tweetIds: z71.string().describe("Comma-separated list of tweet IDs")
|
|
39929
|
+
});
|
|
39930
|
+
var TweetsSearchInputSchema = z71.object({
|
|
39931
|
+
query: z71.string(),
|
|
39932
|
+
queryType: z71.enum(["Top", "Latest", "Photos", "Videos"]).optional().describe("Search type. Defaults to Top"),
|
|
39933
|
+
cursor: z71.string().optional()
|
|
39934
|
+
});
|
|
39935
|
+
var TwitterLanguageCode = z71.enum([
|
|
39936
|
+
"am",
|
|
39937
|
+
"ar",
|
|
39938
|
+
"bg",
|
|
39939
|
+
"bn",
|
|
39940
|
+
"bo",
|
|
39941
|
+
"ca",
|
|
39942
|
+
"cs",
|
|
39943
|
+
"cy",
|
|
39944
|
+
"da",
|
|
39945
|
+
"de",
|
|
39946
|
+
"dv",
|
|
39947
|
+
"el",
|
|
39948
|
+
"en",
|
|
39949
|
+
"es",
|
|
39950
|
+
"et",
|
|
39951
|
+
"eu",
|
|
39952
|
+
"fa",
|
|
39953
|
+
"fi",
|
|
39954
|
+
"fr",
|
|
39955
|
+
"ga",
|
|
39956
|
+
"gl",
|
|
39957
|
+
"gu",
|
|
39958
|
+
"he",
|
|
39959
|
+
"hi",
|
|
39960
|
+
"hr",
|
|
39961
|
+
"hy",
|
|
39962
|
+
"id",
|
|
39963
|
+
"is",
|
|
39964
|
+
"it",
|
|
39965
|
+
"ja",
|
|
39966
|
+
"ka",
|
|
39967
|
+
"km",
|
|
39968
|
+
"kn",
|
|
39969
|
+
"ko",
|
|
39970
|
+
"lo",
|
|
39971
|
+
"lt",
|
|
39972
|
+
"lv",
|
|
39973
|
+
"ml",
|
|
39974
|
+
"mr",
|
|
39975
|
+
"my",
|
|
39976
|
+
"ne",
|
|
39977
|
+
"nl",
|
|
39978
|
+
"no",
|
|
39979
|
+
"or",
|
|
39980
|
+
"pa",
|
|
39981
|
+
"pl",
|
|
39982
|
+
"ps",
|
|
39983
|
+
"pt",
|
|
39984
|
+
"ro",
|
|
39985
|
+
"ru",
|
|
39986
|
+
"si",
|
|
39987
|
+
"sk",
|
|
39988
|
+
"sl",
|
|
39989
|
+
"sq",
|
|
39990
|
+
"sr",
|
|
39991
|
+
"sv",
|
|
39992
|
+
"sw",
|
|
39993
|
+
"ta",
|
|
39994
|
+
"te",
|
|
39995
|
+
"th",
|
|
39996
|
+
"tl",
|
|
39997
|
+
"tr",
|
|
39998
|
+
"ug",
|
|
39999
|
+
"uk",
|
|
40000
|
+
"ur",
|
|
40001
|
+
"vi",
|
|
40002
|
+
"zh"
|
|
40003
|
+
]);
|
|
40004
|
+
var TweetsAdvancedSearchInputSchema = z71.object({
|
|
40005
|
+
// ── Content filters ────────────────────────────────────────────────────
|
|
40006
|
+
/** Words that must ALL appear in the tweet (AND logic) */
|
|
40007
|
+
keywords: z71.array(z71.string().min(1)).optional().describe("Words that must all appear in tweets (AND logic)"),
|
|
40008
|
+
/** Exact phrase that must appear verbatim */
|
|
40009
|
+
exactPhrase: z71.string().optional().describe("Exact phrase that must appear in tweets"),
|
|
40010
|
+
/** At least one of these words must appear (OR logic) */
|
|
40011
|
+
anyOf: z71.array(z71.string().min(1)).min(2).optional().describe("At least one of these words must appear (OR logic, minimum 2 items)"),
|
|
40012
|
+
/** Words that must NOT appear in the tweet */
|
|
40013
|
+
excludeKeywords: z71.array(z71.string().min(1)).optional().describe("Words that must not appear in tweets"),
|
|
40014
|
+
/** Hashtags to match (with or without leading #) */
|
|
40015
|
+
hashtags: z71.array(z71.string().min(1)).optional().describe("Hashtags to search for (with or without leading #)"),
|
|
40016
|
+
// ── User filters ───────────────────────────────────────────────────────
|
|
40017
|
+
/** Only return tweets sent by these usernames */
|
|
40018
|
+
fromUsers: z71.array(z71.string().min(1)).optional().describe("Only tweets from these usernames"),
|
|
40019
|
+
/** Only return tweets that are replies to these usernames */
|
|
40020
|
+
toUsers: z71.array(z71.string().min(1)).optional().describe("Only replies to these usernames"),
|
|
40021
|
+
/** Only return tweets that mention these usernames */
|
|
40022
|
+
mentioningUsers: z71.array(z71.string().min(1)).optional().describe("Only tweets mentioning these usernames"),
|
|
40023
|
+
// ── Language filter ────────────────────────────────────────────────────
|
|
40024
|
+
/** ISO 639-1 language code to restrict results */
|
|
40025
|
+
language: TwitterLanguageCode.optional().describe(
|
|
40026
|
+
'ISO 639-1 language code (e.g. "en", "fr", "ja")'
|
|
40027
|
+
),
|
|
40028
|
+
// ── Time filters ───────────────────────────────────────────────────────
|
|
40029
|
+
/** Return tweets posted on or after this date (YYYY-MM-DD) */
|
|
40030
|
+
since: z71.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD").optional().describe("Only tweets posted on or after this date (YYYY-MM-DD)"),
|
|
40031
|
+
/** Return tweets posted before this date (YYYY-MM-DD) */
|
|
40032
|
+
until: z71.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Must be YYYY-MM-DD").optional().describe("Only tweets posted before this date (YYYY-MM-DD)"),
|
|
40033
|
+
// ── Tweet-type filters ─────────────────────────────────────────────────
|
|
40034
|
+
/** Whether to include or exclude replies */
|
|
40035
|
+
replies: z71.enum(["only", "exclude"]).optional().describe('"only" to return only replies; "exclude" to omit replies'),
|
|
40036
|
+
/** Whether to include or exclude retweets */
|
|
40037
|
+
retweets: z71.enum(["only", "exclude"]).optional().describe('"only" to return only retweets; "exclude" to omit retweets'),
|
|
40038
|
+
/** Only return tweets that contain at least one link */
|
|
40039
|
+
onlyLinks: z71.boolean().optional().describe("Only tweets containing links"),
|
|
40040
|
+
/** Only return tweets that contain media (images or video) */
|
|
40041
|
+
onlyMedia: z71.boolean().optional().describe("Only tweets with media"),
|
|
40042
|
+
/** Only return tweets that contain images */
|
|
40043
|
+
onlyImages: z71.boolean().optional().describe("Only tweets with images"),
|
|
40044
|
+
/** Only return tweets that contain native video */
|
|
40045
|
+
onlyVideos: z71.boolean().optional().describe("Only tweets with native video"),
|
|
40046
|
+
// ── Engagement thresholds ──────────────────────────────────────────────
|
|
40047
|
+
/** Only return tweets with at least this many replies */
|
|
40048
|
+
minReplies: z71.number().int().nonnegative().optional().describe("Minimum number of replies"),
|
|
40049
|
+
/** Only return tweets with at least this many likes */
|
|
40050
|
+
minLikes: z71.number().int().nonnegative().optional().describe("Minimum number of likes"),
|
|
40051
|
+
/** Only return tweets with at least this many retweets */
|
|
40052
|
+
minRetweets: z71.number().int().nonnegative().optional().describe("Minimum number of retweets"),
|
|
40053
|
+
// ── Result ordering & pagination ───────────────────────────────────────
|
|
40054
|
+
queryType: z71.enum(["Latest", "Top"]).optional().describe('Result ordering \u2014 "Latest" (default) or "Top"'),
|
|
40055
|
+
cursor: z71.string().optional()
|
|
40056
|
+
});
|
|
40057
|
+
function buildAdvancedSearchQuery(input) {
|
|
40058
|
+
const parts = [];
|
|
40059
|
+
if (input.keywords?.length) {
|
|
40060
|
+
parts.push(input.keywords.join(" "));
|
|
39810
40061
|
}
|
|
39811
|
-
|
|
39812
|
-
|
|
39813
|
-
"twitterapiio.tweets.getByIds",
|
|
39814
|
-
{ ...input },
|
|
39815
|
-
"completed"
|
|
39816
|
-
);
|
|
39817
|
-
return response;
|
|
39818
|
-
};
|
|
39819
|
-
var search11 = async (ctx, input) => {
|
|
39820
|
-
const { query, queryType, cursor } = input;
|
|
39821
|
-
const response = await makeTwitterApiIORequest("/twitter/tweet/advanced_search", ctx.key, {
|
|
39822
|
-
method: "GET",
|
|
39823
|
-
query: { query, queryType, cursor }
|
|
39824
|
-
});
|
|
39825
|
-
if (response.tweets) {
|
|
39826
|
-
try {
|
|
39827
|
-
for (const tweet of response.tweets) {
|
|
39828
|
-
await persistTweetWithAuthor(tweet, ctx.db);
|
|
39829
|
-
}
|
|
39830
|
-
} catch (error) {
|
|
39831
|
-
console.warn("[twitterapiio] Failed to save tweets to database:", error);
|
|
39832
|
-
}
|
|
40062
|
+
if (input.exactPhrase) {
|
|
40063
|
+
parts.push(`"${input.exactPhrase}"`);
|
|
39833
40064
|
}
|
|
39834
|
-
|
|
39835
|
-
|
|
39836
|
-
"twitterapiio.tweets.search",
|
|
39837
|
-
{ ...input },
|
|
39838
|
-
"completed"
|
|
39839
|
-
);
|
|
39840
|
-
return response;
|
|
39841
|
-
};
|
|
39842
|
-
var getUserTimeline = async (ctx, input) => {
|
|
39843
|
-
const response = await makeTwitterApiIORequest("/twitter/user/timeline", ctx.key, {
|
|
39844
|
-
method: "GET",
|
|
39845
|
-
query: { userId: input.userId, cursor: input.cursor }
|
|
39846
|
-
});
|
|
39847
|
-
if (response.tweets) {
|
|
39848
|
-
try {
|
|
39849
|
-
for (const tweet of response.tweets) {
|
|
39850
|
-
await persistTweetWithAuthor(tweet, ctx.db);
|
|
39851
|
-
}
|
|
39852
|
-
} catch (error) {
|
|
39853
|
-
console.warn(
|
|
39854
|
-
"[twitterapiio] Failed to save tweets to database:",
|
|
39855
|
-
error
|
|
39856
|
-
);
|
|
39857
|
-
}
|
|
40065
|
+
if (input.anyOf?.length) {
|
|
40066
|
+
parts.push(`(${input.anyOf.join(" OR ")})`);
|
|
39858
40067
|
}
|
|
39859
|
-
|
|
39860
|
-
|
|
39861
|
-
"twitterapiio.tweets.getUserTimeline",
|
|
39862
|
-
{ ...input },
|
|
39863
|
-
"completed"
|
|
39864
|
-
);
|
|
39865
|
-
return response;
|
|
39866
|
-
};
|
|
39867
|
-
var getUserLastTweets = async (ctx, input) => {
|
|
39868
|
-
const response = await makeTwitterApiIORequest("/twitter/user/last_tweets", ctx.key, {
|
|
39869
|
-
method: "GET",
|
|
39870
|
-
query: { userName: input.userName, cursor: input.cursor }
|
|
39871
|
-
});
|
|
39872
|
-
if (response.tweets) {
|
|
39873
|
-
try {
|
|
39874
|
-
for (const tweet of response.tweets) {
|
|
39875
|
-
await persistTweetWithAuthor(tweet, ctx.db);
|
|
39876
|
-
}
|
|
39877
|
-
} catch (error) {
|
|
39878
|
-
console.warn(
|
|
39879
|
-
"[twitterapiio] Failed to save tweets to database:",
|
|
39880
|
-
error
|
|
39881
|
-
);
|
|
39882
|
-
}
|
|
40068
|
+
if (input.excludeKeywords?.length) {
|
|
40069
|
+
parts.push(...input.excludeKeywords.map((k) => `-${k}`));
|
|
39883
40070
|
}
|
|
39884
|
-
|
|
39885
|
-
|
|
39886
|
-
|
|
39887
|
-
|
|
39888
|
-
"completed"
|
|
39889
|
-
);
|
|
39890
|
-
return response;
|
|
39891
|
-
};
|
|
39892
|
-
var getUserMentions = async (ctx, input) => {
|
|
39893
|
-
const response = await makeTwitterApiIORequest("/twitter/user/mentions", ctx.key, {
|
|
39894
|
-
method: "GET",
|
|
39895
|
-
query: { userName: input.userName, cursor: input.cursor }
|
|
39896
|
-
});
|
|
39897
|
-
if (response.tweets) {
|
|
39898
|
-
try {
|
|
39899
|
-
for (const tweet of response.tweets) {
|
|
39900
|
-
await persistTweetWithAuthor(tweet, ctx.db);
|
|
39901
|
-
}
|
|
39902
|
-
} catch (error) {
|
|
39903
|
-
console.warn(
|
|
39904
|
-
"[twitterapiio] Failed to save tweets to database:",
|
|
39905
|
-
error
|
|
39906
|
-
);
|
|
39907
|
-
}
|
|
40071
|
+
if (input.hashtags?.length) {
|
|
40072
|
+
parts.push(
|
|
40073
|
+
...input.hashtags.map((h) => h.startsWith("#") ? h : `#${h}`)
|
|
40074
|
+
);
|
|
39908
40075
|
}
|
|
39909
|
-
|
|
39910
|
-
|
|
39911
|
-
"twitterapiio.tweets.getUserMentions",
|
|
39912
|
-
{ ...input },
|
|
39913
|
-
"completed"
|
|
39914
|
-
);
|
|
39915
|
-
return response;
|
|
39916
|
-
};
|
|
39917
|
-
var getReplies2 = async (ctx, input) => {
|
|
39918
|
-
const { tweetId, sinceTime, untilTime, cursor } = input;
|
|
39919
|
-
const response = await makeTwitterApiIORequest("/twitter/tweet/replies", ctx.key, {
|
|
39920
|
-
method: "GET",
|
|
39921
|
-
query: { tweetId, sinceTime, untilTime, cursor }
|
|
39922
|
-
});
|
|
39923
|
-
if (response.tweets) {
|
|
39924
|
-
try {
|
|
39925
|
-
for (const tweet of response.tweets) {
|
|
39926
|
-
await persistTweetWithAuthor(tweet, ctx.db);
|
|
39927
|
-
}
|
|
39928
|
-
} catch (error) {
|
|
39929
|
-
console.warn("[twitterapiio] Failed to save tweets to database:", error);
|
|
39930
|
-
}
|
|
40076
|
+
if (input.fromUsers?.length) {
|
|
40077
|
+
parts.push(...input.fromUsers.map((u) => `from:${u}`));
|
|
39931
40078
|
}
|
|
39932
|
-
|
|
39933
|
-
|
|
39934
|
-
"twitterapiio.tweets.getReplies",
|
|
39935
|
-
{ ...input },
|
|
39936
|
-
"completed"
|
|
39937
|
-
);
|
|
39938
|
-
return response;
|
|
39939
|
-
};
|
|
39940
|
-
var getQuotations = async (ctx, input) => {
|
|
39941
|
-
const response = await makeTwitterApiIORequest("/twitter/tweet/quotes", ctx.key, {
|
|
39942
|
-
method: "GET",
|
|
39943
|
-
query: { tweetId: input.tweetId, cursor: input.cursor }
|
|
39944
|
-
});
|
|
39945
|
-
if (response.tweets) {
|
|
39946
|
-
try {
|
|
39947
|
-
for (const tweet of response.tweets) {
|
|
39948
|
-
await persistTweetWithAuthor(tweet, ctx.db);
|
|
39949
|
-
}
|
|
39950
|
-
} catch (error) {
|
|
39951
|
-
console.warn(
|
|
39952
|
-
"[twitterapiio] Failed to save tweets to database:",
|
|
39953
|
-
error
|
|
39954
|
-
);
|
|
39955
|
-
}
|
|
40079
|
+
if (input.toUsers?.length) {
|
|
40080
|
+
parts.push(...input.toUsers.map((u) => `to:${u}`));
|
|
39956
40081
|
}
|
|
39957
|
-
|
|
39958
|
-
|
|
39959
|
-
"twitterapiio.tweets.getQuotations",
|
|
39960
|
-
{ ...input },
|
|
39961
|
-
"completed"
|
|
39962
|
-
);
|
|
39963
|
-
return response;
|
|
39964
|
-
};
|
|
39965
|
-
var getRetweeters = async (ctx, input) => {
|
|
39966
|
-
const response = await makeTwitterApiIORequest("/twitter/tweet/retweeters", ctx.key, {
|
|
39967
|
-
method: "GET",
|
|
39968
|
-
query: { tweetId: input.tweetId, cursor: input.cursor }
|
|
39969
|
-
});
|
|
39970
|
-
if (response.users && ctx.db.users) {
|
|
39971
|
-
try {
|
|
39972
|
-
for (const user of response.users) {
|
|
39973
|
-
await ctx.db.users.upsertByEntityId(user.id, user);
|
|
39974
|
-
}
|
|
39975
|
-
} catch (error) {
|
|
39976
|
-
console.warn("[twitterapiio] Failed to save users to database:", error);
|
|
39977
|
-
}
|
|
40082
|
+
if (input.mentioningUsers?.length) {
|
|
40083
|
+
parts.push(...input.mentioningUsers.map((u) => `@${u}`));
|
|
39978
40084
|
}
|
|
39979
|
-
|
|
39980
|
-
|
|
39981
|
-
"twitterapiio.tweets.getRetweeters",
|
|
39982
|
-
{ ...input },
|
|
39983
|
-
"completed"
|
|
39984
|
-
);
|
|
39985
|
-
return response;
|
|
39986
|
-
};
|
|
39987
|
-
var getThreadContext = async (ctx, input) => {
|
|
39988
|
-
const response = await makeTwitterApiIORequest("/twitter/tweet/thread_context", ctx.key, {
|
|
39989
|
-
method: "GET",
|
|
39990
|
-
query: { tweetId: input.tweetId, cursor: input.cursor }
|
|
39991
|
-
});
|
|
39992
|
-
if (response.tweets) {
|
|
39993
|
-
try {
|
|
39994
|
-
for (const tweet of response.tweets) {
|
|
39995
|
-
await persistTweetWithAuthor(tweet, ctx.db);
|
|
39996
|
-
}
|
|
39997
|
-
} catch (error) {
|
|
39998
|
-
console.warn(
|
|
39999
|
-
"[twitterapiio] Failed to save tweets to database:",
|
|
40000
|
-
error
|
|
40001
|
-
);
|
|
40002
|
-
}
|
|
40085
|
+
if (input.language) {
|
|
40086
|
+
parts.push(`lang:${input.language}`);
|
|
40003
40087
|
}
|
|
40004
|
-
|
|
40005
|
-
|
|
40006
|
-
"twitterapiio.tweets.getThreadContext",
|
|
40007
|
-
{ ...input },
|
|
40008
|
-
"completed"
|
|
40009
|
-
);
|
|
40010
|
-
return response;
|
|
40011
|
-
};
|
|
40012
|
-
var create44 = async (ctx, input) => {
|
|
40013
|
-
const { tweet, loginCookie, replyToTweetId, mediaIds } = input;
|
|
40014
|
-
const response = await makeTwitterApiIORequest("/twitter/create_tweet", ctx.key, {
|
|
40015
|
-
method: "POST",
|
|
40016
|
-
body: {
|
|
40017
|
-
tweet,
|
|
40018
|
-
login_cookie: loginCookie,
|
|
40019
|
-
...replyToTweetId ? { reply_to_tweet_id: replyToTweetId } : {},
|
|
40020
|
-
...mediaIds ? { media_ids: mediaIds } : {}
|
|
40021
|
-
}
|
|
40022
|
-
});
|
|
40023
|
-
await logEventFromContext(
|
|
40024
|
-
ctx,
|
|
40025
|
-
"twitterapiio.tweets.create",
|
|
40026
|
-
{ tweet, replyToTweetId },
|
|
40027
|
-
"completed"
|
|
40028
|
-
);
|
|
40029
|
-
return response;
|
|
40030
|
-
};
|
|
40031
|
-
var deleteTweet = async (ctx, input) => {
|
|
40032
|
-
const response = await makeTwitterApiIORequest("/twitter/tweet/delete", ctx.key, {
|
|
40033
|
-
method: "POST",
|
|
40034
|
-
body: { tweetId: input.tweetId, login_cookie: input.loginCookie }
|
|
40035
|
-
});
|
|
40036
|
-
await logEventFromContext(
|
|
40037
|
-
ctx,
|
|
40038
|
-
"twitterapiio.tweets.delete",
|
|
40039
|
-
{ tweetId: input.tweetId },
|
|
40040
|
-
"completed"
|
|
40041
|
-
);
|
|
40042
|
-
return response;
|
|
40043
|
-
};
|
|
40044
|
-
var like = async (ctx, input) => {
|
|
40045
|
-
const response = await makeTwitterApiIORequest("/twitter/tweet/like", ctx.key, {
|
|
40046
|
-
method: "POST",
|
|
40047
|
-
body: { tweetId: input.tweetId, login_cookie: input.loginCookie }
|
|
40048
|
-
});
|
|
40049
|
-
await logEventFromContext(
|
|
40050
|
-
ctx,
|
|
40051
|
-
"twitterapiio.tweets.like",
|
|
40052
|
-
{ tweetId: input.tweetId },
|
|
40053
|
-
"completed"
|
|
40054
|
-
);
|
|
40055
|
-
return response;
|
|
40056
|
-
};
|
|
40057
|
-
var unlike = async (ctx, input) => {
|
|
40058
|
-
const response = await makeTwitterApiIORequest("/twitter/tweet/unlike", ctx.key, {
|
|
40059
|
-
method: "POST",
|
|
40060
|
-
body: { tweetId: input.tweetId, login_cookie: input.loginCookie }
|
|
40061
|
-
});
|
|
40062
|
-
await logEventFromContext(
|
|
40063
|
-
ctx,
|
|
40064
|
-
"twitterapiio.tweets.unlike",
|
|
40065
|
-
{ tweetId: input.tweetId },
|
|
40066
|
-
"completed"
|
|
40067
|
-
);
|
|
40068
|
-
return response;
|
|
40069
|
-
};
|
|
40070
|
-
var retweet = async (ctx, input) => {
|
|
40071
|
-
const response = await makeTwitterApiIORequest("/twitter/tweet/retweet", ctx.key, {
|
|
40072
|
-
method: "POST",
|
|
40073
|
-
body: { tweetId: input.tweetId, login_cookie: input.loginCookie }
|
|
40074
|
-
});
|
|
40075
|
-
await logEventFromContext(
|
|
40076
|
-
ctx,
|
|
40077
|
-
"twitterapiio.tweets.retweet",
|
|
40078
|
-
{ tweetId: input.tweetId },
|
|
40079
|
-
"completed"
|
|
40080
|
-
);
|
|
40081
|
-
return response;
|
|
40082
|
-
};
|
|
40083
|
-
|
|
40084
|
-
// plugins/twitterapiio/endpoints/users.ts
|
|
40085
|
-
var getByUsername = async (ctx, input) => {
|
|
40086
|
-
const response = await makeTwitterApiIORequest("/twitter/user/info", ctx.key, {
|
|
40087
|
-
method: "GET",
|
|
40088
|
-
query: { userName: input.userName }
|
|
40089
|
-
});
|
|
40090
|
-
if (response.data && ctx.db.users) {
|
|
40091
|
-
try {
|
|
40092
|
-
await ctx.db.users.upsertByEntityId(response.data.id, response.data);
|
|
40093
|
-
} catch (error) {
|
|
40094
|
-
console.warn("[twitterapiio] Failed to save user to database:", error);
|
|
40095
|
-
}
|
|
40088
|
+
if (input.since) {
|
|
40089
|
+
parts.push(`since:${input.since}`);
|
|
40096
40090
|
}
|
|
40097
|
-
|
|
40098
|
-
|
|
40099
|
-
"twitterapiio.users.getByUsername",
|
|
40100
|
-
{ ...input },
|
|
40101
|
-
"completed"
|
|
40102
|
-
);
|
|
40103
|
-
return response;
|
|
40104
|
-
};
|
|
40105
|
-
var batchGetByIds = async (ctx, input) => {
|
|
40106
|
-
const response = await makeTwitterApiIORequest("/twitter/user/batch_info_by_ids", ctx.key, {
|
|
40107
|
-
method: "GET",
|
|
40108
|
-
query: { userIds: input.userIds }
|
|
40109
|
-
});
|
|
40110
|
-
if (response.data && ctx.db.users) {
|
|
40111
|
-
try {
|
|
40112
|
-
for (const user of response.data) {
|
|
40113
|
-
await ctx.db.users.upsertByEntityId(user.id, user);
|
|
40114
|
-
}
|
|
40115
|
-
} catch (error) {
|
|
40116
|
-
console.warn("[twitterapiio] Failed to save users to database:", error);
|
|
40117
|
-
}
|
|
40091
|
+
if (input.until) {
|
|
40092
|
+
parts.push(`until:${input.until}`);
|
|
40118
40093
|
}
|
|
40119
|
-
|
|
40120
|
-
|
|
40121
|
-
|
|
40122
|
-
|
|
40123
|
-
"completed"
|
|
40124
|
-
);
|
|
40125
|
-
return response;
|
|
40126
|
-
};
|
|
40127
|
-
var search12 = async (ctx, input) => {
|
|
40128
|
-
const response = await makeTwitterApiIORequest("/twitter/user/search", ctx.key, {
|
|
40129
|
-
method: "GET",
|
|
40130
|
-
query: { keyword: input.keyword, cursor: input.cursor }
|
|
40131
|
-
});
|
|
40132
|
-
if (response.users && ctx.db.users) {
|
|
40133
|
-
try {
|
|
40134
|
-
for (const user of response.users) {
|
|
40135
|
-
await ctx.db.users.upsertByEntityId(user.id, user);
|
|
40136
|
-
}
|
|
40137
|
-
} catch (error) {
|
|
40138
|
-
console.warn("[twitterapiio] Failed to save users to database:", error);
|
|
40139
|
-
}
|
|
40094
|
+
if (input.replies === "only") {
|
|
40095
|
+
parts.push("filter:replies");
|
|
40096
|
+
} else if (input.replies === "exclude") {
|
|
40097
|
+
parts.push("-filter:replies");
|
|
40140
40098
|
}
|
|
40141
|
-
|
|
40142
|
-
|
|
40143
|
-
|
|
40144
|
-
|
|
40145
|
-
"completed"
|
|
40146
|
-
);
|
|
40147
|
-
return response;
|
|
40148
|
-
};
|
|
40149
|
-
var getFollowers2 = async (ctx, input) => {
|
|
40150
|
-
const response = await makeTwitterApiIORequest("/twitter/user/followers", ctx.key, {
|
|
40151
|
-
method: "GET",
|
|
40152
|
-
query: { userName: input.userName, cursor: input.cursor }
|
|
40153
|
-
});
|
|
40154
|
-
if (response.users && ctx.db.users) {
|
|
40155
|
-
try {
|
|
40156
|
-
for (const user of response.users) {
|
|
40157
|
-
await ctx.db.users.upsertByEntityId(user.id, user);
|
|
40158
|
-
}
|
|
40159
|
-
} catch (error) {
|
|
40160
|
-
console.warn("[twitterapiio] Failed to save users to database:", error);
|
|
40161
|
-
}
|
|
40099
|
+
if (input.retweets === "only") {
|
|
40100
|
+
parts.push("filter:retweets");
|
|
40101
|
+
} else if (input.retweets === "exclude") {
|
|
40102
|
+
parts.push("-filter:retweets");
|
|
40162
40103
|
}
|
|
40163
|
-
|
|
40164
|
-
|
|
40165
|
-
"twitterapiio.users.getFollowers",
|
|
40166
|
-
{ ...input },
|
|
40167
|
-
"completed"
|
|
40168
|
-
);
|
|
40169
|
-
return response;
|
|
40170
|
-
};
|
|
40171
|
-
var getVerifiedFollowers = async (ctx, input) => {
|
|
40172
|
-
const response = await makeTwitterApiIORequest("/twitter/user/verified_followers", ctx.key, {
|
|
40173
|
-
method: "GET",
|
|
40174
|
-
query: { userName: input.userName, cursor: input.cursor }
|
|
40175
|
-
});
|
|
40176
|
-
if (response.users && ctx.db.users) {
|
|
40177
|
-
try {
|
|
40178
|
-
for (const user of response.users) {
|
|
40179
|
-
await ctx.db.users.upsertByEntityId(user.id, user);
|
|
40180
|
-
}
|
|
40181
|
-
} catch (error) {
|
|
40182
|
-
console.warn("[twitterapiio] Failed to save users to database:", error);
|
|
40183
|
-
}
|
|
40104
|
+
if (input.onlyLinks) {
|
|
40105
|
+
parts.push("filter:links");
|
|
40184
40106
|
}
|
|
40185
|
-
|
|
40186
|
-
|
|
40187
|
-
"twitterapiio.users.getVerifiedFollowers",
|
|
40188
|
-
{ ...input },
|
|
40189
|
-
"completed"
|
|
40190
|
-
);
|
|
40191
|
-
return response;
|
|
40192
|
-
};
|
|
40193
|
-
var getFollowings = async (ctx, input) => {
|
|
40194
|
-
const response = await makeTwitterApiIORequest("/twitter/user/followings", ctx.key, {
|
|
40195
|
-
method: "GET",
|
|
40196
|
-
query: { userName: input.userName, cursor: input.cursor }
|
|
40197
|
-
});
|
|
40198
|
-
if (response.users && ctx.db.users) {
|
|
40199
|
-
try {
|
|
40200
|
-
for (const user of response.users) {
|
|
40201
|
-
await ctx.db.users.upsertByEntityId(user.id, user);
|
|
40202
|
-
}
|
|
40203
|
-
} catch (error) {
|
|
40204
|
-
console.warn("[twitterapiio] Failed to save users to database:", error);
|
|
40205
|
-
}
|
|
40107
|
+
if (input.onlyMedia) {
|
|
40108
|
+
parts.push("filter:media");
|
|
40206
40109
|
}
|
|
40207
|
-
|
|
40208
|
-
|
|
40209
|
-
"twitterapiio.users.getFollowings",
|
|
40210
|
-
{ ...input },
|
|
40211
|
-
"completed"
|
|
40212
|
-
);
|
|
40213
|
-
return response;
|
|
40214
|
-
};
|
|
40215
|
-
var checkFollowRelationship = async (ctx, input) => {
|
|
40216
|
-
const response = await makeTwitterApiIORequest("/twitter/user/follow_relation", ctx.key, {
|
|
40217
|
-
method: "GET",
|
|
40218
|
-
query: {
|
|
40219
|
-
sourceUserName: input.sourceUserName,
|
|
40220
|
-
targetUserName: input.targetUserName
|
|
40221
|
-
}
|
|
40222
|
-
});
|
|
40223
|
-
await logEventFromContext(
|
|
40224
|
-
ctx,
|
|
40225
|
-
"twitterapiio.users.checkFollowRelationship",
|
|
40226
|
-
{ ...input },
|
|
40227
|
-
"completed"
|
|
40228
|
-
);
|
|
40229
|
-
return response;
|
|
40230
|
-
};
|
|
40231
|
-
var follow = async (ctx, input) => {
|
|
40232
|
-
const response = await makeTwitterApiIORequest("/twitter/user/follow", ctx.key, {
|
|
40233
|
-
method: "POST",
|
|
40234
|
-
body: { followId: input.followId, login_cookie: input.loginCookie }
|
|
40235
|
-
});
|
|
40236
|
-
await logEventFromContext(
|
|
40237
|
-
ctx,
|
|
40238
|
-
"twitterapiio.users.follow",
|
|
40239
|
-
{ followId: input.followId },
|
|
40240
|
-
"completed"
|
|
40241
|
-
);
|
|
40242
|
-
return response;
|
|
40243
|
-
};
|
|
40244
|
-
var unfollow = async (ctx, input) => {
|
|
40245
|
-
const response = await makeTwitterApiIORequest("/twitter/user/unfollow", ctx.key, {
|
|
40246
|
-
method: "POST",
|
|
40247
|
-
body: { followId: input.followId, login_cookie: input.loginCookie }
|
|
40248
|
-
});
|
|
40249
|
-
await logEventFromContext(
|
|
40250
|
-
ctx,
|
|
40251
|
-
"twitterapiio.users.unfollow",
|
|
40252
|
-
{ followId: input.followId },
|
|
40253
|
-
"completed"
|
|
40254
|
-
);
|
|
40255
|
-
return response;
|
|
40256
|
-
};
|
|
40257
|
-
var getMe = async (ctx, input) => {
|
|
40258
|
-
const response = await makeTwitterApiIORequest("/twitter/user/me", ctx.key, {
|
|
40259
|
-
method: "GET",
|
|
40260
|
-
query: { login_cookie: input.loginCookie }
|
|
40261
|
-
});
|
|
40262
|
-
if (response.data && ctx.db.users) {
|
|
40263
|
-
try {
|
|
40264
|
-
await ctx.db.users.upsertByEntityId(response.data.id, response.data);
|
|
40265
|
-
} catch (error) {
|
|
40266
|
-
console.warn("[twitterapiio] Failed to save user to database:", error);
|
|
40267
|
-
}
|
|
40110
|
+
if (input.onlyImages) {
|
|
40111
|
+
parts.push("filter:images");
|
|
40268
40112
|
}
|
|
40269
|
-
|
|
40270
|
-
|
|
40271
|
-
}
|
|
40272
|
-
|
|
40273
|
-
|
|
40274
|
-
|
|
40275
|
-
|
|
40276
|
-
|
|
40277
|
-
|
|
40278
|
-
|
|
40279
|
-
|
|
40280
|
-
|
|
40281
|
-
|
|
40282
|
-
|
|
40283
|
-
followingCount: z70.number().optional(),
|
|
40284
|
-
profilePicture: z70.string().nullable().optional(),
|
|
40285
|
-
coverPicture: z70.string().nullable().optional(),
|
|
40286
|
-
description: z70.string().nullable().optional(),
|
|
40287
|
-
location: z70.string().nullable().optional(),
|
|
40288
|
-
isBlueVerified: z70.boolean().optional(),
|
|
40289
|
-
isGovernmentVerified: z70.boolean().optional(),
|
|
40290
|
-
favouritesCount: z70.number().optional(),
|
|
40291
|
-
statusesCount: z70.number().optional(),
|
|
40292
|
-
mediaCount: z70.number().optional(),
|
|
40293
|
-
createdAt: z70.string().optional(),
|
|
40294
|
-
isProtected: z70.boolean().optional(),
|
|
40295
|
-
isSuspended: z70.boolean().optional(),
|
|
40296
|
-
isUnavailable: z70.boolean().optional(),
|
|
40297
|
-
pinnedTweetIds: z70.array(z70.string()).optional(),
|
|
40298
|
-
website: z70.string().nullable().optional()
|
|
40299
|
-
});
|
|
40300
|
-
var TwitterApiIOTweetMedia = z70.object({
|
|
40301
|
-
type: z70.string().optional(),
|
|
40302
|
-
url: z70.string().optional(),
|
|
40303
|
-
mediaUrlHttps: z70.string().optional(),
|
|
40304
|
-
expandedUrl: z70.string().optional(),
|
|
40305
|
-
width: z70.number().optional(),
|
|
40306
|
-
height: z70.number().optional(),
|
|
40307
|
-
altText: z70.string().nullable().optional(),
|
|
40308
|
-
durationMs: z70.number().nullable().optional()
|
|
40309
|
-
});
|
|
40310
|
-
var TwitterApiIOTweet = z70.object({
|
|
40311
|
-
id: z70.string(),
|
|
40312
|
-
text: z70.string(),
|
|
40313
|
-
author: z70.string().optional(),
|
|
40314
|
-
createdAt: z70.string().optional(),
|
|
40315
|
-
likeCount: z70.number().optional(),
|
|
40316
|
-
retweetCount: z70.number().optional(),
|
|
40317
|
-
replyCount: z70.number().optional(),
|
|
40318
|
-
quoteCount: z70.number().optional(),
|
|
40319
|
-
viewCount: z70.number().nullable().optional(),
|
|
40320
|
-
bookmarkCount: z70.number().optional(),
|
|
40321
|
-
lang: z70.string().optional(),
|
|
40322
|
-
source: z70.string().optional(),
|
|
40323
|
-
isRetweet: z70.boolean().optional(),
|
|
40324
|
-
isQuote: z70.boolean().optional(),
|
|
40325
|
-
isPinned: z70.boolean().optional(),
|
|
40326
|
-
inReplyToStatusId: z70.string().nullable().optional(),
|
|
40327
|
-
inReplyToUserId: z70.string().nullable().optional(),
|
|
40328
|
-
quotedTweetId: z70.string().nullable().optional(),
|
|
40329
|
-
media: z70.array(TwitterApiIOTweetMedia).optional(),
|
|
40330
|
-
entities: z70.object({
|
|
40331
|
-
urls: z70.array(
|
|
40332
|
-
z70.object({
|
|
40333
|
-
url: z70.string().optional(),
|
|
40334
|
-
expandedUrl: z70.string().optional(),
|
|
40335
|
-
displayUrl: z70.string().optional()
|
|
40336
|
-
})
|
|
40337
|
-
).optional(),
|
|
40338
|
-
hashtags: z70.array(
|
|
40339
|
-
z70.object({
|
|
40340
|
-
text: z70.string().optional()
|
|
40341
|
-
})
|
|
40342
|
-
).optional(),
|
|
40343
|
-
userMentions: z70.array(
|
|
40344
|
-
z70.object({
|
|
40345
|
-
id: z70.string().optional(),
|
|
40346
|
-
name: z70.string().optional(),
|
|
40347
|
-
screenName: z70.string().optional()
|
|
40348
|
-
})
|
|
40349
|
-
).optional()
|
|
40350
|
-
}).optional(),
|
|
40351
|
-
conversationId: z70.string().optional()
|
|
40352
|
-
});
|
|
40353
|
-
var TwitterApiIOList = z70.object({
|
|
40354
|
-
id: z70.string(),
|
|
40355
|
-
name: z70.string(),
|
|
40356
|
-
description: z70.string().nullable().optional(),
|
|
40357
|
-
memberCount: z70.number().optional(),
|
|
40358
|
-
followerCount: z70.number().optional(),
|
|
40359
|
-
owner: TwitterApiIOUser.optional(),
|
|
40360
|
-
createdAt: z70.string().optional(),
|
|
40361
|
-
isPrivate: z70.boolean().optional()
|
|
40362
|
-
});
|
|
40363
|
-
var TwitterApiIOCommunity = z70.object({
|
|
40364
|
-
id: z70.string(),
|
|
40365
|
-
name: z70.string(),
|
|
40366
|
-
description: z70.string().nullable().optional(),
|
|
40367
|
-
memberCount: z70.number().optional(),
|
|
40368
|
-
role: z70.string().optional(),
|
|
40369
|
-
createdAt: z70.string().optional(),
|
|
40370
|
-
isNsfw: z70.boolean().optional(),
|
|
40371
|
-
adminResults: z70.array(z70.any()).optional(),
|
|
40372
|
-
moderatorResults: z70.array(z70.any()).optional(),
|
|
40373
|
-
rules: z70.array(z70.any()).optional(),
|
|
40374
|
-
primaryTopic: z70.any().optional()
|
|
40375
|
-
});
|
|
40376
|
-
var TwitterApiIOTrend = z70.object({
|
|
40377
|
-
name: z70.string(),
|
|
40378
|
-
tweetVolume: z70.number().nullable().optional(),
|
|
40379
|
-
url: z70.string().optional(),
|
|
40380
|
-
woeid: z70.number().optional(),
|
|
40381
|
-
trendingAt: z70.string().optional()
|
|
40382
|
-
});
|
|
40383
|
-
var RawApiTweet = TwitterApiIOTweet.extend({
|
|
40384
|
-
author: TwitterApiIOUser.optional()
|
|
40385
|
-
});
|
|
40386
|
-
|
|
40387
|
-
// plugins/twitterapiio/endpoints/types.ts
|
|
40388
|
-
var PaginatedTweetsResponseSchema = z71.object({
|
|
40389
|
-
status: z71.boolean().optional(),
|
|
40390
|
-
tweets: z71.array(RawApiTweet).optional(),
|
|
40391
|
-
next_cursor: z71.string().nullable().optional(),
|
|
40392
|
-
has_next_page: z71.boolean().optional()
|
|
40393
|
-
});
|
|
40394
|
-
var PaginatedUsersResponseSchema = z71.object({
|
|
40395
|
-
status: z71.boolean().optional(),
|
|
40396
|
-
users: z71.array(TwitterApiIOUser).optional(),
|
|
40397
|
-
next_cursor: z71.string().nullable().optional(),
|
|
40398
|
-
has_next_page: z71.boolean().optional()
|
|
40399
|
-
});
|
|
40400
|
-
var ActionResponseSchema = z71.object({
|
|
40401
|
-
status: z71.boolean().optional(),
|
|
40402
|
-
message: z71.string().optional()
|
|
40403
|
-
});
|
|
40404
|
-
var TweetsGetByIdsInputSchema = z71.object({
|
|
40405
|
-
tweetIds: z71.string().describe("Comma-separated list of tweet IDs")
|
|
40406
|
-
});
|
|
40407
|
-
var TweetsSearchInputSchema = z71.object({
|
|
40408
|
-
query: z71.string(),
|
|
40409
|
-
queryType: z71.enum(["Top", "Latest", "Photos", "Videos"]).optional().describe("Search type. Defaults to Top"),
|
|
40410
|
-
cursor: z71.string().optional()
|
|
40411
|
-
});
|
|
40113
|
+
if (input.onlyVideos) {
|
|
40114
|
+
parts.push("filter:native_video");
|
|
40115
|
+
}
|
|
40116
|
+
if (input.minReplies !== void 0) {
|
|
40117
|
+
parts.push(`min_replies:${input.minReplies}`);
|
|
40118
|
+
}
|
|
40119
|
+
if (input.minLikes !== void 0) {
|
|
40120
|
+
parts.push(`min_faves:${input.minLikes}`);
|
|
40121
|
+
}
|
|
40122
|
+
if (input.minRetweets !== void 0) {
|
|
40123
|
+
parts.push(`min_retweets:${input.minRetweets}`);
|
|
40124
|
+
}
|
|
40125
|
+
return parts.join(" ");
|
|
40126
|
+
}
|
|
40412
40127
|
var TweetsGetUserTimelineInputSchema = z71.object({
|
|
40413
40128
|
userId: z71.string(),
|
|
40414
40129
|
cursor: z71.string().optional()
|
|
@@ -40583,6 +40298,7 @@ var TrendsGetResponseSchema = z71.object({
|
|
|
40583
40298
|
var TwitterApiIOEndpointInputSchemas = {
|
|
40584
40299
|
tweetsGetByIds: TweetsGetByIdsInputSchema,
|
|
40585
40300
|
tweetsSearch: TweetsSearchInputSchema,
|
|
40301
|
+
tweetsAdvancedSearch: TweetsAdvancedSearchInputSchema,
|
|
40586
40302
|
tweetsGetUserTimeline: TweetsGetUserTimelineInputSchema,
|
|
40587
40303
|
tweetsGetUserLastTweets: TweetsGetUserLastTweetsInputSchema,
|
|
40588
40304
|
tweetsGetUserMentions: TweetsGetUserMentionsInputSchema,
|
|
@@ -40619,50 +40335,556 @@ var TwitterApiIOEndpointInputSchemas = {
|
|
|
40619
40335
|
communitiesLeave: CommunitiesLeaveInputSchema,
|
|
40620
40336
|
trendsGet: TrendsGetInputSchema
|
|
40621
40337
|
};
|
|
40622
|
-
var TwitterApiIOEndpointOutputSchemas = {
|
|
40623
|
-
tweetsGetByIds: TweetsGetByIdsResponseSchema,
|
|
40624
|
-
tweetsSearch: PaginatedTweetsResponseSchema,
|
|
40625
|
-
|
|
40626
|
-
|
|
40627
|
-
|
|
40628
|
-
|
|
40629
|
-
|
|
40630
|
-
|
|
40631
|
-
|
|
40632
|
-
|
|
40633
|
-
|
|
40634
|
-
|
|
40635
|
-
|
|
40636
|
-
|
|
40637
|
-
|
|
40638
|
-
|
|
40639
|
-
|
|
40640
|
-
|
|
40641
|
-
|
|
40642
|
-
|
|
40643
|
-
|
|
40644
|
-
|
|
40645
|
-
|
|
40646
|
-
|
|
40647
|
-
|
|
40648
|
-
|
|
40649
|
-
|
|
40650
|
-
|
|
40651
|
-
|
|
40652
|
-
|
|
40653
|
-
|
|
40654
|
-
|
|
40655
|
-
|
|
40656
|
-
|
|
40657
|
-
|
|
40658
|
-
|
|
40659
|
-
|
|
40338
|
+
var TwitterApiIOEndpointOutputSchemas = {
|
|
40339
|
+
tweetsGetByIds: TweetsGetByIdsResponseSchema,
|
|
40340
|
+
tweetsSearch: PaginatedTweetsResponseSchema,
|
|
40341
|
+
tweetsAdvancedSearch: PaginatedTweetsResponseSchema,
|
|
40342
|
+
tweetsGetUserTimeline: PaginatedTweetsResponseSchema,
|
|
40343
|
+
tweetsGetUserLastTweets: PaginatedTweetsResponseSchema,
|
|
40344
|
+
tweetsGetUserMentions: PaginatedTweetsResponseSchema,
|
|
40345
|
+
tweetsGetReplies: PaginatedTweetsResponseSchema,
|
|
40346
|
+
tweetsGetQuotations: PaginatedTweetsResponseSchema,
|
|
40347
|
+
tweetsGetRetweeters: PaginatedUsersResponseSchema,
|
|
40348
|
+
tweetsGetThreadContext: PaginatedTweetsResponseSchema,
|
|
40349
|
+
tweetsCreate: ActionResponseSchema,
|
|
40350
|
+
tweetsDelete: ActionResponseSchema,
|
|
40351
|
+
tweetsLike: ActionResponseSchema,
|
|
40352
|
+
tweetsUnlike: ActionResponseSchema,
|
|
40353
|
+
tweetsRetweet: ActionResponseSchema,
|
|
40354
|
+
usersGetByUsername: UserGetResponseSchema2,
|
|
40355
|
+
usersBatchGetByIds: UsersBatchGetByIdsResponseSchema,
|
|
40356
|
+
usersSearch: PaginatedUsersResponseSchema,
|
|
40357
|
+
usersGetFollowers: PaginatedUsersResponseSchema,
|
|
40358
|
+
usersGetVerifiedFollowers: PaginatedUsersResponseSchema,
|
|
40359
|
+
usersGetFollowings: PaginatedUsersResponseSchema,
|
|
40360
|
+
usersCheckFollowRelationship: UsersCheckFollowRelationshipResponseSchema,
|
|
40361
|
+
usersFollow: ActionResponseSchema,
|
|
40362
|
+
usersUnfollow: ActionResponseSchema,
|
|
40363
|
+
usersGetMe: UserGetResponseSchema2,
|
|
40364
|
+
listsGetFollowers: PaginatedUsersResponseSchema,
|
|
40365
|
+
listsGetMembers: PaginatedUsersResponseSchema,
|
|
40366
|
+
listsGetTweets: PaginatedTweetsResponseSchema,
|
|
40367
|
+
communitiesGetById: CommunitiesGetByIdResponseSchema,
|
|
40368
|
+
communitiesGetMembers: CommunitiesMembersResponseSchema,
|
|
40369
|
+
communitiesGetModerators: CommunitiesMembersResponseSchema,
|
|
40370
|
+
communitiesGetTweets: PaginatedTweetsResponseSchema,
|
|
40371
|
+
communitiesSearchTweets: PaginatedTweetsResponseSchema,
|
|
40372
|
+
communitiesCreate: ActionResponseSchema,
|
|
40373
|
+
communitiesDelete: ActionResponseSchema,
|
|
40374
|
+
communitiesJoin: ActionResponseSchema,
|
|
40375
|
+
communitiesLeave: ActionResponseSchema,
|
|
40376
|
+
trendsGet: TrendsGetResponseSchema
|
|
40377
|
+
};
|
|
40378
|
+
|
|
40379
|
+
// plugins/twitterapiio/endpoints/tweets.ts
|
|
40380
|
+
var getByIds = async (ctx, input) => {
|
|
40381
|
+
const response = await makeTwitterApiIORequest("/twitter/tweets", ctx.key, {
|
|
40382
|
+
method: "GET",
|
|
40383
|
+
query: { tweet_ids: input.tweetIds }
|
|
40384
|
+
});
|
|
40385
|
+
if (response.tweets) {
|
|
40386
|
+
try {
|
|
40387
|
+
for (const tweet of response.tweets) {
|
|
40388
|
+
await persistTweetWithAuthor(tweet, ctx.db);
|
|
40389
|
+
}
|
|
40390
|
+
} catch (error) {
|
|
40391
|
+
console.warn("[twitterapiio] Failed to save tweets to database:", error);
|
|
40392
|
+
}
|
|
40393
|
+
}
|
|
40394
|
+
await logEventFromContext(
|
|
40395
|
+
ctx,
|
|
40396
|
+
"twitterapiio.tweets.getByIds",
|
|
40397
|
+
{ ...input },
|
|
40398
|
+
"completed"
|
|
40399
|
+
);
|
|
40400
|
+
return response;
|
|
40401
|
+
};
|
|
40402
|
+
var search11 = async (ctx, input) => {
|
|
40403
|
+
const { query, queryType, cursor } = input;
|
|
40404
|
+
const response = await makeTwitterApiIORequest("/twitter/tweet/advanced_search", ctx.key, {
|
|
40405
|
+
method: "GET",
|
|
40406
|
+
query: { query, queryType, cursor }
|
|
40407
|
+
});
|
|
40408
|
+
if (response.tweets) {
|
|
40409
|
+
try {
|
|
40410
|
+
for (const tweet of response.tweets) {
|
|
40411
|
+
await persistTweetWithAuthor(tweet, ctx.db);
|
|
40412
|
+
}
|
|
40413
|
+
} catch (error) {
|
|
40414
|
+
console.warn("[twitterapiio] Failed to save tweets to database:", error);
|
|
40415
|
+
}
|
|
40416
|
+
}
|
|
40417
|
+
await logEventFromContext(
|
|
40418
|
+
ctx,
|
|
40419
|
+
"twitterapiio.tweets.search",
|
|
40420
|
+
{ ...input },
|
|
40421
|
+
"completed"
|
|
40422
|
+
);
|
|
40423
|
+
return response;
|
|
40424
|
+
};
|
|
40425
|
+
var advancedSearch = async (ctx, input) => {
|
|
40426
|
+
const { cursor, queryType, ...queryBuilderInput } = input;
|
|
40427
|
+
const query = buildAdvancedSearchQuery(queryBuilderInput);
|
|
40428
|
+
const response = await makeTwitterApiIORequest("/twitter/tweet/advanced_search", ctx.key, {
|
|
40429
|
+
method: "GET",
|
|
40430
|
+
query: { query, queryType: queryType ?? "Latest", cursor }
|
|
40431
|
+
});
|
|
40432
|
+
if (response.tweets) {
|
|
40433
|
+
try {
|
|
40434
|
+
for (const tweet of response.tweets) {
|
|
40435
|
+
await persistTweetWithAuthor(tweet, ctx.db);
|
|
40436
|
+
}
|
|
40437
|
+
} catch (error) {
|
|
40438
|
+
console.warn(
|
|
40439
|
+
"[twitterapiio] Failed to save tweets to database:",
|
|
40440
|
+
error
|
|
40441
|
+
);
|
|
40442
|
+
}
|
|
40443
|
+
}
|
|
40444
|
+
await logEventFromContext(
|
|
40445
|
+
ctx,
|
|
40446
|
+
"twitterapiio.tweets.advancedSearch",
|
|
40447
|
+
{ query, queryType, cursor },
|
|
40448
|
+
"completed"
|
|
40449
|
+
);
|
|
40450
|
+
return response;
|
|
40451
|
+
};
|
|
40452
|
+
var getUserTimeline = async (ctx, input) => {
|
|
40453
|
+
const response = await makeTwitterApiIORequest("/twitter/user/timeline", ctx.key, {
|
|
40454
|
+
method: "GET",
|
|
40455
|
+
query: { userId: input.userId, cursor: input.cursor }
|
|
40456
|
+
});
|
|
40457
|
+
if (response.tweets) {
|
|
40458
|
+
try {
|
|
40459
|
+
for (const tweet of response.tweets) {
|
|
40460
|
+
await persistTweetWithAuthor(tweet, ctx.db);
|
|
40461
|
+
}
|
|
40462
|
+
} catch (error) {
|
|
40463
|
+
console.warn(
|
|
40464
|
+
"[twitterapiio] Failed to save tweets to database:",
|
|
40465
|
+
error
|
|
40466
|
+
);
|
|
40467
|
+
}
|
|
40468
|
+
}
|
|
40469
|
+
await logEventFromContext(
|
|
40470
|
+
ctx,
|
|
40471
|
+
"twitterapiio.tweets.getUserTimeline",
|
|
40472
|
+
{ ...input },
|
|
40473
|
+
"completed"
|
|
40474
|
+
);
|
|
40475
|
+
return response;
|
|
40476
|
+
};
|
|
40477
|
+
var getUserLastTweets = async (ctx, input) => {
|
|
40478
|
+
const response = await makeTwitterApiIORequest("/twitter/user/last_tweets", ctx.key, {
|
|
40479
|
+
method: "GET",
|
|
40480
|
+
query: { userName: input.userName, cursor: input.cursor }
|
|
40481
|
+
});
|
|
40482
|
+
if (response.tweets) {
|
|
40483
|
+
try {
|
|
40484
|
+
for (const tweet of response.tweets) {
|
|
40485
|
+
await persistTweetWithAuthor(tweet, ctx.db);
|
|
40486
|
+
}
|
|
40487
|
+
} catch (error) {
|
|
40488
|
+
console.warn(
|
|
40489
|
+
"[twitterapiio] Failed to save tweets to database:",
|
|
40490
|
+
error
|
|
40491
|
+
);
|
|
40492
|
+
}
|
|
40493
|
+
}
|
|
40494
|
+
await logEventFromContext(
|
|
40495
|
+
ctx,
|
|
40496
|
+
"twitterapiio.tweets.getUserLastTweets",
|
|
40497
|
+
{ ...input },
|
|
40498
|
+
"completed"
|
|
40499
|
+
);
|
|
40500
|
+
return response;
|
|
40501
|
+
};
|
|
40502
|
+
var getUserMentions = async (ctx, input) => {
|
|
40503
|
+
const response = await makeTwitterApiIORequest("/twitter/user/mentions", ctx.key, {
|
|
40504
|
+
method: "GET",
|
|
40505
|
+
query: { userName: input.userName, cursor: input.cursor }
|
|
40506
|
+
});
|
|
40507
|
+
if (response.tweets) {
|
|
40508
|
+
try {
|
|
40509
|
+
for (const tweet of response.tweets) {
|
|
40510
|
+
await persistTweetWithAuthor(tweet, ctx.db);
|
|
40511
|
+
}
|
|
40512
|
+
} catch (error) {
|
|
40513
|
+
console.warn(
|
|
40514
|
+
"[twitterapiio] Failed to save tweets to database:",
|
|
40515
|
+
error
|
|
40516
|
+
);
|
|
40517
|
+
}
|
|
40518
|
+
}
|
|
40519
|
+
await logEventFromContext(
|
|
40520
|
+
ctx,
|
|
40521
|
+
"twitterapiio.tweets.getUserMentions",
|
|
40522
|
+
{ ...input },
|
|
40523
|
+
"completed"
|
|
40524
|
+
);
|
|
40525
|
+
return response;
|
|
40526
|
+
};
|
|
40527
|
+
var getReplies2 = async (ctx, input) => {
|
|
40528
|
+
const { tweetId, sinceTime, untilTime, cursor } = input;
|
|
40529
|
+
const response = await makeTwitterApiIORequest("/twitter/tweet/replies", ctx.key, {
|
|
40530
|
+
method: "GET",
|
|
40531
|
+
query: { tweetId, sinceTime, untilTime, cursor }
|
|
40532
|
+
});
|
|
40533
|
+
if (response.tweets) {
|
|
40534
|
+
try {
|
|
40535
|
+
for (const tweet of response.tweets) {
|
|
40536
|
+
await persistTweetWithAuthor(tweet, ctx.db);
|
|
40537
|
+
}
|
|
40538
|
+
} catch (error) {
|
|
40539
|
+
console.warn("[twitterapiio] Failed to save tweets to database:", error);
|
|
40540
|
+
}
|
|
40541
|
+
}
|
|
40542
|
+
await logEventFromContext(
|
|
40543
|
+
ctx,
|
|
40544
|
+
"twitterapiio.tweets.getReplies",
|
|
40545
|
+
{ ...input },
|
|
40546
|
+
"completed"
|
|
40547
|
+
);
|
|
40548
|
+
return response;
|
|
40549
|
+
};
|
|
40550
|
+
var getQuotations = async (ctx, input) => {
|
|
40551
|
+
const response = await makeTwitterApiIORequest("/twitter/tweet/quotes", ctx.key, {
|
|
40552
|
+
method: "GET",
|
|
40553
|
+
query: { tweetId: input.tweetId, cursor: input.cursor }
|
|
40554
|
+
});
|
|
40555
|
+
if (response.tweets) {
|
|
40556
|
+
try {
|
|
40557
|
+
for (const tweet of response.tweets) {
|
|
40558
|
+
await persistTweetWithAuthor(tweet, ctx.db);
|
|
40559
|
+
}
|
|
40560
|
+
} catch (error) {
|
|
40561
|
+
console.warn(
|
|
40562
|
+
"[twitterapiio] Failed to save tweets to database:",
|
|
40563
|
+
error
|
|
40564
|
+
);
|
|
40565
|
+
}
|
|
40566
|
+
}
|
|
40567
|
+
await logEventFromContext(
|
|
40568
|
+
ctx,
|
|
40569
|
+
"twitterapiio.tweets.getQuotations",
|
|
40570
|
+
{ ...input },
|
|
40571
|
+
"completed"
|
|
40572
|
+
);
|
|
40573
|
+
return response;
|
|
40574
|
+
};
|
|
40575
|
+
var getRetweeters = async (ctx, input) => {
|
|
40576
|
+
const response = await makeTwitterApiIORequest("/twitter/tweet/retweeters", ctx.key, {
|
|
40577
|
+
method: "GET",
|
|
40578
|
+
query: { tweetId: input.tweetId, cursor: input.cursor }
|
|
40579
|
+
});
|
|
40580
|
+
if (response.users && ctx.db.users) {
|
|
40581
|
+
try {
|
|
40582
|
+
for (const user of response.users) {
|
|
40583
|
+
await ctx.db.users.upsertByEntityId(user.id, user);
|
|
40584
|
+
}
|
|
40585
|
+
} catch (error) {
|
|
40586
|
+
console.warn("[twitterapiio] Failed to save users to database:", error);
|
|
40587
|
+
}
|
|
40588
|
+
}
|
|
40589
|
+
await logEventFromContext(
|
|
40590
|
+
ctx,
|
|
40591
|
+
"twitterapiio.tweets.getRetweeters",
|
|
40592
|
+
{ ...input },
|
|
40593
|
+
"completed"
|
|
40594
|
+
);
|
|
40595
|
+
return response;
|
|
40596
|
+
};
|
|
40597
|
+
var getThreadContext = async (ctx, input) => {
|
|
40598
|
+
const response = await makeTwitterApiIORequest("/twitter/tweet/thread_context", ctx.key, {
|
|
40599
|
+
method: "GET",
|
|
40600
|
+
query: { tweetId: input.tweetId, cursor: input.cursor }
|
|
40601
|
+
});
|
|
40602
|
+
if (response.tweets) {
|
|
40603
|
+
try {
|
|
40604
|
+
for (const tweet of response.tweets) {
|
|
40605
|
+
await persistTweetWithAuthor(tweet, ctx.db);
|
|
40606
|
+
}
|
|
40607
|
+
} catch (error) {
|
|
40608
|
+
console.warn(
|
|
40609
|
+
"[twitterapiio] Failed to save tweets to database:",
|
|
40610
|
+
error
|
|
40611
|
+
);
|
|
40612
|
+
}
|
|
40613
|
+
}
|
|
40614
|
+
await logEventFromContext(
|
|
40615
|
+
ctx,
|
|
40616
|
+
"twitterapiio.tweets.getThreadContext",
|
|
40617
|
+
{ ...input },
|
|
40618
|
+
"completed"
|
|
40619
|
+
);
|
|
40620
|
+
return response;
|
|
40621
|
+
};
|
|
40622
|
+
var create44 = async (ctx, input) => {
|
|
40623
|
+
const { tweet, loginCookie, replyToTweetId, mediaIds } = input;
|
|
40624
|
+
const response = await makeTwitterApiIORequest("/twitter/create_tweet", ctx.key, {
|
|
40625
|
+
method: "POST",
|
|
40626
|
+
body: {
|
|
40627
|
+
tweet,
|
|
40628
|
+
login_cookie: loginCookie,
|
|
40629
|
+
...replyToTweetId ? { reply_to_tweet_id: replyToTweetId } : {},
|
|
40630
|
+
...mediaIds ? { media_ids: mediaIds } : {}
|
|
40631
|
+
}
|
|
40632
|
+
});
|
|
40633
|
+
await logEventFromContext(
|
|
40634
|
+
ctx,
|
|
40635
|
+
"twitterapiio.tweets.create",
|
|
40636
|
+
{ tweet, replyToTweetId },
|
|
40637
|
+
"completed"
|
|
40638
|
+
);
|
|
40639
|
+
return response;
|
|
40640
|
+
};
|
|
40641
|
+
var deleteTweet = async (ctx, input) => {
|
|
40642
|
+
const response = await makeTwitterApiIORequest("/twitter/tweet/delete", ctx.key, {
|
|
40643
|
+
method: "POST",
|
|
40644
|
+
body: { tweetId: input.tweetId, login_cookie: input.loginCookie }
|
|
40645
|
+
});
|
|
40646
|
+
await logEventFromContext(
|
|
40647
|
+
ctx,
|
|
40648
|
+
"twitterapiio.tweets.delete",
|
|
40649
|
+
{ tweetId: input.tweetId },
|
|
40650
|
+
"completed"
|
|
40651
|
+
);
|
|
40652
|
+
return response;
|
|
40653
|
+
};
|
|
40654
|
+
var like = async (ctx, input) => {
|
|
40655
|
+
const response = await makeTwitterApiIORequest("/twitter/tweet/like", ctx.key, {
|
|
40656
|
+
method: "POST",
|
|
40657
|
+
body: { tweetId: input.tweetId, login_cookie: input.loginCookie }
|
|
40658
|
+
});
|
|
40659
|
+
await logEventFromContext(
|
|
40660
|
+
ctx,
|
|
40661
|
+
"twitterapiio.tweets.like",
|
|
40662
|
+
{ tweetId: input.tweetId },
|
|
40663
|
+
"completed"
|
|
40664
|
+
);
|
|
40665
|
+
return response;
|
|
40666
|
+
};
|
|
40667
|
+
var unlike = async (ctx, input) => {
|
|
40668
|
+
const response = await makeTwitterApiIORequest("/twitter/tweet/unlike", ctx.key, {
|
|
40669
|
+
method: "POST",
|
|
40670
|
+
body: { tweetId: input.tweetId, login_cookie: input.loginCookie }
|
|
40671
|
+
});
|
|
40672
|
+
await logEventFromContext(
|
|
40673
|
+
ctx,
|
|
40674
|
+
"twitterapiio.tweets.unlike",
|
|
40675
|
+
{ tweetId: input.tweetId },
|
|
40676
|
+
"completed"
|
|
40677
|
+
);
|
|
40678
|
+
return response;
|
|
40679
|
+
};
|
|
40680
|
+
var retweet = async (ctx, input) => {
|
|
40681
|
+
const response = await makeTwitterApiIORequest("/twitter/tweet/retweet", ctx.key, {
|
|
40682
|
+
method: "POST",
|
|
40683
|
+
body: { tweetId: input.tweetId, login_cookie: input.loginCookie }
|
|
40684
|
+
});
|
|
40685
|
+
await logEventFromContext(
|
|
40686
|
+
ctx,
|
|
40687
|
+
"twitterapiio.tweets.retweet",
|
|
40688
|
+
{ tweetId: input.tweetId },
|
|
40689
|
+
"completed"
|
|
40690
|
+
);
|
|
40691
|
+
return response;
|
|
40692
|
+
};
|
|
40693
|
+
|
|
40694
|
+
// plugins/twitterapiio/endpoints/users.ts
|
|
40695
|
+
var getByUsername = async (ctx, input) => {
|
|
40696
|
+
const response = await makeTwitterApiIORequest("/twitter/user/info", ctx.key, {
|
|
40697
|
+
method: "GET",
|
|
40698
|
+
query: { userName: input.userName }
|
|
40699
|
+
});
|
|
40700
|
+
if (response.data && ctx.db.users) {
|
|
40701
|
+
try {
|
|
40702
|
+
await ctx.db.users.upsertByEntityId(response.data.id, response.data);
|
|
40703
|
+
} catch (error) {
|
|
40704
|
+
console.warn("[twitterapiio] Failed to save user to database:", error);
|
|
40705
|
+
}
|
|
40706
|
+
}
|
|
40707
|
+
await logEventFromContext(
|
|
40708
|
+
ctx,
|
|
40709
|
+
"twitterapiio.users.getByUsername",
|
|
40710
|
+
{ ...input },
|
|
40711
|
+
"completed"
|
|
40712
|
+
);
|
|
40713
|
+
return response;
|
|
40714
|
+
};
|
|
40715
|
+
var batchGetByIds = async (ctx, input) => {
|
|
40716
|
+
const response = await makeTwitterApiIORequest("/twitter/user/batch_info_by_ids", ctx.key, {
|
|
40717
|
+
method: "GET",
|
|
40718
|
+
query: { userIds: input.userIds }
|
|
40719
|
+
});
|
|
40720
|
+
if (response.data && ctx.db.users) {
|
|
40721
|
+
try {
|
|
40722
|
+
for (const user of response.data) {
|
|
40723
|
+
await ctx.db.users.upsertByEntityId(user.id, user);
|
|
40724
|
+
}
|
|
40725
|
+
} catch (error) {
|
|
40726
|
+
console.warn("[twitterapiio] Failed to save users to database:", error);
|
|
40727
|
+
}
|
|
40728
|
+
}
|
|
40729
|
+
await logEventFromContext(
|
|
40730
|
+
ctx,
|
|
40731
|
+
"twitterapiio.users.batchGetByIds",
|
|
40732
|
+
{ ...input },
|
|
40733
|
+
"completed"
|
|
40734
|
+
);
|
|
40735
|
+
return response;
|
|
40736
|
+
};
|
|
40737
|
+
var search12 = async (ctx, input) => {
|
|
40738
|
+
const response = await makeTwitterApiIORequest("/twitter/user/search", ctx.key, {
|
|
40739
|
+
method: "GET",
|
|
40740
|
+
query: { keyword: input.keyword, cursor: input.cursor }
|
|
40741
|
+
});
|
|
40742
|
+
if (response.users && ctx.db.users) {
|
|
40743
|
+
try {
|
|
40744
|
+
for (const user of response.users) {
|
|
40745
|
+
await ctx.db.users.upsertByEntityId(user.id, user);
|
|
40746
|
+
}
|
|
40747
|
+
} catch (error) {
|
|
40748
|
+
console.warn("[twitterapiio] Failed to save users to database:", error);
|
|
40749
|
+
}
|
|
40750
|
+
}
|
|
40751
|
+
await logEventFromContext(
|
|
40752
|
+
ctx,
|
|
40753
|
+
"twitterapiio.users.search",
|
|
40754
|
+
{ ...input },
|
|
40755
|
+
"completed"
|
|
40756
|
+
);
|
|
40757
|
+
return response;
|
|
40758
|
+
};
|
|
40759
|
+
var getFollowers2 = async (ctx, input) => {
|
|
40760
|
+
const response = await makeTwitterApiIORequest("/twitter/user/followers", ctx.key, {
|
|
40761
|
+
method: "GET",
|
|
40762
|
+
query: { userName: input.userName, cursor: input.cursor }
|
|
40763
|
+
});
|
|
40764
|
+
if (response.users && ctx.db.users) {
|
|
40765
|
+
try {
|
|
40766
|
+
for (const user of response.users) {
|
|
40767
|
+
await ctx.db.users.upsertByEntityId(user.id, user);
|
|
40768
|
+
}
|
|
40769
|
+
} catch (error) {
|
|
40770
|
+
console.warn("[twitterapiio] Failed to save users to database:", error);
|
|
40771
|
+
}
|
|
40772
|
+
}
|
|
40773
|
+
await logEventFromContext(
|
|
40774
|
+
ctx,
|
|
40775
|
+
"twitterapiio.users.getFollowers",
|
|
40776
|
+
{ ...input },
|
|
40777
|
+
"completed"
|
|
40778
|
+
);
|
|
40779
|
+
return response;
|
|
40780
|
+
};
|
|
40781
|
+
var getVerifiedFollowers = async (ctx, input) => {
|
|
40782
|
+
const response = await makeTwitterApiIORequest("/twitter/user/verified_followers", ctx.key, {
|
|
40783
|
+
method: "GET",
|
|
40784
|
+
query: { userName: input.userName, cursor: input.cursor }
|
|
40785
|
+
});
|
|
40786
|
+
if (response.users && ctx.db.users) {
|
|
40787
|
+
try {
|
|
40788
|
+
for (const user of response.users) {
|
|
40789
|
+
await ctx.db.users.upsertByEntityId(user.id, user);
|
|
40790
|
+
}
|
|
40791
|
+
} catch (error) {
|
|
40792
|
+
console.warn("[twitterapiio] Failed to save users to database:", error);
|
|
40793
|
+
}
|
|
40794
|
+
}
|
|
40795
|
+
await logEventFromContext(
|
|
40796
|
+
ctx,
|
|
40797
|
+
"twitterapiio.users.getVerifiedFollowers",
|
|
40798
|
+
{ ...input },
|
|
40799
|
+
"completed"
|
|
40800
|
+
);
|
|
40801
|
+
return response;
|
|
40802
|
+
};
|
|
40803
|
+
var getFollowings = async (ctx, input) => {
|
|
40804
|
+
const response = await makeTwitterApiIORequest("/twitter/user/followings", ctx.key, {
|
|
40805
|
+
method: "GET",
|
|
40806
|
+
query: { userName: input.userName, cursor: input.cursor }
|
|
40807
|
+
});
|
|
40808
|
+
if (response.users && ctx.db.users) {
|
|
40809
|
+
try {
|
|
40810
|
+
for (const user of response.users) {
|
|
40811
|
+
await ctx.db.users.upsertByEntityId(user.id, user);
|
|
40812
|
+
}
|
|
40813
|
+
} catch (error) {
|
|
40814
|
+
console.warn("[twitterapiio] Failed to save users to database:", error);
|
|
40815
|
+
}
|
|
40816
|
+
}
|
|
40817
|
+
await logEventFromContext(
|
|
40818
|
+
ctx,
|
|
40819
|
+
"twitterapiio.users.getFollowings",
|
|
40820
|
+
{ ...input },
|
|
40821
|
+
"completed"
|
|
40822
|
+
);
|
|
40823
|
+
return response;
|
|
40824
|
+
};
|
|
40825
|
+
var checkFollowRelationship = async (ctx, input) => {
|
|
40826
|
+
const response = await makeTwitterApiIORequest("/twitter/user/follow_relation", ctx.key, {
|
|
40827
|
+
method: "GET",
|
|
40828
|
+
query: {
|
|
40829
|
+
sourceUserName: input.sourceUserName,
|
|
40830
|
+
targetUserName: input.targetUserName
|
|
40831
|
+
}
|
|
40832
|
+
});
|
|
40833
|
+
await logEventFromContext(
|
|
40834
|
+
ctx,
|
|
40835
|
+
"twitterapiio.users.checkFollowRelationship",
|
|
40836
|
+
{ ...input },
|
|
40837
|
+
"completed"
|
|
40838
|
+
);
|
|
40839
|
+
return response;
|
|
40840
|
+
};
|
|
40841
|
+
var follow = async (ctx, input) => {
|
|
40842
|
+
const response = await makeTwitterApiIORequest("/twitter/user/follow", ctx.key, {
|
|
40843
|
+
method: "POST",
|
|
40844
|
+
body: { followId: input.followId, login_cookie: input.loginCookie }
|
|
40845
|
+
});
|
|
40846
|
+
await logEventFromContext(
|
|
40847
|
+
ctx,
|
|
40848
|
+
"twitterapiio.users.follow",
|
|
40849
|
+
{ followId: input.followId },
|
|
40850
|
+
"completed"
|
|
40851
|
+
);
|
|
40852
|
+
return response;
|
|
40853
|
+
};
|
|
40854
|
+
var unfollow = async (ctx, input) => {
|
|
40855
|
+
const response = await makeTwitterApiIORequest("/twitter/user/unfollow", ctx.key, {
|
|
40856
|
+
method: "POST",
|
|
40857
|
+
body: { followId: input.followId, login_cookie: input.loginCookie }
|
|
40858
|
+
});
|
|
40859
|
+
await logEventFromContext(
|
|
40860
|
+
ctx,
|
|
40861
|
+
"twitterapiio.users.unfollow",
|
|
40862
|
+
{ followId: input.followId },
|
|
40863
|
+
"completed"
|
|
40864
|
+
);
|
|
40865
|
+
return response;
|
|
40866
|
+
};
|
|
40867
|
+
var getMe = async (ctx, input) => {
|
|
40868
|
+
const response = await makeTwitterApiIORequest("/twitter/user/me", ctx.key, {
|
|
40869
|
+
method: "GET",
|
|
40870
|
+
query: { login_cookie: input.loginCookie }
|
|
40871
|
+
});
|
|
40872
|
+
if (response.data && ctx.db.users) {
|
|
40873
|
+
try {
|
|
40874
|
+
await ctx.db.users.upsertByEntityId(response.data.id, response.data);
|
|
40875
|
+
} catch (error) {
|
|
40876
|
+
console.warn("[twitterapiio] Failed to save user to database:", error);
|
|
40877
|
+
}
|
|
40878
|
+
}
|
|
40879
|
+
await logEventFromContext(ctx, "twitterapiio.users.getMe", {}, "completed");
|
|
40880
|
+
return response;
|
|
40660
40881
|
};
|
|
40661
40882
|
|
|
40662
40883
|
// plugins/twitterapiio/endpoints/index.ts
|
|
40663
40884
|
var TweetsEndpoints = {
|
|
40664
40885
|
getByIds,
|
|
40665
40886
|
search: search11,
|
|
40887
|
+
advancedSearch,
|
|
40666
40888
|
getUserTimeline,
|
|
40667
40889
|
getUserLastTweets,
|
|
40668
40890
|
getUserMentions,
|
|
@@ -41012,6 +41234,7 @@ var twitterApiIOEndpointsNested = {
|
|
|
41012
41234
|
tweets: {
|
|
41013
41235
|
getByIds: TweetsEndpoints.getByIds,
|
|
41014
41236
|
search: TweetsEndpoints.search,
|
|
41237
|
+
advancedSearch: TweetsEndpoints.advancedSearch,
|
|
41015
41238
|
getUserTimeline: TweetsEndpoints.getUserTimeline,
|
|
41016
41239
|
getUserLastTweets: TweetsEndpoints.getUserLastTweets,
|
|
41017
41240
|
getUserMentions: TweetsEndpoints.getUserMentions,
|
|
@@ -41072,6 +41295,10 @@ var twitterApiIOEndpointSchemas = {
|
|
|
41072
41295
|
input: TwitterApiIOEndpointInputSchemas.tweetsSearch,
|
|
41073
41296
|
output: TwitterApiIOEndpointOutputSchemas.tweetsSearch
|
|
41074
41297
|
},
|
|
41298
|
+
"tweets.advancedSearch": {
|
|
41299
|
+
input: TwitterApiIOEndpointInputSchemas.tweetsAdvancedSearch,
|
|
41300
|
+
output: TwitterApiIOEndpointOutputSchemas.tweetsAdvancedSearch
|
|
41301
|
+
},
|
|
41075
41302
|
"tweets.getUserTimeline": {
|
|
41076
41303
|
input: TwitterApiIOEndpointInputSchemas.tweetsGetUserTimeline,
|
|
41077
41304
|
output: TwitterApiIOEndpointOutputSchemas.tweetsGetUserTimeline
|
|
@@ -41232,7 +41459,11 @@ var twitterApiIOEndpointMeta = {
|
|
|
41232
41459
|
},
|
|
41233
41460
|
"tweets.search": {
|
|
41234
41461
|
riskLevel: "read",
|
|
41235
|
-
description: "Search tweets with a query"
|
|
41462
|
+
description: "Search tweets with a raw query string"
|
|
41463
|
+
},
|
|
41464
|
+
"tweets.advancedSearch": {
|
|
41465
|
+
riskLevel: "read",
|
|
41466
|
+
description: "Search tweets using structured operators (keywords, users, dates, engagement thresholds, media filters, etc.)"
|
|
41236
41467
|
},
|
|
41237
41468
|
"tweets.getUserTimeline": {
|
|
41238
41469
|
riskLevel: "read",
|
|
@@ -41590,7 +41821,7 @@ function describeZodSchema(schema) {
|
|
|
41590
41821
|
if (schema instanceof ZodNumber) return "number";
|
|
41591
41822
|
if (schema instanceof ZodBoolean) return "boolean";
|
|
41592
41823
|
if (schema instanceof ZodDate) return "date";
|
|
41593
|
-
if (schema instanceof ZodRecord) return "
|
|
41824
|
+
if (schema instanceof ZodRecord) return "jsonb";
|
|
41594
41825
|
return "unknown";
|
|
41595
41826
|
}
|
|
41596
41827
|
async function checkTables(db, warn) {
|