Skip to content

Commit ee41efb

Browse files
committed
refactoring
1 parent 6844354 commit ee41efb

File tree

31 files changed

+262
-233
lines changed

31 files changed

+262
-233
lines changed

components/trello/actions/add-attachment-to-card/add-attachment-to-card.mjs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ConfigurationError } from "@pipedream/platform";
22
import fs from "fs";
33
import FormData from "form-data";
4-
import common from "../common.mjs";
4+
import common from "../common/common.mjs";
55

66
export default {
77
...common,
@@ -62,20 +62,8 @@ export default {
6262
default: false,
6363
},
6464
},
65-
methods: {
66-
...common.methods,
67-
addAttachmentToCard({
68-
cardId, ...args
69-
} = {}) {
70-
return this.app.post({
71-
path: `/cards/${cardId}/attachments`,
72-
...args,
73-
});
74-
},
75-
},
7665
async run({ $ }) {
7766
const {
78-
addAttachmentToCard,
7967
cardId,
8068
name,
8169
url,
@@ -99,7 +87,7 @@ export default {
9987
const form = new FormData();
10088
form.append("file", fs.createReadStream(file));
10189

102-
response = await addAttachmentToCard({
90+
response = await this.app.addAttachmentToCard({
10391
$,
10492
cardId,
10593
params,
@@ -108,7 +96,7 @@ export default {
10896
});
10997

11098
} else {
111-
response = await addAttachmentToCard({
99+
response = await this.app.addAttachmentToCard({
112100
$,
113101
cardId,
114102
params: {

components/trello/actions/add-checklist/add-checklist.mjs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import app from "../../trello.app.mjs";
22

33
export default {
44
key: "trello-add-checklist",
5-
name: "Create a Checklist",
5+
name: "Add Checklist",
66
description: "Adds a new checklist to a card. [See the documentation](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-checklists-post).",
77
version: "0.2.0",
88
type: "action",
@@ -44,32 +44,21 @@ export default {
4444
],
4545
},
4646
pos: {
47-
type: "string",
48-
label: "Position",
49-
description: "The position of the checklist on the card. One of: top, bottom, or a positive number.",
50-
optional: true,
51-
},
52-
},
53-
methods: {
54-
addChecklist({
55-
cardId, ...args
56-
} = {}) {
57-
return this.app.post({
58-
path: `/cards/${cardId}/checklists`,
59-
...args,
60-
});
47+
propDefinition: [
48+
app,
49+
"pos",
50+
],
6151
},
6252
},
6353
async run({ $ }) {
6454
const {
65-
addChecklist,
6655
cardId,
6756
name,
6857
idChecklistSource,
6958
pos,
7059
} = this;
7160

72-
const response = await addChecklist({
61+
const response = await this.app.addChecklist({
7362
$,
7463
cardId,
7564
params: {
@@ -79,7 +68,7 @@ export default {
7968
},
8069
});
8170

82-
$.export("$summary", "Successfully added checklist.");
71+
$.export("$summary", `Successfully added checklist with ID: ${response.id}`);
8372

8473
return response;
8574
},

components/trello/actions/add-comment/add-comment.mjs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import app from "../../trello.app.mjs";
22

33
export default {
44
key: "trello-add-comment",
5-
name: "Create a Comment",
5+
name: "Add Comment",
66
description: "Create a new comment on a specific card. [See the documentation](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-actions-comments-post).",
77
version: "0.2.0",
88
type: "action",
@@ -45,20 +45,19 @@ export default {
4545
},
4646
async run({ $ }) {
4747
const {
48-
addComment,
4948
cardId,
5049
text,
5150
} = this;
5251

53-
const response = await addComment({
52+
const response = await this.app.addComment({
5453
$,
5554
cardId,
5655
params: {
5756
text,
5857
},
5958
});
6059

61-
$.export("$summary", "Successfully added comment.");
60+
$.export("$summary", `Successfully added comment with ID: ${response.id}`);
6261

6362
return response;
6463
},

components/trello/actions/add-existing-label-to-card/add-existing-label-to-card.mjs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import common from "../common.mjs";
1+
import common from "../common/common.mjs";
22

33
export default {
44
...common,
@@ -38,19 +38,8 @@ export default {
3838
],
3939
},
4040
},
41-
methods: {
42-
...common.methods,
43-
addExistingLabelToCard({
44-
cardId, ...args
45-
} = {}) {
46-
return this.app.post({
47-
path: `/cards/${cardId}/idLabels`,
48-
...args,
49-
});
50-
},
51-
},
5241
async run({ $ }) {
53-
const res = await this.addExistingLabelToCard({
42+
const res = await this.app.addExistingLabelToCard({
5443
$,
5544
cardId: this.cardId,
5645
params: {

components/trello/actions/add-member-to-card/add-member-to-card.mjs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import common from "../common.mjs";
1+
import common from "../common/common.mjs";
22

33
export default {
44
...common,
@@ -38,19 +38,8 @@ export default {
3838
],
3939
},
4040
},
41-
methods: {
42-
...common.methods,
43-
addMemberToCard({
44-
cardId, ...args
45-
} = {}) {
46-
return this.app.post({
47-
path: `/cards/${cardId}/idMembers`,
48-
...args,
49-
});
50-
},
51-
},
5241
async run({ $ }) {
53-
const res = await this.addMemberToCard({
42+
const res = await this.app.addMemberToCard({
5443
$,
5544
cardId: this.cardId,
5645
params: {

components/trello/actions/archive-card/archive-card.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import common from "../common.mjs";
1+
import common from "../common/common.mjs";
22

33
export default {
44
...common,

components/trello/actions/close-board/close-board.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import common from "../common.mjs";
1+
import common from "../common/common.mjs";
22

33
export default {
44
...common,

components/trello/actions/common.mjs renamed to components/trello/actions/common/common.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import app from "../trello.app.mjs";
1+
import app from "../../trello.app.mjs";
22

33
export default {
44
props: {

components/trello/actions/complete-checklist-item/complete-checklist-item.mjs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,13 @@ export default {
4646
],
4747
},
4848
},
49-
methods: {
50-
completeChecklistItem({
51-
cardId, checklistItemId, ...args
52-
} = {}) {
53-
return this.app.put({
54-
path: `/cards/${cardId}/checkItem/${checklistItemId}`,
55-
...args,
56-
});
57-
},
58-
},
5949
async run({ $ }) {
6050
const {
61-
completeChecklistItem,
6251
cardId,
6352
checklistItemId,
6453
} = this;
6554

66-
const response = await completeChecklistItem({
55+
const response = await this.app.completeChecklistItem({
6756
$,
6857
cardId,
6958
checklistItemId,
@@ -72,7 +61,7 @@ export default {
7261
},
7362
});
7463

75-
$.export("$summary", "Successfully completed checklist item.");
64+
$.export("$summary", `Successfully completed checklist item with ID: ${checklistItemId}`);
7665

7766
return response;
7867
},

components/trello/actions/create-board/create-board.mjs

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import app from "../../trello.app.mjs";
2+
import constants from "../../common/constants.mjs";
23

34
export default {
45
key: "trello-create-board",
@@ -22,7 +23,7 @@ export default {
2223
defaultLists: {
2324
type: "boolean",
2425
label: "Default Lists",
25-
description: "Determines whether to add the default set of lists to a board (To Do, Doing, Done). It is ignored if idBoardSource is provided.",
26+
description: "Determines whether to add the default set of lists to a board (To Do, Doing, Done). It is ignored if ***Board Source ID*** is provided.",
2627
optional: true,
2728
},
2829
desc: {
@@ -53,7 +54,7 @@ export default {
5354
keepFromSource: {
5455
type: "string",
5556
label: "Keep From Source",
56-
description: "To keep cards from the original board pass in the value `cards`.",
57+
description: "To keep cards from the original board, pass in the value `cards`.",
5758
optional: true,
5859
options: [
5960
"none",
@@ -65,60 +66,35 @@ export default {
6566
label: "Power-Ups",
6667
description: "The Power-Ups that should be enabled on the new board. One of: `all`, `calendar`, `cardAging`, `recap`, `voting`.",
6768
optional: true,
68-
options: [
69-
"all",
70-
"calendar",
71-
"cardAging",
72-
"recap",
73-
"voting",
74-
],
69+
options: constants.POWER_UPS,
7570
},
7671
prefsPermissionLevel: {
7772
type: "string",
7873
description: "The permissions level of the board. One of: org, private, public.",
7974
label: "Prefs Permission Level",
8075
optional: true,
81-
options: [
82-
"org",
83-
"private",
84-
"public",
85-
],
76+
options: constants.PREFS_PERMISSION_LEVELS,
8677
},
8778
prefsVoting: {
8879
type: "string",
8980
label: "Prefs Voting",
9081
description: "Who can vote on this board. One of disabled, members, observers, org, public.",
9182
optional: true,
92-
options: [
93-
"disabled",
94-
"members",
95-
"observers",
96-
"org",
97-
"public",
98-
],
83+
options: constants.PREFS_VOTING,
9984
},
10085
prefsComments: {
10186
type: "string",
10287
label: "Prefs Comments",
10388
description: "Who can comment on cards on this board. One of: disabled, members, observers, org, public.",
10489
optional: true,
105-
options: [
106-
"disabled",
107-
"members",
108-
"observers",
109-
"org",
110-
"public",
111-
],
90+
options: constants.PREFS_COMMENTS,
11291
},
11392
prefsInvitations: {
11493
type: "string",
11594
label: "Prefs Invitations",
11695
description: "Determines what types of members can invite users to join. One of: admins, members.",
11796
optional: true,
118-
options: [
119-
"admins",
120-
"members",
121-
],
97+
options: constants.PREFS_INVITATIONS,
12298
},
12399
prefsSelfJoin: {
124100
type: "boolean",
@@ -137,27 +113,14 @@ export default {
137113
label: "Prefs Background",
138114
description: "The id of a custom background or one of: `blue`, `orange`, `green`, `red`, `purple`, `pink`, `lime`, `sky`, `grey`.",
139115
optional: true,
140-
options: [
141-
"blue",
142-
"orange",
143-
"green",
144-
"red",
145-
"purple",
146-
"pink",
147-
"lime",
148-
"sky",
149-
"grey",
150-
],
116+
options: constants.PREFS_BACKGROUNDS,
151117
},
152118
prefsCardAging: {
153119
type: "string",
154120
label: "Prefs Card Aging",
155121
description: "Determines the type of card aging that should take place on the board if card aging is enabled. One of: pirate, regular.",
156122
optional: true,
157-
options: [
158-
"pirate",
159-
"regular",
160-
],
123+
options: constants.PREFS_CARD_AGING,
161124
},
162125
},
163126
async run({ $ }) {

0 commit comments

Comments
 (0)