@pipedream/twitter 0.3.11 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +20 -71
  2. package/dist/actions/add-user-to-list/add-user-to-list.d.ts +380 -0
  3. package/dist/actions/add-user-to-list/add-user-to-list.mjs +42 -0
  4. package/dist/actions/create-tweet/create-tweet.d.ts +163 -0
  5. package/dist/actions/create-tweet/create-tweet.mjs +78 -0
  6. package/dist/actions/delete-tweet/delete-tweet.d.ts +252 -0
  7. package/dist/actions/delete-tweet/delete-tweet.mjs +28 -0
  8. package/dist/actions/follow-user/follow-user.d.ts +255 -0
  9. package/dist/actions/follow-user/follow-user.mjs +37 -0
  10. package/dist/actions/get-tweet/get-tweet.d.ts +1006 -0
  11. package/dist/actions/get-tweet/get-tweet.mjs +35 -0
  12. package/dist/actions/get-user/get-user.d.ts +634 -0
  13. package/dist/actions/get-user/get-user.mjs +37 -0
  14. package/dist/actions/like-tweet/like-tweet.d.ts +252 -0
  15. package/dist/actions/like-tweet/like-tweet.mjs +30 -0
  16. package/dist/actions/list-favorites/list-favorites.d.ts +1138 -0
  17. package/dist/actions/list-favorites/list-favorites.mjs +52 -0
  18. package/dist/actions/list-followers/list-followers.d.ts +765 -0
  19. package/dist/actions/list-followers/list-followers.mjs +52 -0
  20. package/dist/actions/list-lists/list-lists.d.ts +762 -0
  21. package/dist/actions/list-lists/list-lists.mjs +52 -0
  22. package/dist/actions/list-mentions/list-mentions.d.ts +1136 -0
  23. package/dist/actions/list-mentions/list-mentions.mjs +52 -0
  24. package/dist/actions/list-user-tweets/list-user-tweets.d.ts +1138 -0
  25. package/dist/actions/list-user-tweets/list-user-tweets.mjs +52 -0
  26. package/dist/actions/retweet/retweet.d.ts +252 -0
  27. package/dist/actions/retweet/retweet.mjs +31 -0
  28. package/dist/actions/simple-search/simple-search.d.ts +1137 -0
  29. package/dist/actions/simple-search/simple-search.mjs +51 -0
  30. package/dist/actions/simple-search-in-list/simple-search-in-list.d.ts +1142 -0
  31. package/dist/actions/simple-search-in-list/simple-search-in-list.mjs +60 -0
  32. package/dist/actions/unfollow-user/unfollow-user.d.ts +255 -0
  33. package/dist/actions/unfollow-user/unfollow-user.mjs +33 -0
  34. package/dist/actions/unlike-tweet/unlike-tweet.d.ts +252 -0
  35. package/dist/actions/unlike-tweet/unlike-tweet.mjs +28 -0
  36. package/dist/app/twitter.app.d.ts +127 -0
  37. package/dist/app/twitter.app.mjs +341 -0
  38. package/dist/common/dataFields.d.ts +6 -0
  39. package/dist/common/dataFields.mjs +80 -0
  40. package/dist/common/expansions.d.ts +3 -0
  41. package/dist/common/expansions.mjs +17 -0
  42. package/dist/common/methods.d.ts +20 -0
  43. package/dist/common/methods.mjs +48 -0
  44. package/dist/common/propGroups.d.ts +1509 -0
  45. package/dist/common/propGroups.mjs +82 -0
  46. package/dist/common/types/fields.d.ts +18 -0
  47. package/dist/common/types/fields.mjs +1 -0
  48. package/dist/common/types/requestParams.d.ts +103 -0
  49. package/dist/common/types/requestParams.mjs +1 -0
  50. package/dist/common/types/responseSchemas.d.ts +42 -0
  51. package/dist/common/types/responseSchemas.mjs +1 -0
  52. package/dist/sources/common/base.d.ts +149 -0
  53. package/dist/sources/common/base.mjs +62 -0
  54. package/dist/sources/common/cacheUserId.d.ts +7 -0
  55. package/dist/sources/common/cacheUserId.mjs +18 -0
  56. package/dist/sources/common/getItemSummary.d.ts +4 -0
  57. package/dist/sources/common/getItemSummary.mjs +12 -0
  58. package/dist/sources/new-follower-of-user/new-follower-of-user.d.ts +650 -0
  59. package/dist/sources/new-follower-of-user/new-follower-of-user.mjs +49 -0
  60. package/dist/sources/new-list-followed/new-list-followed.d.ts +649 -0
  61. package/dist/sources/new-list-followed/new-list-followed.mjs +50 -0
  62. package/dist/sources/new-tweet-in-list/new-tweet-in-list.d.ts +1021 -0
  63. package/dist/sources/new-tweet-in-list/new-tweet-in-list.mjs +46 -0
  64. package/dist/sources/new-tweet-liked-by-user/new-tweet-liked-by-user.d.ts +1023 -0
  65. package/dist/sources/new-tweet-liked-by-user/new-tweet-liked-by-user.mjs +49 -0
  66. package/dist/sources/new-tweet-posted-by-user/new-tweet-posted-by-user.d.ts +1023 -0
  67. package/dist/sources/new-tweet-posted-by-user/new-tweet-posted-by-user.mjs +49 -0
  68. package/dist/sources/new-tweet-posted-matching-query/new-tweet-posted-matching-query.d.ts +1021 -0
  69. package/dist/sources/new-tweet-posted-matching-query/new-tweet-posted-matching-query.mjs +51 -0
  70. package/dist/sources/new-unfollower-of-user/new-unfollower-of-user.d.ts +273 -0
  71. package/dist/sources/new-unfollower-of-user/new-unfollower-of-user.mjs +75 -0
  72. package/dist/sources/new-user-followed/new-user-followed.d.ts +649 -0
  73. package/dist/sources/new-user-followed/new-user-followed.mjs +50 -0
  74. package/dist/tsconfig.tsbuildinfo +1 -0
  75. package/package.json +10 -14
  76. package/actions/add-user-to-list/add-user-to-list.mjs +0 -62
  77. package/actions/advanced-search/advanced-search.mjs +0 -113
  78. package/actions/common.mjs +0 -29
  79. package/actions/create-tweet/create-tweet.mjs +0 -146
  80. package/actions/delete-tweet/delete-tweet.mjs +0 -42
  81. package/actions/follow-user/follow-user.mjs +0 -48
  82. package/actions/get-tweet/get-tweet.mjs +0 -42
  83. package/actions/get-user/get-user.mjs +0 -50
  84. package/actions/like-tweet/like-tweet.mjs +0 -42
  85. package/actions/list-favorites/list-favorites.mjs +0 -63
  86. package/actions/list-followers/list-followers.mjs +0 -67
  87. package/actions/list-lists/list-lists.mjs +0 -69
  88. package/actions/list-mentions/list-mentions.mjs +0 -55
  89. package/actions/list-pending-followers/list-pending-followers.mjs +0 -32
  90. package/actions/list-retweets/list-retweets.mjs +0 -54
  91. package/actions/list-user-tweets/list-user-tweets.mjs +0 -80
  92. package/actions/retweet/retweet.mjs +0 -27
  93. package/actions/simple-search/simple-search.mjs +0 -62
  94. package/actions/simple-search-in-list/simple-search-in-list.mjs +0 -48
  95. package/actions/unfollow-user/unfollow-user.mjs +0 -48
  96. package/actions/unlike-tweet/unlike-tweet.mjs +0 -40
  97. package/actions/upload-media/upload-media.mjs +0 -122
  98. package/old.md +0 -169
  99. package/sources/common/followed.mjs +0 -38
  100. package/sources/common/followers.mjs +0 -159
  101. package/sources/common/tweets.mjs +0 -155
  102. package/sources/language-codes.mjs +0 -742
  103. package/sources/my-liked-tweets/my-liked-tweets.mjs +0 -30
  104. package/sources/my-tweets/my-tweets.mjs +0 -48
  105. package/sources/new-follower-of-me/new-follower-of-me.mjs +0 -69
  106. package/sources/new-follower-of-user/new-follower-of-user.mjs +0 -25
  107. package/sources/new-list-followed/new-list-followed.mjs +0 -24
  108. package/sources/new-trends-by-geo/new-trends-by-geo.mjs +0 -40
  109. package/sources/new-tweet-in-list/new-tweet-in-list.mjs +0 -49
  110. package/sources/new-unfollower-of-me/new-unfollower-of-me.mjs +0 -16
  111. package/sources/new-unfollower-of-user/new-unfollower-of-user.mjs +0 -25
  112. package/sources/new-user-followed/new-user-followed.mjs +0 -25
  113. package/sources/search-mentions/search-mentions.mjs +0 -144
  114. package/sources/tweets-liked-by-user/tweets-liked-by-user.mjs +0 -38
  115. package/sources/user-tweets/user-tweets.mjs +0 -49
  116. package/sources/watch-retweets-of-me/watch-retweets-of-me.mjs +0 -36
  117. package/sources/watch-retweets-of-my-tweet/watch-retweets-of-my-tweet.mjs +0 -44
  118. package/sources/watch-retweets-of-user-tweet/watch-retweets-of-user-tweet.mjs +0 -34
  119. package/twitter.app.mjs +0 -1161
