@pipedream/twitter 0.3.2 → 0.3.5

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 (55) hide show
  1. package/actions/add-user-to-list/add-user-to-list.mjs +62 -0
  2. package/actions/advanced-search/advanced-search.mjs +113 -0
  3. package/actions/common.mjs +29 -0
  4. package/actions/create-tweet/create-tweet.mjs +146 -0
  5. package/actions/delete-tweet/delete-tweet.mjs +42 -0
  6. package/actions/follow-user/follow-user.mjs +48 -0
  7. package/actions/get-tweet/get-tweet.mjs +42 -0
  8. package/actions/get-user/get-user.mjs +50 -0
  9. package/actions/like-tweet/like-tweet.mjs +42 -0
  10. package/actions/list-favorites/list-favorites.mjs +63 -0
  11. package/actions/list-followers/list-followers.mjs +67 -0
  12. package/actions/list-lists/list-lists.mjs +69 -0
  13. package/actions/list-mentions/list-mentions.mjs +55 -0
  14. package/actions/list-pending-followers/list-pending-followers.mjs +32 -0
  15. package/actions/list-retweets/list-retweets.mjs +54 -0
  16. package/actions/list-user-tweets/list-user-tweets.mjs +80 -0
  17. package/actions/retweet/retweet.mjs +27 -0
  18. package/actions/simple-search/simple-search.mjs +62 -0
  19. package/actions/simple-search-in-list/simple-search-in-list.mjs +48 -0
  20. package/actions/unfollow-user/unfollow-user.mjs +48 -0
  21. package/actions/unlike-tweet/unlike-tweet.mjs +40 -0
  22. package/package.json +21 -21
  23. package/readme.md +0 -4
  24. package/sources/common/followed.mjs +37 -0
  25. package/sources/common/followers.mjs +158 -0
  26. package/sources/common/tweets.mjs +154 -0
  27. package/sources/{language-codes.js → language-codes.mjs} +6 -2
  28. package/sources/my-liked-tweets/my-liked-tweets.mjs +29 -0
  29. package/sources/my-tweets/my-tweets.mjs +48 -0
  30. package/sources/new-follower-of-me/new-follower-of-me.mjs +69 -0
  31. package/sources/new-follower-of-user/new-follower-of-user.mjs +25 -0
  32. package/sources/new-list-followed/new-list-followed.mjs +24 -0
  33. package/sources/new-trends-by-geo/new-trends-by-geo.mjs +39 -0
  34. package/sources/new-tweet-in-list/new-tweet-in-list.mjs +49 -0
  35. package/sources/new-unfollower-of-me/{new-unfollower-of-me.js → new-unfollower-of-me.mjs} +5 -4
  36. package/sources/new-unfollower-of-user/new-unfollower-of-user.mjs +25 -0
  37. package/sources/new-user-followed/new-user-followed.mjs +25 -0
  38. package/sources/search-mentions/search-mentions.mjs +143 -0
  39. package/sources/tweets-liked-by-user/tweets-liked-by-user.mjs +37 -0
  40. package/sources/user-tweets/user-tweets.mjs +49 -0
  41. package/sources/watch-retweets-of-me/watch-retweets-of-me.mjs +36 -0
  42. package/sources/watch-retweets-of-my-tweet/watch-retweets-of-my-tweet.mjs +44 -0
  43. package/sources/watch-retweets-of-user-tweet/watch-retweets-of-user-tweet.mjs +34 -0
  44. package/twitter.app.mjs +1149 -0
  45. package/sources/common-followers.js +0 -99
  46. package/sources/my-liked-tweets/my-liked-tweets.js +0 -26
  47. package/sources/my-tweets/my-tweets.js +0 -83
  48. package/sources/new-follower-of-me/new-follower-of-me.js +0 -68
  49. package/sources/new-follower-of-user/new-follower-of-user.js +0 -69
  50. package/sources/new-trends-by-geo/new-trends-by-geo.js +0 -29
  51. package/sources/new-unfollower-of-user/new-unfollower-of-user.js +0 -22
  52. package/sources/search-mentions/search-mentions.js +0 -76
  53. package/sources/tweets-liked-by-user/tweets-liked-by-user.js +0 -27
  54. package/sources/user-tweets/user-tweets.js +0 -66
  55. package/twitter.app.js +0 -461
