Skip to content

Commit dece727

Browse files
authored
Canny - new components (#19474)
* wip * new components * move options to constants file * update
1 parent 85624cc commit dece727

File tree

12 files changed

+865
-5
lines changed

12 files changed

+865
-5
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import canny from "../../canny.app.mjs";
2+
import { POST_STATUSES } from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "canny-change-post-status",
6+
name: "Change Post Status",
7+
description: "Change the status of a post. [See the documentation](https://developers.canny.io/api-reference#change_post_status)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: false,
14+
},
15+
props: {
16+
canny,
17+
boardId: {
18+
propDefinition: [
19+
canny,
20+
"boardId",
21+
],
22+
optional: true,
23+
},
24+
postId: {
25+
propDefinition: [
26+
canny,
27+
"postId",
28+
(c) => ({
29+
boardId: c.boardId,
30+
}),
31+
],
32+
},
33+
changerId: {
34+
propDefinition: [
35+
canny,
36+
"userId",
37+
],
38+
label: "Changer ID",
39+
description: "The identifier of the admin to record as having changed the post's status",
40+
},
41+
shouldNotifyVoters: {
42+
type: "boolean",
43+
label: "Should Notify Voters",
44+
description: "Whether or not to notify non-admin voters of the status change",
45+
},
46+
status: {
47+
type: "string",
48+
label: "Status",
49+
description: "The new status of the post",
50+
options: POST_STATUSES,
51+
},
52+
},
53+
async run({ $ }) {
54+
const response = await this.canny.updatePostStatus({
55+
$,
56+
data: {
57+
postID: this.postId,
58+
changerID: this.changerId,
59+
shouldNotifyVoters: this.shouldNotifyVoters,
60+
status: this.status,
61+
},
62+
});
63+
$.export("$summary", `Successfully changed the status of post ${this.postId} to ${this.status}`);
64+
return response;
65+
},
66+
};
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import canny from "../../canny.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "canny-create-comment",
6+
name: "Create Comment",
7+
description: "Create a comment. [See the documentation](https://developers.canny.io/api-reference#create_comment)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: false,
14+
},
15+
props: {
16+
canny,
17+
authorId: {
18+
propDefinition: [
19+
canny,
20+
"userId",
21+
],
22+
label: "Author ID",
23+
description: "The ID of the author of the comment",
24+
},
25+
postId: {
26+
propDefinition: [
27+
canny,
28+
"postId",
29+
],
30+
description: "The ID of the post to comment on",
31+
},
32+
value: {
33+
type: "string",
34+
label: "Value",
35+
description: "The comment value. Optional if imageURLs are provided. Must be under 2500 characters.",
36+
optional: true,
37+
},
38+
imageUrls: {
39+
type: "string[]",
40+
label: "Image URLs",
41+
description: "An array of the URLs of comment's images",
42+
optional: true,
43+
},
44+
parentId: {
45+
propDefinition: [
46+
canny,
47+
"commentId",
48+
],
49+
label: "Parent ID",
50+
description: "The ID of the parent comment",
51+
optional: true,
52+
},
53+
shouldNotifyVoters: {
54+
type: "boolean",
55+
label: "Should Notify Voters",
56+
description: "Whether this comment should be allowed to trigger email notifications. Default is false.",
57+
optional: true,
58+
},
59+
},
60+
async run({ $ }) {
61+
if (!this.value && !this.imageUrls) {
62+
throw new ConfigurationError("Either value or imageUrls must be provided");
63+
}
64+
65+
const response = await this.canny.createComment({
66+
$,
67+
data: {
68+
authorID: this.authorId,
69+
postID: this.postId,
70+
value: this.value,
71+
imageURLs: this.imageUrls,
72+
parentID: this.parentId,
73+
shouldNotifyVoters: this.shouldNotifyVoters,
74+
},
75+
});
76+
$.export("$summary", `Successfully created comment with ID ${response.id}`);
77+
return response;
78+
},
79+
};
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import canny from "../../canny.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "canny-create-post",
6+
name: "Create Post",
7+
description: "Create a post. [See the documentation](https://developers.canny.io/api-reference#create_post)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: false,
14+
},
15+
props: {
16+
canny,
17+
authorId: {
18+
propDefinition: [
19+
canny,
20+
"userId",
21+
],
22+
label: "Author ID",
23+
description: "The ID of the author of the post",
24+
},
25+
boardId: {
26+
propDefinition: [
27+
canny,
28+
"boardId",
29+
],
30+
},
31+
title: {
32+
type: "string",
33+
label: "Title",
34+
description: "The title of the post",
35+
},
36+
details: {
37+
type: "string",
38+
label: "Details",
39+
description: "The details of the post",
40+
},
41+
categoryId: {
42+
propDefinition: [
43+
canny,
44+
"categoryId",
45+
],
46+
optional: true,
47+
},
48+
eta: {
49+
type: "string",
50+
label: "ETA",
51+
description: "The estimated date of the post's completion. In the format of MM/YYYY, eg, 06/2022.",
52+
optional: true,
53+
},
54+
etaPublic: {
55+
type: "boolean",
56+
label: "ETA Public",
57+
description: "If the ETA should be made visible to all users",
58+
optional: true,
59+
},
60+
ownerId: {
61+
propDefinition: [
62+
canny,
63+
"userId",
64+
],
65+
label: "Owner ID",
66+
description: "The ID of the user responsible for the completion of the work described in the post",
67+
optional: true,
68+
},
69+
imageUrls: {
70+
type: "string[]",
71+
label: "Image URLs",
72+
description: "An array of the URLs of post's images",
73+
optional: true,
74+
},
75+
customFields: {
76+
type: "object",
77+
label: "Custom Fields",
78+
description: "Any custom fields associated with the post. Each field name (key) must be between 0 and 30 characters long. If field values are strings, they must be less than 200 characters long.",
79+
optional: true,
80+
},
81+
},
82+
async run({ $ }) {
83+
const response = await this.canny.createPost({
84+
$,
85+
data: {
86+
authorID: this.authorId,
87+
boardID: this.boardId,
88+
title: this.title,
89+
categoryID: this.categoryId,
90+
details: this.details,
91+
eta: this.eta,
92+
etaPublic: this.etaPublic,
93+
ownerID: this.ownerId,
94+
imageURLs: this.imageUrls,
95+
customFields: parseObject(this.customFields),
96+
},
97+
});
98+
$.export("$summary", `Successfully created a post with ID ${response.id}`);
99+
return response;
100+
},
101+
};
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import canny from "../../canny.app.mjs";
2+
3+
export default {
4+
key: "canny-get-post",
5+
name: "Get Post",
6+
description: "Get a post. [See the documentation](https://developers.canny.io/api-reference#retrieve_post)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
canny,
16+
boardId: {
17+
propDefinition: [
18+
canny,
19+
"boardId",
20+
],
21+
optional: true,
22+
},
23+
postId: {
24+
propDefinition: [
25+
canny,
26+
"postId",
27+
(c) => ({
28+
boardId: c.boardId,
29+
}),
30+
],
31+
optional: true,
32+
},
33+
urlName: {
34+
type: "string",
35+
label: "URL Name",
36+
description: "The post's unique urlName",
37+
optional: true,
38+
},
39+
},
40+
async run({ $ }) {
41+
const response = await this.canny.getPost({
42+
$,
43+
data: {
44+
boardID: this.boardId,
45+
urlName: this.urlName,
46+
id: this.postId,
47+
},
48+
});
49+
$.export("$summary", `Successfully retrieved post ${this.postId}`);
50+
return response;
51+
},
52+
};

0 commit comments

Comments
 (0)