@pipedream/twitter 0.3.11 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +20 -71
  2. package/dist/actions/add-user-to-list/add-user-to-list.d.ts +380 -0
  3. package/dist/actions/add-user-to-list/add-user-to-list.mjs +42 -0
  4. package/dist/actions/create-tweet/create-tweet.d.ts +163 -0
  5. package/dist/actions/create-tweet/create-tweet.mjs +78 -0
  6. package/dist/actions/delete-tweet/delete-tweet.d.ts +252 -0
  7. package/dist/actions/delete-tweet/delete-tweet.mjs +28 -0
  8. package/dist/actions/follow-user/follow-user.d.ts +255 -0
  9. package/dist/actions/follow-user/follow-user.mjs +37 -0
  10. package/dist/actions/get-tweet/get-tweet.d.ts +1006 -0
  11. package/dist/actions/get-tweet/get-tweet.mjs +35 -0
  12. package/dist/actions/get-user/get-user.d.ts +634 -0
  13. package/dist/actions/get-user/get-user.mjs +37 -0
  14. package/dist/actions/like-tweet/like-tweet.d.ts +252 -0
  15. package/dist/actions/like-tweet/like-tweet.mjs +30 -0
  16. package/dist/actions/list-favorites/list-favorites.d.ts +1138 -0
  17. package/dist/actions/list-favorites/list-favorites.mjs +52 -0
  18. package/dist/actions/list-followers/list-followers.d.ts +765 -0
  19. package/dist/actions/list-followers/list-followers.mjs +52 -0
  20. package/dist/actions/list-lists/list-lists.d.ts +762 -0
  21. package/dist/actions/list-lists/list-lists.mjs +52 -0
  22. package/dist/actions/list-mentions/list-mentions.d.ts +1136 -0
  23. package/dist/actions/list-mentions/list-mentions.mjs +52 -0
  24. package/dist/actions/list-user-tweets/list-user-tweets.d.ts +1138 -0
  25. package/dist/actions/list-user-tweets/list-user-tweets.mjs +52 -0
  26. package/dist/actions/retweet/retweet.d.ts +252 -0
  27. package/dist/actions/retweet/retweet.mjs +31 -0
  28. package/dist/actions/simple-search/simple-search.d.ts +1137 -0
  29. package/dist/actions/simple-search/simple-search.mjs +51 -0
  30. package/dist/actions/simple-search-in-list/simple-search-in-list.d.ts +1142 -0
  31. package/dist/actions/simple-search-in-list/simple-search-in-list.mjs +60 -0
  32. package/dist/actions/unfollow-user/unfollow-user.d.ts +255 -0
  33. package/dist/actions/unfollow-user/unfollow-user.mjs +33 -0
  34. package/dist/actions/unlike-tweet/unlike-tweet.d.ts +252 -0
  35. package/dist/actions/unlike-tweet/unlike-tweet.mjs +28 -0
  36. package/dist/app/twitter.app.d.ts +127 -0
  37. package/dist/app/twitter.app.mjs +341 -0
  38. package/dist/common/dataFields.d.ts +6 -0
  39. package/dist/common/dataFields.mjs +80 -0
  40. package/dist/common/expansions.d.ts +3 -0
  41. package/dist/common/expansions.mjs +17 -0
  42. package/dist/common/methods.d.ts +20 -0
  43. package/dist/common/methods.mjs +48 -0
  44. package/dist/common/propGroups.d.ts +1509 -0
  45. package/dist/common/propGroups.mjs +82 -0
  46. package/dist/common/types/fields.d.ts +18 -0
  47. package/dist/common/types/fields.mjs +1 -0
  48. package/dist/common/types/requestParams.d.ts +103 -0
  49. package/dist/common/types/requestParams.mjs +1 -0
  50. package/dist/common/types/responseSchemas.d.ts +42 -0
  51. package/dist/common/types/responseSchemas.mjs +1 -0
  52. package/dist/sources/common/base.d.ts +149 -0
  53. package/dist/sources/common/base.mjs +62 -0
  54. package/dist/sources/common/cacheUserId.d.ts +7 -0
  55. package/dist/sources/common/cacheUserId.mjs +18 -0
  56. package/dist/sources/common/getItemSummary.d.ts +4 -0
  57. package/dist/sources/common/getItemSummary.mjs +12 -0
  58. package/dist/sources/new-follower-of-user/new-follower-of-user.d.ts +650 -0
  59. package/dist/sources/new-follower-of-user/new-follower-of-user.mjs +49 -0
  60. package/dist/sources/new-list-followed/new-list-followed.d.ts +649 -0
  61. package/dist/sources/new-list-followed/new-list-followed.mjs +50 -0
  62. package/dist/sources/new-tweet-in-list/new-tweet-in-list.d.ts +1021 -0
  63. package/dist/sources/new-tweet-in-list/new-tweet-in-list.mjs +46 -0
  64. package/dist/sources/new-tweet-liked-by-user/new-tweet-liked-by-user.d.ts +1023 -0
  65. package/dist/sources/new-tweet-liked-by-user/new-tweet-liked-by-user.mjs +49 -0
  66. package/dist/sources/new-tweet-posted-by-user/new-tweet-posted-by-user.d.ts +1023 -0
  67. package/dist/sources/new-tweet-posted-by-user/new-tweet-posted-by-user.mjs +49 -0
  68. package/dist/sources/new-tweet-posted-matching-query/new-tweet-posted-matching-query.d.ts +1021 -0
  69. package/dist/sources/new-tweet-posted-matching-query/new-tweet-posted-matching-query.mjs +51 -0
  70. package/dist/sources/new-unfollower-of-user/new-unfollower-of-user.d.ts +273 -0
  71. package/dist/sources/new-unfollower-of-user/new-unfollower-of-user.mjs +75 -0
  72. package/dist/sources/new-user-followed/new-user-followed.d.ts +649 -0
  73. package/dist/sources/new-user-followed/new-user-followed.mjs +50 -0
  74. package/dist/tsconfig.tsbuildinfo +1 -0
  75. package/package.json +10 -14
  76. package/actions/add-user-to-list/add-user-to-list.mjs +0 -62
  77. package/actions/advanced-search/advanced-search.mjs +0 -113
  78. package/actions/common.mjs +0 -29
  79. package/actions/create-tweet/create-tweet.mjs +0 -146
  80. package/actions/delete-tweet/delete-tweet.mjs +0 -42
  81. package/actions/follow-user/follow-user.mjs +0 -48
  82. package/actions/get-tweet/get-tweet.mjs +0 -42
  83. package/actions/get-user/get-user.mjs +0 -50
  84. package/actions/like-tweet/like-tweet.mjs +0 -42
  85. package/actions/list-favorites/list-favorites.mjs +0 -63
  86. package/actions/list-followers/list-followers.mjs +0 -67
  87. package/actions/list-lists/list-lists.mjs +0 -69
  88. package/actions/list-mentions/list-mentions.mjs +0 -55
  89. package/actions/list-pending-followers/list-pending-followers.mjs +0 -32
  90. package/actions/list-retweets/list-retweets.mjs +0 -54
  91. package/actions/list-user-tweets/list-user-tweets.mjs +0 -80
  92. package/actions/retweet/retweet.mjs +0 -27
  93. package/actions/simple-search/simple-search.mjs +0 -62
  94. package/actions/simple-search-in-list/simple-search-in-list.mjs +0 -48
  95. package/actions/unfollow-user/unfollow-user.mjs +0 -48
  96. package/actions/unlike-tweet/unlike-tweet.mjs +0 -40
  97. package/actions/upload-media/upload-media.mjs +0 -122
  98. package/old.md +0 -169
  99. package/sources/common/followed.mjs +0 -38
  100. package/sources/common/followers.mjs +0 -159
  101. package/sources/common/tweets.mjs +0 -155
  102. package/sources/language-codes.mjs +0 -742
  103. package/sources/my-liked-tweets/my-liked-tweets.mjs +0 -30
  104. package/sources/my-tweets/my-tweets.mjs +0 -48
  105. package/sources/new-follower-of-me/new-follower-of-me.mjs +0 -69
  106. package/sources/new-follower-of-user/new-follower-of-user.mjs +0 -25
  107. package/sources/new-list-followed/new-list-followed.mjs +0 -24
  108. package/sources/new-trends-by-geo/new-trends-by-geo.mjs +0 -40
  109. package/sources/new-tweet-in-list/new-tweet-in-list.mjs +0 -49
  110. package/sources/new-unfollower-of-me/new-unfollower-of-me.mjs +0 -16
  111. package/sources/new-unfollower-of-user/new-unfollower-of-user.mjs +0 -25
  112. package/sources/new-user-followed/new-user-followed.mjs +0 -25
  113. package/sources/search-mentions/search-mentions.mjs +0 -144
  114. package/sources/tweets-liked-by-user/tweets-liked-by-user.mjs +0 -38
  115. package/sources/user-tweets/user-tweets.mjs +0 -49
  116. package/sources/watch-retweets-of-me/watch-retweets-of-me.mjs +0 -36
  117. package/sources/watch-retweets-of-my-tweet/watch-retweets-of-my-tweet.mjs +0 -44
  118. package/sources/watch-retweets-of-user-tweet/watch-retweets-of-user-tweet.mjs +0 -34
  119. package/twitter.app.mjs +0 -1161
