@pipedream/twitter 0.3.10 → 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 -13
  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 -114
  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,51 @@
1
+ import app from "../../app/twitter.app.mjs";
2
+ import { defineSource } from "@pipedream/types";
3
+ import common from "../common/base.mjs";
4
+ import { getTweetSummary as getItemSummary } from "../common/getItemSummary.mjs";
5
+ import { tweetFieldProps } from "../../common/propGroups.mjs";
6
+ import { getTweetFields } from "../../common/methods.mjs";
7
+ import { DOCS_LINK, MAX_RESULTS_PER_PAGE, } from "../../actions/simple-search/simple-search.mjs";
8
+ export default defineSource({
9
+ ...common,
10
+ key: "twitter-new-tweet-posted-matching-query",
11
+ name: "New Tweet Posted Matching Query",
12
+ description: `Emit new event when a new tweet matching the specified query is posted [See docs here](${DOCS_LINK})`,
13
+ version: "0.0.1",
14
+ type: "source",
15
+ props: {
16
+ ...common.props,
17
+ query: {
18
+ propDefinition: [
19
+ app,
20
+ "query",
21
+ ],
22
+ },
23
+ ...tweetFieldProps,
24
+ },
25
+ methods: {
26
+ ...common.methods,
27
+ getTweetFields,
28
+ getEntityName() {
29
+ return "Tweet";
30
+ },
31
+ getItemSummary,
32
+ async getResources(customize) {
33
+ const params = {
34
+ $: this,
35
+ maxPerPage: MAX_RESULTS_PER_PAGE,
36
+ maxResults: MAX_RESULTS_PER_PAGE,
37
+ params: {
38
+ query: this.query,
39
+ },
40
+ };
41
+ if (customize) {
42
+ params.params = {
43
+ ...params.params,
44
+ ...this.getTweetFields(),
45
+ };
46
+ }
47
+ const { data } = await this.app.searchTweets(params);
48
+ return data;
49
+ },
50
+ },
51
+ });
@@ -0,0 +1,273 @@
1
+ import { getUserSummary as getItemSummary } from "../common/getItemSummary.js";
2
+ import { User } from "../../common/types/responseSchemas.js";
3
+ import { GetUserFollowersParams } from "../../common/types/requestParams.js";
4
+ declare const _default: import("@pipedream/types").Source<{
5
+ getItemSummary: typeof getItemSummary;
6
+ getEntityName(): "Unfollower";
7
+ getSavedUsers(): User[];
8
+ setSavedUsers(data: User[]): void;
9
+ getResources(): Promise<User[]>;
10
+ getAndProcessData(emit?: boolean): Promise<void>;
11
+ getCachedUserId: () => Promise<string>;
12
+ getUserId: typeof import("../../common/methods.js").getUserId;
13
+ getSavedIds(): string[];
14
+ setSavedIds(data: string[]): void;
15
+ emitEvent(data: import("../../common/types/responseSchemas.js").TwitterEntity): void;
16
+ }, {
17
+ userNameOrId: {
18
+ propDefinition: (string | import("@pipedream/types").App<{
19
+ _getAuthHeader(config: import("../../common/types/requestParams.js").HttpRequestParams): Promise<import("oauth-1.0a").Header>;
20
+ _getBaseUrl(): "https://api.twitter.com/2";
21
+ _httpRequest({ $, ...args }: import("../../common/types/requestParams.js").HttpRequestParams): Promise<import("../../common/types/responseSchemas").ResponseObject<import("../../common/types/responseSchemas").TwitterEntity>>;
22
+ _paginatedRequest({ maxResults, maxPerPage, params, ...args }: import("../../common/types/requestParams.js").PaginatedRequestParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").TwitterEntity>>;
23
+ addUserToList({ listId, ...args }: import("../../common/types/requestParams.js").AddUserToListParams): Promise<object>;
24
+ createTweet(args: import("../../common/types/requestParams.js").CreateTweetParams): Promise<object>;
25
+ deleteTweet({ tweetId, ...args }: import("../../common/types/requestParams.js").DeleteTweetParams): Promise<object>;
26
+ followUser(args: import("../../common/types/requestParams.js").FollowUserParams): Promise<object>;
27
+ getListTweets({ listId, ...args }: import("../../common/types/requestParams.js").GetListTweetsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
28
+ getTweet({ tweetId, ...args }: import("../../common/types/requestParams.js").GetTweetParams): Promise<import("../../common/types/responseSchemas").ResponseObject<import("../../common/types/responseSchemas").Tweet>>;
29
+ getAuthenticatedUserId(): Promise<string>;
30
+ getUserLikedTweets({ userId, ...args }: import("../../common/types/requestParams.js").GetUserLikedTweetParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
31
+ getUserOwnedLists({ userId, ...args }: import("../../common/types/requestParams.js").GetUserOwnedListsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").List>>;
32
+ getUserFollowedLists({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowedListsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").List>>;
33
+ getUserMentions({ userId, ...args }: import("../../common/types/requestParams.js").GetUserMentionsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
34
+ getUserTweets({ userId, ...args }: import("../../common/types/requestParams.js").GetUserTweetsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
35
+ getUserByUsername(username: string): Promise<import("../../common/types/responseSchemas").ResponseObject<User>>;
36
+ getUser({ userId, ...args }: import("../../common/types/requestParams.js").GetUserParams): Promise<import("../../common/types/responseSchemas").ResponseObject<User>>;
37
+ likeTweet(args: import("../../common/types/requestParams.js").LikeTweetParams): Promise<object>;
38
+ getUserFollowers({ userId, ...args }: GetUserFollowersParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<User>>;
39
+ getUserFollowing({ userId, ...args }: GetUserFollowersParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<User>>;
40
+ retweet(args: import("../../common/types/requestParams.js").LikeTweetParams): Promise<object>;
41
+ searchTweets(args: import("../../common/types/requestParams.js").SearchTweetsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
42
+ unfollowUser({ userId, ...args }: import("../../common/types/requestParams.js").UnfollowUserParams): Promise<object>;
43
+ unlikeTweet({ tweetId, ...args }: import("../../common/types/requestParams.js").UnlikeTweetParams): Promise<object>;
44
+ }, {
45
+ maxResults: {
46
+ type: string;
47
+ label: string;
48
+ description: string;
49
+ optional: boolean;
50
+ };
51
+ listId: {
52
+ type: string;
53
+ label: string;
54
+ description: string;
55
+ options(): Promise<{
56
+ label: string;
57
+ value: string;
58
+ }[]>;
59
+ };
60
+ userNameOrId: {
61
+ type: string;
62
+ label: string;
63
+ description: string;
64
+ optional: boolean;
65
+ default: string;
66
+ };
67
+ tweetId: {
68
+ type: string;
69
+ label: string;
70
+ description: string;
71
+ };
72
+ query: {
73
+ type: string;
74
+ label: string;
75
+ description: string;
76
+ };
77
+ listExpansions: {
78
+ type: string;
79
+ label: string;
80
+ optional: boolean;
81
+ description: string;
82
+ options: string[];
83
+ };
84
+ tweetExpansions: {
85
+ type: string;
86
+ label: string;
87
+ optional: boolean;
88
+ description: string;
89
+ options: string[];
90
+ };
91
+ userExpansions: {
92
+ type: string;
93
+ label: string;
94
+ optional: boolean;
95
+ description: string;
96
+ options: string[];
97
+ };
98
+ listFields: {
99
+ type: string;
100
+ label: string;
101
+ description: string;
102
+ optional: boolean;
103
+ options: string[];
104
+ };
105
+ mediaFields: {
106
+ type: string;
107
+ label: string;
108
+ description: string;
109
+ optional: boolean;
110
+ options: string[];
111
+ };
112
+ placeFields: {
113
+ type: string;
114
+ label: string;
115
+ description: string;
116
+ optional: boolean;
117
+ options: string[];
118
+ };
119
+ pollFields: {
120
+ type: string;
121
+ label: string;
122
+ description: string;
123
+ optional: boolean;
124
+ options: string[];
125
+ };
126
+ tweetFields: {
127
+ type: string;
128
+ label: string;
129
+ description: string;
130
+ optional: boolean;
131
+ options: string[];
132
+ };
133
+ userFields: {
134
+ type: string;
135
+ label: string;
136
+ description: string;
137
+ optional: boolean;
138
+ options: string[];
139
+ };
140
+ }>)[];
141
+ };
142
+ app: import("@pipedream/types").App<{
143
+ _getAuthHeader(config: import("../../common/types/requestParams.js").HttpRequestParams): Promise<import("oauth-1.0a").Header>;
144
+ _getBaseUrl(): "https://api.twitter.com/2";
145
+ _httpRequest({ $, ...args }: import("../../common/types/requestParams.js").HttpRequestParams): Promise<import("../../common/types/responseSchemas").ResponseObject<import("../../common/types/responseSchemas").TwitterEntity>>;
146
+ _paginatedRequest({ maxResults, maxPerPage, params, ...args }: import("../../common/types/requestParams.js").PaginatedRequestParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").TwitterEntity>>;
147
+ addUserToList({ listId, ...args }: import("../../common/types/requestParams.js").AddUserToListParams): Promise<object>;
148
+ createTweet(args: import("../../common/types/requestParams.js").CreateTweetParams): Promise<object>;
149
+ deleteTweet({ tweetId, ...args }: import("../../common/types/requestParams.js").DeleteTweetParams): Promise<object>;
150
+ followUser(args: import("../../common/types/requestParams.js").FollowUserParams): Promise<object>;
151
+ getListTweets({ listId, ...args }: import("../../common/types/requestParams.js").GetListTweetsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
152
+ getTweet({ tweetId, ...args }: import("../../common/types/requestParams.js").GetTweetParams): Promise<import("../../common/types/responseSchemas").ResponseObject<import("../../common/types/responseSchemas").Tweet>>;
153
+ getAuthenticatedUserId(): Promise<string>;
154
+ getUserLikedTweets({ userId, ...args }: import("../../common/types/requestParams.js").GetUserLikedTweetParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
155
+ getUserOwnedLists({ userId, ...args }: import("../../common/types/requestParams.js").GetUserOwnedListsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").List>>;
156
+ getUserFollowedLists({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowedListsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").List>>;
157
+ getUserMentions({ userId, ...args }: import("../../common/types/requestParams.js").GetUserMentionsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
158
+ getUserTweets({ userId, ...args }: import("../../common/types/requestParams.js").GetUserTweetsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
159
+ getUserByUsername(username: string): Promise<import("../../common/types/responseSchemas").ResponseObject<User>>;
160
+ getUser({ userId, ...args }: import("../../common/types/requestParams.js").GetUserParams): Promise<import("../../common/types/responseSchemas").ResponseObject<User>>;
161
+ likeTweet(args: import("../../common/types/requestParams.js").LikeTweetParams): Promise<object>;
162
+ getUserFollowers({ userId, ...args }: GetUserFollowersParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<User>>;
163
+ getUserFollowing({ userId, ...args }: GetUserFollowersParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<User>>;
164
+ retweet(args: import("../../common/types/requestParams.js").LikeTweetParams): Promise<object>;
165
+ searchTweets(args: import("../../common/types/requestParams.js").SearchTweetsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
166
+ unfollowUser({ userId, ...args }: import("../../common/types/requestParams.js").UnfollowUserParams): Promise<object>;
167
+ unlikeTweet({ tweetId, ...args }: import("../../common/types/requestParams.js").UnlikeTweetParams): Promise<object>;
168
+ }, {
169
+ maxResults: {
170
+ type: string;
171
+ label: string;
172
+ description: string;
173
+ optional: boolean;
174
+ };
175
+ listId: {
176
+ type: string;
177
+ label: string;
178
+ description: string;
179
+ options(): Promise<{
180
+ label: string;
181
+ value: string;
182
+ }[]>;
183
+ };
184
+ userNameOrId: {
185
+ type: string;
186
+ label: string;
187
+ description: string;
188
+ optional: boolean;
189
+ default: string;
190
+ };
191
+ tweetId: {
192
+ type: string;
193
+ label: string;
194
+ description: string;
195
+ };
196
+ query: {
197
+ type: string;
198
+ label: string;
199
+ description: string;
200
+ };
201
+ listExpansions: {
202
+ type: string;
203
+ label: string;
204
+ optional: boolean;
205
+ description: string;
206
+ options: string[];
207
+ };
208
+ tweetExpansions: {
209
+ type: string;
210
+ label: string;
211
+ optional: boolean;
212
+ description: string;
213
+ options: string[];
214
+ };
215
+ userExpansions: {
216
+ type: string;
217
+ label: string;
218
+ optional: boolean;
219
+ description: string;
220
+ options: string[];
221
+ };
222
+ listFields: {
223
+ type: string;
224
+ label: string;
225
+ description: string;
226
+ optional: boolean;
227
+ options: string[];
228
+ };
229
+ mediaFields: {
230
+ type: string;
231
+ label: string;
232
+ description: string;
233
+ optional: boolean;
234
+ options: string[];
235
+ };
236
+ placeFields: {
237
+ type: string;
238
+ label: string;
239
+ description: string;
240
+ optional: boolean;
241
+ options: string[];
242
+ };
243
+ pollFields: {
244
+ type: string;
245
+ label: string;
246
+ description: string;
247
+ optional: boolean;
248
+ options: string[];
249
+ };
250
+ tweetFields: {
251
+ type: string;
252
+ label: string;
253
+ description: string;
254
+ optional: boolean;
255
+ options: string[];
256
+ };
257
+ userFields: {
258
+ type: string;
259
+ label: string;
260
+ description: string;
261
+ optional: boolean;
262
+ options: string[];
263
+ };
264
+ }>;
265
+ db: string;
266
+ timer: {
267
+ type: string;
268
+ default: {
269
+ intervalSeconds: number;
270
+ };
271
+ };
272
+ }>;
273
+ export default _default;
@@ -0,0 +1,75 @@
1
+ import app from "../../app/twitter.app.mjs";
2
+ import { defineSource } from "@pipedream/types";
3
+ import common from "../common/base.mjs";
4
+ import { getUserSummary as getItemSummary } from "../common/getItemSummary.mjs";
5
+ import { DOCS_LINK, MAX_RESULTS_PER_PAGE, } from "../../actions/list-followers/list-followers.mjs";
6
+ import cacheUserId from "../common/cacheUserId.mjs";
7
+ export default defineSource({
8
+ ...common,
9
+ key: "twitter-new-unfollower-of-user",
10
+ name: "New Unfollower of User",
11
+ description: `Emit new event when the specified User loses a Follower [See docs here](${DOCS_LINK})`,
12
+ version: "1.0.0",
13
+ type: "source",
14
+ props: {
15
+ ...common.props,
16
+ userNameOrId: {
17
+ propDefinition: [
18
+ app,
19
+ "userNameOrId",
20
+ ],
21
+ },
22
+ },
23
+ methods: {
24
+ ...common.methods,
25
+ ...cacheUserId,
26
+ getItemSummary,
27
+ getEntityName() {
28
+ return "Unfollower";
29
+ },
30
+ getSavedUsers() {
31
+ return this.db.get("savedUsers");
32
+ },
33
+ setSavedUsers(data) {
34
+ this.db.set("savedUsers", data);
35
+ },
36
+ async getResources() {
37
+ const userId = await this.getCachedUserId();
38
+ const params = {
39
+ $: this,
40
+ maxPerPage: MAX_RESULTS_PER_PAGE,
41
+ maxResults: MAX_RESULTS_PER_PAGE,
42
+ userId,
43
+ };
44
+ const { data } = await this.app.getUserFollowers(params);
45
+ return data;
46
+ },
47
+ async getAndProcessData(emit = false) {
48
+ const data = await this.getResources(emit);
49
+ if (data) {
50
+ let savedUsers = this.getSavedUsers();
51
+ if (savedUsers && emit) {
52
+ const currentFollowerIds = data.map(({ id }) => id);
53
+ if (data.length === MAX_RESULTS_PER_PAGE) {
54
+ const lastKnownFollower = Array.from(data)
55
+ .reverse() // could be .findLast in Node 18+
56
+ .find(({ id }) => currentFollowerIds.includes(id));
57
+ const lastKnownIndex = savedUsers.indexOf(lastKnownFollower);
58
+ savedUsers = savedUsers.slice(0, lastKnownIndex + 1);
59
+ }
60
+ savedUsers
61
+ .filter(({ id }) => !currentFollowerIds.includes(id))
62
+ .reverse()
63
+ .forEach((obj) => {
64
+ if (emit)
65
+ this.emitEvent(obj);
66
+ });
67
+ }
68
+ this.setSavedUsers(data.map(({ id, username, }) => ({
69
+ id,
70
+ username,
71
+ })));
72
+ }
73
+ },
74
+ },
75
+ });