@@ -0,0 +1,69 @@
1
+ import common from "../common.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "twitter-list-lists",
6
+ name: "List Lists",
7
+ description: "Return all lists the authenticated or specified user subscribes to including their own. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-list)",
8
+ version: "0.0.1",
9
+ type: "action",
10
+ props: {
11
+ ...common.props,
12
+ userId: {
13
+ propDefinition: [
14
+ common.props.twitter,
15
+ "userId",
16
+ ],
17
+ optional: true,
18
+ },
19
+ screenName: {
20
+ propDefinition: [
21
+ common.props.twitter,
22
+ "screenName",
23
+ ],
24
+ optional: true,
25
+ },
26
+ reverse: {
27
+ type: "boolean",
28
+ label: "Reverse",
29
+ description: "Set this to `true` if you would like owned lists to be returned first.",
30
+ optional: true,
31
+ default: false,
32
+ },
33
+ maxRequests: {
34
+ propDefinition: [
35
+ common.props.twitter,
36
+ "maxRequests",
37
+ ],
38
+ },
39
+ },
40
+ async run({ $ }) {
41
+ const {
42
+ userId,
43
+ screenName,
44
+ reverse,
45
+ maxRequests,
46
+ } = this;
47
+
48
+ if (!userId && !screenName) {
49
+ throw new Error("This action requires either User ID or Screen Name. Please enter one or the other above.");
50
+ }
51
+
52
+ const params = {
53
+ $,
54
+ maxRequests,
55
+ params: {
56
+ user_id: userId,
57
+ screen_name: screenName,
58
+ reverse,
59
+ },
60
+ };
61
+ const lists = await this.paginate(this.twitter.getLists.bind(this), params);
62
+ const results = [];
63
+ for await (const list of lists) {
64
+ results.push(list);
65
+ }
66
+ $.export("$summary", "Successfully retrieved lists");
67
+ return results;
68
+ },
69
+ };
@@ -0,0 +1,55 @@
1
+ import common from "../common.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "twitter-list-mentions",
6
+ name: "List Mentions",
7
+ description: "Return the 20 most recent mentions for the authenticated user. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-mentions_timeline)",
8
+ version: "0.0.1",
9
+ type: "action",
10
+ props: {
11
+ ...common.props,
12
+ count: {
13
+ propDefinition: [
14
+ common.props.twitter,
15
+ "count",
16
+ ],
17
+ description: "Specifies the number of records to retrieve. Must be less than or equal to `200`; defaults to `20`.",
18
+ optional: true,
19
+ default: 20,
20
+ },
21
+ maxRequests: {
22
+ propDefinition: [
23
+ common.props.twitter,
24
+ "maxRequests",
25
+ ],
26
+ },
27
+ includeEntities: {
28
+ propDefinition: [
29
+ common.props.twitter,
30
+ "includeEntities",
31
+ ],
32
+ },
33
+ },
34
+ async run({ $ }) {
35
+ const {
36
+ count,
37
+ maxRequests,
38
+ includeEntities,
39
+ } = this;
40
+
41
+ const params = {
42
+ $,
43
+ count,
44
+ maxRequests,
45
+ includeEntities,
46
+ };
47
+ const tweets = await this.paginate(this.twitter.getMentionsTimeline.bind(this), params);
48
+ const results = [];
49
+ for await (const tweet of tweets) {
50
+ results.push(tweet);
51
+ }
52
+ $.export("$summary", "Sucessfully retrieved mentions");
53
+ return results;
54
+ },
55
+ };
@@ -0,0 +1,32 @@
1
+ import common from "../common.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "twitter-list-pending-followers",
6
+ name: "List Pending Followers",
7
+ description: "Return a collection of numeric IDs for every user who has a pending request to follow the authenticated user. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-friendships-incoming)",
8
+ version: "0.0.1",
9
+ type: "action",
10
+ props: {
11
+ ...common.props,
12
+ maxRequests: {
13
+ propDefinition: [
14
+ common.props.twitter,
15
+ "maxRequests",
16
+ ],
17
+ },
18
+ },
19
+ async run({ $ }) {
20
+ const { maxRequests } = this;
21
+ const followers = await this.paginate(this.twitter.getPendingFollowers.bind(this), {
22
+ $,
23
+ maxRequests,
24
+ }, "ids");
25
+ const results = [];
26
+ for await (const follower of followers) {
27
+ results.push(follower);
28
+ }
29
+ $.export("$summary", "Successfully retrieved pending followers");
30
+ return results;
31
+ },
32
+ };
@@ -0,0 +1,54 @@
1
+ import common from "../common.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "twitter-list-retweets",
6
+ name: "List Retweets",
7
+ description: "Return a collection of recent retweets of a tweet by ID parameter. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-statuses-retweets-id)",
8
+ version: "0.0.1",
9
+ type: "action",
10
+ props: {
11
+ ...common.props,
12
+ id: {
13
+ propDefinition: [
14
+ common.props.twitter,
15
+ "tweetID",
16
+ ],
17
+ },
18
+ count: {
19
+ propDefinition: [
20
+ common.props.twitter,
21
+ "count",
22
+ ],
23
+ optional: true,
24
+ default: 20,
25
+ },
26
+ maxRequests: {
27
+ propDefinition: [
28
+ common.props.twitter,
29
+ "maxRequests",
30
+ ],
31
+ },
32
+ },
33
+ async run({ $ }) {
34
+ const {
35
+ id,
36
+ count,
37
+ maxRequests,
38
+ } = this;
39
+
40
+ const params = {
41
+ $,
42
+ id,
43
+ count,
44
+ maxRequests,
45
+ };
46
+ const tweets = await this.paginate(this.twitter.getRetweets.bind(this), params);
47
+ const results = [];
48
+ for await (const tweet of tweets) {
49
+ results.push(tweet);
50
+ }
51
+ $.export("$summary", "Successfully retrieved retweets");
52
+ return results;
53
+ },
54
+ };
@@ -0,0 +1,80 @@
1
+ import common from "../common.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "twitter-list-user-tweets",
6
+ name: "List User Tweets",
7
+ description: "Return a collection of the most recent tweets posted by a user. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-user_timeline)",
8
+ version: "0.0.1",
9
+ type: "action",
10
+ props: {
11
+ ...common.props,
12
+ screenName: {
13
+ propDefinition: [
14
+ common.props.twitter,
15
+ "screenName",
16
+ ],
17
+ optional: true,
18
+ },
19
+ count: {
20
+ propDefinition: [
21
+ common.props.twitter,
22
+ "count",
23
+ ],
24
+ optional: true,
25
+ default: 20,
26
+ },
27
+ maxRequests: {
28
+ propDefinition: [
29
+ common.props.twitter,
30
+ "maxRequests",
31
+ ],
32
+ },
33
+ includeRetweets: {
34
+ propDefinition: [
35
+ common.props.twitter,
36
+ "includeRetweets",
37
+ ],
38
+ },
39
+ includeReplies: {
40
+ propDefinition: [
41
+ common.props.twitter,
42
+ "includeReplies",
43
+ ],
44
+ },
45
+ },
46
+ methods: {
47
+ ...common.methods,
48
+ shouldExcludeReplies(includeReplies) {
49
+ return includeReplies === "exclude";
50
+ },
51
+ shouldIncludeRetweets(includeRetweets) {
52
+ return includeRetweets !== "exclude";
53
+ },
54
+ },
55
+ async run({ $ }) {
56
+ const {
57
+ screenName,
58
+ count,
59
+ maxRequests,
60
+ includeRetweets,
61
+ includeReplies,
62
+ } = this;
63
+
64
+ const params = {
65
+ $,
66
+ screenName,
67
+ count,
68
+ maxRequests,
69
+ exclude_replies: this.shouldExcludeReplies(includeReplies),
70
+ include_rts: this.shouldIncludeRetweets(includeRetweets),
71
+ };
72
+ const tweets = await this.paginate(this.twitter.getUserTimeline.bind(this), params);
73
+ const results = [];
74
+ for await (const tweet of tweets) {
75
+ results.push(tweet);
76
+ }
77
+ $.export("$summary", "Successfully retrieved user tweets");
78
+ return results;
79
+ },
80
+ };
@@ -0,0 +1,27 @@
1
+ import twitter from "../../twitter.app.mjs";
2
+
3
+ export default {
4
+ key: "twitter-retweet",
5
+ name: "Retweet a tweet",
6
+ description: "Retweets a specific tweet by ID. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-retweet-id)",
7
+ version: "0.0.2",
8
+ type: "action",
9
+ props: {
10
+ twitter,
11
+ tweetID: {
12
+ propDefinition: [
13
+ twitter,
14
+ "tweetID",
15
+ ],
16
+ description: "The numerical ID of the tweet you'd like to retweet",
17
+ },
18
+ },
19
+ async run({ $ }) {
20
+ const res = await this.twitter.retweet({
21
+ $,
22
+ tweetID: this.tweetID,
23
+ });
24
+ $.export("$summary", "Tweet successfully retweeted");
25
+ return res;
26
+ },
27
+ };
@@ -0,0 +1,62 @@
1
+ import twitter from "../../twitter.app.mjs";
2
+
3
+ export default {
4
+ key: "twitter-simple-search",
5
+ name: "Simple Search",
6
+ description: "Return Tweets that matches your search criteria. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets)",
7
+ version: "0.0.7",
8
+ type: "action",
9
+ props: {
10
+ twitter,
11
+ q: {
12
+ propDefinition: [
13
+ twitter,
14
+ "q",
15
+ ],
16
+ },
17
+ resultType: {
18
+ propDefinition: [
19
+ twitter,
20
+ "resultType",
21
+ ],
22
+ },
23
+ includeRetweets: {
24
+ propDefinition: [
25
+ twitter,
26
+ "includeRetweets",
27
+ ],
28
+ },
29
+ includeReplies: {
30
+ propDefinition: [
31
+ twitter,
32
+ "includeReplies",
33
+ ],
34
+ },
35
+ },
36
+ async run({ $ }) {
37
+ const {
38
+ resultType,
39
+ enrichTweets,
40
+ includeReplies,
41
+ includeRetweets,
42
+ maxRequests,
43
+ count,
44
+ } = this;
45
+ let q = this.q;
46
+
47
+ // run paginated search
48
+ const res = await this.twitter.paginatedSearch({
49
+ $,
50
+ q,
51
+ resultType,
52
+ enrichTweets,
53
+ includeReplies,
54
+ includeRetweets,
55
+ maxRequests,
56
+ count,
57
+ limitFirstPage: false,
58
+ });
59
+ $.export("$summary", "Search completed successfully");
60
+ return res;
61
+ },
62
+ };
@@ -0,0 +1,48 @@
1
+ import twitter from "../../twitter.app.mjs";
2
+
3
+ export default {
4
+ key: "twitter-simple-search-in-list",
5
+ name: "Simple Search in List",
6
+ description: "Return Tweets that match your search criteria in a specific list. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/get-lists-statuses)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ twitter,
11
+ listId: {
12
+ propDefinition: [
13
+ twitter,
14
+ "list",
15
+ ],
16
+ },
17
+ query: {
18
+ propDefinition: [
19
+ twitter,
20
+ "q",
21
+ ],
22
+ },
23
+ includeRetweets: {
24
+ propDefinition: [
25
+ twitter,
26
+ "includeRetweets",
27
+ ],
28
+ },
29
+ includeEntities: {
30
+ type: "boolean",
31
+ label: "Entities",
32
+ description: "Include the 'entities' node, which offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags",
33
+ default: false,
34
+ },
35
+ },
36
+ async run({ $ }) {
37
+ let tweets = await this.twitter.getPaginateListTweets({
38
+ listId: this.listId,
39
+ includeEntities: this.includeEntities,
40
+ includeRetweets: this.includeRetweets !== "exclude",
41
+ });
42
+ tweets = tweets.filter((tweet) => tweet?.full_text?.includes(this.query));
43
+ $.export("$summary", `${tweets.length} search ${tweets.length === 1
44
+ ? "result has"
45
+ : "results have"} been found.`);
46
+ return tweets;
47
+ },
48
+ };
@@ -0,0 +1,48 @@
1
+ import twitter from "../../twitter.app.mjs";
2
+ import { ConfigurationError } from "@pipedream/platform";
3
+
4
+ export default {
5
+ key: "twitter-unfollow-user",
6
+ name: "Unfollow User",
7
+ description: "Unfollow the user specified by ID or screen name parameter. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/post-friendships-destroy)",
8
+ version: "0.0.1",
9
+ type: "action",
10
+ props: {
11
+ twitter,
12
+ userId: {
13
+ propDefinition: [
14
+ twitter,
15
+ "userId",
16
+ ],
17
+ optional: true,
18
+ },
19
+ screenName: {
20
+ propDefinition: [
21
+ twitter,
22
+ "screenName",
23
+ ],
24
+ optional: true,
25
+ },
26
+ },
27
+ async run({ $ }) {
28
+ const {
29
+ userId,
30
+ screenName,
31
+ } = this;
32
+
33
+ if (!userId && !screenName) {
34
+ throw new ConfigurationError("This action requires either User ID or Screen Name. Please enter one or the other above.");
35
+ }
36
+
37
+ const params = {
38
+ user_id: userId,
39
+ screen_name: screenName,
40
+ };
41
+ const response = await this.twitter.unfollowUser({
42
+ params,
43
+ $,
44
+ });
45
+ $.export("$summary", "Successfully unfollowed user");
46
+ return response;
47
+ },
48
+ };
@@ -0,0 +1,40 @@
1
+ import twitter from "../../twitter.app.mjs";
2
+
3
+ export default {
4
+ key: "twitter-unlike-tweet",
5
+ name: "Unike Tweet",
6
+ description: "Unike the tweet specified specified in the ID parameter. [See the docs here](https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-destroy)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ twitter,
11
+ id: {
12
+ propDefinition: [
13
+ twitter,
14
+ "tweetID",
15
+ ],
16
+ },
17
+ includeEntities: {
18
+ propDefinition: [
19
+ twitter,
20
+ "includeEntities",
21
+ ],
22
+ },
23
+ },
24
+ async run({ $ }) {
25
+ const {
26
+ id,
27
+ includeEntities,
28
+ } = this;
29
+
30
+ const params = {
31
+ $,
32
+ id,
33
+ includeEntities,
34
+ };
35
+
36
+ const res = this.twitter.unlikeTweet(params);
37
+ $.export("$summary", "Successfully unliked tweet");
38
+ return res;
39
+ },
40
+ };
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
- "name": "@pipedream/twitter",
3
- "version": "0.3.2",
4
- "description": "Pipedream Twitter Components",
5
- "main": "twitter.app.js",
6
- "keywords": [
7
- "pipedream",
8
- "twitter"
9
- ],
10
- "homepage": "https://pipedream.com/apps/twitter",
11
- "author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
12
- "license": "MIT",
13
- "dependencies": {
14
- "axios": "^0.21.1",
15
- "moment": "^2.29.1",
16
- "querystring": "^0.2.0"
17
- },
18
- "gitHead": "bf0e1cb3ad6da248c6125f9b512c59bfe35bf1fa",
19
- "publishConfig": {
20
- "access": "public"
21
- }
22
- }
2
+ "name": "@pipedream/twitter",
3
+ "version": "0.3.5",
4
+ "description": "Pipedream Twitter Components",
5
+ "main": "twitter.app.mjs",
6
+ "keywords": [
7
+ "pipedream",
8
+ "twitter"
9
+ ],
10
+ "homepage": "https://pipedream.com/apps/twitter",
11
+ "author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
12
+ "license": "MIT",
13
+ "dependencies": {
14
+ "axios": "^0.21.1",
15
+ "moment": "^2.29.1",
16
+ "querystring": "^0.2.0"
17
+ },
18
+ "gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",
19
+ "publishConfig": {
20
+ "access": "public"
21
+ }
22
+ }
package/readme.md CHANGED
@@ -64,10 +64,6 @@ Pipedream is currently free, subject to the [limits noted below](https://docs.pi
64
64
 
65
65
  If you exceed any of these limits, please [reach out](https://docs.pipedream.com/support/).
66
66
 
67
- ## Getting Support
68
-
69
- You can get help [on our public Slack](https://pipedream.com/community) or [reach out to our team directly](https://docs.pipedream.com/support/) with any questions or feedback. We'd love to hear from you!
70
-
71
67
  ## Found a Bug? Have a Feature to suggest?
72
68
 
73
69
  Before adding an issue, please search the [existing issues](https://github.com/PipedreamHQ/pipedream/issues) or [reach out to our team](https://docs.pipedream.com/support/) to see if a similar request already exists.
@@ -0,0 +1,37 @@
1
+ import twitter from "../../twitter.app.mjs";
2
+
3
+ export default {
4
+ props: {
5
+ twitter,
6
+ db: "$.service.db",
7
+ timer: {
8
+ label: "Polling interval",
9
+ description: "Pipedream will poll the Twitter API on this schedule",
10
+ type: "$.interface.timer",
11
+ default: {
12
+ intervalSeconds: 60 * 15,
13
+ },
14
+ },
15
+ },
16
+ methods: {
17
+ _getPreviousIds() {
18
+ return this.db.get("previousIds") || [];
19
+ },
20
+ _setPreviousIds(previousIds) {
21
+ this.db.set("previousIds", previousIds);
22
+ },
23
+ },
24
+ async run() {
25
+ const previousIds = this._getPreviousIds();
26
+ const followedItems = await this.getFollowed();
27
+ for (const item of followedItems.reverse()) {
28
+ if (previousIds.includes(item.id)) {
29
+ continue;
30
+ }
31
+ previousIds.push(item.id);
32
+ const meta = this.generateMeta(item);
33
+ this.$emit(item, meta);
34
+ }
35
+ this._setPreviousIds(previousIds);
36
+ },
37
+ };