@pipedream/twitter 2.3.3 → 2.3.4

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 (94) hide show
  1. package/dist/actions/add-user-to-list/add-user-to-list.mjs +545 -50
  2. package/dist/actions/create-tweet/create-tweet.mjs +542 -81
  3. package/dist/actions/delete-tweet/delete-tweet.mjs +513 -34
  4. package/dist/actions/follow-user/follow-user.mjs +538 -43
  5. package/dist/actions/get-tweet/get-tweet.mjs +622 -40
  6. package/dist/actions/get-user/get-user.mjs +596 -44
  7. package/dist/actions/like-tweet/like-tweet.mjs +515 -36
  8. package/dist/actions/list-favorites/list-favorites.mjs +657 -56
  9. package/dist/actions/list-followers/list-followers.mjs +614 -56
  10. package/dist/actions/list-lists/list-lists.mjs +597 -56
  11. package/dist/actions/list-mentions/list-mentions.mjs +657 -56
  12. package/dist/actions/list-user-tweets/list-user-tweets.mjs +657 -56
  13. package/dist/actions/retweet/retweet.mjs +519 -39
  14. package/dist/actions/send-dm/send-dm.mjs +546 -49
  15. package/dist/actions/simple-search/simple-search.mjs +646 -56
  16. package/dist/actions/simple-search-in-list/simple-search-in-list.mjs +656 -63
  17. package/dist/actions/unfollow-user/unfollow-user.mjs +533 -39
  18. package/dist/actions/unlike-tweet/unlike-tweet.mjs +513 -34
  19. package/dist/actions/upload-media/upload-media.mjs +549 -57
  20. package/dist/app/twitter.app.mjs +443 -342
  21. package/dist/common/addObjIncludes.mjs +89 -63
  22. package/dist/common/additionalProps.mjs +0 -138
  23. package/dist/common/appValidation.mjs +475 -24
  24. package/dist/common/constants.mjs +11 -7
  25. package/dist/common/dataFields.mjs +100 -89
  26. package/dist/common/errorMessage.mjs +32 -26
  27. package/dist/common/expansions.mjs +26 -19
  28. package/dist/common/methods.mjs +170 -81
  29. package/dist/common/types/fields.mjs +0 -1
  30. package/dist/common/types/includeMapping.mjs +0 -1
  31. package/dist/common/types/requestParams.mjs +0 -1
  32. package/dist/common/types/responseSchemas.mjs +0 -1
  33. package/dist/sources/common/base.mjs +546 -69
  34. package/dist/sources/common/cacheUserId.mjs +32 -15
  35. package/dist/sources/common/getItemSummary.mjs +13 -9
  36. package/dist/sources/new-follower-of-user/new-follower-of-user.mjs +799 -40
  37. package/dist/sources/new-list-followed/new-list-followed.mjs +722 -41
  38. package/dist/sources/new-mention-received-by-user/new-mention-received-by-user.mjs +860 -40
  39. package/dist/sources/new-message/new-message.mjs +738 -32
  40. package/dist/sources/new-tweet-in-list/new-tweet-in-list.mjs +839 -37
  41. package/dist/sources/new-tweet-liked-by-user/new-tweet-liked-by-user.mjs +860 -40
  42. package/dist/sources/new-tweet-metrics/new-tweet-metrics.mjs +629 -59
  43. package/dist/sources/new-tweet-posted-by-user/new-tweet-posted-by-user.mjs +860 -40
  44. package/dist/sources/new-tweet-posted-matching-query/new-tweet-posted-matching-query.mjs +830 -39
  45. package/dist/sources/new-unfollower-of-user/new-unfollower-of-user.mjs +829 -70
  46. package/dist/sources/new-user-followed/new-user-followed.mjs +737 -41
  47. package/package.json +2 -2
  48. package/dist/actions/add-user-to-list/add-user-to-list.d.ts +0 -6
  49. package/dist/actions/create-tweet/create-tweet.d.ts +0 -105
  50. package/dist/actions/delete-tweet/delete-tweet.d.ts +0 -4
  51. package/dist/actions/follow-user/follow-user.d.ts +0 -6
  52. package/dist/actions/get-tweet/get-tweet.d.ts +0 -6
  53. package/dist/actions/get-user/get-user.d.ts +0 -7
  54. package/dist/actions/like-tweet/like-tweet.d.ts +0 -4
  55. package/dist/actions/list-favorites/list-favorites.d.ts +0 -10
  56. package/dist/actions/list-followers/list-followers.d.ts +0 -10
  57. package/dist/actions/list-lists/list-lists.d.ts +0 -8
  58. package/dist/actions/list-mentions/list-mentions.d.ts +0 -10
  59. package/dist/actions/list-user-tweets/list-user-tweets.d.ts +0 -10
  60. package/dist/actions/retweet/retweet.d.ts +0 -4
  61. package/dist/actions/send-dm/send-dm.d.ts +0 -6
  62. package/dist/actions/simple-search/simple-search.d.ts +0 -9
  63. package/dist/actions/simple-search-in-list/simple-search-in-list.d.ts +0 -9
  64. package/dist/actions/unfollow-user/unfollow-user.d.ts +0 -6
  65. package/dist/actions/unlike-tweet/unlike-tweet.d.ts +0 -4
  66. package/dist/actions/upload-media/upload-media.d.ts +0 -4
  67. package/dist/app/twitter.app.d.ts +0 -69
  68. package/dist/common/addObjIncludes.d.ts +0 -9
  69. package/dist/common/additionalProps.d.ts +0 -0
  70. package/dist/common/appValidation.d.ts +0 -144
  71. package/dist/common/constants.d.ts +0 -7
  72. package/dist/common/dataFields.d.ts +0 -8
  73. package/dist/common/errorMessage.d.ts +0 -25
  74. package/dist/common/expansions.d.ts +0 -4
  75. package/dist/common/methods.d.ts +0 -27
  76. package/dist/common/types/fields.d.ts +0 -25
  77. package/dist/common/types/includeMapping.d.ts +0 -11
  78. package/dist/common/types/requestParams.d.ts +0 -126
  79. package/dist/common/types/responseSchemas.d.ts +0 -82
  80. package/dist/sources/common/base.d.ts +0 -163
  81. package/dist/sources/common/cacheUserId.d.ts +0 -7
  82. package/dist/sources/common/getItemSummary.d.ts +0 -4
  83. package/dist/sources/new-follower-of-user/new-follower-of-user.d.ts +0 -17
  84. package/dist/sources/new-list-followed/new-list-followed.d.ts +0 -17
  85. package/dist/sources/new-mention-received-by-user/new-mention-received-by-user.d.ts +0 -17
  86. package/dist/sources/new-message/new-message.d.ts +0 -15
  87. package/dist/sources/new-tweet-in-list/new-tweet-in-list.d.ts +0 -15
  88. package/dist/sources/new-tweet-liked-by-user/new-tweet-liked-by-user.d.ts +0 -17
  89. package/dist/sources/new-tweet-metrics/new-tweet-metrics.d.ts +0 -13
  90. package/dist/sources/new-tweet-posted-by-user/new-tweet-posted-by-user.d.ts +0 -17
  91. package/dist/sources/new-tweet-posted-matching-query/new-tweet-posted-matching-query.d.ts +0 -15
  92. package/dist/sources/new-unfollower-of-user/new-unfollower-of-user.d.ts +0 -17
  93. package/dist/sources/new-user-followed/new-user-followed.d.ts +0 -17
  94. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,42 +1,522 @@
