Skip to content

Commit b2c012e

Browse files
committed
[FEATURE] New Trello action
1 parent dae0a6a commit b2c012e

File tree

3 files changed

+214
-10
lines changed

3 files changed

+214
-10
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
import common from "../common/common.mjs";
2+
import fields from "../../common/fields.mjs";
3+
4+
export default {
5+
...common,
6+
key: "trello-get-board",
7+
name: "Get Board",
8+
description: "Request a single board. [See the documentation](https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-get).",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
...common.props,
13+
boardId: {
14+
propDefinition: [
15+
common.props.app,
16+
"board",
17+
],
18+
label: "Board ID",
19+
description: "The ID of the board to retrieve",
20+
},
21+
actions: {
22+
propDefinition: [
23+
common.props.app,
24+
"actions",
25+
],
26+
},
27+
boardStars: {
28+
type: "string",
29+
label: "Board Stars",
30+
description: "Valid values are one of: `mine` or `none`. Default is `none`.",
31+
options: [
32+
"mine",
33+
"none",
34+
],
35+
optional: true,
36+
},
37+
cardPluginData: {
38+
type: "boolean",
39+
label: "Card Plugin Data",
40+
description: "Use with the cards param to include card pluginData with the response. Default is `none`.",
41+
optional: true,
42+
},
43+
customFields: {
44+
type: "boolean",
45+
label: "Custom Fields",
46+
description: "This is a nested resource. Include custom fields in the response.",
47+
default: false,
48+
optional: true,
49+
},
50+
fields: {
51+
type: "string[]",
52+
label: "Fields",
53+
description: "The fields of the board to be included in the response. Valid values: all or a comma-separated list of specific fields.",
54+
options: fields.board,
55+
optional: true,
56+
},
57+
labels: {
58+
type: "string",
59+
label: "Labels",
60+
description: "This is a nested resource. Specify what labels to include in the response. One of: `all` or `none`",
61+
optional: true,
62+
options: [
63+
"all",
64+
"none",
65+
],
66+
},
67+
lists: {
68+
description: "This is a nested resource. Specify what lists to include in the response.",
69+
propDefinition: [
70+
common.props.app,
71+
"lists",
72+
({ boardId }) => ({
73+
board: boardId,
74+
}),
75+
],
76+
},
77+
members: {
78+
propDefinition: [
79+
common.props.app,
80+
"members",
81+
({ boardId }) => ({
82+
boardId,
83+
}),
84+
],
85+
},
86+
pluginData: {
87+
type: "boolean",
88+
label: "Plugin Data",
89+
description: "Determines whether the pluginData for this board should be returned.",
90+
optional: true,
91+
},
92+
organization: {
93+
type: "boolean",
94+
label: "Organization",
95+
description: "This is a nested resource. Include organization information in the response.",
96+
optional: true,
97+
},
98+
organizationPluginData: {
99+
type: "boolean",
100+
label: "Organization Plugin Data",
101+
description: "Use with the organization param to include organization pluginData with the response",
102+
optional: true,
103+
},
104+
myPrefs: {
105+
type: "boolean",
106+
label: "My Preferences",
107+
description: "Include the user's preferences for this board in the response.",
108+
optional: true,
109+
},
110+
tags: {
111+
type: "boolean",
112+
label: "Tags",
113+
description: "Also known as collections, tags, refer to the collection(s) that a Board belongs to.",
114+
optional: true,
115+
},
116+
},
117+
methods: {
118+
getCommaSeparatedString(array) {
119+
return Array.isArray(array)
120+
? array.join(",")
121+
: array;
122+
},
123+
},
124+
async run({ $ }) {
125+
const {
126+
app,
127+
getCommaSeparatedString,
128+
boardId,
129+
actions,
130+
boardStars,
131+
cardPluginData,
132+
customFields,
133+
fields,
134+
labels,
135+
lists,
136+
members,
137+
pluginData,
138+
organization,
139+
organizationPluginData,
140+
myPrefs,
141+
tags,
142+
} = this;
143+
144+
const response = await app.getBoard({
145+
$,
146+
boardId,
147+
params: {
148+
actions: getCommaSeparatedString(actions),
149+
boardStars,
150+
card_pluginData: cardPluginData,
151+
customFields,
152+
fields: getCommaSeparatedString(fields),
153+
labels: getCommaSeparatedString(labels),
154+
lists: getCommaSeparatedString(lists),
155+
members: getCommaSeparatedString(members),
156+
pluginData,
157+
organization,
158+
organizationPluginData,
159+
myPrefs,
160+
tags,
161+
},
162+
});
163+
164+
$.export("$summary", `Successfully retrieved board with ID \`${response.id}\``);
165+
return response;
166+
},
167+
};

components/trello/trello.app.mjs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { axios } from "@pipedream/platform";
22
import fields from "./common/fields.mjs";
33
import constants from "./common/constants.mjs";
44
import mime from "mime/types/standard.js";
5+
import actions from "./sources/common/actions.mjs";
56

67
export default {
78
type: "app",
@@ -338,6 +339,48 @@ export default {
338339
"url",
339340
],
340341
},
342+
actions: {
343+
type: "string[]",
344+
label: "Actions",
345+
description: "This is a nested resource. Specify what actions to include in the response. Default is `all`.",
346+
optional: true,
347+
options: actions,
348+
},
349+
labels: {
350+
type: "string[]",
351+
label: "Labels",
352+
description: "This is a nested resource. Specify what labels to include in the response.",
353+
optional: true,
354+
async options({ boardId }) {
355+
if (!boardId) {
356+
return [];
357+
}
358+
const labels = await this.findLabel({
359+
boardId,
360+
});
361+
return labels.map(({ name }) => name);
362+
},
363+
},
364+
members: {
365+
type: "string[]",
366+
label: "Members",
367+
description: "This is a nested resource. Specify what members to include in the response.",
368+
optional: true,
369+
async options({ boardId }) {
370+
if (!boardId) {
371+
return [];
372+
}
373+
const members = await this.listMembers({
374+
boardId,
375+
});
376+
return members.map(({
377+
fullName: label, id: value,
378+
}) => ({
379+
label,
380+
value,
381+
}));
382+
},
383+
},
341384
},
342385
methods: {
343386
getSignerUri() {

pnpm-lock.yaml

Lines changed: 4 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)