@@ -0,0 +1,82 @@
1
+ import app from "../app/twitter.app.mjs";
2
+ export const listFieldProps = {
3
+ expansions: {
4
+ propDefinition: [
5
+ app,
6
+ "listExpansions",
7
+ ],
8
+ },
9
+ listFields: {
10
+ propDefinition: [
11
+ app,
12
+ "listFields",
13
+ ],
14
+ },
15
+ userFields: {
16
+ propDefinition: [
17
+ app,
18
+ "userFields",
19
+ ],
20
+ description: "Specific [user fields](https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/user) to be included in the returned user object. Only applicable if you've requested the `owner_id` expansion.",
21
+ },
22
+ };
23
+ export const tweetFieldProps = {
24
+ expansions: {
25
+ propDefinition: [
26
+ app,
27
+ "tweetExpansions",
28
+ ],
29
+ },
30
+ mediaFields: {
31
+ propDefinition: [
32
+ app,
33
+ "mediaFields",
34
+ ],
35
+ },
36
+ placeFields: {
37
+ propDefinition: [
38
+ app,
39
+ "placeFields",
40
+ ],
41
+ },
42
+ pollFields: {
43
+ propDefinition: [
44
+ app,
45
+ "pollFields",
46
+ ],
47
+ },
48
+ tweetFields: {
49
+ propDefinition: [
50
+ app,
51
+ "tweetFields",
52
+ ],
53
+ },
54
+ userFields: {
55
+ propDefinition: [
56
+ app,
57
+ "userFields",
58
+ ],
59
+ },
60
+ };
61
+ export const userFieldProps = {
62
+ expansions: {
63
+ propDefinition: [
64
+ app,
65
+ "userExpansions",
66
+ ],
67
+ },
68
+ tweetFields: {
69
+ propDefinition: [
70
+ app,
71
+ "tweetFields",
72
+ ],
73
+ description: "Specific [tweet fields](https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet) to be included in the returned pinned Tweet. Only applicable if the user has a pinned Tweet and you've requested the `referenced_tweets.id` expansion.",
74
+ },
75
+ userFields: {
76
+ propDefinition: [
77
+ app,
78
+ "userFields",
79
+ ],
80
+ description: "Specific [user fields](https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/user) to be included in the returned user object.",
81
+ },
82
+ };
@@ -0,0 +1,18 @@
1
+ export interface ListFields {
2
+ expansions?: string;
3
+ "list.fields"?: string;
4
+ "user.fields"?: string;
5
+ }
6
+ export interface UserFields {
7
+ expansions?: string;
8
+ "tweet.fields"?: string;
9
+ "user.fields"?: string;
10
+ }
11
+ export interface TweetFields {
12
+ expansions?: string;
13
+ "media.fields"?: string;
14
+ "place.fields"?: string;
15
+ "poll.fields"?: string;
16
+ "tweet.fields"?: string;
17
+ "user.fields"?: string;
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,103 @@
1
+ import { Pipedream } from "@pipedream/types";
2
+ import { ListFields, TweetFields, UserFields } from "./fields.js";
3
+ interface PdAxiosRequest {
4
+ $: Pipedream;
5
+ }
6
+ interface PaginationParams {
7
+ maxPerPage?: number;
8
+ maxResults?: number;
9
+ }
10
+ interface PaginatedRequest extends PdAxiosRequest, PaginationParams {
11
+ }
12
+ export interface HttpRequestParams extends PdAxiosRequest {
13
+ url: string;
14
+ method: string;
15
+ data?: object | string;
16
+ params?: object;
17
+ }
18
+ export interface PaginatedRequestParams extends HttpRequestParams, PaginationParams {
19
+ }
20
+ export interface AddUserToListParams extends PdAxiosRequest {
21
+ listId: string;
22
+ data: {
23
+ user_id: string;
24
+ };
25
+ }
26
+ export interface CreateTweetParams extends PdAxiosRequest {
27
+ data: {
28
+ text: string;
29
+ geo?: {
30
+ place_id: string;
31
+ };
32
+ media?: {
33
+ media_ids: string[];
34
+ tagged_user_ids: string[];
35
+ };
36
+ reply?: {
37
+ exclude_reply_user_ids: string[];
38
+ in_reply_to_tweet_id: string;
39
+ };
40
+ };
41
+ }
42
+ interface ListId {
43
+ listId: string;
44
+ }
45
+ interface UserId {
46
+ userId: string;
47
+ }
48
+ interface TweetId {
49
+ tweetId: string;
50
+ }
51
+ export interface DeleteTweetParams extends PdAxiosRequest, TweetId {
52
+ }
53
+ export interface FollowUserParams extends PdAxiosRequest {
54
+ data: {
55
+ target_user_id: string;
56
+ };
57
+ }
58
+ export interface GetUserLikedTweetParams extends PaginatedRequest, UserId {
59
+ params?: TweetFields;
60
+ }
61
+ export interface GetListTweetsParams extends PaginatedRequest, ListId {
62
+ params?: TweetFields;
63
+ }
64
+ export interface GetUserOwnedListsParams extends PaginatedRequest, UserId {
65
+ params?: ListFields;
66
+ }
67
+ export interface GetUserMentionsParams extends PaginatedRequest, UserId {
68
+ params?: TweetFields;
69
+ }
70
+ export interface GetUserTweetsParams extends PaginatedRequest, UserId {
71
+ params?: TweetFields & {
72
+ since_id?: string;
73
+ };
74
+ }
75
+ export interface GetUserFollowedListsParams extends PaginatedRequest, UserId {
76
+ params?: ListFields;
77
+ }
78
+ export interface GetUserParams extends PdAxiosRequest, UserId {
79
+ params?: UserFields;
80
+ }
81
+ export interface GetTweetParams extends PdAxiosRequest, TweetId {
82
+ params?: TweetFields;
83
+ }
84
+ export interface GetUserFollowersParams extends PaginatedRequest, UserId {
85
+ params?: UserFields;
86
+ }
87
+ export type GetUserFollowingParams = GetUserFollowersParams;
88
+ export interface LikeTweetParams extends PdAxiosRequest {
89
+ data: {
90
+ tweet_id: string;
91
+ };
92
+ }
93
+ export type RetweetParams = LikeTweetParams;
94
+ export interface SearchTweetsParams extends PaginatedRequest {
95
+ params: {
96
+ query: string;
97
+ };
98
+ }
99
+ export interface UnfollowUserParams extends PdAxiosRequest, UserId {
100
+ }
101
+ export interface UnlikeTweetParams extends PdAxiosRequest, TweetId {
102
+ }
103
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ export interface TwitterEntity {
2
+ id: string;
3
+ }
4
+ export type TwitterEntityMap = Record<string, object>;
5
+ export interface List extends TwitterEntity {
6
+ name: string;
7
+ }
8
+ export interface Tweet extends TwitterEntity {
9
+ text: string;
10
+ edit_history_tweet_ids: string[];
11
+ referenced_tweets?: ReferencedTweet[];
12
+ includes?: {
13
+ tweets?: Tweet[];
14
+ };
15
+ }
16
+ export interface ReferencedTweet {
17
+ id: string;
18
+ type: "retweeted" | "quoted" | "replied_to";
19
+ }
20
+ export interface User extends TwitterEntity {
21
+ name: string;
22
+ username: string;
23
+ }
24
+ interface ResponseIncludes {
25
+ users?: User[];
26
+ tweets?: Tweet[];
27
+ }
28
+ interface ResponseBase {
29
+ includes?: ResponseIncludes;
30
+ errors?: object;
31
+ }
32
+ export type ResponseObject<T extends TwitterEntity> = ResponseBase & {
33
+ data?: T | T[];
34
+ };
35
+ export type PaginatedResponseObject<T extends TwitterEntity> = ResponseBase & {
36
+ data?: T[];
37
+ meta?: {
38
+ next_token?: string;
39
+ result_count: number;
40
+ };
41
+ };
42
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,149 @@
1
+ import { TwitterEntity } from "../../common/types/responseSchemas.js";
2
+ declare const _default: {
3
+ props: {
4
+ app: import("@pipedream/types").App<{
5
+ _getAuthHeader(config: import("../../common/types/requestParams.js").HttpRequestParams): Promise<import("oauth-1.0a").Header>;
6
+ _getBaseUrl(): "https://api.twitter.com/2";
7
+ _httpRequest({ $, ...args }: import("../../common/types/requestParams.js").HttpRequestParams): Promise<import("../../common/types/responseSchemas").ResponseObject<TwitterEntity>>;
8
+ _paginatedRequest({ maxResults, maxPerPage, params, ...args }: import("../../common/types/requestParams.js").PaginatedRequestParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<TwitterEntity>>;
9
+ addUserToList({ listId, ...args }: import("../../common/types/requestParams.js").AddUserToListParams): Promise<object>;
10
+ createTweet(args: import("../../common/types/requestParams.js").CreateTweetParams): Promise<object>;
11
+ deleteTweet({ tweetId, ...args }: import("../../common/types/requestParams.js").DeleteTweetParams): Promise<object>;
12
+ followUser(args: import("../../common/types/requestParams.js").FollowUserParams): Promise<object>;
13
+ getListTweets({ listId, ...args }: import("../../common/types/requestParams.js").GetListTweetsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
14
+ getTweet({ tweetId, ...args }: import("../../common/types/requestParams.js").GetTweetParams): Promise<import("../../common/types/responseSchemas").ResponseObject<import("../../common/types/responseSchemas").Tweet>>;
15
+ getAuthenticatedUserId(): Promise<string>;
16
+ getUserLikedTweets({ userId, ...args }: import("../../common/types/requestParams.js").GetUserLikedTweetParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
17
+ getUserOwnedLists({ userId, ...args }: import("../../common/types/requestParams.js").GetUserOwnedListsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").List>>;
18
+ getUserFollowedLists({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowedListsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").List>>;
19
+ getUserMentions({ userId, ...args }: import("../../common/types/requestParams.js").GetUserMentionsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
20
+ getUserTweets({ userId, ...args }: import("../../common/types/requestParams.js").GetUserTweetsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
21
+ getUserByUsername(username: string): Promise<import("../../common/types/responseSchemas").ResponseObject<import("../../common/types/responseSchemas").User>>;
22
+ getUser({ userId, ...args }: import("../../common/types/requestParams.js").GetUserParams): Promise<import("../../common/types/responseSchemas").ResponseObject<import("../../common/types/responseSchemas").User>>;
23
+ likeTweet(args: import("../../common/types/requestParams.js").LikeTweetParams): Promise<object>;
24
+ getUserFollowers({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowersParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").User>>;
25
+ getUserFollowing({ userId, ...args }: import("../../common/types/requestParams.js").GetUserFollowersParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").User>>;
26
+ retweet(args: import("../../common/types/requestParams.js").LikeTweetParams): Promise<object>;
27
+ searchTweets(args: import("../../common/types/requestParams.js").SearchTweetsParams): Promise<import("../../common/types/responseSchemas").PaginatedResponseObject<import("../../common/types/responseSchemas").Tweet>>;
28
+ unfollowUser({ userId, ...args }: import("../../common/types/requestParams.js").UnfollowUserParams): Promise<object>;
29
+ unlikeTweet({ tweetId, ...args }: import("../../common/types/requestParams.js").UnlikeTweetParams): Promise<object>;
30
+ }, {
31
+ maxResults: {
32
+ type: string;
33
+ label: string;
34
+ description: string;
35
+ optional: boolean;
36
+ };
37
+ listId: {
38
+ type: string;
39
+ label: string;
40
+ description: string;
41
+ options(): Promise<{
42
+ label: string;
43
+ value: string;
44
+ }[]>;
45
+ };
46
+ userNameOrId: {
47
+ type: string;
48
+ label: string;
49
+ description: string;
50
+ optional: boolean;
51
+ default: string;
52
+ };
53
+ tweetId: {
54
+ type: string;
55
+ label: string;
56
+ description: string;
57
+ };
58
+ query: {
59
+ type: string;
60
+ label: string;
61
+ description: string;
62
+ };
63
+ listExpansions: {
64
+ type: string;
65
+ label: string;
66
+ optional: boolean;
67
+ description: string;
68
+ options: string[];
69
+ };
70
+ tweetExpansions: {
71
+ type: string;
72
+ label: string;
73
+ optional: boolean;
74
+ description: string;
75
+ options: string[];
76
+ };
77
+ userExpansions: {
78
+ type: string;
79
+ label: string;
80
+ optional: boolean;
81
+ description: string;
82
+ options: string[];
83
+ };
84
+ listFields: {
85
+ type: string;
86
+ label: string;
87
+ description: string;
88
+ optional: boolean;
89
+ options: string[];
90
+ };
91
+ mediaFields: {
92
+ type: string;
93
+ label: string;
94
+ description: string;
95
+ optional: boolean;
96
+ options: string[];
97
+ };
98
+ placeFields: {
99
+ type: string;
100
+ label: string;
101
+ description: string;
102
+ optional: boolean;
103
+ options: string[];
104
+ };
105
+ pollFields: {
106
+ type: string;
107
+ label: string;
108
+ description: string;
109
+ optional: boolean;
110
+ options: string[];
111
+ };
112
+ tweetFields: {
113
+ type: string;
114
+ label: string;
115
+ description: string;
116
+ optional: boolean;
117
+ options: string[];
118
+ };
119
+ userFields: {
120
+ type: string;
121
+ label: string;
122
+ description: string;
123
+ optional: boolean;
124
+ options: string[];
125
+ };
126
+ }>;
127
+ db: string;
128
+ timer: {
129
+ type: string;
130
+ default: {
131
+ intervalSeconds: number;
132
+ };
133
+ };
134
+ };
135
+ hooks: {
136
+ deploy(): Promise<void>;
137
+ };
138
+ methods: {
139
+ getEntityName(): string;
140
+ getItemSummary(): string;
141
+ getResources(): Promise<TwitterEntity[]>;
142
+ getSavedIds(): string[];
143
+ setSavedIds(data: string[]): void;
144
+ getAndProcessData(emit?: boolean): Promise<void>;
145
+ emitEvent(data: TwitterEntity): void;
146
+ };
147
+ run(): Promise<void>;
148
+ };
149
+ export default _default;
@@ -0,0 +1,62 @@
1
+ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
2
+ import app from "../../app/twitter.app.mjs";
3
+ export default {
4
+ props: {
5
+ app,
6
+ db: "$.service.db",
7
+ timer: {
8
+ type: "$.interface.timer",
9
+ default: {
10
+ intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
11
+ },
12
+ },
13
+ },
14
+ hooks: {
15
+ async deploy() {
16
+ await this.getAndProcessData();
17
+ },
18
+ },
19
+ methods: {
20
+ getEntityName() {
21
+ return "Entity";
22
+ },
23
+ getItemSummary() {
24
+ throw new Error("getItemSummary() not implemented in component");
25
+ },
26
+ async getResources() {
27
+ throw new Error("getResources() not implemented in component");
28
+ },
29
+ getSavedIds() {
30
+ return this.db.get("savedEntityIds");
31
+ },
32
+ setSavedIds(data) {
33
+ this.db.set("savedEntityIds", data);
34
+ },
35
+ async getAndProcessData(emit = false) {
36
+ const data = await this.getResources(emit);
37
+ if (data) {
38
+ const savedIds = this.getSavedIds() ?? [];
39
+ data.filter(({ id }) => !savedIds.includes(id)).reverse()
40
+ .forEach((obj) => {
41
+ if (emit)
42
+ this.emitEvent(obj);
43
+ const { id } = obj;
44
+ savedIds.push(id);
45
+ });
46
+ this.setSavedIds(savedIds);
47
+ }
48
+ },
49
+ emitEvent(data) {
50
+ const ts = Date.now();
51
+ const { id } = data;
52
+ this.$emit(data, {
53
+ id,
54
+ summary: `New ${this.getEntityName()}: "${this.getItemSummary(data)}"`,
55
+ ts,
56
+ });
57
+ },
58
+ },
59
+ async run() {
60
+ await this.getAndProcessData(true);
61
+ },
62
+ };
@@ -0,0 +1,7 @@
1
+ import { getUserId } from "../../common/methods.js";
2
+ declare function getCachedUserId(): Promise<string>;
3
+ declare const _default: {
4
+ getCachedUserId: typeof getCachedUserId;
5
+ getUserId: typeof getUserId;
6
+ };
7
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import { getUserId } from "../../common/methods.mjs";
2
+ async function getCachedUserId() {
3
+ const { userNameOrId: name } = this;
4
+ const cache = this.db.get("cachedUser");
5
+ if (cache?.name === name) {
6
+ return cache.id;
7
+ }
8
+ const id = await this.getUserId();
9
+ this.db.set("cachedUser", {
10
+ id,
11
+ name,
12
+ });
13
+ return id;
14
+ }
15
+ export default {
16
+ getCachedUserId,
17
+ getUserId,
18
+ };
@@ -0,0 +1,4 @@
1
+ import { List, Tweet, User } from "../../common/types/responseSchemas.js";
2
+ export declare function getListSummary({ name }: List): string;
3
+ export declare function getTweetSummary({ text }: Tweet): string;
4
+ export declare function getUserSummary({ username }: User): string;
@@ -0,0 +1,12 @@
1
+ export function getListSummary({ name }) {
2
+ return name;
3
+ }
4
+ export function getTweetSummary({ text }) {
5
+ const TWEET_SUMMARY_MAX_LENGTH = 30;
6
+ return text.length > TWEET_SUMMARY_MAX_LENGTH
7
+ ? text.slice(0, TWEET_SUMMARY_MAX_LENGTH) + "..."
8
+ : text;
9
+ }
10
+ export function getUserSummary({ username }) {
11
+ return username;
12
+ }