@@ -0,0 +1,127 @@
1
+ import OAuth from "oauth-1.0a";
2
+ import { AddUserToListParams, CreateTweetParams, DeleteTweetParams, FollowUserParams, GetUserLikedTweetParams, GetUserOwnedListsParams, GetTweetParams, GetUserFollowedListsParams, GetUserMentionsParams, GetUserParams, GetUserTweetsParams, HttpRequestParams, LikeTweetParams, GetUserFollowersParams, GetUserFollowingParams, PaginatedRequestParams, RetweetParams, SearchTweetsParams, UnfollowUserParams, UnlikeTweetParams, GetListTweetsParams } from "../common/types/requestParams.js";
3
+ import { List, PaginatedResponseObject, ResponseObject, Tweet, TwitterEntity, User } from "../common/types/responseSchemas.js";
4
+ declare const _default: import("@pipedream/types").App<{
5
+ _getAuthHeader(config: HttpRequestParams): Promise<OAuth.Header>;
6
+ _getBaseUrl(): "https://api.twitter.com/2";
7
+ _httpRequest({ $, ...args }: HttpRequestParams): Promise<ResponseObject<TwitterEntity>>;
8
+ _paginatedRequest({ maxResults, maxPerPage, params, ...args }: PaginatedRequestParams): Promise<PaginatedResponseObject<TwitterEntity>>;
9
+ addUserToList({ listId, ...args }: AddUserToListParams): Promise<object>;
10
+ createTweet(args: CreateTweetParams): Promise<object>;
11
+ deleteTweet({ tweetId, ...args }: DeleteTweetParams): Promise<object>;
12
+ followUser(args: FollowUserParams): Promise<object>;
13
+ getListTweets({ listId, ...args }: GetListTweetsParams): Promise<PaginatedResponseObject<Tweet>>;
14
+ getTweet({ tweetId, ...args }: GetTweetParams): Promise<ResponseObject<Tweet>>;
15
+ getAuthenticatedUserId(): Promise<User["id"]>;
16
+ getUserLikedTweets({ userId, ...args }: GetUserLikedTweetParams): Promise<PaginatedResponseObject<Tweet>>;
17
+ getUserOwnedLists({ userId, ...args }: GetUserOwnedListsParams): Promise<PaginatedResponseObject<List>>;
18
+ getUserFollowedLists({ userId, ...args }: GetUserFollowedListsParams): Promise<PaginatedResponseObject<List>>;
19
+ getUserMentions({ userId, ...args }: GetUserMentionsParams): Promise<PaginatedResponseObject<Tweet>>;
20
+ getUserTweets({ userId, ...args }: GetUserTweetsParams): Promise<PaginatedResponseObject<Tweet>>;
21
+ getUserByUsername(username: string): Promise<ResponseObject<User>>;
22
+ getUser({ userId, ...args }: GetUserParams): Promise<ResponseObject<User>>;
23
+ likeTweet(args: LikeTweetParams): Promise<object>;
24
+ getUserFollowers({ userId, ...args }: GetUserFollowersParams): Promise<PaginatedResponseObject<User>>;
25
+ getUserFollowing({ userId, ...args }: GetUserFollowingParams): Promise<PaginatedResponseObject<User>>;
26
+ retweet(args: RetweetParams): Promise<object>;
27
+ searchTweets(args: SearchTweetsParams): Promise<PaginatedResponseObject<Tweet>>;
28
+ unfollowUser({ userId, ...args }: UnfollowUserParams): Promise<object>;
29
+ unlikeTweet({ tweetId, ...args }: UnlikeTweetParams): Promise<object>;
30
+ }, {
31
+ maxResults: {
32
+ type: string;
33
+ label: string;
34
+ description: string;
35
+ optional: boolean;
36
+ };
37
+ listId: {
38
+ type: string;
39
+ label: string;
40
+ description: string;
41
+ options(): Promise<{
42
+ label: string;
43
+ value: string;
44
+ }[]>;
45
+ };
46
+ userNameOrId: {
47
+ type: string;
48
+ label: string;
49
+ description: string;
50
+ optional: boolean;
51
+ default: string;
52
+ };
53
+ tweetId: {
54
+ type: string;
55
+ label: string;
56
+ description: string;
57
+ };
58
+ query: {
59
+ type: string;
60
+ label: string;
61
+ description: string;
62
+ };
63
+ listExpansions: {
64
+ type: string;
65
+ label: string;
66
+ optional: boolean;
67
+ description: string;
68
+ options: string[];
69
+ };
70
+ tweetExpansions: {
71
+ type: string;
72
+ label: string;
73
+ optional: boolean;
74
+ description: string;
75
+ options: string[];
76
+ };
77
+ userExpansions: {
78
+ type: string;
79
+ label: string;
80
+ optional: boolean;
81
+ description: string;
82
+ options: string[];
83
+ };
84
+ listFields: {
85
+ type: string;
86
+ label: string;
87
+ description: string;
88
+ optional: boolean;
89
+ options: string[];
90
+ };
91
+ mediaFields: {
92
+ type: string;
93
+ label: string;
94
+ description: string;
95
+ optional: boolean;
96
+ options: string[];
97
+ };
98
+ placeFields: {
99
+ type: string;
100
+ label: string;
101
+ description: string;
102
+ optional: boolean;
103
+ options: string[];
104
+ };
105
+ pollFields: {
106
+ type: string;
107
+ label: string;
108
+ description: string;
109
+ optional: boolean;
110
+ options: string[];
111
+ };
112
+ tweetFields: {
113
+ type: string;
114
+ label: string;
115
+ description: string;
116
+ optional: boolean;
117
+ options: string[];
118
+ };
119
+ userFields: {
120
+ type: string;
121
+ label: string;
122
+ description: string;
123
+ optional: boolean;
124
+ options: string[];
125
+ };
126
+ }>;
127
+ export default _default;
@@ -0,0 +1,341 @@
1
+ import OAuth from "oauth-1.0a";
2
+ import crypto from "crypto";
3
+ import { defineApp } from "@pipedream/types";
4
+ import { axios } from "@pipedream/platform";
5
+ import { LIST_FIELD_OPTIONS, MEDIA_FIELD_OPTIONS, PLACE_FIELD_OPTIONS, POLL_FIELD_OPTIONS, TWEET_FIELD_OPTIONS, USER_FIELD_OPTIONS, } from "../common/dataFields.mjs";
6
+ import { LIST_EXPANSION_OPTIONS, TWEET_EXPANSION_OPTIONS, USER_EXPANSION_OPTIONS, } from "../common/expansions.mjs";
7
+ export default defineApp({
8
+ type: "app",
9
+ app: "twitter",
10
+ propDefinitions: {
11
+ maxResults: {
12
+ type: "integer",
13
+ label: "Max Results",
14
+ description: "Maximum total amount of items to return. The maximum amount of requests that can be made is 5.",
15
+ optional: true,
16
+ },
17
+ listId: {
18
+ type: "string",
19
+ label: "List ID",
20
+ description: "Select a **List** owned by the authenticated user, or use a custom *List ID*.",
21
+ async options() {
22
+ const userId = await this.getAuthenticatedUserId();
23
+ const lists = await this.getUserOwnedLists({
24
+ userId,
25
+ });
26
+ return (lists.data?.map(({ id, name, }) => ({
27
+ label: name,
28
+ value: id,
29
+ })) ?? []);
30
+ },
31
+ },
32
+ userNameOrId: {
33
+ type: "string",
34
+ label: "User Name or ID",
35
+ description: "A Twitter username (handle) prefixed with `@` (e.g. `@pipedream`). You can also use the string `me` to use the authenticated user (default), or a numeric User ID.",
36
+ optional: true,
37
+ default: "me",
38
+ },
39
+ tweetId: {
40
+ type: "string",
41
+ label: "Tweet ID",
42
+ description: "The numerical ID of the tweet.",
43
+ },
44
+ query: {
45
+ type: "string",
46
+ label: "Query",
47
+ description: "One query for matching Tweets. See the [Twitter API guide on building queries](https://developer.twitter.com/en/docs/twitter-api/tweets/search/integrate/build-a-query).",
48
+ },
49
+ listExpansions: {
50
+ type: "string[]",
51
+ label: "Expansions",
52
+ optional: true,
53
+ description: "Additional data objects related to the List(s) to be included in the response.",
54
+ options: LIST_EXPANSION_OPTIONS,
55
+ },
56
+ tweetExpansions: {
57
+ type: "string[]",
58
+ label: "Expansions",
59
+ optional: true,
60
+ description: "Additional data objects related to the Tweet(s) to be included in the response.",
61
+ options: TWEET_EXPANSION_OPTIONS,
62
+ },
63
+ userExpansions: {
64
+ type: "string[]",
65
+ label: "Expansions",
66
+ optional: true,
67
+ description: "Additional data objects related to the User(s) to be included in the response.",
68
+ options: USER_EXPANSION_OPTIONS,
69
+ },
70
+ listFields: {
71
+ type: "string[]",
72
+ label: "List Fields",
73
+ description: "Specific [list fields](https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/lists) to be included in the returned list object.",
74
+ optional: true,
75
+ options: LIST_FIELD_OPTIONS,
76
+ },
77
+ mediaFields: {
78
+ type: "string[]",
79
+ label: "Media Fields",
80
+ description: "Specific [media fields](https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/media) to be included in the returned Tweet(s). Only applicable if the Tweet contains media and you've requested the `attachments.media_keys` expansion.",
81
+ optional: true,
82
+ options: MEDIA_FIELD_OPTIONS,
83
+ },
84
+ placeFields: {
85
+ type: "string[]",
86
+ label: "Place Fields",
87
+ description: "Specific [place fields](https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/place) to be included in the returned Tweet(s). Only applicable if the Tweet contains a place and you've requested the `geo.place_id` expansion.",
88
+ optional: true,
89
+ options: PLACE_FIELD_OPTIONS,
90
+ },
91
+ pollFields: {
92
+ type: "string[]",
93
+ label: "Poll Fields",
94
+ description: "Specific [poll fields](https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/poll) to be included in the returned Tweet(s). Only applicable if the Tweet contains a poll and you've requested the `attachments.poll_ids` expansion.",
95
+ optional: true,
96
+ options: POLL_FIELD_OPTIONS,
97
+ },
98
+ tweetFields: {
99
+ type: "string[]",
100
+ label: "Tweet Fields",
101
+ description: "Specific [tweet fields](https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet) to be included in the returned Tweet(s). If you've requested the `referenced_tweets.id` expansion, these fields will also be returned for any included referenced Tweets.",
102
+ optional: true,
103
+ options: TWEET_FIELD_OPTIONS,
104
+ },
105
+ userFields: {
106
+ type: "string[]",
107
+ label: "User Fields",
108
+ description: "Specific [user fields](https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/user) to be included in the returned Tweet(s). Only applicable if you've requested one of the user expansions: `author_id`, `entities.mentions.username`, `in_reply_to_user_id`, `referenced_tweets.id.author_id`.",
109
+ optional: true,
110
+ options: USER_FIELD_OPTIONS,
111
+ },
112
+ },
113
+ methods: {
114
+ async _getAuthHeader(config) {
115
+ const { oauth_access_token: key, oauth_refresh_token: secret, } = this.$auth;
116
+ const consumer = {
117
+ key,
118
+ secret,
119
+ };
120
+ const oauth = new OAuth({
121
+ consumer,
122
+ signature_method: "HMAC-SHA1",
123
+ hash_function(base_string, key) {
124
+ return crypto
125
+ .createHmac("sha1", key)
126
+ .update(base_string)
127
+ .digest("base64");
128
+ },
129
+ });
130
+ if (!config.method)
131
+ config.method = "GET";
132
+ return oauth.toHeader(oauth.authorize(config, consumer));
133
+ },
134
+ _getBaseUrl() {
135
+ return "https://api.twitter.com/2";
136
+ },
137
+ async _httpRequest({ $ = this, ...args }) {
138
+ const config = {
139
+ baseURL: this._getBaseUrl(),
140
+ ...args,
141
+ };
142
+ //const headers = this._getAuthHeader(config);
143
+ const request = () => axios($, {
144
+ ...config,
145
+ //headers,
146
+ }, {
147
+ oauthSignerUri: this.$auth.oauth_signer_uri,
148
+ token: {
149
+ key: this.$auth.oauth_access_token,
150
+ secret: this.$auth.oauth_refresh_token,
151
+ },
152
+ });
153
+ let response, counter = 1;
154
+ do {
155
+ try {
156
+ response = await request();
157
+ }
158
+ catch (err) {
159
+ console.log(`Request error on attempt #${counter}: `, err);
160
+ }
161
+ } while (!response && ++counter < 3);
162
+ if (!response)
163
+ response = await request();
164
+ return response;
165
+ },
166
+ async _paginatedRequest({ maxResults = 100, maxPerPage = 100, params, ...args }) {
167
+ const totalData = [], totalIncludes = {};
168
+ let paginationToken;
169
+ let resultCount = 0;
170
+ do {
171
+ const perPage = Math.min(maxResults - resultCount, maxPerPage);
172
+ const { data, meta: { next_token }, includes, } = await this._httpRequest({
173
+ params: {
174
+ ...params,
175
+ max_results: perPage,
176
+ pagination_token: paginationToken,
177
+ },
178
+ ...args,
179
+ });
180
+ if (!data)
181
+ break;
182
+ totalData.push(...(Array.isArray(data)
183
+ ? data
184
+ : [
185
+ data,
186
+ ]));
187
+ if (includes) {
188
+ Object.entries(includes).forEach(([key, value]) => {
189
+ if (!totalIncludes[key])
190
+ totalIncludes[key] = [];
191
+ totalIncludes[key].push(...value);
192
+ });
193
+ }
194
+ paginationToken = next_token;
195
+ resultCount += perPage;
196
+ } while (paginationToken && resultCount < maxResults);
197
+ return {
198
+ data: totalData,
199
+ includes: totalIncludes,
200
+ };
201
+ },
202
+ async addUserToList({ listId, ...args }) {
203
+ return this._httpRequest({
204
+ method: "POST",
205
+ url: `/lists/${listId}/members`,
206
+ ...args,
207
+ });
208
+ },
209
+ async createTweet(args) {
210
+ return this._httpRequest({
211
+ method: "POST",
212
+ url: "/tweets",
213
+ ...args,
214
+ });
215
+ },
216
+ async deleteTweet({ tweetId, ...args }) {
217
+ return this._httpRequest({
218
+ method: "DELETE",
219
+ url: `/tweets/${tweetId}`,
220
+ ...args,
221
+ });
222
+ },
223
+ async followUser(args) {
224
+ const id = await this.getAuthenticatedUserId();
225
+ return this._httpRequest({
226
+ method: "POST",
227
+ url: `/users/${id}/following`,
228
+ ...args,
229
+ });
230
+ },
231
+ async getListTweets({ listId, ...args }) {
232
+ return this._paginatedRequest({
233
+ url: `/lists/${listId}/tweets`,
234
+ ...args,
235
+ });
236
+ },
237
+ async getTweet({ tweetId, ...args }) {
238
+ return this._httpRequest({
239
+ url: `/tweets/${tweetId}`,
240
+ ...args,
241
+ });
242
+ },
243
+ async getAuthenticatedUserId() {
244
+ const response = await this._httpRequest({
245
+ url: "/users/me",
246
+ });
247
+ return response.data.id;
248
+ },
249
+ async getUserLikedTweets({ userId, ...args }) {
250
+ return this._paginatedRequest({
251
+ url: `/users/${userId}/liked_tweets`,
252
+ ...args,
253
+ });
254
+ },
255
+ async getUserOwnedLists({ userId, ...args }) {
256
+ return this._httpRequest({
257
+ url: `/users/${userId}/owned_lists`,
258
+ ...args,
259
+ });
260
+ },
261
+ async getUserFollowedLists({ userId, ...args }) {
262
+ return this._paginatedRequest({
263
+ url: `/users/${userId}/followed_lists`,
264
+ ...args,
265
+ });
266
+ },
267
+ async getUserMentions({ userId, ...args }) {
268
+ return this._paginatedRequest({
269
+ url: `/users/${userId}/mentions`,
270
+ ...args,
271
+ });
272
+ },
273
+ async getUserTweets({ userId, ...args }) {
274
+ return this._paginatedRequest({
275
+ url: `/users/${userId}/tweets`,
276
+ ...args,
277
+ });
278
+ },
279
+ async getUserByUsername(username) {
280
+ return this._httpRequest({
281
+ url: `/users/by/username/${username}`,
282
+ });
283
+ },
284
+ async getUser({ userId, ...args }) {
285
+ return this._httpRequest({
286
+ url: `/users/${userId}`,
287
+ ...args,
288
+ });
289
+ },
290
+ async likeTweet(args) {
291
+ const id = await this.getAuthenticatedUserId();
292
+ return this._httpRequest({
293
+ method: "POST",
294
+ url: `/users/${id}/likes`,
295
+ ...args,
296
+ });
297
+ },
298
+ async getUserFollowers({ userId, ...args }) {
299
+ return this._paginatedRequest({
300
+ url: `/users/${userId}/followers`,
301
+ ...args,
302
+ });
303
+ },
304
+ async getUserFollowing({ userId, ...args }) {
305
+ return this._paginatedRequest({
306
+ url: `/users/${userId}/following`,
307
+ ...args,
308
+ });
309
+ },
310
+ async retweet(args) {
311
+ const id = await this.getAuthenticatedUserId();
312
+ return this._httpRequest({
313
+ method: "POST",
314
+ url: `/users/${id}/retweets`,
315
+ ...args,
316
+ });
317
+ },
318
+ async searchTweets(args) {
319
+ return this._paginatedRequest({
320
+ url: "/tweets/search/recent",
321
+ ...args,
322
+ });
323
+ },
324
+ async unfollowUser({ userId, ...args }) {
325
+ const id = await this.getAuthenticatedUserId();
326
+ return this._httpRequest({
327
+ method: "DELETE",
328
+ url: `/users/${id}/following/${userId}`,
329
+ ...args,
330
+ });
331
+ },
332
+ async unlikeTweet({ tweetId, ...args }) {
333
+ const id = await this.getAuthenticatedUserId();
334
+ return this._httpRequest({
335
+ method: "DELETE",
336
+ url: `/users/${id}/likes/${tweetId}`,
337
+ ...args,
338
+ });
339
+ },
340
+ },
341
+ });
@@ -0,0 +1,6 @@
1
+ export declare const LIST_FIELD_OPTIONS: string[];
2
+ export declare const MEDIA_FIELD_OPTIONS: string[];
3
+ export declare const PLACE_FIELD_OPTIONS: string[];
4
+ export declare const POLL_FIELD_OPTIONS: string[];
5
+ export declare const TWEET_FIELD_OPTIONS: string[];
6
+ export declare const USER_FIELD_OPTIONS: string[];
@@ -0,0 +1,80 @@
1
+ export const LIST_FIELD_OPTIONS = [
2
+ "created_at",
3
+ "follower_count",
4
+ "member_count",
5
+ "private",
6
+ "description",
7
+ "owner_id",
8
+ ];
9
+ export const MEDIA_FIELD_OPTIONS = [
10
+ "duration_ms",
11
+ "height",
12
+ "media_key",
13
+ "preview_image_url",
14
+ "type",
15
+ "url",
16
+ "width",
17
+ "public_metrics",
18
+ "non_public_metrics",
19
+ "organic_metrics",
20
+ "promoted_metrics",
21
+ "alt_text",
22
+ "variants",
23
+ ];
24
+ export const PLACE_FIELD_OPTIONS = [
25
+ "contained_within",
26
+ "country",
27
+ "country_code",
28
+ "full_name",
29
+ "geo",
30
+ "id",
31
+ "name",
32
+ "place_type",
33
+ ];
34
+ export const POLL_FIELD_OPTIONS = [
35
+ "duration_minutes",
36
+ "end_datetime",
37
+ "id",
38
+ "options",
39
+ "voting_status",
40
+ ];
41
+ export const TWEET_FIELD_OPTIONS = [
42
+ "attachments",
43
+ "author_id",
44
+ "context_annotations",
45
+ "conversation_id",
46
+ "created_at",
47
+ "edit_controls",
48
+ "entities",
49
+ "geo",
50
+ "id",
51
+ "in_reply_to_user_id",
52
+ "lang",
53
+ "non_public_metrics",
54
+ "public_metrics",
55
+ "organic_metrics",
56
+ "promoted_metrics",
57
+ "possibly_sensitive",
58
+ "referenced_tweets",
59
+ "reply_settings",
60
+ "source",
61
+ "text",
62
+ "withheld",
63
+ ];
64
+ export const USER_FIELD_OPTIONS = [
65
+ "created_at",
66
+ "description",
67
+ "entities",
68
+ "id",
69
+ "location",
70
+ "name",
71
+ "pinned_tweet_id",
72
+ "profile_image_url",
73
+ "protected",
74
+ "public_metrics",
75
+ "url",
76
+ "username",
77
+ "verified",
78
+ "verified_type",
79
+ "withheld",
80
+ ];
@@ -0,0 +1,3 @@
1
+ export declare const LIST_EXPANSION_OPTIONS: string[];
2
+ export declare const TWEET_EXPANSION_OPTIONS: string[];
3
+ export declare const USER_EXPANSION_OPTIONS: string[];
@@ -0,0 +1,17 @@
1
+ export const LIST_EXPANSION_OPTIONS = [
2
+ "owner_id",
3
+ ];
4
+ export const TWEET_EXPANSION_OPTIONS = [
5
+ "attachments.poll_ids",
6
+ "attachments.media_keys",
7
+ "author_id",
8
+ "edit_history_tweet_ids",
9
+ "entities.mentions.username",
10
+ "geo.place_id",
11
+ "in_reply_to_user_id",
12
+ "referenced_tweets.id",
13
+ "referenced_tweets.id.author_id",
14
+ ];
15
+ export const USER_EXPANSION_OPTIONS = [
16
+ "pinned_tweet_id",
17
+ ];
@@ -0,0 +1,20 @@
1
+ export declare function getUserId(): Promise<string>;
2
+ export declare function getMultiItemSummary(name: string, length: number): string;
3
+ export declare function getListFields(): {
4
+ expansions: string;
5
+ "list.fields": string;
6
+ "user.fields": string;
7
+ };
8
+ export declare function getTweetFields(): {
9
+ expansions: string;
10
+ "media.fields": string;
11
+ "place.fields": string;
12
+ "poll.fields": string;
13
+ "tweet.fields": string;
14
+ "user.fields": string;
15
+ };
16
+ export declare function getUserFields(): {
17
+ expansions: string;
18
+ "tweet.fields": string;
19
+ "user.fields": string;
20
+ };
@@ -0,0 +1,48 @@
1
+ import { ConfigurationError } from "@pipedream/platform";
2
+ export async function getUserId() {
3
+ let { userNameOrId: id } = this;
4
+ if (id === "me" || id === undefined) {
5
+ id = await this.app.getAuthenticatedUserId();
6
+ }
7
+ else if (id.startsWith("@")) {
8
+ const userData = await this.app.getUserByUsername(id.slice(1));
9
+ id = userData?.data?.id;
10
+ if (!id)
11
+ throw new ConfigurationError("**User not found!** Check the `User Name or ID` prop.");
12
+ }
13
+ return id;
14
+ }
15
+ export function getMultiItemSummary(name, length) {
16
+ return length
17
+ ? `Successfully obtained ${length} ${name}${length === 1
18
+ ? ""
19
+ : "s"}`
20
+ : `No ${name}s were found`;
21
+ }
22
+ export function getListFields() {
23
+ const { expansions, listFields, userFields, } = this;
24
+ return {
25
+ "expansions": expansions?.join(),
26
+ "list.fields": listFields?.join(),
27
+ "user.fields": userFields?.join(),
28
+ };
29
+ }
30
+ export function getTweetFields() {
31
+ const { expansions, mediaFields, placeFields, pollFields, tweetFields, userFields, } = this;
32
+ return {
33
+ "expansions": expansions?.join(),
34
+ "media.fields": mediaFields?.join(),
35
+ "place.fields": placeFields?.join(),
36
+ "poll.fields": pollFields?.join(),
37
+ "tweet.fields": tweetFields?.join(),
38
+ "user.fields": userFields?.join(),
39
+ };
40
+ }
41
+ export function getUserFields() {
42
+ const { expansions, tweetFields, userFields, } = this;
43
+ return {
44
+ "expansions": expansions?.join(),
45
+ "tweet.fields": tweetFields?.join(),
46
+ "user.fields": userFields?.join(),
47
+ };
48
+ }