@pipedream/twitter 2.3.2 → 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 -45
  2. package/dist/actions/create-tweet/create-tweet.mjs +542 -76
  3. package/dist/actions/delete-tweet/delete-tweet.mjs +513 -29
  4. package/dist/actions/follow-user/follow-user.mjs +538 -38
  5. package/dist/actions/get-tweet/get-tweet.mjs +622 -35
  6. package/dist/actions/get-user/get-user.mjs +596 -39
  7. package/dist/actions/like-tweet/like-tweet.mjs +515 -31
  8. package/dist/actions/list-favorites/list-favorites.mjs +657 -51
  9. package/dist/actions/list-followers/list-followers.mjs +614 -51
  10. package/dist/actions/list-lists/list-lists.mjs +597 -51
  11. package/dist/actions/list-mentions/list-mentions.mjs +657 -51
  12. package/dist/actions/list-user-tweets/list-user-tweets.mjs +657 -51
  13. package/dist/actions/retweet/retweet.mjs +519 -34
  14. package/dist/actions/send-dm/send-dm.mjs +546 -44
  15. package/dist/actions/simple-search/simple-search.mjs +646 -51
  16. package/dist/actions/simple-search-in-list/simple-search-in-list.mjs +656 -58
  17. package/dist/actions/unfollow-user/unfollow-user.mjs +533 -34
  18. package/dist/actions/unlike-tweet/unlike-tweet.mjs +513 -29
  19. package/dist/actions/upload-media/upload-media.mjs +549 -52
  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 +3 -3
  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,80 +1,546 @@