1
- import common from "../../common/appValidation.mjs";
2
- import { ACTION_ERROR_MESSAGE } from "../../common/errorMessage.mjs";
3
- import { defineAction } from "@pipedream/types";
4
- const DOCS_LINK = "https://developer.twitter.com/en/docs/twitter-api/tweets/retweets/api-reference/post-users-id-retweets";
5
- export default defineAction({
6
- ...common,
7
- key: "twitter-retweet",
8
- name: "Retweet a tweet",
9
- description: `Retweet a tweet specified by ID. [See the documentation](${DOCS_LINK})`,
10
- version: "2.0.9",
11
- annotations: {
12
- destructiveHint: false,
13
- openWorldHint: true,
14
- readOnlyHint: false,
15
- },
16
- type: "action",
17
- props: {
18
- ...common.props,
19
- tweetId: {
20
- propDefinition: [
21
- common.props.app,
22
- "tweetId",
23
- ],
24
- description: "The ID of the tweet you'd like to retweet",
25
- },
1
+ // components/twitter/app/twitter.app.ts
2
+ import OAuth from "oauth-1.0a";
3
+ import crypto from "crypto";
4
+ import { defineApp } from "@pipedream/types";
5
+ import {
6
+ axios,
7
+ transformConfigForOauth,
8
+ ConfigurationError
9
+ } from "@pipedream/platform";
10
+
11
+ // components/twitter/common/errorMessage.ts
12
+ var ERROR_URL = "https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#item0";
13
+ var ERROR_MESSAGE = `Check if your app is properly configured on the [Twitter Developer Portal](${ERROR_URL}), and if your plan has access to the endpoint used by this component.`;
14
+ var ACTION_ERROR_MESSAGE = `${ERROR_MESSAGE} Additional debugging information has been exported from the step.`;
15
+ var PROBLEM_BASE_URL = "https://api.twitter.com/2/problems";
16
+ var ERROR_BY_TYPE = {
17
+ [`${PROBLEM_BASE_URL}/client-forbidden`]: "This X (Twitter) account appears to be on the Free plan, which only has access to **Create Tweets**. [Refer to Twitter's developer docs](https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve) for the latest info on API access.",
18
+ ["about:blank"]: "A generic problem with no additional information beyond that provided by the HTTP status code.",
19
+ [`${PROBLEM_BASE_URL}/invalid-request`]: "A problem that indicates this request is invalid. If your request takes a POST body, ensure the contents is valid JSON and matches the [OpenAPI spec](https://api.twitter.com/2/openapi.json).",
20
+ [`${PROBLEM_BASE_URL}/resource-not-found`]: "A problem that indicates that a given Post, User, etc. does not exist.",
21
+ [`${PROBLEM_BASE_URL}/not-authorized-for-resource`]: "A problem that indicates you are not allowed to see a particular Post, User, etc.",
22
+ [`${PROBLEM_BASE_URL}/disallowed-resource`]: "A problem that indicates that the resource requested violates the precepts of this API.",
23
+ [`${PROBLEM_BASE_URL}/unsupported-authentication`]: "A problem that indicates that the authentication used is not supported.",
24
+ [`${PROBLEM_BASE_URL}/usage-capped`]: "A problem that indicates that a usage cap has been exceeded.",
25
+ [`${PROBLEM_BASE_URL}/streaming-connection`]: "A problem that indicates something is wrong with the connection.",
26
+ [`${PROBLEM_BASE_URL}/client-disconnected`]: "Your client has gone away.",
27
+ [`${PROBLEM_BASE_URL}/operational-disconnect`]: "You have been disconnected for operational reasons.",
28
+ [`${PROBLEM_BASE_URL}/rule-cap`]: "You have exceeded the maximum number of rules.",
29
+ [`${PROBLEM_BASE_URL}/rule-length`]: "You have exceeded the maximum number of characters allowed on your query or rule based on your access level. See [access levels](https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api.html#Access).",
30
+ [`${PROBLEM_BASE_URL}/invalid-rules`]: "The rule you have submitted is invalid.",
31
+ [`${PROBLEM_BASE_URL}/duplicate-rules`]: "The rule you have submitted is a duplicate.",
32
+ [`${PROBLEM_BASE_URL}/conflict`]: "The rule you have submitted is in conflict with another rule.",
33
+ [`${PROBLEM_BASE_URL}/noncompliant-rules`]: "The rule you have submitted is not compliant with Twitter's Automation Rules",
34
+ [`${PROBLEM_BASE_URL}/not-authorized-for-field`]: "A problem that indicates you are not allowed to see a particular field.",
35
+ [`${PROBLEM_BASE_URL}/oauth1-permissions`]: "A problem that indicates you are not allowed to see a particular field.",
36
+ [`${PROBLEM_BASE_URL}/resource-unavailable`]: "A problem that indicates that a given Post, User, etc. is temporarily unavailable."
37
+ };
38
+
39
+ // components/twitter/app/twitter.app.ts
40
+ var twitter_app_default = defineApp({
41
+ type: "app",
42
+ app: "twitter",
43
+ propDefinitions: {
44
+ maxResults: {
45
+ type: "integer",
46
+ label: "Max Results",
47
+ description: "Maximum amount of items to return. The maximum amount per request for each endpoint is included in the API documentation.",
48
+ optional: true
49
+ },
50
+ listId: {
51
+ type: "string",
52
+ label: "List ID",
53
+ description: "Select a **List** owned by the authenticated user, or use a custom *List ID*.",
54
+ async options() {
55
+ const userId = await this.getAuthenticatedUserId();
56
+ const lists = await this.getUserOwnedLists({
57
+ userId
58
+ });
59
+ return lists.data?.map(({
60
+ id,
61
+ name
62
+ }) => ({
63
+ label: name,
64
+ value: id
65
+ })) ?? [];
66
+ }
67
+ },
68
+ userNameOrId: {
69
+ type: "string",
70
+ label: "User Name or ID",
71
+ 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.",
72
+ optional: true,
73
+ default: "me"
74
+ },
75
+ // See comment on "../common/additionalProps.ts"
76
+ /*
77
+ includeAllFields: {
78
+ type: "boolean",
79
+ label: "Include All Metadata",
80
+ description: "If set to `false`, you can choose which fields will be returned for each data type.",
81
+ optional: true,
82
+ default: true,
83
+ reloadProps: true,
84
+ },
85
+ */
86
+ tweetId: {
87
+ type: "string",
88
+ label: "Tweet ID",
89
+ description: "The numerical ID of the tweet."
90
+ },
91
+ query: {
92
+ type: "string",
93
+ label: "Query",
94
+ 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)."
95
+ }
96
+ },
97
+ methods: {
98
+ throwError(data) {
99
+ const errorMessage = ERROR_BY_TYPE[data?.type];
100
+ if (!errorMessage) {
101
+ return;
102
+ }
103
+ throw new ConfigurationError(errorMessage);
104
+ },
105
+ _getAuthHeader(config) {
106
+ const {
107
+ developer_consumer_key: devKey,
108
+ developer_consumer_secret: devSecret,
109
+ oauth_access_token: key,
110
+ oauth_refresh_token: secret
111
+ } = this.$auth;
112
+ const consumer = {
113
+ key: devKey,
114
+ secret: devSecret
115
+ };
116
+ const oauth = new OAuth({
117
+ consumer,
118
+ signature_method: "HMAC-SHA1",
119
+ hash_function(base_string, key2) {
120
+ return crypto.createHmac("sha1", key2).update(base_string).digest("base64");
121
+ }
122
+ });
123
+ const token = {
124
+ key,
125
+ secret
126
+ };
127
+ const requestData = transformConfigForOauth(config);
128
+ return oauth.toHeader(oauth.authorize(requestData, token));
129
+ },
130
+ _getBaseUrl() {
131
+ return "https://api.twitter.com/2";
132
+ },
133
+ async _httpRequest({
134
+ $ = this,
135
+ headers,
136
+ specialAuth = false,
137
+ throwError = true,
138
+ fallbackError,
139
+ ...args
140
+ }) {
141
+ const maxRetries = 3;
142
+ let response;
143
+ let counter = 1;
144
+ const config = {
145
+ baseURL: this._getBaseUrl(),
146
+ ...args
147
+ };
148
+ const authConfig = specialAuth ? {
149
+ ...config,
150
+ params: {},
151
+ data: {}
152
+ } : config;
153
+ const axiosConfig = {
154
+ debug: true,
155
+ ...config,
156
+ headers: {
157
+ ...headers,
158
+ ...this._getAuthHeader(authConfig)
159
+ }
160
+ };
161
+ do {
162
+ try {
163
+ response = await axios($, axiosConfig);
164
+ } catch (err) {
165
+ console.log(`Request error on attempt #${counter}: `, err);
166
+ if (counter === maxRetries) {
167
+ if (throwError && err.response?.data) {
168
+ this.throwError(err.response.data);
169
+ }
170
+ if (fallbackError) {
171
+ throw new ConfigurationError(fallbackError);
172
+ }
173
+ throw err;
174
+ }
175
+ }
176
+ } while (!response && ++counter <= maxRetries);
177
+ return response;
178
+ },
179
+ async _paginatedRequest({
180
+ maxResults = 100,
181
+ maxPerPage = 100,
182
+ params,
183
+ ...args
184
+ }) {
185
+ const totalData = [], totalErrors = [], totalIncludes = {};
186
+ let paginationToken;
187
+ let resultCount = 0;
188
+ do {
189
+ const perPage = Math.min(maxResults - resultCount, maxPerPage);
190
+ const {
191
+ data,
192
+ errors,
193
+ meta: { next_token },
194
+ includes
195
+ } = await this._httpRequest({
196
+ params: {
197
+ ...params,
198
+ max_results: perPage,
199
+ pagination_token: paginationToken
200
+ },
201
+ ...args
202
+ });
203
+ if (data) {
204
+ totalData.push(...Array.isArray(data) ? data : [
205
+ data
206
+ ]);
207
+ }
208
+ if (errors) {
209
+ totalErrors.push(...Array.isArray(errors) ? errors : [
210
+ errors
211
+ ]);
212
+ }
213
+ if (includes) {
214
+ Object.entries(includes).forEach(
215
+ ([
216
+ key,
217
+ value
218
+ ]) => {
219
+ if (!totalIncludes[key]) totalIncludes[key] = [];
220
+ totalIncludes[key].push(...value);
221
+ }
222
+ );
223
+ }
224
+ paginationToken = next_token;
225
+ resultCount += perPage;
226
+ } while (paginationToken && resultCount < maxResults);
227
+ return {
228
+ data: totalData,
229
+ errors: totalErrors,
230
+ includes: totalIncludes
231
+ };
232
+ },
233
+ async addUserToList({
234
+ listId,
235
+ ...args
236
+ }) {
237
+ return this._httpRequest({
238
+ method: "POST",
239
+ url: `/lists/${listId}/members`,
240
+ ...args
241
+ });
242
+ },
243
+ async createTweet(args) {
244
+ return this._httpRequest({
245
+ throwError: false,
246
+ method: "POST",
247
+ url: "/tweets",
248
+ ...args
249
+ });
250
+ },
251
+ async deleteTweet({
252
+ tweetId,
253
+ ...args
254
+ }) {
255
+ return this._httpRequest({
256
+ method: "DELETE",
257
+ url: `/tweets/${tweetId}`,
258
+ ...args
259
+ });
260
+ },
261
+ async followUser(args) {
262
+ const id = await this.getAuthenticatedUserId();
263
+ return this._httpRequest({
264
+ method: "POST",
265
+ url: `/users/${id}/following`,
266
+ ...args
267
+ });
268
+ },
269
+ async getListTweets({
270
+ listId,
271
+ ...args
272
+ }) {
273
+ return this._paginatedRequest({
274
+ url: `/lists/${listId}/tweets`,
275
+ ...args
276
+ });
277
+ },
278
+ async getTweet({
279
+ tweetId,
280
+ ...args
281
+ }) {
282
+ return this._httpRequest({
283
+ url: `/tweets/${tweetId}`,
284
+ ...args
285
+ });
286
+ },
287
+ async getAuthenticatedUser(args) {
288
+ return this._httpRequest({
289
+ url: "/users/me",
290
+ ...args
291
+ });
292
+ },
293
+ async getAuthenticatedUserId() {
294
+ const response = await this.getAuthenticatedUser();
295
+ return response.data.id;
26
296
  },
27
- async run({ $ }) {
28
- const { tweetId } = this;
29
- const params = {
30
- $,
31
- data: {
32
- tweet_id: tweetId,
33
- },
34
- fallbackError: ACTION_ERROR_MESSAGE,
35
- };
36
- const response = await this.app.retweet(params);
37
- $.export("$summary", response.data?.retweeted !== true
38
- ? "Retweet failed"
39
- : "Tweet successfully retweeted");
40
- return response;
297
+ async getDirectMessages(args) {
298
+ return this._paginatedRequest({
299
+ url: "/dm_events",
300
+ ...args
301
+ });
41
302
  },
303
+ async getUserLikedTweets({
304
+ userId,
305
+ ...args
306
+ }) {
307
+ return this._paginatedRequest({
308
+ url: `/users/${userId}/liked_tweets`,
309
+ ...args
310
+ });
311
+ },
312
+ async getUserOwnedLists({
313
+ userId,
314
+ ...args
315
+ }) {
316
+ return this._httpRequest({
317
+ url: `/users/${userId}/owned_lists`,
318
+ ...args
319
+ });
320
+ },
321
+ async getUserFollowedLists({
322
+ userId,
323
+ ...args
324
+ }) {
325
+ return this._paginatedRequest({
326
+ url: `/users/${userId}/followed_lists`,
327
+ ...args
328
+ });
329
+ },
330
+ async getUserMentions({
331
+ userId,
332
+ ...args
333
+ }) {
334
+ return this._paginatedRequest({
335
+ url: `/users/${userId}/mentions`,
336
+ ...args
337
+ });
338
+ },
339
+ async getUserTweets({
340
+ userId,
341
+ ...args
342
+ }) {
343
+ return this._paginatedRequest({
344
+ url: `/users/${userId}/tweets`,
345
+ ...args
346
+ });
347
+ },
348
+ async getUserByUsername(username) {
349
+ return this._httpRequest({
350
+ url: `/users/by/username/${username}`
351
+ });
352
+ },
353
+ async getUser({
354
+ userId,
355
+ ...args
356
+ }) {
357
+ return this._httpRequest({
358
+ url: `/users/${userId}`,
359
+ ...args
360
+ });
361
+ },
362
+ async likeTweet(args) {
363
+ const id = await this.getAuthenticatedUserId();
364
+ return this._httpRequest({
365
+ method: "POST",
366
+ url: `/users/${id}/likes`,
367
+ ...args
368
+ });
369
+ },
370
+ async getUserFollowers({
371
+ userId,
372
+ ...args
373
+ }) {
374
+ return this._paginatedRequest({
375
+ url: `/users/${userId}/followers`,
376
+ ...args
377
+ });
378
+ },
379
+ async getUserFollowing({
380
+ userId,
381
+ ...args
382
+ }) {
383
+ return this._paginatedRequest({
384
+ url: `/users/${userId}/following`,
385
+ ...args
386
+ });
387
+ },
388
+ async retweet(args) {
389
+ const id = await this.getAuthenticatedUserId();
390
+ return this._httpRequest({
391
+ method: "POST",
392
+ url: `/users/${id}/retweets`,
393
+ ...args
394
+ });
395
+ },
396
+ async searchTweets(args) {
397
+ return this._paginatedRequest({
398
+ url: "/tweets/search/recent",
399
+ ...args
400
+ });
401
+ },
402
+ async sendMessage({
403
+ userId,
404
+ ...args
405
+ }) {
406
+ return this._httpRequest({
407
+ method: "POST",
408
+ url: `/dm_conversations/with/${userId}/messages`,
409
+ ...args
410
+ });
411
+ },
412
+ async unfollowUser({
413
+ userId,
414
+ ...args
415
+ }) {
416
+ const id = await this.getAuthenticatedUserId();
417
+ return this._httpRequest({
418
+ method: "DELETE",
419
+ url: `/users/${id}/following/${userId}`,
420
+ ...args
421
+ });
422
+ },
423
+ async unlikeTweet({
424
+ tweetId,
425
+ ...args
426
+ }) {
427
+ const id = await this.getAuthenticatedUserId();
428
+ return this._httpRequest({
429
+ method: "DELETE",
430
+ url: `/users/${id}/likes/${tweetId}`,
431
+ ...args
432
+ });
433
+ },
434
+ async uploadMedia(args) {
435
+ return this._httpRequest({
436
+ baseURL: "https://upload.twitter.com/1.1",
437
+ url: "/media/upload.json",
438
+ method: "POST",
439
+ headers: {
440
+ "Content-Type": `multipart/form-data; boundary=${args.data.getBoundary()}`
441
+ },
442
+ specialAuth: true,
443
+ ...args
444
+ });
445
+ }
446
+ }
447
+ });
448
+
449
+ // components/twitter/common/appValidation.ts
450
+ var appValidation_default = {
451
+ props: {
452
+ app: {
453
+ ...twitter_app_default,
454
+ reloadProps: true
455
+ }
456
+ },
457
+ async additionalProps() {
458
+ const q = "Pipedream";
459
+ const data = await this.getRecentTweets({
460
+ params: {
461
+ query: q
462
+ },
463
+ validateStatus: () => true
464
+ });
465
+ this.app.throwError(data);
466
+ return {};
467
+ },
468
+ methods: {
469
+ getRecentTweets(args = {}) {
470
+ return this.app._httpRequest({
471
+ url: "/tweets/search/recent",
472
+ ...args
473
+ });
474
+ }
475
+ }
476
+ };
477
+
478
+ // components/twitter/actions/retweet/retweet.ts
479
+ import { defineAction } from "@pipedream/types";
480
+ var DOCS_LINK = "https://developer.twitter.com/en/docs/twitter-api/tweets/retweets/api-reference/post-users-id-retweets";
481
+ var retweet_default = defineAction({
482
+ ...appValidation_default,
483
+ key: "twitter-retweet",
484
+ name: "Retweet a tweet",
485
+ description: `Retweet a tweet specified by ID. [See the documentation](${DOCS_LINK})`,
486
+ version: "2.0.9",
487
+ annotations: {
488
+ destructiveHint: false,
489
+ openWorldHint: true,
490
+ readOnlyHint: false
491
+ },
492
+ type: "action",
493
+ props: {
494
+ ...appValidation_default.props,
495
+ tweetId: {
496
+ propDefinition: [
497
+ appValidation_default.props.app,
498
+ "tweetId"
499
+ ],
500
+ description: "The ID of the tweet you'd like to retweet"
501
+ }
502
+ },
503
+ async run({ $ }) {
504
+ const { tweetId } = this;
505
+ const params = {
506
+ $,
507
+ data: {
508
+ tweet_id: tweetId
509
+ },
510
+ fallbackError: ACTION_ERROR_MESSAGE
511
+ };
512
+ const response = await this.app.retweet(params);
513
+ $.export(
514
+ "$summary",
515
+ response.data?.retweeted !== true ? "Retweet failed" : "Tweet successfully retweeted"
516
+ );
517
+ return response;
518
+ }
42
519
  });
520
+ export {
521
+ retweet_default as default
522
+ };