@activepieces/piece-reddit 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 +37 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +77 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/create-reddit-comment.d.ts +4 -0
- package/src/lib/actions/create-reddit-comment.js +58 -0
- package/src/lib/actions/create-reddit-comment.js.map +1 -0
- package/src/lib/actions/create-reddit-post.d.ts +5 -0
- package/src/lib/actions/create-reddit-post.js +61 -0
- package/src/lib/actions/create-reddit-post.js.map +1 -0
- package/src/lib/actions/delete-reddit-comment.d.ts +3 -0
- package/src/lib/actions/delete-reddit-comment.js +51 -0
- package/src/lib/actions/delete-reddit-comment.js.map +1 -0
- package/src/lib/actions/delete-reddit-post.d.ts +3 -0
- package/src/lib/actions/delete-reddit-post.js +51 -0
- package/src/lib/actions/delete-reddit-post.js.map +1 -0
- package/src/lib/actions/edit-reddit-comment.d.ts +4 -0
- package/src/lib/actions/edit-reddit-comment.js +57 -0
- package/src/lib/actions/edit-reddit-comment.js.map +1 -0
- package/src/lib/actions/edit-reddit-post.d.ts +4 -0
- package/src/lib/actions/edit-reddit-post.js +57 -0
- package/src/lib/actions/edit-reddit-post.js.map +1 -0
- package/src/lib/actions/fetch-post-comments.d.ts +5 -0
- package/src/lib/actions/fetch-post-comments.js +95 -0
- package/src/lib/actions/fetch-post-comments.js.map +1 -0
- package/src/lib/actions/get-reddit-post-details.d.ts +3 -0
- package/src/lib/actions/get-reddit-post-details.js +84 -0
- package/src/lib/actions/get-reddit-post-details.js.map +1 -0
- package/src/lib/actions/retrieve-reddit-post.d.ts +5 -0
- package/src/lib/actions/retrieve-reddit-post.js +65 -0
- package/src/lib/actions/retrieve-reddit-post.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-reddit",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@ai-sdk/anthropic": "1.2.12",
|
|
6
|
+
"@ai-sdk/openai": "1.3.22",
|
|
7
|
+
"@ai-sdk/replicate": "0.2.8",
|
|
8
|
+
"@sinclair/typebox": "0.34.11",
|
|
9
|
+
"ai": "4.3.16",
|
|
10
|
+
"axios": "1.8.3",
|
|
11
|
+
"axios-retry": "4.4.1",
|
|
12
|
+
"deepmerge-ts": "7.1.0",
|
|
13
|
+
"fast-glob": "3.3.3",
|
|
14
|
+
"mime-types": "2.1.35",
|
|
15
|
+
"nanoid": "3.3.8",
|
|
16
|
+
"semver": "7.6.0",
|
|
17
|
+
"zod": "3.25.64",
|
|
18
|
+
"@activepieces/pieces-common": "0.5.2",
|
|
19
|
+
"@activepieces/pieces-framework": "0.14.1",
|
|
20
|
+
"@activepieces/shared": "0.13.2",
|
|
21
|
+
"tslib": "2.8.1"
|
|
22
|
+
},
|
|
23
|
+
"overrides": {
|
|
24
|
+
"@tryfabric/martian": {
|
|
25
|
+
"@notionhq/client": "$@notionhq/client"
|
|
26
|
+
},
|
|
27
|
+
"vite": {
|
|
28
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"resolutions": {
|
|
32
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
33
|
+
},
|
|
34
|
+
"types": "./src/index.d.ts",
|
|
35
|
+
"main": "./src/index.js",
|
|
36
|
+
"type": "commonjs"
|
|
37
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const redditAuth: import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>;
|
|
2
|
+
export declare const reddit: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reddit = exports.redditAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const retrieve_reddit_post_1 = require("./lib/actions/retrieve-reddit-post");
|
|
8
|
+
const get_reddit_post_details_1 = require("./lib/actions/get-reddit-post-details");
|
|
9
|
+
const create_reddit_post_1 = require("./lib/actions/create-reddit-post");
|
|
10
|
+
const create_reddit_comment_1 = require("./lib/actions/create-reddit-comment");
|
|
11
|
+
const fetch_post_comments_1 = require("./lib/actions/fetch-post-comments");
|
|
12
|
+
const edit_reddit_post_1 = require("./lib/actions/edit-reddit-post");
|
|
13
|
+
const edit_reddit_comment_1 = require("./lib/actions/edit-reddit-comment");
|
|
14
|
+
const delete_reddit_post_1 = require("./lib/actions/delete-reddit-post");
|
|
15
|
+
const delete_reddit_comment_1 = require("./lib/actions/delete-reddit-comment");
|
|
16
|
+
const shared_1 = require("@activepieces/shared");
|
|
17
|
+
const shared_2 = require("@activepieces/shared");
|
|
18
|
+
const markdown = `
|
|
19
|
+
To obtain your Reddit API credentials:
|
|
20
|
+
|
|
21
|
+
1. Go to https://www.reddit.com/prefs/apps.
|
|
22
|
+
2. Click "create another app..." at the bottom.
|
|
23
|
+
3. Select "script" as the app type.
|
|
24
|
+
4. Fill in the required information:
|
|
25
|
+
- name: Your app name
|
|
26
|
+
- description: Brief description
|
|
27
|
+
- about url: Can be left blank
|
|
28
|
+
- redirect uri: as shown in Redirect URL field
|
|
29
|
+
5. Click "create app".
|
|
30
|
+
6. Note down the client ID (under the app name) and client secret.
|
|
31
|
+
`;
|
|
32
|
+
exports.redditAuth = pieces_framework_1.PieceAuth.OAuth2({
|
|
33
|
+
description: markdown,
|
|
34
|
+
authUrl: 'https://www.reddit.com/api/v1/authorize',
|
|
35
|
+
tokenUrl: 'https://www.reddit.com/api/v1/access_token',
|
|
36
|
+
required: true,
|
|
37
|
+
scope: ['identity', 'read', 'submit', 'edit', 'history', 'flair'],
|
|
38
|
+
authorizationMethod: pieces_framework_1.OAuth2AuthorizationMethod.HEADER,
|
|
39
|
+
extra: {
|
|
40
|
+
grantType: shared_2.OAuth2GrantType.AUTHORIZATION_CODE,
|
|
41
|
+
responseType: 'code'
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
exports.reddit = (0, pieces_framework_1.createPiece)({
|
|
45
|
+
displayName: 'Reddit',
|
|
46
|
+
description: 'Interact with Reddit - fetch and submit posts.',
|
|
47
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/reddit.png',
|
|
48
|
+
minimumSupportedRelease: '0.36.1',
|
|
49
|
+
categories: [shared_1.PieceCategory.COMMUNICATION],
|
|
50
|
+
authors: ['bhaviksingla1403'],
|
|
51
|
+
auth: exports.redditAuth,
|
|
52
|
+
actions: [
|
|
53
|
+
retrieve_reddit_post_1.retrieveRedditPost,
|
|
54
|
+
get_reddit_post_details_1.getRedditPostDetails,
|
|
55
|
+
create_reddit_post_1.createRedditPost,
|
|
56
|
+
create_reddit_comment_1.createRedditComment,
|
|
57
|
+
fetch_post_comments_1.fetchPostComments,
|
|
58
|
+
edit_reddit_post_1.editRedditPost,
|
|
59
|
+
edit_reddit_comment_1.editRedditComment,
|
|
60
|
+
delete_reddit_post_1.deleteRedditPost,
|
|
61
|
+
delete_reddit_comment_1.deleteRedditComment,
|
|
62
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
63
|
+
auth: exports.redditAuth,
|
|
64
|
+
baseUrl: () => {
|
|
65
|
+
return 'https://oauth.reddit.com';
|
|
66
|
+
},
|
|
67
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
+
return {
|
|
69
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
70
|
+
'User-Agent': 'ActivePieces/1.0.0'
|
|
71
|
+
};
|
|
72
|
+
}),
|
|
73
|
+
}),
|
|
74
|
+
],
|
|
75
|
+
triggers: [],
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/reddit/src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAAkI;AAClI,6EAAwE;AACxE,mFAA6E;AAC7E,yEAAoE;AACpE,+EAA0E;AAC1E,2EAAqE;AACrE,qEAAgE;AAChE,2EAAsE;AACtE,yEAAoE;AACpE,+EAA0E;AAC1E,iDAAqD;AACrD,iDAAuD;AAEvD,MAAM,QAAQ,GAAG;;;;;;;;;;;;;CAahB,CAAC;AAEW,QAAA,UAAU,GAAG,4BAAS,CAAC,MAAM,CAAC;IACzC,WAAW,EAAE,QAAQ;IACrB,OAAO,EAAE,yCAAyC;IAClD,QAAQ,EAAE,4CAA4C;IACtD,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC;IACjE,mBAAmB,EAAE,4CAAyB,CAAC,MAAM;IACrD,KAAK,EAAE;QACL,SAAS,EAAE,wBAAe,CAAC,kBAAkB;QAC7C,YAAY,EAAE,MAAM;KACrB;CACF,CAAC,CAAC;AAEU,QAAA,MAAM,GAAG,IAAA,8BAAW,EAAC;IAChC,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,gDAAgD;IAC7D,OAAO,EAAE,gDAAgD;IACzD,uBAAuB,EAAE,QAAQ;IACjC,UAAU,EAAE,CAAC,sBAAa,CAAC,aAAa,CAAC;IACzC,OAAO,EAAE,CAAC,kBAAkB,CAAC;IAC7B,IAAI,EAAE,kBAAU;IAChB,OAAO,EAAE;QACP,yCAAkB;QAClB,8CAAoB;QACpB,qCAAgB;QAChB,2CAAmB;QACnB,uCAAiB;QACjB,iCAAc;QACd,uCAAiB;QACjB,qCAAgB;QAChB,2CAAmB;QACnB,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,kBAAU;YAChB,OAAO,EAAE,GAAG,EAAE;gBACZ,OAAO,0BAA0B,CAAC;YACpC,CAAC;YACD,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,OAAO;oBACL,aAAa,EAAE,UAAW,IAA4B,CAAC,YAAY,EAAE;oBACrE,YAAY,EAAE,oBAAoB;iBACnC,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const createRedditComment: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
parent_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
content: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
4
|
+
}>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRedditComment = 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 index_1 = require("../../index");
|
|
8
|
+
exports.createRedditComment = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.redditAuth,
|
|
10
|
+
name: 'createRedditComment',
|
|
11
|
+
displayName: 'Create Comment',
|
|
12
|
+
description: 'Comment on a Reddit post or reply to a comment.',
|
|
13
|
+
props: {
|
|
14
|
+
parent_id: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Parent ID',
|
|
16
|
+
description: 'ID of the post (t3_*) or comment (t1_*) to reply to.',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
content: pieces_framework_1.Property.LongText({
|
|
20
|
+
displayName: 'Comment Text',
|
|
21
|
+
description: 'Text of the comment.',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
run(context) {
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
let parentId = context.propsValue.parent_id.trim();
|
|
28
|
+
// If it's just a post ID, prefix it
|
|
29
|
+
if (!parentId.startsWith('t1_') && !parentId.startsWith('t3_')) {
|
|
30
|
+
parentId = `t3_${parentId}`;
|
|
31
|
+
}
|
|
32
|
+
const url = 'https://oauth.reddit.com/api/comment';
|
|
33
|
+
const payload = new URLSearchParams({
|
|
34
|
+
thing_id: parentId,
|
|
35
|
+
text: context.propsValue.content,
|
|
36
|
+
api_type: 'json',
|
|
37
|
+
});
|
|
38
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
39
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
40
|
+
url,
|
|
41
|
+
headers: {
|
|
42
|
+
'Authorization': `Bearer ${context.auth.access_token}`,
|
|
43
|
+
'User-Agent': 'ActivePieces Reddit Client',
|
|
44
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
45
|
+
},
|
|
46
|
+
body: payload.toString(),
|
|
47
|
+
});
|
|
48
|
+
if (response.status !== 200) {
|
|
49
|
+
return {
|
|
50
|
+
error: `Failed to create comment: ${response.status}`,
|
|
51
|
+
details: response.body,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return response.body;
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=create-reddit-comment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-reddit-comment.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/reddit/src/lib/actions/create-reddit-comment.ts"],"names":[],"mappings":";;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pD;gBACD,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE;aACzB,CAAC,CAAC;YAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC5B,OAAO;oBACL,KAAK,EAAE,6BAA6B,QAAQ,CAAC,MAAM,EAAE;oBACrD,OAAO,EAAE,QAAQ,CAAC,IAAI;iBACvB,CAAC;YACJ,CAAC;YAED,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const createRedditPost: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
subreddit: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
title: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
content: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRedditPost = 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 index_1 = require("../../index");
|
|
8
|
+
exports.createRedditPost = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.redditAuth,
|
|
10
|
+
name: 'createRedditPost',
|
|
11
|
+
displayName: 'Create Post',
|
|
12
|
+
description: 'Submit a new self (text) post to a subreddit.',
|
|
13
|
+
props: {
|
|
14
|
+
subreddit: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Subreddit',
|
|
16
|
+
description: 'The subreddit to post in (without r/).',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
title: pieces_framework_1.Property.ShortText({
|
|
20
|
+
displayName: 'Title',
|
|
21
|
+
description: 'Title of the Reddit post.',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
content: pieces_framework_1.Property.LongText({
|
|
25
|
+
displayName: 'Content',
|
|
26
|
+
description: 'Text content of the post.',
|
|
27
|
+
required: true,
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
run(context) {
|
|
31
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const { subreddit, title, content } = context.propsValue;
|
|
33
|
+
const url = 'https://oauth.reddit.com/api/submit';
|
|
34
|
+
const payload = new URLSearchParams({
|
|
35
|
+
api_type: 'json',
|
|
36
|
+
sr: subreddit,
|
|
37
|
+
title,
|
|
38
|
+
text: content,
|
|
39
|
+
kind: 'self',
|
|
40
|
+
});
|
|
41
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
42
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
43
|
+
url,
|
|
44
|
+
headers: {
|
|
45
|
+
'Authorization': `Bearer ${context.auth.access_token}`,
|
|
46
|
+
'User-Agent': 'ActivePieces Reddit Client',
|
|
47
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
48
|
+
},
|
|
49
|
+
body: payload.toString(),
|
|
50
|
+
});
|
|
51
|
+
if (response.status !== 200) {
|
|
52
|
+
return {
|
|
53
|
+
error: `Failed to create post: ${response.status}`,
|
|
54
|
+
details: response.body,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return response.body;
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=create-reddit-post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-reddit-post.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/reddit/src/lib/actions/create-reddit-post.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,uCAAyC;AAE5B,QAAA,g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,CAAC;gBAC5B,OAAO;oBACL,KAAK,EAAE,0BAA0B,QAAQ,CAAC,MAAM,EAAE;oBAClD,OAAO,EAAE,QAAQ,CAAC,IAAI;iBACvB,CAAC;YACJ,CAAC;YAED,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const deleteRedditComment: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
comment_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
}>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteRedditComment = 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 index_1 = require("../../index");
|
|
8
|
+
exports.deleteRedditComment = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.redditAuth,
|
|
10
|
+
name: 'deleteRedditComment',
|
|
11
|
+
displayName: 'Delete Comment',
|
|
12
|
+
description: 'Delete a specific Reddit comment by ID.',
|
|
13
|
+
props: {
|
|
14
|
+
comment_id: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Comment ID',
|
|
16
|
+
description: 'ID of the Reddit comment to delete (e.g., "def456" or "t1_def456").',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
run(context) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
let commentId = context.propsValue.comment_id.trim();
|
|
23
|
+
if (commentId.startsWith('t1_')) {
|
|
24
|
+
commentId = commentId.slice(3);
|
|
25
|
+
}
|
|
26
|
+
const url = 'https://oauth.reddit.com/api/del';
|
|
27
|
+
const payload = new URLSearchParams({
|
|
28
|
+
api_type: 'json',
|
|
29
|
+
id: `t1_${commentId}`,
|
|
30
|
+
});
|
|
31
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
32
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
33
|
+
url,
|
|
34
|
+
headers: {
|
|
35
|
+
'Authorization': `Bearer ${context.auth.access_token}`,
|
|
36
|
+
'User-Agent': 'ActivePieces Reddit Client',
|
|
37
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
38
|
+
},
|
|
39
|
+
body: payload.toString(),
|
|
40
|
+
});
|
|
41
|
+
if (response.status !== 200) {
|
|
42
|
+
return {
|
|
43
|
+
error: `Failed to delete comment: ${response.status}`,
|
|
44
|
+
details: response.body,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return { success: true, response: response.body };
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=delete-reddit-comment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-reddit-comment.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/reddit/src/lib/actions/delete-reddit-comment.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,uCAAyC;AAE5B,QAAA,mBAAmB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,kBAAU;IAChB,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,yCAAyC;IACtD,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,qEAAqE;YAClF,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,IAAI,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YACrD,IAAI,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBAChC,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjC,CAAC;YAED,MAAM,GAAG,GAAG,kCAAkC,CAAC;YAC/C,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC;gBAClC,QAAQ,EAAE,MAAM;gBAChB,EAAE,EAAE,MAAM,SAAS,EAAE;aACtB,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG;gBACH,OAAO,EAAE;oBACP,eAAe,EAAE,UAAU,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE;oBACtD,YAAY,EAAE,4BAA4B;oBAC1C,cAAc,EAAE,mCAAmC;iBACpD;gBACD,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE;aACzB,CAAC,CAAC;YAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC5B,OAAO;oBACL,KAAK,EAAE,6BAA6B,QAAQ,CAAC,MAAM,EAAE;oBACrD,OAAO,EAAE,QAAQ,CAAC,IAAI;iBACvB,CAAC;YACJ,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;QACpD,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const deleteRedditPost: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
post_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
}>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteRedditPost = 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 index_1 = require("../../index");
|
|
8
|
+
exports.deleteRedditPost = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.redditAuth,
|
|
10
|
+
name: 'deleteRedditPost',
|
|
11
|
+
displayName: 'Delete Post',
|
|
12
|
+
description: 'Delete a specific Reddit post by ID.',
|
|
13
|
+
props: {
|
|
14
|
+
post_id: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Post ID',
|
|
16
|
+
description: 'ID of the Reddit post to delete (e.g., "abc123" or "t3_abc123").',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
run(context) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
let postId = context.propsValue.post_id.trim();
|
|
23
|
+
if (postId.startsWith('t3_')) {
|
|
24
|
+
postId = postId.slice(3);
|
|
25
|
+
}
|
|
26
|
+
const url = 'https://oauth.reddit.com/api/del';
|
|
27
|
+
const payload = new URLSearchParams({
|
|
28
|
+
api_type: 'json',
|
|
29
|
+
id: `t3_${postId}`,
|
|
30
|
+
});
|
|
31
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
32
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
33
|
+
url,
|
|
34
|
+
headers: {
|
|
35
|
+
'Authorization': `Bearer ${context.auth.access_token}`,
|
|
36
|
+
'User-Agent': 'ActivePieces Reddit Client',
|
|
37
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
38
|
+
},
|
|
39
|
+
body: payload.toString(),
|
|
40
|
+
});
|
|
41
|
+
if (response.status !== 200) {
|
|
42
|
+
return {
|
|
43
|
+
error: `Failed to delete post: ${response.status}`,
|
|
44
|
+
details: response.body,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return { success: true, response: response.body };
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=delete-reddit-post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-reddit-post.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/reddit/src/lib/actions/delete-reddit-post.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,uCAAyC;AAE5B,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,kBAAU;IAChB,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,sCAAsC;IACnD,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,kEAAkE;YAC/E,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,IAAI,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAC/C,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC3B,CAAC;YAED,MAAM,GAAG,GAAG,kCAAkC,CAAC;YAC/C,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC;gBAClC,QAAQ,EAAE,MAAM;gBAChB,EAAE,EAAE,MAAM,MAAM,EAAE;aACnB,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG;gBACH,OAAO,EAAE;oBACP,eAAe,EAAE,UAAU,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE;oBACtD,YAAY,EAAE,4BAA4B;oBAC1C,cAAc,EAAE,mCAAmC;iBACpD;gBACD,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE;aACzB,CAAC,CAAC;YAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC5B,OAAO;oBACL,KAAK,EAAE,0BAA0B,QAAQ,CAAC,MAAM,EAAE;oBAClD,OAAO,EAAE,QAAQ,CAAC,IAAI;iBACvB,CAAC;YACJ,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;QACpD,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const editRedditComment: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
comment_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
content: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
4
|
+
}>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.editRedditComment = 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 index_1 = require("../../index");
|
|
8
|
+
exports.editRedditComment = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.redditAuth,
|
|
10
|
+
name: 'editRedditComment',
|
|
11
|
+
displayName: 'Edit Comment',
|
|
12
|
+
description: 'Edits the content of an existing Reddit comment.',
|
|
13
|
+
props: {
|
|
14
|
+
comment_id: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Comment ID',
|
|
16
|
+
description: 'ID of the Reddit comment to edit (e.g., "def456" or "t1_def456").',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
content: pieces_framework_1.Property.LongText({
|
|
20
|
+
displayName: 'New Comment Content',
|
|
21
|
+
description: 'Updated text content for the comment.',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
run(context) {
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
let commentId = context.propsValue.comment_id.trim();
|
|
28
|
+
if (commentId.startsWith('t1_')) {
|
|
29
|
+
commentId = commentId.slice(3);
|
|
30
|
+
}
|
|
31
|
+
const url = 'https://oauth.reddit.com/api/editusertext';
|
|
32
|
+
const payload = new URLSearchParams({
|
|
33
|
+
api_type: 'json',
|
|
34
|
+
thing_id: `t1_${commentId}`,
|
|
35
|
+
text: context.propsValue.content,
|
|
36
|
+
});
|
|
37
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
38
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
39
|
+
url,
|
|
40
|
+
headers: {
|
|
41
|
+
'Authorization': `Bearer ${context.auth.access_token}`,
|
|
42
|
+
'User-Agent': 'ActivePieces Reddit Client',
|
|
43
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
44
|
+
},
|
|
45
|
+
body: payload.toString(),
|
|
46
|
+
});
|
|
47
|
+
if (response.status !== 200) {
|
|
48
|
+
return {
|
|
49
|
+
error: `Failed to edit comment: ${response.status}`,
|
|
50
|
+
details: response.body,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return response.body;
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=edit-reddit-comment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-reddit-comment.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/reddit/src/lib/actions/edit-reddit-comment.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,uCAA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AM,KAAK,GAAG,EAAE,CAAC;gBAC5B,OAAO;oBACL,KAAK,EAAE,2BAA2B,QAAQ,CAAC,MAAM,EAAE;oBACnD,OAAO,EAAE,QAAQ,CAAC,IAAI;iBACvB,CAAC;YACJ,CAAC;YAED,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const editRedditPost: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
post_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
content: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
4
|
+
}>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.editRedditPost = 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 index_1 = require("../../index");
|
|
8
|
+
exports.editRedditPost = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.redditAuth,
|
|
10
|
+
name: 'editRedditPost',
|
|
11
|
+
displayName: 'Edit Post',
|
|
12
|
+
description: 'Edits the content of an existing Reddit post.',
|
|
13
|
+
props: {
|
|
14
|
+
post_id: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Post ID',
|
|
16
|
+
description: 'ID of the Reddit post to edit (e.g., "abc123" or "t3_abc123").',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
content: pieces_framework_1.Property.LongText({
|
|
20
|
+
displayName: 'New Post Content',
|
|
21
|
+
description: 'Updated text content for the post.',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
run(context) {
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
let postId = context.propsValue.post_id.trim();
|
|
28
|
+
if (postId.startsWith('t3_')) {
|
|
29
|
+
postId = postId.slice(3);
|
|
30
|
+
}
|
|
31
|
+
const url = 'https://oauth.reddit.com/api/editusertext';
|
|
32
|
+
const payload = new URLSearchParams({
|
|
33
|
+
api_type: 'json',
|
|
34
|
+
thing_id: `t3_${postId}`,
|
|
35
|
+
text: context.propsValue.content,
|
|
36
|
+
});
|
|
37
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
38
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
39
|
+
url,
|
|
40
|
+
headers: {
|
|
41
|
+
'Authorization': `Bearer ${context.auth.access_token}`,
|
|
42
|
+
'User-Agent': 'ActivePieces Reddit Client',
|
|
43
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
44
|
+
},
|
|
45
|
+
body: payload.toString(),
|
|
46
|
+
});
|
|
47
|
+
if (response.status !== 200) {
|
|
48
|
+
return {
|
|
49
|
+
error: `Failed to edit post: ${response.status}`,
|
|
50
|
+
details: response.body,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return response.body;
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=edit-reddit-post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-reddit-post.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/reddit/src/lib/actions/edit-reddit-post.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,uCAAyC;AAE5B,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,kBAAU;IAChB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,+CAA+C;IAC5D,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,S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AC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const fetchPostComments: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
post_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
sort: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
4
|
+
limit: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchPostComments = 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 index_1 = require("../../index");
|
|
8
|
+
exports.fetchPostComments = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.redditAuth,
|
|
10
|
+
name: 'fetchPostComments',
|
|
11
|
+
displayName: 'Fetch Post Comments',
|
|
12
|
+
description: 'Fetch comments from a specific Reddit post.',
|
|
13
|
+
props: {
|
|
14
|
+
post_id: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Post ID',
|
|
16
|
+
description: 'The ID of the Reddit post (e.g. "abc123" or "t3_abc123").',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
sort: pieces_framework_1.Property.StaticDropdown({
|
|
20
|
+
displayName: 'Sort By',
|
|
21
|
+
description: 'Sorting method for comments',
|
|
22
|
+
defaultValue: 'new',
|
|
23
|
+
required: false,
|
|
24
|
+
options: {
|
|
25
|
+
options: [
|
|
26
|
+
{ label: 'New', value: 'new' },
|
|
27
|
+
{ label: 'Top', value: 'top' },
|
|
28
|
+
{ label: 'Hot', value: 'hot' },
|
|
29
|
+
{ label: 'Best', value: 'best' },
|
|
30
|
+
{ label: 'Old', value: 'old' },
|
|
31
|
+
{ label: 'Controversial', value: 'controversial' },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
limit: pieces_framework_1.Property.Number({
|
|
36
|
+
displayName: 'Limit',
|
|
37
|
+
description: 'Maximum number of top-level comments to fetch',
|
|
38
|
+
defaultValue: 10,
|
|
39
|
+
required: false,
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
42
|
+
run(context) {
|
|
43
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
var _a, _b, _c, _d, _e;
|
|
45
|
+
let postId = context.propsValue.post_id.trim();
|
|
46
|
+
if (postId.startsWith('t3_')) {
|
|
47
|
+
postId = postId.slice(3);
|
|
48
|
+
}
|
|
49
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
50
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
51
|
+
url: `https://oauth.reddit.com/comments/${postId}`,
|
|
52
|
+
headers: {
|
|
53
|
+
'Authorization': `Bearer ${context.auth.access_token}`,
|
|
54
|
+
'User-Agent': 'ActivePieces Reddit Client',
|
|
55
|
+
'Content-Type': 'application/json',
|
|
56
|
+
},
|
|
57
|
+
queryParams: {
|
|
58
|
+
sort: (_a = context.propsValue.sort) !== null && _a !== void 0 ? _a : 'new',
|
|
59
|
+
limit: ((_b = context.propsValue.limit) !== null && _b !== void 0 ? _b : 10).toString(),
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
if (response.status !== 200) {
|
|
63
|
+
return {
|
|
64
|
+
error: `Failed to retrieve comments: ${response.status}`,
|
|
65
|
+
details: response.body,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function processComments(comments) {
|
|
69
|
+
return comments
|
|
70
|
+
.filter(c => c.kind === 't1')
|
|
71
|
+
.map(c => {
|
|
72
|
+
const d = c.data;
|
|
73
|
+
return {
|
|
74
|
+
id: d.id,
|
|
75
|
+
author: d.author,
|
|
76
|
+
body: d.body,
|
|
77
|
+
score: d.score,
|
|
78
|
+
created_utc: d.created_utc,
|
|
79
|
+
permalink: d.permalink,
|
|
80
|
+
edited: d.edited,
|
|
81
|
+
is_submitter: d.is_submitter,
|
|
82
|
+
stickied: d.stickied,
|
|
83
|
+
replies: d.replies && typeof d.replies === 'object'
|
|
84
|
+
? processComments(d.replies.data.children)
|
|
85
|
+
: [],
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const data = response.body;
|
|
90
|
+
const commentsTree = (_e = (_d = (_c = data[1]) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.children) !== null && _e !== void 0 ? _e : [];
|
|
91
|
+
return processComments(commentsTree);
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=fetch-post-comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-post-comments.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/reddit/src/lib/actions/fetch-post-comments.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,uCAAyC;AAE5B,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,kBAAU;IAChB,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,6CAA6C;IAC1D,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,2DAA2D;YACxE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC5B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,6BAA6B;YAC1C,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE;gBACP,OAAO,EAAE;oBAC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,CAAC;QACvC,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const getRedditPostDetails: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
post_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
}>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRedditPostDetails = 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 index_1 = require("../../index");
|
|
8
|
+
exports.getRedditPostDetails = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.redditAuth,
|
|
10
|
+
name: 'getRedditPostDetails',
|
|
11
|
+
displayName: 'Get Post Details',
|
|
12
|
+
description: 'Fetch detailed information about a specific Reddit post using its ID.',
|
|
13
|
+
props: {
|
|
14
|
+
post_id: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Post ID',
|
|
16
|
+
description: 'The ID of the Reddit post (e.g. "t3_abc123" or "abc123")',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
run(context) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
let postId = context.propsValue.post_id.trim();
|
|
24
|
+
if (postId.startsWith('t3_')) {
|
|
25
|
+
postId = postId.slice(3);
|
|
26
|
+
}
|
|
27
|
+
const url = `https://oauth.reddit.com/api/info?id=t3_${postId}`;
|
|
28
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
29
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
30
|
+
url,
|
|
31
|
+
headers: {
|
|
32
|
+
'Authorization': `Bearer ${context.auth.access_token}`,
|
|
33
|
+
'User-Agent': 'ActivePieces Reddit Client',
|
|
34
|
+
'Content-Type': 'application/json',
|
|
35
|
+
},
|
|
36
|
+
timeout: 5000,
|
|
37
|
+
});
|
|
38
|
+
if (response.status !== 200) {
|
|
39
|
+
return {
|
|
40
|
+
error: `Failed to retrieve post details: ${response.status}`,
|
|
41
|
+
details: response.body,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const children = (_c = (_b = (_a = response.body) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.children) !== null && _c !== void 0 ? _c : [];
|
|
45
|
+
if (children.length === 0) {
|
|
46
|
+
return { error: 'No post found with the given ID' };
|
|
47
|
+
}
|
|
48
|
+
const data = children[0].data;
|
|
49
|
+
const result = {
|
|
50
|
+
id: data.id,
|
|
51
|
+
title: data.title,
|
|
52
|
+
author: data.author,
|
|
53
|
+
author_fullname: data.author_fullname,
|
|
54
|
+
subreddit: data.subreddit,
|
|
55
|
+
subreddit_id: data.subreddit_id,
|
|
56
|
+
selftext: data.selftext,
|
|
57
|
+
selftext_html: data.selftext_html,
|
|
58
|
+
score: data.score,
|
|
59
|
+
upvote_ratio: data.upvote_ratio,
|
|
60
|
+
created_utc: data.created_utc,
|
|
61
|
+
permalink: data.permalink,
|
|
62
|
+
url: data.url,
|
|
63
|
+
domain: data.domain,
|
|
64
|
+
num_comments: data.num_comments,
|
|
65
|
+
is_self: data.is_self,
|
|
66
|
+
is_video: data.is_video,
|
|
67
|
+
is_original_content: data.is_original_content,
|
|
68
|
+
over_18: data.over_18,
|
|
69
|
+
spoiler: data.spoiler,
|
|
70
|
+
locked: data.locked,
|
|
71
|
+
stickied: data.stickied,
|
|
72
|
+
post_hint: data.post_hint,
|
|
73
|
+
};
|
|
74
|
+
if (data.media) {
|
|
75
|
+
result['media'] = data.media;
|
|
76
|
+
}
|
|
77
|
+
if (data.gallery_data) {
|
|
78
|
+
result['gallery_data'] = data.gallery_data;
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=get-reddit-post-details.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-reddit-post-details.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/reddit/src/lib/actions/get-reddit-post-details.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,uCAAyC;AAE5B,QAAA,oBAAoB,GAAG,IAAA,+BAAY,EAAC;IAC/C,IAAI,EAAE,kBAAU;IAChB,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,uEAAuE;IACpF,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,0DAA0D;YACvE,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,IAAI,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAC/C,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC3B,CAAC;YAED,MAAM,GAAG,GAAG,2CAA2C,MAAM,EAAE,CAAC;YAEhE,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG;gBACH,OAAO,EAAE;oBACP,eAAe,EAAE,UAAU,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE;oBACtD,YAAY,EAAE,4BAA4B;oBAC1C,cAAc,EAAE,kBAAkB;iBACnC;gBACD,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;YA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B,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,SAAS,EAAE,IAAI,CAAC,SAAS;aAC1B,CAAC;YAEF,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;YAC/B,CAAC;YAED,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACtB,MAAM,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;YAC7C,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const retrieveRedditPost: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
post_category: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
3
|
+
subreddit: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
size: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.retrieveRedditPost = 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 __1 = require("../../");
|
|
8
|
+
exports.retrieveRedditPost = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: __1.redditAuth,
|
|
10
|
+
name: 'retrieveRedditPost',
|
|
11
|
+
displayName: 'Retrieve Post',
|
|
12
|
+
description: 'Fetch top posts in a subreddit with optional size limit.',
|
|
13
|
+
props: {
|
|
14
|
+
post_category: pieces_framework_1.Property.StaticDropdown({
|
|
15
|
+
displayName: 'Post Category',
|
|
16
|
+
description: 'Select the category of posts to retrieve',
|
|
17
|
+
required: true,
|
|
18
|
+
defaultValue: 'hot',
|
|
19
|
+
options: {
|
|
20
|
+
options: [
|
|
21
|
+
{ label: 'Hot', value: 'hot' },
|
|
22
|
+
{ label: 'New', value: 'new' },
|
|
23
|
+
{ label: 'Top', value: 'top' },
|
|
24
|
+
{ label: 'Rising', value: 'rising' },
|
|
25
|
+
{ label: 'Controversial', value: 'controversial' },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
subreddit: pieces_framework_1.Property.ShortText({
|
|
30
|
+
displayName: 'Subreddit',
|
|
31
|
+
description: 'The subreddit to fetch posts from',
|
|
32
|
+
required: true,
|
|
33
|
+
}),
|
|
34
|
+
size: pieces_framework_1.Property.Number({
|
|
35
|
+
displayName: 'Number of Posts',
|
|
36
|
+
description: 'Number of posts to fetch (max 100)',
|
|
37
|
+
required: false,
|
|
38
|
+
defaultValue: 10,
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
run(context) {
|
|
42
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const baseUrl = `https://oauth.reddit.com/r/${context.propsValue.subreddit}/${context.propsValue.post_category}`;
|
|
44
|
+
const limit = context.propsValue.size || 10;
|
|
45
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
46
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
47
|
+
url: baseUrl,
|
|
48
|
+
queryParams: {
|
|
49
|
+
limit: limit.toString(),
|
|
50
|
+
},
|
|
51
|
+
headers: {
|
|
52
|
+
'Authorization': `Bearer ${context.auth.access_token}`,
|
|
53
|
+
'User-Agent': 'ActivePieces Reddit Client',
|
|
54
|
+
'Content-Type': 'application/json',
|
|
55
|
+
},
|
|
56
|
+
timeout: 5000,
|
|
57
|
+
});
|
|
58
|
+
if (response.status !== 200) {
|
|
59
|
+
throw new Error(`Reddit API error: ${response.status} ${JSON.stringify(response.body)}`);
|
|
60
|
+
}
|
|
61
|
+
return response.body;
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=retrieve-reddit-post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieve-reddit-post.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/reddit/src/lib/actions/retrieve-reddit-post.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAIqC;AACrC,8BAAoC;AAEvB,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,cAAU;IAChB,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,0DAA0D;IACvE,KAAK,EAAE;QACL,aAAa,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACrC,WAAW,EAAE,eAAe;YAC5B,WAAW,EAAE,0CAA0C;YACvD,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,KAAK;YACnB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;oBAC9B,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;oBAC9B,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;oBAC9B,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;oBACpC,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,EAAE;iBACnD;aACF;SACF,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,mCAAmC;YAChD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACpB,WA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