1
- import app from "../../app/twitter.app.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/manage-tweets/api-reference/post-tweets";
5
- export default defineAction({
6
- key: "twitter-create-tweet",
7
- name: "Create Tweet",
8
- description: `Create a new tweet. [See the documentation](${DOCS_LINK})`,
9
- version: "2.1.6",
10
- type: "action",
11
- props: {
12
- app,
13
- text: {
14
- type: "string",
15
- label: "Text",
16
- description: "Text of the Tweet being created. Required if `Media IDs` is not set.",
17
- optional: true,
18
- },
19
- inReplyToTweetId: {
20
- type: "string",
21
- label: "In Reply To Tweet (ID)",
22
- description: "Tweet ID of the Tweet being replied to. Please note that this prop needs to be set if `Exclude Reply User IDs` is also set.",
23
- optional: true,
24
- },
25
- excludeReplyUserIds: {
26
- type: "string[]",
27
- label: "Exclude Reply User IDs",
28
- description: "A list of User IDs to be excluded from the reply Tweet thus removing a user from a thread.",
29
- optional: true,
30
- },
31
- mediaIds: {
32
- type: "string[]",
33
- label: "Media IDs",
34
- description: "A list of Media IDs being attached to the Tweet. This is only required if `Tagged User IDs` is set.",
35
- optional: true,
36
- },
37
- taggedUserIds: {
38
- type: "string[]",
39
- label: "Tagged User IDs",
40
- description: "A list of User IDs being tagged in the Tweet with Media. If the user you're tagging doesn't have photo-tagging enabled, their names won't show up in the list of tagged users even though the Tweet is successfully created.",
41
- optional: true,
42
- },
43
- placeId: {
44
- type: "string",
45
- label: "Place ID",
46
- description: "Place ID being attached to the Tweet for geo location.",
47
- optional: true,
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;
296
+ },
297
+ async getDirectMessages(args) {
298
+ return this._paginatedRequest({
299
+ url: "/dm_events",
300
+ ...args
301
+ });
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()}`
48
441
  },
442
+ specialAuth: true,
443
+ ...args
444
+ });
445
+ }
446
+ }
447
+ });
448
+
449
+ // components/twitter/actions/create-tweet/create-tweet.ts
450
+ import { defineAction } from "@pipedream/types";
451
+ var DOCS_LINK = "https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/post-tweets";
452
+ var create_tweet_default = defineAction({
453
+ key: "twitter-create-tweet",
454
+ name: "Create Tweet",
455
+ description: `Create a new tweet. [See the documentation](${DOCS_LINK})`,
456
+ version: "2.1.8",
457
+ annotations: {
458
+ destructiveHint: false,
459
+ openWorldHint: true,
460
+ readOnlyHint: false
461
+ },
462
+ type: "action",
463
+ ai: "optimized",
464
+ props: {
465
+ app: twitter_app_default,
466
+ text: {
467
+ type: "string",
468
+ label: "Text",
469
+ description: "Text of the Tweet being created. Required if `Media IDs` is not set.",
470
+ optional: true
49
471
  },
50
- async run({ $ }) {
51
- const { text, inReplyToTweetId, excludeReplyUserIds, mediaIds, placeId, taggedUserIds, } = this;
52
- const params = {
53
- $,
54
- data: {
55
- text,
56
- ...((inReplyToTweetId || excludeReplyUserIds) && {
57
- reply: {
58
- exclude_reply_user_ids: excludeReplyUserIds,
59
- in_reply_to_tweet_id: inReplyToTweetId,
60
- },
61
- }),
62
- ...((mediaIds || taggedUserIds) && {
63
- media: {
64
- media_ids: mediaIds,
65
- tagged_user_ids: taggedUserIds,
66
- },
67
- }),
68
- ...(placeId && {
69
- geo: {
70
- place_id: placeId,
71
- },
72
- }),
73
- },
74
- fallbackError: ACTION_ERROR_MESSAGE,
75
- };
76
- const response = await this.app.createTweet(params);
77
- $.export("$summary", `Successfully posted tweet (ID ${response.data?.id})`);
78
- return response;
472
+ inReplyToTweetId: {
473
+ type: "string",
474
+ label: "In Reply To Tweet (ID)",
475
+ description: "Tweet ID of the Tweet being replied to. Please note that this prop needs to be set if `Exclude Reply User IDs` is also set.",
476
+ optional: true
79
477
  },
478
+ excludeReplyUserIds: {
479
+ type: "string[]",
480
+ label: "Exclude Reply User IDs",
481
+ description: "A list of User IDs to be excluded from the reply Tweet thus removing a user from a thread.",
482
+ optional: true
483
+ },
484
+ mediaIds: {
485
+ type: "string[]",
486
+ label: "Media IDs",
487
+ description: "A list of Media IDs being attached to the Tweet. This is only required if `Tagged User IDs` is set.",
488
+ optional: true
489
+ },
490
+ taggedUserIds: {
491
+ type: "string[]",
492
+ label: "Tagged User IDs",
493
+ description: "A list of User IDs being tagged in the Tweet with Media. If the user you're tagging doesn't have photo-tagging enabled, their names won't show up in the list of tagged users even though the Tweet is successfully created.",
494
+ optional: true
495
+ },
496
+ placeId: {
497
+ type: "string",
498
+ label: "Place ID",
499
+ description: "Place ID being attached to the Tweet for geo location.",
500
+ optional: true
501
+ }
502
+ },
503
+ async run({ $ }) {
504
+ const {
505
+ text,
506
+ inReplyToTweetId,
507
+ excludeReplyUserIds,
508
+ mediaIds,
509
+ placeId,
510
+ taggedUserIds
511
+ } = this;
512
+ const params = {
513
+ $,
514
+ data: {
515
+ text,
516
+ ...(inReplyToTweetId || excludeReplyUserIds) && {
517
+ reply: {
518
+ exclude_reply_user_ids: excludeReplyUserIds,
519
+ in_reply_to_tweet_id: inReplyToTweetId
520
+ }
521
+ },
522
+ ...(mediaIds || taggedUserIds) && {
523
+ media: {
524
+ media_ids: mediaIds,
525
+ tagged_user_ids: taggedUserIds
526
+ }
527
+ },
528
+ ...placeId && {
529
+ geo: {
530
+ place_id: placeId
531
+ }
532
+ }
533
+ },
534
+ fallbackError: ACTION_ERROR_MESSAGE
535
+ };
536
+ const response = await this.app.createTweet(params);
537
+ $.export(
538
+ "$summary",
539
+ `Successfully posted tweet (ID ${response.data?.id})`
540
+ );
541
+ return response;
542
+ }
80
543
  });
544
+ export {
545
+ create_tweet_default as default
546
+ };