@skillful-ai/piece-x 0.0.1
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.
- package/README.md +7 -0
- package/package.json +39 -0
- package/skillful-ai-piece-x-0.0.1.tgz +0 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +46 -0
- package/src/index.js.map +1 -0
- package/src/lib/common/actions/create-tweet.d.ts +7 -0
- package/src/lib/common/actions/create-tweet.js +65 -0
- package/src/lib/common/actions/create-tweet.js.map +1 -0
- package/src/lib/common/actions/get-latest-mentions.d.ts +5 -0
- package/src/lib/common/actions/get-latest-mentions.js +44 -0
- package/src/lib/common/actions/get-latest-mentions.js.map +1 -0
- package/src/lib/common/actions/get-own-posts.d.ts +6 -0
- package/src/lib/common/actions/get-own-posts.js +49 -0
- package/src/lib/common/actions/get-own-posts.js.map +1 -0
- package/src/lib/common/actions/get-replies.d.ts +5 -0
- package/src/lib/common/actions/get-replies.js +40 -0
- package/src/lib/common/actions/get-replies.js.map +1 -0
- package/src/lib/common/actions/get-user-content.d.ts +6 -0
- package/src/lib/common/actions/get-user-content.js +94 -0
- package/src/lib/common/actions/get-user-content.js.map +1 -0
- package/src/lib/common/actions/search-recent.d.ts +5 -0
- package/src/lib/common/actions/search-recent.js +38 -0
- package/src/lib/common/actions/search-recent.js.map +1 -0
- package/src/lib/common/auth.d.ts +1 -0
- package/src/lib/common/auth.js +39 -0
- package/src/lib/common/auth.js.map +1 -0
- package/src/lib/common/index.d.ts +18 -0
- package/src/lib/common/index.js +137 -0
- package/src/lib/common/index.js.map +1 -0
- package/src/lib/common/triggers/new-mention.d.ts +11 -0
- package/src/lib/common/triggers/new-mention.js +59 -0
- package/src/lib/common/triggers/new-mention.js.map +1 -0
- package/src/lib/common/triggers/new-posts-from-me.d.ts +14 -0
- package/src/lib/common/triggers/new-posts-from-me.js +65 -0
- package/src/lib/common/triggers/new-posts-from-me.js.map +1 -0
- package/src/lib/common/triggers/new-search-match.d.ts +11 -0
- package/src/lib/common/triggers/new-search-match.js +55 -0
- package/src/lib/common/triggers/new-search-match.js.map +1 -0
- package/src/lib/common/triggers/new-unreplied-mention.d.ts +17 -0
- package/src/lib/common/triggers/new-unreplied-mention.js +166 -0
- package/src/lib/common/triggers/new-unreplied-mention.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skillful-ai/piece-x",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@activepieces/pieces-common": "^0.7.0",
|
|
9
|
+
"@activepieces/pieces-framework": "^0.36.1",
|
|
10
|
+
"@ai-sdk/anthropic": "1.2.12",
|
|
11
|
+
"@ai-sdk/google": "1.2.19",
|
|
12
|
+
"@ai-sdk/openai": "1.3.22",
|
|
13
|
+
"@ai-sdk/replicate": "0.2.8",
|
|
14
|
+
"@sinclair/typebox": "0.34.11",
|
|
15
|
+
"ai": "4.3.16",
|
|
16
|
+
"axios": "1.8.3",
|
|
17
|
+
"axios-retry": "4.4.1",
|
|
18
|
+
"deepmerge-ts": "7.1.0",
|
|
19
|
+
"fast-glob": "3.3.3",
|
|
20
|
+
"mime-types": "2.1.35",
|
|
21
|
+
"nanoid": "3.3.8",
|
|
22
|
+
"semver": "7.6.0",
|
|
23
|
+
"tslib": "^2.3.0",
|
|
24
|
+
"twitter-api-v2": "^1.25.0",
|
|
25
|
+
"zod": "^3.23.8",
|
|
26
|
+
"@activepieces/shared": "0.17.2"
|
|
27
|
+
},
|
|
28
|
+
"overrides": {
|
|
29
|
+
"@tryfabric/martian": {
|
|
30
|
+
"@notionhq/client": "$@notionhq/client"
|
|
31
|
+
},
|
|
32
|
+
"vite": {
|
|
33
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"resolutions": {
|
|
37
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
Binary file
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const twitter: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.twitter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const shared_1 = require("@activepieces/shared");
|
|
7
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
8
|
+
const create_tweet_1 = require("./lib/common/actions/create-tweet");
|
|
9
|
+
const get_latest_mentions_1 = require("./lib/common/actions/get-latest-mentions");
|
|
10
|
+
const get_own_posts_1 = require("./lib/common/actions/get-own-posts");
|
|
11
|
+
const get_replies_1 = require("./lib/common/actions/get-replies");
|
|
12
|
+
const get_user_content_1 = require("./lib/common/actions/get-user-content");
|
|
13
|
+
const search_recent_1 = require("./lib/common/actions/search-recent");
|
|
14
|
+
const new_mention_1 = require("./lib/common/triggers/new-mention");
|
|
15
|
+
const new_posts_from_me_1 = require("./lib/common/triggers/new-posts-from-me");
|
|
16
|
+
const new_search_match_1 = require("./lib/common/triggers/new-search-match");
|
|
17
|
+
const auth_1 = require("./lib/common/auth");
|
|
18
|
+
const new_unreplied_mention_1 = require("./lib/common/triggers/new-unreplied-mention");
|
|
19
|
+
exports.twitter = (0, pieces_framework_1.createPiece)({
|
|
20
|
+
displayName: 'Twitter',
|
|
21
|
+
description: 'Post, reply, search, and work with mentions using OAuth2 + twitter-api-v2.',
|
|
22
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/twitter.png',
|
|
23
|
+
minimumSupportedRelease: '0.36.1',
|
|
24
|
+
categories: [shared_1.PieceCategory.COMMUNICATION, shared_1.PieceCategory.MARKETING],
|
|
25
|
+
authors: ['Isaac Touma Rodriguez'],
|
|
26
|
+
auth: auth_1.twitterAuth,
|
|
27
|
+
actions: [
|
|
28
|
+
create_tweet_1.createTweetAction,
|
|
29
|
+
get_latest_mentions_1.getLatestMentionsAction,
|
|
30
|
+
get_own_posts_1.getOwnLatestPostsAction,
|
|
31
|
+
search_recent_1.searchRecentAction,
|
|
32
|
+
get_replies_1.getRepliesAction,
|
|
33
|
+
get_user_content_1.getUserContentAction,
|
|
34
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
35
|
+
auth: auth_1.twitterAuth,
|
|
36
|
+
baseUrl: () => 'https://api.twitter.com/2',
|
|
37
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
return ({
|
|
39
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
40
|
+
});
|
|
41
|
+
}),
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
triggers: [new_mention_1.newMentionTrigger, new_search_match_1.newSearchMatchTrigger, new_posts_from_me_1.newPostsFromMeTrigger, new_unreplied_mention_1.newUnrepliedMentionTrigger],
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/custom/x/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,iDAAqD;AACrD,+DAAwE;AAGxE,oEAAsE;AACtE,kFAAmF;AAEnF,sEAA6E;AAC7E,kEAAoE;AACpE,4EAA6E;AAC7E,sEAAwE;AACxE,mEAAsE;AACtE,+EAAgF;AAChF,6EAA+E;AAC/E,4CAAgD;AAChD,uFAAyF;AAG5E,QAAA,OAAO,GAAG,IAAA,8BAAW,EAAC;IACjC,WAAW,EAAE,SAAS;IACtB,WAAW,EACT,4EAA4E;IAC9E,OAAO,EAAE,iDAAiD;IAC1D,uBAAuB,EAAE,QAAQ;IACjC,UAAU,EAAE,CAAC,sBAAa,CAAC,aAAa,EAAE,sBAAa,CAAC,SAAS,CAAC;IAClE,OAAO,EAAE,CAAC,uBAAuB,CAAC;IAClC,IAAI,EAAE,kBAAW;IACjB,OAAO,EAAE;QACP,gCAAiB;QACjB,6CAAuB;QACvB,uCAAuB;QACvB,kCAAkB;QAClB,8BAAgB;QAChB,uCAAoB;QAEpB,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,kBAAW;YACjB,OAAO,EAAE,GAAG,EAAE,CAAC,2BAA2B;YAC1C,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,UAAW,IAA4B,CAAC,YAAY,EAAE;iBACtE,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,+BAAiB,EAAE,wCAAqB,EAAE,yCAAqB,EAAE,kDAA0B,CAAC;CACxG,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const createTweetAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
text: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
3
|
+
replyToId: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
image1: import("@activepieces/pieces-framework").FileProperty<false>;
|
|
5
|
+
image2: import("@activepieces/pieces-framework").FileProperty<false>;
|
|
6
|
+
image3: import("@activepieces/pieces-framework").FileProperty<false>;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTweetAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const __1 = require("..");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
exports.createTweetAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.twitterAuth,
|
|
10
|
+
name: 'twitter-create',
|
|
11
|
+
displayName: 'Create Tweet',
|
|
12
|
+
description: 'Create a tweet or reply to an existing tweet. Optionally include up to 4 images (OAuth2 v2 media upload).',
|
|
13
|
+
props: {
|
|
14
|
+
text: pieces_framework_1.Property.LongText({ displayName: 'Text', required: true }),
|
|
15
|
+
replyToId: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'Reply To Post ID (optional)',
|
|
17
|
+
required: false,
|
|
18
|
+
}),
|
|
19
|
+
image1: pieces_framework_1.Property.File({
|
|
20
|
+
displayName: 'Image 1 (optional)',
|
|
21
|
+
required: false,
|
|
22
|
+
}),
|
|
23
|
+
image2: pieces_framework_1.Property.File({
|
|
24
|
+
displayName: 'Image 2 (optional)',
|
|
25
|
+
required: false,
|
|
26
|
+
}),
|
|
27
|
+
image3: pieces_framework_1.Property.File({
|
|
28
|
+
displayName: 'Image 3 (optional)',
|
|
29
|
+
required: false,
|
|
30
|
+
})
|
|
31
|
+
},
|
|
32
|
+
run(ctx) {
|
|
33
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
var _a;
|
|
35
|
+
const client = (0, __1.twitterClient)(ctx.auth);
|
|
36
|
+
const files = [
|
|
37
|
+
ctx.propsValue.image1,
|
|
38
|
+
ctx.propsValue.image2,
|
|
39
|
+
ctx.propsValue.image3,
|
|
40
|
+
].filter(Boolean);
|
|
41
|
+
let media_ids;
|
|
42
|
+
if (files.length > 0) {
|
|
43
|
+
media_ids = [];
|
|
44
|
+
for (const f of files) {
|
|
45
|
+
const id = yield (0, __1.uploadMediaV2)(ctx.auth, {
|
|
46
|
+
base64: f.base64,
|
|
47
|
+
mimeType: f.extension,
|
|
48
|
+
fileName: f.filename,
|
|
49
|
+
});
|
|
50
|
+
media_ids.push(String(id));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const body = { text: ctx.propsValue.text };
|
|
54
|
+
if (ctx.propsValue.replyToId) {
|
|
55
|
+
body.reply = { in_reply_to_tweet_id: ctx.propsValue.replyToId };
|
|
56
|
+
}
|
|
57
|
+
if (media_ids === null || media_ids === void 0 ? void 0 : media_ids.length) {
|
|
58
|
+
body.media = { media_ids };
|
|
59
|
+
}
|
|
60
|
+
const res = yield client.v2.tweet(body);
|
|
61
|
+
return (_a = res.data) !== null && _a !== void 0 ? _a : { success: true };
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=create-tweet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-tweet.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/custom/x/src/lib/common/actions/create-tweet.ts"],"names":[],"mappings":";;;;AAAA,qEAK0C;AAC1C,0BAAkD;AAClD,kCAAsC;AAGvB,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,cAAc;IAC3B,WAAW,EACT,2GAA2G;IAC7G,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAChE,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,6BAA6B;YAC1C,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,IAAI,CAAC;YACpB,WAAW,EAAE,oBAAoB;YACjC,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,IAAI,CAAC;YACpB,WAAW,EAAE,oBAAoB;YACjC,QAA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AAE,SAAS,EAAE,CAAC;YAC7B,CAAC;YAED,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACxC,OAAO,MAAA,GAAG,CAAC,IAAI,mCAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACvC,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const getLatestMentionsAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
handle: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
3
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
4
|
+
useMemory: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLatestMentionsAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const __1 = require("..");
|
|
8
|
+
exports.getLatestMentionsAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.twitterAuth,
|
|
10
|
+
name: 'twitter-get-latest-mentions',
|
|
11
|
+
displayName: 'Get Latest Mentions',
|
|
12
|
+
description: 'Returns recent mentions. With memory, only new ones are returned.',
|
|
13
|
+
props: {
|
|
14
|
+
handle: pieces_framework_1.Property.ShortText({ displayName: 'Handle (optional, without @)', required: false }),
|
|
15
|
+
maxResults: pieces_framework_1.Property.Number({ displayName: 'Max Results', defaultValue: 20, required: false }),
|
|
16
|
+
useMemory: pieces_framework_1.Property.Checkbox({ displayName: 'Only new since last run', defaultValue: true, required: false }),
|
|
17
|
+
},
|
|
18
|
+
run(ctx) {
|
|
19
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const client = (0, __1.twitterClient)(ctx.auth);
|
|
22
|
+
const { handle, maxResults, useMemory } = ctx.propsValue;
|
|
23
|
+
const me = yield client.v2.me();
|
|
24
|
+
const targetId = handle
|
|
25
|
+
? (yield client.v2.userByUsername(handle.replace(/^@/, ''))).data.id
|
|
26
|
+
: me.data.id;
|
|
27
|
+
const memKey = (0, __1.storeKey)(['mentions:last_id', targetId]);
|
|
28
|
+
const sinceId = useMemory ? yield ctx.store.get(memKey) : undefined;
|
|
29
|
+
const res = yield client.v2.userMentionTimeline(targetId, {
|
|
30
|
+
max_results: (0, __1.clamp)(maxResults !== null && maxResults !== void 0 ? maxResults : 20, 10, 100),
|
|
31
|
+
since_id: sinceId || undefined,
|
|
32
|
+
'tweet.fields': ['id', 'text', 'created_at', 'author_id', 'conversation_id'],
|
|
33
|
+
expansions: ['author_id'],
|
|
34
|
+
'user.fields': ['username', 'name', 'profile_image_url'],
|
|
35
|
+
});
|
|
36
|
+
const tweets = (_a = res.data.data) !== null && _a !== void 0 ? _a : [];
|
|
37
|
+
const newest = (_b = res.data.meta) === null || _b === void 0 ? void 0 : _b.newest_id;
|
|
38
|
+
if (useMemory && newest)
|
|
39
|
+
yield ctx.store.put(memKey, newest);
|
|
40
|
+
return tweets;
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=get-latest-mentions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-latest-mentions.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/custom/x/src/lib/common/actions/get-latest-mentions.ts"],"names":[],"mappings":";;;;AAAA,qEAA6F;AAC7F,kCAAsC;AACtC,0BAAoD;AAEvC,QAAA,uBAAuB,GAAG,IAAA,+BAAY,EAAC;IAClD,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,6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mBAAmB,CAAC,QAAQ,EAAE;gBACxD,WAAW,EAAE,IAAA,SAAK,EAAC,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;gBAC7C,QAAQ,EAAE,OAAO,IAAI,SAAS;gBAC9B,cAAc,EAAE,CAAC,IAAI,EAAC,MAAM,EAAC,YAAY,EAAC,WAAW,EAAC,iBAAiB,CAAC;gBACxE,UAAU,EAAE,CAAC,WAAW,CAAC;gBACzB,aAAa,EAAE,CAAC,UAAU,EAAC,MAAM,EAAC,mBAAmB,CAAC;aACvD,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAA,GAAG,CAAC,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC;YACnC,MAAM,MAAM,GAAG,MAAA,GAAG,CAAC,IAAI,CAAC,IAAI,0CAAE,SAAS,CAAC;YACxC,IAAI,SAAS,IAAI,MAAM;gBAAE,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAE7D,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const getOwnLatestPostsAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
count: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
3
|
+
includeRetweets: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
4
|
+
includeReplies: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
5
|
+
useMemory: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOwnLatestPostsAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const __1 = require("..");
|
|
8
|
+
exports.getOwnLatestPostsAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.twitterAuth,
|
|
10
|
+
name: 'twitter-get-own-posts',
|
|
11
|
+
displayName: 'Get Own Latest Posts',
|
|
12
|
+
description: 'Fetch your recent posts. With memory, only new ones are returned.',
|
|
13
|
+
props: {
|
|
14
|
+
count: pieces_framework_1.Property.Number({ displayName: 'Count', defaultValue: 20, required: false }),
|
|
15
|
+
includeRetweets: pieces_framework_1.Property.Checkbox({ displayName: 'Include Retweets', defaultValue: false, required: false }),
|
|
16
|
+
includeReplies: pieces_framework_1.Property.Checkbox({ displayName: 'Include Replies', defaultValue: false, required: false }),
|
|
17
|
+
useMemory: pieces_framework_1.Property.Checkbox({ displayName: 'Only new since last run', defaultValue: true, required: false }),
|
|
18
|
+
},
|
|
19
|
+
run(ctx) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const client = (0, __1.twitterClient)(ctx.auth);
|
|
23
|
+
const me = yield client.v2.me();
|
|
24
|
+
const { count, includeRetweets, includeReplies, useMemory } = ctx.propsValue;
|
|
25
|
+
const memKey = (0, __1.storeKey)(['own:last_id', me.data.id]);
|
|
26
|
+
const sinceId = useMemory ? yield ctx.store.get(memKey) : undefined;
|
|
27
|
+
// ✅ narrow the type to the expected literal union
|
|
28
|
+
const excludeArr = [];
|
|
29
|
+
if (!includeRetweets)
|
|
30
|
+
excludeArr.push('retweets');
|
|
31
|
+
if (!includeReplies)
|
|
32
|
+
excludeArr.push('replies');
|
|
33
|
+
// TypeOrArrayOf<'retweets' | 'replies'> | undefined
|
|
34
|
+
const excludeParam = excludeArr.length === 0 ? undefined : (excludeArr.length === 1 ? excludeArr[0] : excludeArr);
|
|
35
|
+
const res = yield client.v2.userTimeline(me.data.id, {
|
|
36
|
+
max_results: (0, __1.clamp)(count !== null && count !== void 0 ? count : 20, 10, 100),
|
|
37
|
+
since_id: sinceId || undefined,
|
|
38
|
+
exclude: excludeParam, // 👈 now correctly typed
|
|
39
|
+
'tweet.fields': ['id', 'text', 'created_at', 'conversation_id', 'referenced_tweets'],
|
|
40
|
+
});
|
|
41
|
+
const tweets = (_a = res.data.data) !== null && _a !== void 0 ? _a : [];
|
|
42
|
+
const newest = (_b = res.data.meta) === null || _b === void 0 ? void 0 : _b.newest_id;
|
|
43
|
+
if (useMemory && newest)
|
|
44
|
+
yield ctx.store.put(memKey, newest);
|
|
45
|
+
return tweets;
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=get-own-posts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-own-posts.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/custom/x/src/lib/common/actions/get-own-posts.ts"],"names":[],"mappings":";;;;AAAA,qEAA6F;AAC7F,kCAAsC;AACtC,0BAAoD;AAEvC,QAAA,uBAAuB,GAAG,IAAA,+BAAY,EAAC;IAClD,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE,mEAAmE;IAChF,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACnF,eAAe,EAAE,2BAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC7G,cAAc,EAAE,2BAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,K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EAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;gBACxC,QAAQ,EAAE,OAAO,IAAI,SAAS;gBAC9B,OAAO,EAAE,YAAY,EAAE,yBAAyB;gBAChD,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,CAAC;aACrF,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAA,GAAG,CAAC,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC;YACnC,MAAM,MAAM,GAAG,MAAA,GAAG,CAAC,IAAI,CAAC,IAAI,0CAAE,SAAS,CAAC;YACxC,IAAI,SAAS,IAAI,MAAM;gBAAE,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAE7D,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const getRepliesAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
postId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
4
|
+
useMemory: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRepliesAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const __1 = require("..");
|
|
8
|
+
exports.getRepliesAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.twitterAuth,
|
|
10
|
+
name: 'twitter-get-replies',
|
|
11
|
+
displayName: 'Get Replies for a Post',
|
|
12
|
+
description: 'Fetch replies in a conversation. With memory, only new ones are returned.',
|
|
13
|
+
props: {
|
|
14
|
+
postId: pieces_framework_1.Property.ShortText({ displayName: 'Post ID', required: true }),
|
|
15
|
+
maxResults: pieces_framework_1.Property.Number({ displayName: 'Max Results', defaultValue: 20, required: false }),
|
|
16
|
+
useMemory: pieces_framework_1.Property.Checkbox({ displayName: 'Only new since last run', defaultValue: true, required: false }),
|
|
17
|
+
},
|
|
18
|
+
run(ctx) {
|
|
19
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const client = (0, __1.twitterClient)(ctx.auth);
|
|
22
|
+
const { postId, maxResults, useMemory } = ctx.propsValue;
|
|
23
|
+
const t = yield client.v2.singleTweet(postId, { 'tweet.fields': ['conversation_id'] });
|
|
24
|
+
const convId = t.data.conversation_id;
|
|
25
|
+
const memKey = (0, __1.storeKey)(['replies:last_id', postId]);
|
|
26
|
+
const sinceId = useMemory ? yield ctx.store.get(memKey) : undefined;
|
|
27
|
+
const res = yield client.v2.search(`conversation_id:${convId}`, {
|
|
28
|
+
max_results: (0, __1.clamp)(maxResults !== null && maxResults !== void 0 ? maxResults : 20, 10, 100),
|
|
29
|
+
since_id: sinceId || undefined,
|
|
30
|
+
'tweet.fields': ['id', 'text', 'created_at', 'author_id', 'in_reply_to_user_id'],
|
|
31
|
+
});
|
|
32
|
+
const tweets = ((_a = res.data.data) !== null && _a !== void 0 ? _a : []).filter((x) => x.id !== postId);
|
|
33
|
+
const newest = (_b = res.data.meta) === null || _b === void 0 ? void 0 : _b.newest_id;
|
|
34
|
+
if (useMemory && newest)
|
|
35
|
+
yield ctx.store.put(memKey, newest);
|
|
36
|
+
return tweets;
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=get-replies.js.map
|
|
@@ -0,0 +1 @@
|
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AAG,CAAC,KAAK,CAAC,GAAG,CAAS,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAE5E,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,mBAAmB,MAAM,EAAE,EAAE;gBAC9D,WAAW,EAAE,IAAA,SAAK,EAAC,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;gBAC7C,QAAQ,EAAE,OAAO,IAAI,SAAS;gBAC9B,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,qBAAqB,CAAC;aACjF,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,CAAC,MAAA,GAAG,CAAC,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;YACpE,MAAM,MAAM,GAAG,MAAA,GAAG,CAAC,IAAI,CAAC,IAAI,0CAAE,SAAS,CAAC;YACxC,IAAI,SAAS,IAAI,MAAM;gBAAE,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAE7D,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const getUserContentAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
type: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
4
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
5
|
+
useMemory: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserContentAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const __1 = require("..");
|
|
8
|
+
// local helpers so you don't need to change common.ts
|
|
9
|
+
const toBig = (v) => {
|
|
10
|
+
try {
|
|
11
|
+
return v ? BigInt(v) : undefined;
|
|
12
|
+
}
|
|
13
|
+
catch (_a) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const newestIdBig = (items, seed) => {
|
|
18
|
+
let newest = seed;
|
|
19
|
+
for (const t of items) {
|
|
20
|
+
const b = toBig(t.id);
|
|
21
|
+
if (!b)
|
|
22
|
+
continue;
|
|
23
|
+
if (newest === undefined || b > newest)
|
|
24
|
+
newest = b;
|
|
25
|
+
}
|
|
26
|
+
return newest;
|
|
27
|
+
};
|
|
28
|
+
exports.getUserContentAction = (0, pieces_framework_1.createAction)({
|
|
29
|
+
auth: auth_1.twitterAuth,
|
|
30
|
+
name: 'twitter-get-user-content',
|
|
31
|
+
displayName: 'Get User Content',
|
|
32
|
+
description: 'Fetch a user’s tweets (no RTs), all (incl. RTs), or likes.',
|
|
33
|
+
props: {
|
|
34
|
+
username: pieces_framework_1.Property.ShortText({ displayName: 'Username (@ optional)', required: true }),
|
|
35
|
+
type: pieces_framework_1.Property.StaticDropdown({
|
|
36
|
+
displayName: 'Type',
|
|
37
|
+
required: true,
|
|
38
|
+
options: {
|
|
39
|
+
options: [
|
|
40
|
+
{ label: 'Tweets (no RTs)', value: 'tweets' },
|
|
41
|
+
{ label: 'All (incl. RTs)', value: 'all' },
|
|
42
|
+
{ label: 'Likes', value: 'likes' },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
defaultValue: 'tweets',
|
|
46
|
+
}),
|
|
47
|
+
maxResults: pieces_framework_1.Property.Number({ displayName: 'Max Results', defaultValue: 50, required: false }),
|
|
48
|
+
useMemory: pieces_framework_1.Property.Checkbox({ displayName: 'Only new since last run', defaultValue: true, required: false }),
|
|
49
|
+
},
|
|
50
|
+
run(ctx) {
|
|
51
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
var _a, _b, _c, _d;
|
|
53
|
+
const client = (0, __1.twitterClient)(ctx.auth);
|
|
54
|
+
const { username, type, maxResults, useMemory } = ctx.propsValue;
|
|
55
|
+
const uname = username.replace(/^@/, '');
|
|
56
|
+
const user = yield client.v2.userByUsername(uname);
|
|
57
|
+
const userId = user.data.id;
|
|
58
|
+
const memKey = (0, __1.storeKey)(['user:last_id', userId, type]);
|
|
59
|
+
const sinceId = useMemory ? yield ctx.store.get(memKey) : undefined;
|
|
60
|
+
const sinceBig = toBig(sinceId || undefined);
|
|
61
|
+
const limit = (0, __1.clamp)(maxResults !== null && maxResults !== void 0 ? maxResults : 50, 10, 100);
|
|
62
|
+
if (type === 'likes') {
|
|
63
|
+
// Do not pass since_id; filter locally
|
|
64
|
+
const res = yield client.v2.userLikedTweets(userId, {
|
|
65
|
+
max_results: limit,
|
|
66
|
+
'tweet.fields': ['id', 'text', 'created_at', 'author_id'],
|
|
67
|
+
});
|
|
68
|
+
const tweets = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : [];
|
|
69
|
+
const filtered = sinceBig ? tweets.filter((t) => toBig(t.id) > sinceBig) : tweets;
|
|
70
|
+
const newest = newestIdBig(tweets, sinceBig);
|
|
71
|
+
if (useMemory && newest && (!sinceBig || newest > sinceBig)) {
|
|
72
|
+
yield ctx.store.put(memKey, String(newest));
|
|
73
|
+
}
|
|
74
|
+
return filtered;
|
|
75
|
+
}
|
|
76
|
+
// tweets/all => user timeline
|
|
77
|
+
// For "tweets" exclude retweets; for "all" exclude nothing
|
|
78
|
+
const excludeParam = type === 'tweets' ? 'retweets' : undefined;
|
|
79
|
+
const res = yield client.v2.userTimeline(userId, {
|
|
80
|
+
max_results: limit,
|
|
81
|
+
exclude: excludeParam,
|
|
82
|
+
'tweet.fields': ['id', 'text', 'created_at', 'author_id', 'conversation_id', 'referenced_tweets'],
|
|
83
|
+
});
|
|
84
|
+
const tweets = (_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.data) !== null && _d !== void 0 ? _d : [];
|
|
85
|
+
const filtered = sinceBig ? tweets.filter((t) => toBig(t.id) > sinceBig) : tweets;
|
|
86
|
+
const newest = newestIdBig(tweets, sinceBig);
|
|
87
|
+
if (useMemory && newest && (!sinceBig || newest > sinceBig)) {
|
|
88
|
+
yield ctx.store.put(memKey, String(newest));
|
|
89
|
+
}
|
|
90
|
+
return filtered;
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=get-user-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-user-content.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/custom/x/src/lib/common/actions/get-user-content.ts"],"names":[],"mappings":";;;;AAAA,qEAA6F;AAC7F,kCAAsC;AACtC,0BAAoD;AAEpD,sDAAsD;AACtD,MAAM,KAAK,GAAG,CAAC,CAAU,EAAE,EAAE;IAC3B,IAAI,CAAC;QAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAAC,CAAC;IAAC,WAAM,CAAC;QAAC,OAAO,SAAS,CAAC;IAAC,CAAC;AACvE,CAAC,CAAC;AACF,MAAM,WAAW,GAAG,CAAC,KAA4B,EAAE,IAAa,EAAE,EAAE;IAClE,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACtB,IAAI,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,CAAC;YAC9C,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const searchRecentAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
query: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
4
|
+
useMemory: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.searchRecentAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const __1 = require("..");
|
|
8
|
+
exports.searchRecentAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.twitterAuth,
|
|
10
|
+
name: 'twitter-search-recent',
|
|
11
|
+
displayName: 'Search Recent Posts',
|
|
12
|
+
description: 'Search the last 7 days. With memory, only new results are returned.',
|
|
13
|
+
props: {
|
|
14
|
+
query: pieces_framework_1.Property.ShortText({ displayName: 'Query', required: true }),
|
|
15
|
+
maxResults: pieces_framework_1.Property.Number({ displayName: 'Max Results', defaultValue: 20, required: false }),
|
|
16
|
+
useMemory: pieces_framework_1.Property.Checkbox({ displayName: 'Only new since last run', defaultValue: true, required: false }),
|
|
17
|
+
},
|
|
18
|
+
run(ctx) {
|
|
19
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const client = (0, __1.twitterClient)(ctx.auth);
|
|
22
|
+
const { query, maxResults, useMemory } = ctx.propsValue;
|
|
23
|
+
const memKey = (0, __1.storeKey)(['search:last_id', query]);
|
|
24
|
+
const sinceId = useMemory ? yield ctx.store.get(memKey) : undefined;
|
|
25
|
+
const res = yield client.v2.search(query, {
|
|
26
|
+
max_results: (0, __1.clamp)(maxResults !== null && maxResults !== void 0 ? maxResults : 20, 10, 100),
|
|
27
|
+
since_id: sinceId || undefined,
|
|
28
|
+
'tweet.fields': ['id', 'text', 'created_at', 'author_id', 'conversation_id'],
|
|
29
|
+
});
|
|
30
|
+
const tweets = (_a = res.data.data) !== null && _a !== void 0 ? _a : [];
|
|
31
|
+
const newest = (_b = res.data.meta) === null || _b === void 0 ? void 0 : _b.newest_id;
|
|
32
|
+
if (useMemory && newest)
|
|
33
|
+
yield ctx.store.put(memKey, newest);
|
|
34
|
+
return tweets;
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=search-recent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-recent.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/custom/x/src/lib/common/actions/search-recent.ts"],"names":[],"mappings":";;;;AAAA,qEAA6F;AAC7F,kCAAsC;AACtC,0BAAoD;AAEvC,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,qEAAqE;IAClF,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACnE,UAAU,EAAE,2BAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC9F,SAAS,EAAE,2BAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,yBAAyB,EAAE,YAAY,EAAE,I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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.twitterAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const shared_1 = require("@activepieces/shared");
|
|
7
|
+
const twitter_api_v2_1 = require("twitter-api-v2");
|
|
8
|
+
const markdownDescription = `
|
|
9
|
+
Authenticate with X via OAuth 2.0 (User Context).
|
|
10
|
+
Required scopes: tweet.read tweet.write users.read offline.access media.write
|
|
11
|
+
`;
|
|
12
|
+
exports.twitterAuth = pieces_framework_1.PieceAuth.OAuth2({
|
|
13
|
+
description: markdownDescription,
|
|
14
|
+
grantType: shared_1.OAuth2GrantType.AUTHORIZATION_CODE,
|
|
15
|
+
authorizationMethod: pieces_framework_1.OAuth2AuthorizationMethod.HEADER,
|
|
16
|
+
authUrl: 'https://x.com/i/oauth2/authorize',
|
|
17
|
+
tokenUrl: 'https://api.x.com/2/oauth2/token',
|
|
18
|
+
required: true,
|
|
19
|
+
scope: [
|
|
20
|
+
'tweet.read',
|
|
21
|
+
'tweet.write',
|
|
22
|
+
'users.read',
|
|
23
|
+
'offline.access', // gives you a refresh token
|
|
24
|
+
'media.write', // needed for v2 media upload
|
|
25
|
+
],
|
|
26
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
27
|
+
try {
|
|
28
|
+
const { access_token } = auth;
|
|
29
|
+
const client = new twitter_api_v2_1.TwitterApi(access_token); // OAuth2 user bearer
|
|
30
|
+
yield client.v2.me();
|
|
31
|
+
return { valid: true };
|
|
32
|
+
}
|
|
33
|
+
catch (_b) {
|
|
34
|
+
return { valid: false, error: 'Authentication failed. Check app settings/scopes.' };
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
pkce: true
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/custom/x/src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAA2G;AAC3G,iDAAuD;AACvD,mDAA4C;AAG5C,MAAM,mBAAmB,GAAG;;;CAG3B,CAAC;AAEW,QAAA,WAAW,GAAG,4BAAS,CAAC,MAAM,CAAC;IAC1C,WAAW,EAAE,mBAAmB;IAChC,SAAS,EAAE,wBAAe,CAAC,kBAAkB;IAC7C,mBAAmB,EAAE,4CAAyB,CAAC,MAAM;IACrD,OAAO,EAAE,kCAAkC;IAC3C,QAAQ,EAAE,kCAAkC;IAC5C,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACL,YAAY;QACZ,aAAa;QACb,YAAY;QACZ,gBAAgB,EAAE,4BAA4B;QAC9C,aAAa,EAAK,6BAA6B;KAChD;IACD,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,EAAE,YAAY,EAAE,GAAG,IAA2B,CAAC;YACrD,MAAM,MAAM,GAAG,IAAI,2BAAU,CAAC,YAAY,CAAC,CAAC,CAAC,qBAAqB;YAClE,MAAM,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACrB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,mDAAmD,EAAE,CAAC;QACtF,CAAC;IACH,CAAC,CAAA;IACD,IAAI,EAAE,IAAI;CACX,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OAuth2PropertyValue } from '@activepieces/pieces-framework';
|
|
2
|
+
import { TwitterApi } from 'twitter-api-v2';
|
|
3
|
+
export declare function twitterClient(auth: OAuth2PropertyValue): TwitterApi;
|
|
4
|
+
export declare function clamp(n: number, min: number, max: number): number;
|
|
5
|
+
export declare function storeKey(parts: (string | number | undefined)[]): string;
|
|
6
|
+
/**
|
|
7
|
+
* Upload one file via v2 media API using chunked flow (works for images, GIF, video).
|
|
8
|
+
* Returns the media_id string for use in POST /2/tweets { media: { media_ids: [...] } }
|
|
9
|
+
*/
|
|
10
|
+
export declare function uploadMediaV2(auth: OAuth2PropertyValue, file: {
|
|
11
|
+
base64: string;
|
|
12
|
+
mimeType?: string;
|
|
13
|
+
fileName?: string;
|
|
14
|
+
}): Promise<string>;
|
|
15
|
+
export declare function toBig(v?: string): bigint | undefined;
|
|
16
|
+
export declare function newestIdBig(items: Array<{
|
|
17
|
+
id: string;
|
|
18
|
+
}>, seed?: bigint): bigint | undefined;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.twitterClient = twitterClient;
|
|
4
|
+
exports.clamp = clamp;
|
|
5
|
+
exports.storeKey = storeKey;
|
|
6
|
+
exports.uploadMediaV2 = uploadMediaV2;
|
|
7
|
+
exports.toBig = toBig;
|
|
8
|
+
exports.newestIdBig = newestIdBig;
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
const twitter_api_v2_1 = require("twitter-api-v2");
|
|
11
|
+
function twitterClient(auth) {
|
|
12
|
+
// OAuth2 user-context Bearer
|
|
13
|
+
return new twitter_api_v2_1.TwitterApi(auth.access_token);
|
|
14
|
+
}
|
|
15
|
+
function clamp(n, min, max) {
|
|
16
|
+
return Math.max(min, Math.min(max, n));
|
|
17
|
+
}
|
|
18
|
+
function storeKey(parts) {
|
|
19
|
+
return parts.filter(Boolean).join('::');
|
|
20
|
+
}
|
|
21
|
+
const MEDIA_UPLOAD_URL = 'https://api.x.com/2/media/upload'; // official v2 docs domain
|
|
22
|
+
function formPost(url, token, fields, file) {
|
|
23
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const fd = new FormData();
|
|
25
|
+
for (const [k, v] of Object.entries(fields))
|
|
26
|
+
fd.append(k, String(v));
|
|
27
|
+
if (file)
|
|
28
|
+
fd.append(file.field, file.blob, file.filename);
|
|
29
|
+
const res = yield fetch(url, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
32
|
+
body: fd,
|
|
33
|
+
});
|
|
34
|
+
if (!res.ok) {
|
|
35
|
+
const text = yield res.text().catch(() => '');
|
|
36
|
+
throw new Error(`Media upload error (${res.status}): ${text || res.statusText}`);
|
|
37
|
+
}
|
|
38
|
+
// INIT/FINALIZE return JSON; APPEND returns empty 2xx
|
|
39
|
+
const ct = res.headers.get('content-type') || '';
|
|
40
|
+
if (ct.includes('application/json'))
|
|
41
|
+
return (yield res.json());
|
|
42
|
+
return {};
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function getStatus(url, token, mediaId) {
|
|
46
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const u = new URL(url);
|
|
48
|
+
u.searchParams.set('command', 'STATUS');
|
|
49
|
+
u.searchParams.set('media_id', mediaId);
|
|
50
|
+
const res = yield fetch(u.toString(), { headers: { Authorization: `Bearer ${token}` } });
|
|
51
|
+
if (!res.ok) {
|
|
52
|
+
const text = yield res.text().catch(() => '');
|
|
53
|
+
throw new Error(`Media STATUS error (${res.status}): ${text || res.statusText}`);
|
|
54
|
+
}
|
|
55
|
+
return (yield res.json());
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Upload one file via v2 media API using chunked flow (works for images, GIF, video).
|
|
60
|
+
* Returns the media_id string for use in POST /2/tweets { media: { media_ids: [...] } }
|
|
61
|
+
*/
|
|
62
|
+
function uploadMediaV2(auth, file) {
|
|
63
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
65
|
+
const token = auth.access_token;
|
|
66
|
+
const buffer = Buffer.from(file.base64, 'base64');
|
|
67
|
+
const totalBytes = buffer.byteLength;
|
|
68
|
+
const mime = file.mimeType || 'application/octet-stream';
|
|
69
|
+
const filename = file.fileName || `upload.${mime.split('/')[1] || 'bin'}`;
|
|
70
|
+
// STEP 1: INIT
|
|
71
|
+
const init = yield formPost(MEDIA_UPLOAD_URL, token, {
|
|
72
|
+
command: 'INIT',
|
|
73
|
+
media_type: mime,
|
|
74
|
+
total_bytes: totalBytes,
|
|
75
|
+
// media_category: mime.startsWith('video/') ? 'tweet_video' : 'tweet_image',
|
|
76
|
+
});
|
|
77
|
+
const mediaId = (_a = init === null || init === void 0 ? void 0 : init.data) === null || _a === void 0 ? void 0 : _a.id;
|
|
78
|
+
if (!mediaId)
|
|
79
|
+
throw new Error('Failed to INIT media upload (no media_id returned)');
|
|
80
|
+
// STEP 2: APPEND (chunked)
|
|
81
|
+
const CHUNK_SIZE = 2 * 1024 * 1024;
|
|
82
|
+
let offset = 0;
|
|
83
|
+
let seg = 0;
|
|
84
|
+
while (offset < totalBytes) {
|
|
85
|
+
const end = Math.min(offset + CHUNK_SIZE, totalBytes);
|
|
86
|
+
const slice = buffer.subarray(offset, end);
|
|
87
|
+
const blob = new Blob([slice], { type: mime });
|
|
88
|
+
yield formPost(MEDIA_UPLOAD_URL, token, { command: 'APPEND', media_id: mediaId, segment_index: seg }, { field: 'media', blob, filename });
|
|
89
|
+
offset = end;
|
|
90
|
+
seg += 1;
|
|
91
|
+
}
|
|
92
|
+
// STEP 3: FINALIZE
|
|
93
|
+
const finalize = yield formPost(MEDIA_UPLOAD_URL, token, { command: 'FINALIZE', media_id: mediaId });
|
|
94
|
+
const fin = finalize === null || finalize === void 0 ? void 0 : finalize.data;
|
|
95
|
+
if (!fin)
|
|
96
|
+
throw new Error('Failed to FINALIZE media upload');
|
|
97
|
+
// STEP 4: optional STATUS polling (videos/GIF often async)
|
|
98
|
+
const proc = fin.processing_info;
|
|
99
|
+
if (proc && proc.state !== 'succeeded') {
|
|
100
|
+
let state = proc.state;
|
|
101
|
+
let wait = (_b = proc.check_after_secs) !== null && _b !== void 0 ? _b : 2;
|
|
102
|
+
for (let i = 0; i < 30 && state !== 'succeeded'; i++) {
|
|
103
|
+
yield new Promise((r) => setTimeout(r, Math.max(1, wait) * 1000));
|
|
104
|
+
const st = yield getStatus(MEDIA_UPLOAD_URL, token, mediaId);
|
|
105
|
+
state = (_e = (_d = (_c = st.data) === null || _c === void 0 ? void 0 : _c.processing_info) === null || _d === void 0 ? void 0 : _d.state) !== null && _e !== void 0 ? _e : state;
|
|
106
|
+
wait = (_h = (_g = (_f = st.data) === null || _f === void 0 ? void 0 : _f.processing_info) === null || _g === void 0 ? void 0 : _g.check_after_secs) !== null && _h !== void 0 ? _h : wait;
|
|
107
|
+
if (state === 'failed')
|
|
108
|
+
throw new Error('Media processing failed');
|
|
109
|
+
}
|
|
110
|
+
if (state !== 'succeeded') {
|
|
111
|
+
throw new Error('Media processing did not complete in time');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return mediaId; // use in create tweet body
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
// --- Snowflake helpers ---
|
|
118
|
+
function toBig(v) {
|
|
119
|
+
try {
|
|
120
|
+
return v ? BigInt(v) : undefined;
|
|
121
|
+
}
|
|
122
|
+
catch (_a) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function newestIdBig(items, seed) {
|
|
127
|
+
let newest = seed;
|
|
128
|
+
for (const t of items) {
|
|
129
|
+
const b = toBig(t.id);
|
|
130
|
+
if (!b)
|
|
131
|
+
continue;
|
|
132
|
+
if (newest === undefined || b > newest)
|
|
133
|
+
newest = b;
|
|
134
|
+
}
|
|
135
|
+
return newest;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages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
|
+
export declare const newMentionTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
3
|
+
handle: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
5
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
6
|
+
handle: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
8
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
9
|
+
handle: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
10
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newMentionTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const __1 = require("..");
|
|
9
|
+
const items = (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, propsValue, }) {
|
|
10
|
+
var _b, _c;
|
|
11
|
+
const client = (0, __1.twitterClient)(auth);
|
|
12
|
+
const me = yield client.v2.me();
|
|
13
|
+
const targetId = propsValue.handle
|
|
14
|
+
? (yield client.v2.userByUsername(String(propsValue.handle).replace(/^@/, ''))).data.id
|
|
15
|
+
: me.data.id;
|
|
16
|
+
const res = yield client.v2.userMentionTimeline(targetId, {
|
|
17
|
+
max_results: (0, __1.clamp)((_b = propsValue.maxResults) !== null && _b !== void 0 ? _b : 20, 10, 100),
|
|
18
|
+
'tweet.fields': ['id', 'text', 'created_at', 'author_id', 'conversation_id'],
|
|
19
|
+
});
|
|
20
|
+
const data = (_c = res.data.data) !== null && _c !== void 0 ? _c : [];
|
|
21
|
+
return data.map((d) => ({
|
|
22
|
+
id: d.id,
|
|
23
|
+
data: Object.assign(Object.assign({}, d), { [pieces_framework_1.DEDUPE_KEY_PROPERTY]: d.id }),
|
|
24
|
+
}));
|
|
25
|
+
});
|
|
26
|
+
const polling = { strategy: pieces_common_1.DedupeStrategy.LAST_ITEM, items };
|
|
27
|
+
exports.newMentionTrigger = (0, pieces_framework_1.createTrigger)({
|
|
28
|
+
auth: auth_1.twitterAuth,
|
|
29
|
+
name: 'twitter-new-mention',
|
|
30
|
+
displayName: 'New Mention',
|
|
31
|
+
description: 'Fires when the account (or specified handle) is mentioned.',
|
|
32
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
33
|
+
props: {
|
|
34
|
+
handle: pieces_framework_1.Property.ShortText({ displayName: 'Handle (optional)', required: false }),
|
|
35
|
+
maxResults: pieces_framework_1.Property.Number({ displayName: 'Max per poll', defaultValue: 20, required: false }),
|
|
36
|
+
},
|
|
37
|
+
sampleData: {},
|
|
38
|
+
onEnable(ctx) {
|
|
39
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, ctx);
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
onDisable(ctx) {
|
|
44
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, ctx);
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
test(ctx) {
|
|
49
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
return yield pieces_common_1.pollingHelper.test(polling, ctx);
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
run(ctx) {
|
|
54
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
return yield pieces_common_1.pollingHelper.poll(polling, ctx);
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=new-mention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-mention.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/custom/x/src/lib/common/triggers/new-mention.ts"],"names":[],"mappings":";;;;AAAA,qEAM0C;AACxC,+DAA4E;AAC5E,kCAAsC;AACtC,0BAA0C;AAE1C,MAAM,KAAK,GAAG,KAMX,EAAE,oDANgB,EACnB,IAAI,EACJ,UAAU,GAIX;;IACC,MAAM,MAAM,GAAG,IAAA,iBAAa,EAAC,IAAI,CAAC,CAAC;IACnC,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChC,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM;QAChC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;QACvF,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;IAEf,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,QAAQ,EAAE;QACxD,WAAW,EAAE,IAAA,SAAK,EAAC,MAAA,UAAU,CAAC,UAAU,mCAAI,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;QACxD,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,CAAC;KAC7E,CAAC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AAG,CAAC,GAAG;;YACX,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAc,EAAE,GAAG,CAAC,CAAC;QACvD,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newPostsFromMeTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
3
|
+
includeRetweets: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
4
|
+
includeReplies: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
5
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
6
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
7
|
+
includeRetweets: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
8
|
+
includeReplies: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
9
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
10
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
11
|
+
includeRetweets: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
12
|
+
includeReplies: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
13
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newPostsFromMeTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const __1 = require("..");
|
|
9
|
+
const items = (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, propsValue, }) {
|
|
10
|
+
var _b, _c;
|
|
11
|
+
const client = (0, __1.twitterClient)(auth);
|
|
12
|
+
const me = yield client.v2.me();
|
|
13
|
+
// ✅ narrow type to match TwitterApi TypeOrArrayOf<'retweets' | 'replies'>
|
|
14
|
+
const excludeArr = [];
|
|
15
|
+
if (!propsValue.includeRetweets)
|
|
16
|
+
excludeArr.push('retweets');
|
|
17
|
+
if (!propsValue.includeReplies)
|
|
18
|
+
excludeArr.push('replies');
|
|
19
|
+
const excludeParam = excludeArr.length === 0 ? undefined : excludeArr.length === 1 ? excludeArr[0] : excludeArr;
|
|
20
|
+
const res = yield client.v2.userTimeline(me.data.id, {
|
|
21
|
+
max_results: (0, __1.clamp)((_b = propsValue.maxResults) !== null && _b !== void 0 ? _b : 20, 10, 100),
|
|
22
|
+
exclude: excludeParam,
|
|
23
|
+
'tweet.fields': ['id', 'text', 'created_at', 'referenced_tweets'],
|
|
24
|
+
});
|
|
25
|
+
const data = (_c = res.data.data) !== null && _c !== void 0 ? _c : [];
|
|
26
|
+
return data.map((d) => ({
|
|
27
|
+
id: d.id,
|
|
28
|
+
data: Object.assign(Object.assign({}, d), { [pieces_framework_1.DEDUPE_KEY_PROPERTY]: d.id }),
|
|
29
|
+
}));
|
|
30
|
+
});
|
|
31
|
+
const polling = { strategy: pieces_common_1.DedupeStrategy.LAST_ITEM, items };
|
|
32
|
+
exports.newPostsFromMeTrigger = (0, pieces_framework_1.createTrigger)({
|
|
33
|
+
auth: auth_1.twitterAuth,
|
|
34
|
+
name: 'twitter-new-posts-from-me',
|
|
35
|
+
displayName: 'New Posts From Me',
|
|
36
|
+
description: 'Fires when your account posts something new.',
|
|
37
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
38
|
+
props: {
|
|
39
|
+
includeRetweets: pieces_framework_1.Property.Checkbox({ displayName: 'Include Retweets', defaultValue: false, required: false }),
|
|
40
|
+
includeReplies: pieces_framework_1.Property.Checkbox({ displayName: 'Include Replies', defaultValue: false, required: false }),
|
|
41
|
+
maxResults: pieces_framework_1.Property.Number({ displayName: 'Max per poll', defaultValue: 20, required: false }),
|
|
42
|
+
},
|
|
43
|
+
sampleData: {},
|
|
44
|
+
onEnable(ctx) {
|
|
45
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, ctx);
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
onDisable(ctx) {
|
|
50
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, ctx);
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
test(ctx) {
|
|
55
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
return yield pieces_common_1.pollingHelper.test(polling, ctx);
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
run(ctx) {
|
|
60
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
return yield pieces_common_1.pollingHelper.poll(polling, ctx);
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=new-posts-from-me.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-posts-from-me.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/custom/x/src/lib/common/triggers/new-posts-from-me.ts"],"names":[],"mappings":";;;;AAAA,qEAM0C;AACxC,+DAA4E;AAC5E,kCAAsC;AACtC,0BAA0C;AAE1C,MAAM,KAAK,GAAG,KAMX,EAAE,oDANgB,EACnB,IAAI,EACJ,UAAU,GAIX;;IACC,MAAM,MAAM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const newSearchMatchTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
3
|
+
query: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
5
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
6
|
+
query: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
8
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
9
|
+
query: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newSearchMatchTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const __1 = require("..");
|
|
9
|
+
const items = (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, propsValue, }) {
|
|
10
|
+
var _b, _c;
|
|
11
|
+
const client = (0, __1.twitterClient)(auth);
|
|
12
|
+
const res = yield client.v2.search(propsValue.query, {
|
|
13
|
+
max_results: (0, __1.clamp)((_b = propsValue.maxResults) !== null && _b !== void 0 ? _b : 20, 10, 100),
|
|
14
|
+
'tweet.fields': ['id', 'text', 'created_at'],
|
|
15
|
+
});
|
|
16
|
+
const data = (_c = res.data.data) !== null && _c !== void 0 ? _c : [];
|
|
17
|
+
return data.map((d) => ({
|
|
18
|
+
id: d.id,
|
|
19
|
+
data: Object.assign(Object.assign({}, d), { [pieces_framework_1.DEDUPE_KEY_PROPERTY]: d.id }),
|
|
20
|
+
}));
|
|
21
|
+
});
|
|
22
|
+
const polling = { strategy: pieces_common_1.DedupeStrategy.LAST_ITEM, items };
|
|
23
|
+
exports.newSearchMatchTrigger = (0, pieces_framework_1.createTrigger)({
|
|
24
|
+
auth: auth_1.twitterAuth,
|
|
25
|
+
name: 'twitter-new-search-match',
|
|
26
|
+
displayName: 'New Search Match',
|
|
27
|
+
description: 'Fires when a new post matches a search query.',
|
|
28
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
29
|
+
props: {
|
|
30
|
+
query: pieces_framework_1.Property.ShortText({ displayName: 'Query', required: true }),
|
|
31
|
+
maxResults: pieces_framework_1.Property.Number({ displayName: 'Max per poll', defaultValue: 20, required: false }),
|
|
32
|
+
},
|
|
33
|
+
sampleData: {},
|
|
34
|
+
onEnable(ctx) {
|
|
35
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, ctx);
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
onDisable(ctx) {
|
|
40
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, ctx);
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
test(ctx) {
|
|
45
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
return yield pieces_common_1.pollingHelper.test(polling, ctx);
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
run(ctx) {
|
|
50
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return yield pieces_common_1.pollingHelper.poll(polling, ctx);
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=new-search-match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-search-match.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/custom/x/src/lib/common/triggers/new-search-match.ts"],"names":[],"mappings":";;;;AAAA,qEAM0C;AACxC,+DAA4E;AAC5E,kCAAsC;AACtC,0BAA0C;AAE1C,MAAM,KAAK,GAAG,KAMX,EAAE,oDANgB,EACnB,IAAI,EACJ,UAAU,GAIX;;IACC,MAAM,MAAM,GAAG,IAAA,iBAAa,EAAC,IAAI,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE;QACnD,WAAW,EAAE,IAAA,SAAK,EAAC,MAAA,UAAU,CAAC,UAAU,mCAAI,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;QACxD,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC;KAC7C,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAA,GAAG,CAAC,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC;IACjC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;QAC3B,EAAE,EAAE,CAAC,CAAC,EAAY;QAClB,IAAI,kCAAO,CAAC,KAAE,CAAC,sCAAmB,CAAC,EAAE,CAAC,CAAC,EAAE,GAAE;KAC5C,CAAC,CAAC,CAAC;AACN,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,8BAAc,CAAC,SAAkB,EAAE,KAAK,EAAE,CAAC;AAE1D,QAAA,qBAAqB,GAAG,IAAA,gCAAa,EAAC;IACjD,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,0BAA0B;IAChC,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,+CAA+C;IAC5D,IAAI,EAAE,kCAAe,CAAC,OAAO;IAC7B,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACnE,UAAU,EAAE,2BAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;KAChG;IACD,UAAU,EAAE,EAAE;IACR,QAAQ,CAAC,GAAG;;YAChB,MAAM,6BAAa,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAU,CAAC,CAAC;QACpD,CAAC;KAAA;IACK,SAAS,CAAC,GAAG;;YACjB,MAAM,6BAAa,CAAC,SAAS,CAAC,OAAO,EAAE,GAAU,CAAC,CAAC;QACrD,CAAC;KAAA;IACK,IAAI,CAAC,GAAG;;YACZ,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAc,EAAE,GAAG,CAAC,CAAC;QACvD,CAAC;KAAA;IACK,GAAG,CAAC,GAAG;;YACX,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAc,EAAE,GAAG,CAAC,CAAC;QACvD,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newUnrepliedMentionTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
3
|
+
handle: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
5
|
+
maxChecksPerPoll: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
6
|
+
seedOnEnable: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
7
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
8
|
+
handle: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
10
|
+
maxChecksPerPoll: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
11
|
+
seedOnEnable: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
12
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
13
|
+
handle: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
14
|
+
maxResults: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
15
|
+
maxChecksPerPoll: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
16
|
+
seedOnEnable: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newUnrepliedMentionTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// src/lib/triggers/new-unreplied-mention.ts
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const __1 = require("..");
|
|
9
|
+
/** Build a stable store key per account/handle */
|
|
10
|
+
const storeKey = (targetId) => `x:last_mention_id:${targetId}`;
|
|
11
|
+
/** Try to delete a key from store; fall back to overwriting if delete isn't available */
|
|
12
|
+
const clearStoreKey = (store, key) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
if (typeof store.delete === 'function') {
|
|
14
|
+
yield store.delete(key);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
yield store.put(key, undefined);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
/** Strict reply detector: did I reply to THIS exact mention tweet? */
|
|
21
|
+
function alreadyRepliedToThis(client, myUsername, mention) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
// search replies from me in the same conversation
|
|
25
|
+
const q = `conversation_id:${mention.conversation_id} from:${myUsername}`;
|
|
26
|
+
const res = yield client.v2.search(q, {
|
|
27
|
+
max_results: 50,
|
|
28
|
+
'tweet.fields': ['referenced_tweets'],
|
|
29
|
+
});
|
|
30
|
+
const hits = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : [];
|
|
31
|
+
return hits.some(t => { var _a; return ((_a = t.referenced_tweets) !== null && _a !== void 0 ? _a : []).some(rt => rt.type === 'replied_to' && rt.id === mention.id); });
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/** Safe numeric compare for tweet IDs */
|
|
35
|
+
const maxId = (a, b) => {
|
|
36
|
+
if (!a)
|
|
37
|
+
return b;
|
|
38
|
+
if (!b)
|
|
39
|
+
return a;
|
|
40
|
+
return BigInt(a) >= BigInt(b) ? a : b;
|
|
41
|
+
};
|
|
42
|
+
exports.newUnrepliedMentionTrigger = (0, pieces_framework_1.createTrigger)({
|
|
43
|
+
auth: auth_1.twitterAuth,
|
|
44
|
+
name: 'twitter-new-unreplied-mention',
|
|
45
|
+
displayName: 'New Unreplied Mention',
|
|
46
|
+
description: 'Fires for mentions you have not replied to yet (uses a checkpoint).',
|
|
47
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
48
|
+
props: {
|
|
49
|
+
handle: pieces_framework_1.Property.ShortText({ displayName: 'Handle (optional)', required: false }),
|
|
50
|
+
maxResults: pieces_framework_1.Property.Number({ displayName: 'Max per poll', defaultValue: 50, required: false }),
|
|
51
|
+
maxChecksPerPoll: pieces_framework_1.Property.Number({
|
|
52
|
+
displayName: 'Max conversations to check per poll',
|
|
53
|
+
description: 'Caps how many mention threads we inspect each run (rate-limit safety).',
|
|
54
|
+
defaultValue: 50,
|
|
55
|
+
required: false,
|
|
56
|
+
}),
|
|
57
|
+
seedOnEnable: pieces_framework_1.Property.Checkbox({
|
|
58
|
+
displayName: 'Seed checkpoint on enable',
|
|
59
|
+
description: 'If ON, the trigger starts from the latest mention (avoids historical backlog).',
|
|
60
|
+
defaultValue: true,
|
|
61
|
+
required: false,
|
|
62
|
+
}),
|
|
63
|
+
},
|
|
64
|
+
sampleData: {
|
|
65
|
+
id: '1234567890123456789',
|
|
66
|
+
text: 'Hey @yourhandle can you help?',
|
|
67
|
+
author_id: '1111',
|
|
68
|
+
conversation_id: '1234567890123456789',
|
|
69
|
+
created_at: '2025-09-03T22:19:40.000Z',
|
|
70
|
+
},
|
|
71
|
+
// Seed the checkpoint (optional)
|
|
72
|
+
onEnable(ctx) {
|
|
73
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
var _a, _b, _c;
|
|
75
|
+
if (!ctx.propsValue.seedOnEnable)
|
|
76
|
+
return;
|
|
77
|
+
const client = (0, __1.twitterClient)(ctx.auth);
|
|
78
|
+
const me = yield client.v2.me();
|
|
79
|
+
const targetId = ctx.propsValue.handle
|
|
80
|
+
? (yield client.v2.userByUsername(String(ctx.propsValue.handle).replace(/^@/, ''))).data.id
|
|
81
|
+
: me.data.id;
|
|
82
|
+
const res = yield client.v2.userMentionTimeline(targetId, {
|
|
83
|
+
max_results: 5,
|
|
84
|
+
'tweet.fields': ['id'],
|
|
85
|
+
});
|
|
86
|
+
const latest = (_c = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.id;
|
|
87
|
+
if (latest) {
|
|
88
|
+
yield ctx.store.put(storeKey(targetId), latest);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
onDisable(ctx) {
|
|
93
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
// Clear the checkpoint so a re-enable can reseed cleanly
|
|
95
|
+
const client = (0, __1.twitterClient)(ctx.auth);
|
|
96
|
+
const me = yield client.v2.me();
|
|
97
|
+
const targetId = ctx.propsValue.handle
|
|
98
|
+
? (yield client.v2.userByUsername(String(ctx.propsValue.handle).replace(/^@/, ''))).data.id
|
|
99
|
+
: me.data.id;
|
|
100
|
+
yield clearStoreKey(ctx.store, storeKey(targetId));
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
// Test returns a couple of latest mentions without touching the checkpoint
|
|
104
|
+
test(ctx) {
|
|
105
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
var _a, _b, _c;
|
|
107
|
+
const client = (0, __1.twitterClient)(ctx.auth);
|
|
108
|
+
const me = yield client.v2.me();
|
|
109
|
+
const targetId = ctx.propsValue.handle
|
|
110
|
+
? (yield client.v2.userByUsername(String(ctx.propsValue.handle).replace(/^@/, ''))).data.id
|
|
111
|
+
: me.data.id;
|
|
112
|
+
const res = yield client.v2.userMentionTimeline(targetId, {
|
|
113
|
+
max_results: (0, __1.clamp)((_a = ctx.propsValue.maxResults) !== null && _a !== void 0 ? _a : 10, 10, 100),
|
|
114
|
+
'tweet.fields': ['id', 'text', 'created_at', 'author_id', 'conversation_id'],
|
|
115
|
+
});
|
|
116
|
+
const data = (_c = (_b = res.data) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : [];
|
|
117
|
+
return data.slice(0, 2).map(d => ({ id: d.id, data: d }));
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
// The important bit: fetch → filter unreplied → advance checkpoint → emit
|
|
121
|
+
run(ctx) {
|
|
122
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
var _a, _b, _c, _d;
|
|
124
|
+
const client = (0, __1.twitterClient)(ctx.auth);
|
|
125
|
+
const me = yield client.v2.me();
|
|
126
|
+
const myUsername = me.data.username;
|
|
127
|
+
const targetId = ctx.propsValue.handle
|
|
128
|
+
? (yield client.v2.userByUsername(String(ctx.propsValue.handle).replace(/^@/, ''))).data.id
|
|
129
|
+
: me.data.id;
|
|
130
|
+
const key = storeKey(targetId);
|
|
131
|
+
// Normalize null → undefined for TS correctness
|
|
132
|
+
const sinceIdRaw = yield ctx.store.get(key);
|
|
133
|
+
const sinceId = sinceIdRaw !== null && sinceIdRaw !== void 0 ? sinceIdRaw : undefined;
|
|
134
|
+
const res = yield client.v2.userMentionTimeline(targetId, Object.assign(Object.assign({ max_results: (0, __1.clamp)((_a = ctx.propsValue.maxResults) !== null && _a !== void 0 ? _a : 50, 10, 100) }, (sinceId ? { since_id: sinceId } : {})), { 'tweet.fields': ['id', 'text', 'created_at', 'author_id', 'conversation_id'] }));
|
|
135
|
+
const mentions = (_c = (_b = res.data) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : [];
|
|
136
|
+
if (!mentions.length)
|
|
137
|
+
return [];
|
|
138
|
+
// Track the newest id across everything we fetched this run
|
|
139
|
+
let newest = sinceId;
|
|
140
|
+
const out = [];
|
|
141
|
+
const budget = (0, __1.clamp)((_d = ctx.propsValue.maxChecksPerPoll) !== null && _d !== void 0 ? _d : 50, 1, 100);
|
|
142
|
+
for (const m of mentions) {
|
|
143
|
+
newest = maxId(newest, m.id);
|
|
144
|
+
// Skip if Twitter didn’t return conversation_id (rare, but TS-safe)
|
|
145
|
+
if (!m.conversation_id)
|
|
146
|
+
continue;
|
|
147
|
+
// Guard against excessive checks per run (rate-limit safety)
|
|
148
|
+
if (out.length >= budget)
|
|
149
|
+
break;
|
|
150
|
+
const replied = yield alreadyRepliedToThis(client, myUsername, { id: m.id, conversation_id: m.conversation_id } // now guaranteed string
|
|
151
|
+
);
|
|
152
|
+
if (!replied) {
|
|
153
|
+
out.push({
|
|
154
|
+
id: m.id,
|
|
155
|
+
data: Object.assign(Object.assign({}, m), { [pieces_framework_1.DEDUPE_KEY_PROPERTY]: m.id }),
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// Advance the checkpoint even if everything was already replied to
|
|
160
|
+
if (newest)
|
|
161
|
+
yield ctx.store.put(key, newest);
|
|
162
|
+
return out;
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
//# sourceMappingURL=new-unreplied-mention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-unreplied-mention.js","sourceRoot":"","sources":["../../../../../../../../../packages/pieces/custom/x/src/lib/common/triggers/new-unreplied-mention.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,qEAM0C;AACxC,kCAAsC;AACtC,0BAA0C;AAE1C,kDAAkD;AAClD,MAAM,QAAQ,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,qBAAqB,QAAQ,EAAE,CAAC;AAEvE,yFAAyF;AACzF,MAAM,aAAa,GAAG,CAAO,KAAU,EAAE,GAAW,EAAE,EAAE;IACtD,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QACvC,MAAM,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,SAAgB,CAAC,CAAC;IACzC,CAAC;AACH,CAAC,CAAA,CAAC;AAEF,sEAAsE;AACtE,SAAe,oBAAoB,CACjC,MAAwC,EACxC,UAAkB,EAClB,OAAgD;;;QAEhD,kDAAkD;QAClD,MAAM,CAAC,GAAG,mBAAmB,OAAO,CAAC,eAAe,SAAS,UAAU,EAAE,CAAC;QAC1E,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE;YACpC,WAAW,EAAE,EAAE;YACf,cAA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