@pipedream/trello 0.3.13 → 0.4.0
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 +9 -10
- package/actions/add-attachment-to-card/add-attachment-to-card.mjs +124 -0
- package/actions/add-checklist/add-checklist.mjs +56 -38
- package/actions/add-comment/add-comment.mjs +44 -34
- package/actions/add-existing-label-to-card/add-existing-label-to-card.mjs +26 -11
- package/actions/add-member-to-card/add-member-to-card.mjs +26 -11
- package/actions/archive-card/archive-card.mjs +13 -7
- package/actions/close-board/close-board.mjs +10 -4
- package/actions/common.mjs +2 -2
- package/actions/complete-checklist-item/complete-checklist-item.mjs +61 -31
- package/actions/create-board/create-board.mjs +96 -61
- package/actions/create-card/create-card.mjs +83 -39
- package/actions/create-checklist/create-checklist.mjs +26 -14
- package/actions/create-checklist-item/create-checklist-item.mjs +64 -39
- package/actions/create-comment-on-card/create-comment-on-card.mjs +26 -9
- package/actions/create-label/create-label.mjs +37 -36
- package/actions/create-list/create-list.mjs +51 -42
- package/actions/delete-checklist/delete-checklist.mjs +24 -11
- package/actions/find-labels/find-labels.mjs +13 -10
- package/actions/find-list/find-list.mjs +12 -9
- package/actions/get-card/get-card.mjs +12 -8
- package/actions/get-list/get-list.mjs +29 -15
- package/actions/move-card-to-list/move-card-to-list.mjs +16 -12
- package/actions/remove-label-from-card/remove-label-from-card.mjs +26 -10
- package/actions/rename-list/rename-list.mjs +23 -9
- package/actions/search-boards/search-boards.mjs +17 -15
- package/actions/search-cards/search-cards.mjs +17 -15
- package/actions/search-checklists/search-checklists.mjs +102 -46
- package/actions/search-members/search-members.mjs +48 -28
- package/actions/update-card/update-card.mjs +64 -47
- package/package.json +5 -5
- package/sources/card-archived/card-archived.mjs +21 -5
- package/sources/card-due-date-reminder/card-due-date-reminder.mjs +31 -30
- package/sources/card-moved/card-moved.mjs +12 -6
- package/sources/card-updates/card-updates.mjs +19 -10
- package/sources/common/common-board-based.mjs +4 -2
- package/sources/common/common-webhook.mjs +63 -20
- package/sources/common/common.mjs +2 -2
- package/sources/custom-webhook-events/custom-webhook-events.mjs +30 -11
- package/sources/new-activity/new-activity.mjs +5 -3
- package/sources/new-attachment/new-attachment.mjs +20 -4
- package/sources/new-board/new-board.mjs +5 -3
- package/sources/new-card/new-card.mjs +19 -10
- package/sources/new-checklist/new-checklist.mjs +15 -3
- package/sources/new-comment-added-to-card/new-comment-added-to-card.mjs +30 -9
- package/sources/new-label/new-label.mjs +7 -3
- package/sources/new-label-added-to-card/new-label-added-to-card.mjs +20 -10
- package/sources/new-list/new-list.mjs +7 -3
- package/sources/new-member-on-card/new-member-on-card.mjs +15 -3
- package/sources/new-notification/new-notification.mjs +15 -5
- package/trello.app.mjs +269 -487
- package/actions/add-attachment-to-card-via-url/add-attachment-to-card-via-url.mjs +0 -73
- package/actions/add-file-as-attachment-via-url/add-file-as-attachment-via-url.mjs +0 -72
- package/actions/add-image-attachment/add-image-attachment.mjs +0 -75
- package/actions/add-label-to-card/add-label-to-card.mjs +0 -55
- package/actions/copy-board/copy-board.mjs +0 -174
- /package/{common → sources/common}/events.mjs +0 -0
@@ -1,3 +1,4 @@
|
|
1
|
+
import { createHmac } from "crypto";
|
1
2
|
import common from "./common.mjs";
|
2
3
|
|
3
4
|
export default {
|
@@ -20,40 +21,68 @@ export default {
|
|
20
21
|
},
|
21
22
|
async activate() {
|
22
23
|
const modelId = await this.getModelId();
|
23
|
-
const { id } = await this.
|
24
|
-
|
25
|
-
|
24
|
+
const { id } = await this.createHook({
|
25
|
+
params: {
|
26
|
+
idModel: modelId,
|
27
|
+
description: "Pipedream Source ID",
|
28
|
+
callbackURL: this.http.endpoint,
|
29
|
+
},
|
26
30
|
});
|
27
31
|
this.db.set("hookId", id);
|
28
32
|
},
|
29
33
|
async deactivate() {
|
30
34
|
const hookId = this.db.get("hookId");
|
31
|
-
await this.
|
35
|
+
await this.deleteHook({
|
32
36
|
hookId,
|
33
37
|
});
|
34
38
|
},
|
35
39
|
},
|
36
40
|
methods: {
|
37
41
|
...common.methods,
|
42
|
+
getBase64Digest(data) {
|
43
|
+
const { secret } = this.app.getToken();
|
44
|
+
return createHmac("sha1", secret)
|
45
|
+
.update(data)
|
46
|
+
.digest("base64");
|
47
|
+
},
|
48
|
+
// Do not remove the async keyword from this function
|
49
|
+
async isValidSignature({
|
50
|
+
body, bodyRaw, headers,
|
51
|
+
}) {
|
52
|
+
const data = bodyRaw + body.webhook?.callbackURL;
|
53
|
+
const doubleHash = this.getBase64Digest(data);
|
54
|
+
const headerHash = headers["x-trello-webhook"];
|
55
|
+
return doubleHash === headerHash;
|
56
|
+
},
|
57
|
+
createHook(args = {}) {
|
58
|
+
return this.app.post({
|
59
|
+
...args,
|
60
|
+
debug: true,
|
61
|
+
path: "/webhooks/",
|
62
|
+
});
|
63
|
+
},
|
64
|
+
deleteHook({
|
65
|
+
hookId, ...args
|
66
|
+
} = {}) {
|
67
|
+
return this.app.delete({
|
68
|
+
...args,
|
69
|
+
debug: true,
|
70
|
+
path: `/webhooks/${hookId}`,
|
71
|
+
});
|
72
|
+
},
|
38
73
|
/**
|
39
74
|
* Returns the ID of the current board selected. If no board is selected, returns
|
40
75
|
* the id of the authenticated user.
|
41
76
|
*/
|
42
77
|
async getModelId() {
|
43
|
-
if (this.board)
|
44
|
-
|
78
|
+
if (this.board) {
|
79
|
+
return this.board;
|
80
|
+
}
|
81
|
+
const member = await this.app.getMember({
|
82
|
+
memberId: "me",
|
83
|
+
});
|
45
84
|
return member.id;
|
46
85
|
},
|
47
|
-
/**
|
48
|
-
* Verifies that the event received was sent from Trello.
|
49
|
-
* @param {object} event - The event returned from a webhook
|
50
|
-
*/
|
51
|
-
verifyEvent(event) {
|
52
|
-
return (
|
53
|
-
this.trello.verifyTrelloWebhookRequest(event, this.http.endpoint) &&
|
54
|
-
event.body !== undefined
|
55
|
-
);
|
56
|
-
},
|
57
86
|
/**
|
58
87
|
* Default isCorrectEventType. Used in components to verify that the event received is
|
59
88
|
* of the type that the component is watching for.
|
@@ -73,17 +102,31 @@ export default {
|
|
73
102
|
},
|
74
103
|
},
|
75
104
|
async run(event) {
|
76
|
-
if (
|
105
|
+
if (event.body === undefined) {
|
106
|
+
console.log("Event body is undefined. Skipping...");
|
107
|
+
return;
|
108
|
+
}
|
109
|
+
|
110
|
+
if (!this.isValidSignature(event)) {
|
77
111
|
console.log("The event failed the verification. Skipping...");
|
78
112
|
return;
|
79
113
|
}
|
80
|
-
|
114
|
+
|
115
|
+
if (!this.isCorrectEventType(event)) {
|
116
|
+
console.log("The event is not of the correct type. Skipping...");
|
117
|
+
return;
|
118
|
+
}
|
81
119
|
|
82
120
|
const result = await this.getResult(event);
|
83
|
-
|
121
|
+
const isRelevant = await this.isRelevant({
|
84
122
|
result,
|
85
123
|
event,
|
86
|
-
})
|
124
|
+
});
|
125
|
+
|
126
|
+
if (!isRelevant) {
|
127
|
+
console.log("The event is not relevant. Skipping...");
|
128
|
+
return;
|
129
|
+
}
|
87
130
|
|
88
131
|
this.emitEvent(result);
|
89
132
|
},
|
@@ -1,29 +1,31 @@
|
|
1
1
|
import common from "../common/common-webhook.mjs";
|
2
|
+
import events from "../common/events.mjs";
|
2
3
|
|
3
4
|
export default {
|
4
5
|
...common,
|
5
6
|
key: "trello-custom-webhook-events",
|
6
7
|
name: "Custom Webhook Events (Instant)",
|
7
8
|
description: "Emit new events for activity matching a board, event types, lists and/or cards.",
|
8
|
-
version: "0.0
|
9
|
+
version: "0.1.0",
|
9
10
|
type: "source",
|
10
11
|
props: {
|
11
12
|
...common.props,
|
12
13
|
board: {
|
13
14
|
propDefinition: [
|
14
|
-
common.props.
|
15
|
+
common.props.app,
|
15
16
|
"board",
|
16
17
|
],
|
17
18
|
},
|
18
19
|
eventTypes: {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
type: "string[]",
|
21
|
+
label: "Event Types",
|
22
|
+
optional: true,
|
23
|
+
description: "Only emit events for the selected event types (e.g., `updateCard`).",
|
24
|
+
options: events,
|
23
25
|
},
|
24
26
|
lists: {
|
25
27
|
propDefinition: [
|
26
|
-
common.props.
|
28
|
+
common.props.app,
|
27
29
|
"lists",
|
28
30
|
(c) => ({
|
29
31
|
board: c.board,
|
@@ -32,7 +34,7 @@ export default {
|
|
32
34
|
},
|
33
35
|
cards: {
|
34
36
|
propDefinition: [
|
35
|
-
common.props.
|
37
|
+
common.props.app,
|
36
38
|
"cards",
|
37
39
|
(c) => ({
|
38
40
|
board: c.board,
|
@@ -58,11 +60,24 @@ export default {
|
|
58
60
|
},
|
59
61
|
methods: {
|
60
62
|
...common.methods,
|
63
|
+
getCardList({
|
64
|
+
cardId, ...args
|
65
|
+
} = {}) {
|
66
|
+
return this.app._makeRequest({
|
67
|
+
path: `/cards/${cardId}/list`,
|
68
|
+
...args,
|
69
|
+
});
|
70
|
+
},
|
61
71
|
async getSampleEvents() {
|
62
72
|
const eventTypes = this.eventTypes && this.eventTypes.length > 0
|
63
73
|
? this.eventTypes.join(",")
|
64
74
|
: null;
|
65
|
-
const actions = await this.
|
75
|
+
const actions = await this.app.getBoardActivity({
|
76
|
+
boardId: this.board,
|
77
|
+
params: {
|
78
|
+
filter: eventTypes,
|
79
|
+
},
|
80
|
+
});
|
66
81
|
return {
|
67
82
|
sampleEvents: actions,
|
68
83
|
sortField: "date",
|
@@ -84,8 +99,12 @@ export default {
|
|
84
99
|
let listId = body.action?.data?.list?.id;
|
85
100
|
const cardId = body.action?.data?.card?.id;
|
86
101
|
// If listId not returned, see if we can get it from the cardId
|
87
|
-
if (cardId && !listId)
|
88
|
-
|
102
|
+
if (cardId && !listId) {
|
103
|
+
const res = await this.app.getCardList({
|
104
|
+
cardId,
|
105
|
+
});
|
106
|
+
listId = res.id;
|
107
|
+
}
|
89
108
|
return (
|
90
109
|
(!this.lists ||
|
91
110
|
this.lists.length === 0 ||
|
@@ -5,13 +5,13 @@ export default {
|
|
5
5
|
key: "trello-new-activity",
|
6
6
|
name: "New Activity (Instant)",
|
7
7
|
description: "Emit new event for new activity on a board.",
|
8
|
-
version: "0.0
|
8
|
+
version: "0.1.0",
|
9
9
|
type: "source",
|
10
10
|
props: {
|
11
11
|
...common.props,
|
12
12
|
board: {
|
13
13
|
propDefinition: [
|
14
|
-
common.props.
|
14
|
+
common.props.app,
|
15
15
|
"board",
|
16
16
|
],
|
17
17
|
},
|
@@ -35,7 +35,9 @@ export default {
|
|
35
35
|
methods: {
|
36
36
|
...common.methods,
|
37
37
|
async getSampleEvents() {
|
38
|
-
const actions = await this.
|
38
|
+
const actions = await this.app.getBoardActivity({
|
39
|
+
boardId: this.board,
|
40
|
+
});
|
39
41
|
return {
|
40
42
|
sampleEvents: actions,
|
41
43
|
sortField: "date",
|
@@ -5,13 +5,13 @@ export default {
|
|
5
5
|
key: "trello-new-attachment",
|
6
6
|
name: "New Attachment (Instant)",
|
7
7
|
description: "Emit new event for new attachment on a board.",
|
8
|
-
version: "0.0
|
8
|
+
version: "0.1.0",
|
9
9
|
type: "source",
|
10
10
|
props: {
|
11
11
|
...common.props,
|
12
12
|
board: {
|
13
13
|
propDefinition: [
|
14
|
-
common.props.
|
14
|
+
common.props.app,
|
15
15
|
"board",
|
16
16
|
],
|
17
17
|
},
|
@@ -36,8 +36,21 @@ export default {
|
|
36
36
|
},
|
37
37
|
methods: {
|
38
38
|
...common.methods,
|
39
|
+
getAttachment({
|
40
|
+
cardId, attachmentId, ...args
|
41
|
+
} = {}) {
|
42
|
+
return this.app._makeRequest({
|
43
|
+
path: `/cards/${cardId}/attachments/${attachmentId}`,
|
44
|
+
...args,
|
45
|
+
});
|
46
|
+
},
|
39
47
|
async getSampleEvents() {
|
40
|
-
const actions = await this.
|
48
|
+
const actions = await this.app.getBoardActivity({
|
49
|
+
boardId: this.board,
|
50
|
+
params: {
|
51
|
+
filter: "addAttachmentToCard",
|
52
|
+
},
|
53
|
+
});
|
41
54
|
return {
|
42
55
|
sampleEvents: actions,
|
43
56
|
sortField: "date",
|
@@ -50,7 +63,10 @@ export default {
|
|
50
63
|
async getResult(event) {
|
51
64
|
const cardId = event.body?.action?.data?.card?.id;
|
52
65
|
const attachmentId = event.body?.action?.data?.attachment?.id;
|
53
|
-
return this.
|
66
|
+
return this.getAttachment({
|
67
|
+
cardId,
|
68
|
+
attachmentId,
|
69
|
+
});
|
54
70
|
},
|
55
71
|
isRelevant({ event }) {
|
56
72
|
const boardId = event.body?.action?.data?.board?.id;
|
@@ -5,13 +5,13 @@ export default {
|
|
5
5
|
key: "trello-new-board",
|
6
6
|
name: "New Board (Instant)",
|
7
7
|
description: "Emit new event for each new board added.",
|
8
|
-
version: "0.0
|
8
|
+
version: "0.1.0",
|
9
9
|
type: "source",
|
10
10
|
dedupe: "unique",
|
11
11
|
methods: {
|
12
12
|
...common.methods,
|
13
13
|
async getSampleEvents() {
|
14
|
-
const boards = await this.
|
14
|
+
const boards = await this.app.getBoards();
|
15
15
|
return {
|
16
16
|
sampleEvents: boards,
|
17
17
|
sortField: "dateLastView",
|
@@ -23,7 +23,9 @@ export default {
|
|
23
23
|
},
|
24
24
|
async getResult(event) {
|
25
25
|
const boardId = event.body?.action?.data?.board?.id;
|
26
|
-
return this.
|
26
|
+
return this.app.getBoard({
|
27
|
+
boardId,
|
28
|
+
});
|
27
29
|
},
|
28
30
|
},
|
29
31
|
};
|
@@ -5,20 +5,20 @@ export default {
|
|
5
5
|
key: "trello-new-card",
|
6
6
|
name: "New Card (Instant)",
|
7
7
|
description: "Emit new event for each new Trello card on a board.",
|
8
|
-
version: "0.0
|
8
|
+
version: "0.1.0",
|
9
9
|
type: "source",
|
10
10
|
dedupe: "unique",
|
11
11
|
props: {
|
12
12
|
...common.props,
|
13
13
|
board: {
|
14
14
|
propDefinition: [
|
15
|
-
common.props.
|
15
|
+
common.props.app,
|
16
16
|
"board",
|
17
17
|
],
|
18
18
|
},
|
19
19
|
lists: {
|
20
20
|
propDefinition: [
|
21
|
-
common.props.
|
21
|
+
common.props.app,
|
22
22
|
"lists",
|
23
23
|
(c) => ({
|
24
24
|
board: c.board,
|
@@ -27,7 +27,7 @@ export default {
|
|
27
27
|
},
|
28
28
|
customFieldItems: {
|
29
29
|
propDefinition: [
|
30
|
-
common.props.
|
30
|
+
common.props.app,
|
31
31
|
"customFieldItems",
|
32
32
|
],
|
33
33
|
},
|
@@ -36,11 +36,17 @@ export default {
|
|
36
36
|
...common.methods,
|
37
37
|
async getSampleEvents() {
|
38
38
|
const cards = this.lists && this.lists.length > 0
|
39
|
-
? await this.
|
40
|
-
|
39
|
+
? await this.app.getCardsInList({
|
40
|
+
listId: this.lists[0],
|
41
|
+
params: {
|
42
|
+
customFieldItems: this.customFieldItems,
|
43
|
+
},
|
41
44
|
})
|
42
|
-
: await this.
|
43
|
-
|
45
|
+
: await this.app.getCards({
|
46
|
+
boardId: this.board,
|
47
|
+
params: {
|
48
|
+
customFieldItems: this.customFieldItems,
|
49
|
+
},
|
44
50
|
});
|
45
51
|
return {
|
46
52
|
sampleEvents: cards,
|
@@ -53,8 +59,11 @@ export default {
|
|
53
59
|
},
|
54
60
|
async getResult(event) {
|
55
61
|
const cardId = event.body?.action?.data?.card?.id;
|
56
|
-
return this.
|
57
|
-
|
62
|
+
return this.app.getCard({
|
63
|
+
cardId,
|
64
|
+
params: {
|
65
|
+
customFieldItems: this.customFieldItems,
|
66
|
+
},
|
58
67
|
});
|
59
68
|
},
|
60
69
|
isRelevant({ result: card }) {
|
@@ -5,13 +5,23 @@ export default {
|
|
5
5
|
key: "trello-new-checklist",
|
6
6
|
name: "New Checklist (Instant)",
|
7
7
|
description: "Emit new event for each new checklist added to a board.",
|
8
|
-
version: "0.0
|
8
|
+
version: "0.1.0",
|
9
9
|
type: "source",
|
10
10
|
dedupe: "unique",
|
11
11
|
methods: {
|
12
12
|
...common.methods,
|
13
|
+
getChecklist({
|
14
|
+
checklistId, ...args
|
15
|
+
} = {}) {
|
16
|
+
return this.app._makeRequest({
|
17
|
+
path: `/checklists/${checklistId}`,
|
18
|
+
...args,
|
19
|
+
});
|
20
|
+
},
|
13
21
|
async getSampleEvents() {
|
14
|
-
const checklists = await this.
|
22
|
+
const checklists = await this.app.listBoardChecklists({
|
23
|
+
boardId: this.board,
|
24
|
+
});
|
15
25
|
return {
|
16
26
|
sampleEvents: checklists,
|
17
27
|
sortField: "id",
|
@@ -23,7 +33,9 @@ export default {
|
|
23
33
|
},
|
24
34
|
async getResult(event) {
|
25
35
|
const checklistId = event.body?.action?.data?.checklist?.id;
|
26
|
-
return this.
|
36
|
+
return this.getChecklist({
|
37
|
+
checklistId,
|
38
|
+
});
|
27
39
|
},
|
28
40
|
},
|
29
41
|
};
|
@@ -5,20 +5,20 @@ export default {
|
|
5
5
|
key: "trello-new-comment-added-to-card",
|
6
6
|
name: "New Comment Added to Card (Instant)",
|
7
7
|
description: "Emit new event for each new comment added to a card.",
|
8
|
-
version: "0.
|
8
|
+
version: "0.2.0",
|
9
9
|
type: "source",
|
10
10
|
dedupe: "unique",
|
11
11
|
props: {
|
12
12
|
...common.props,
|
13
13
|
board: {
|
14
14
|
propDefinition: [
|
15
|
-
common.props.
|
15
|
+
common.props.app,
|
16
16
|
"board",
|
17
17
|
],
|
18
18
|
},
|
19
19
|
cards: {
|
20
20
|
propDefinition: [
|
21
|
-
common.props.
|
21
|
+
common.props.app,
|
22
22
|
"cards",
|
23
23
|
(c) => ({
|
24
24
|
board: c.board,
|
@@ -42,13 +42,28 @@ export default {
|
|
42
42
|
},
|
43
43
|
methods: {
|
44
44
|
...common.methods,
|
45
|
+
getCardActivity({
|
46
|
+
cardId, ...args
|
47
|
+
} = {}) {
|
48
|
+
return this.app._makeRequest({
|
49
|
+
path: `/cards/${cardId}/actions`,
|
50
|
+
...args,
|
51
|
+
});
|
52
|
+
},
|
45
53
|
async getSampleEvents() {
|
46
54
|
const cards = this.cards && this.cards.length > 0
|
47
55
|
? this.cards
|
48
|
-
: (await this.
|
56
|
+
: (await this.app.getCards({
|
57
|
+
boardId: this.board,
|
58
|
+
})).map((card) => card.id);
|
49
59
|
const actions = [];
|
50
60
|
for (const card of cards) {
|
51
|
-
const activities = await this.
|
61
|
+
const activities = await this.getCardActivity({
|
62
|
+
cardId: card,
|
63
|
+
params: {
|
64
|
+
filter: "commentCard",
|
65
|
+
},
|
66
|
+
});
|
52
67
|
|
53
68
|
for (const activity of activities) {
|
54
69
|
actions.push(await this.getResult(activity));
|
@@ -64,10 +79,16 @@ export default {
|
|
64
79
|
return eventType === "commentCard";
|
65
80
|
},
|
66
81
|
async getResult(event) {
|
67
|
-
const
|
68
|
-
|
69
|
-
const
|
70
|
-
|
82
|
+
const cardId = event?.body?.action?.data?.card?.id ??
|
83
|
+
event?.data?.card?.id;
|
84
|
+
const card = await this.app.getCard({
|
85
|
+
cardId,
|
86
|
+
});
|
87
|
+
const memberId = event?.body?.action?.idMemberCreator ??
|
88
|
+
event.idMemberCreator;
|
89
|
+
const member = await this.app.getMember({
|
90
|
+
memberId,
|
91
|
+
});
|
71
92
|
|
72
93
|
return {
|
73
94
|
member,
|
@@ -5,13 +5,15 @@ export default {
|
|
5
5
|
key: "trello-new-label",
|
6
6
|
name: "New Label (Instant)",
|
7
7
|
description: "Emit new event for each new label added to a board.",
|
8
|
-
version: "0.0
|
8
|
+
version: "0.1.0",
|
9
9
|
type: "source",
|
10
10
|
dedupe: "unique",
|
11
11
|
methods: {
|
12
12
|
...common.methods,
|
13
13
|
async getSampleEvents() {
|
14
|
-
const labels = await this.
|
14
|
+
const labels = await this.app.findLabel({
|
15
|
+
boardId: this.board,
|
16
|
+
});
|
15
17
|
return {
|
16
18
|
sampleEvents: labels,
|
17
19
|
sortField: "id",
|
@@ -23,7 +25,9 @@ export default {
|
|
23
25
|
},
|
24
26
|
async getResult(event) {
|
25
27
|
const labelId = event.body?.action?.data?.label?.id;
|
26
|
-
return this.
|
28
|
+
return this.app.getLabel({
|
29
|
+
labelId,
|
30
|
+
});
|
27
31
|
},
|
28
32
|
generateMeta({
|
29
33
|
id, name, color: summary,
|
@@ -5,19 +5,19 @@ export default {
|
|
5
5
|
key: "trello-new-label-added-to-card",
|
6
6
|
name: "New Label Added To Card (Instant)",
|
7
7
|
description: "Emit new event for each label added to a card.",
|
8
|
-
version: "0.0
|
8
|
+
version: "0.1.0",
|
9
9
|
type: "source",
|
10
10
|
props: {
|
11
11
|
...common.props,
|
12
12
|
board: {
|
13
13
|
propDefinition: [
|
14
|
-
common.props.
|
14
|
+
common.props.app,
|
15
15
|
"board",
|
16
16
|
],
|
17
17
|
},
|
18
18
|
lists: {
|
19
19
|
propDefinition: [
|
20
|
-
common.props.
|
20
|
+
common.props.app,
|
21
21
|
"lists",
|
22
22
|
(c) => ({
|
23
23
|
board: c.board,
|
@@ -26,7 +26,7 @@ export default {
|
|
26
26
|
},
|
27
27
|
cards: {
|
28
28
|
propDefinition: [
|
29
|
-
common.props.
|
29
|
+
common.props.app,
|
30
30
|
"cards",
|
31
31
|
(c) => ({
|
32
32
|
board: c.board,
|
@@ -43,12 +43,16 @@ export default {
|
|
43
43
|
}
|
44
44
|
if (this.lists && this.lists.length > 0) {
|
45
45
|
for (const listId of this.lists) {
|
46
|
-
const cards = await this.
|
46
|
+
const cards = await this.app.getCardsInList({
|
47
|
+
listId,
|
48
|
+
});
|
47
49
|
await this.emitLabelsFromCards(cards);
|
48
50
|
}
|
49
51
|
return;
|
50
52
|
}
|
51
|
-
const cards = await this.
|
53
|
+
const cards = await this.app.getCards({
|
54
|
+
boardId: this.board,
|
55
|
+
});
|
52
56
|
await this.emitLabelsFromCards(cards);
|
53
57
|
},
|
54
58
|
},
|
@@ -58,7 +62,9 @@ export default {
|
|
58
62
|
for (const card of cards) {
|
59
63
|
const labelIds = card.idLabels;
|
60
64
|
for (const labelId of labelIds) {
|
61
|
-
const label = await this.
|
65
|
+
const label = await this.app.getLabel({
|
66
|
+
labelId,
|
67
|
+
});
|
62
68
|
let summary = label.color;
|
63
69
|
summary += label.name
|
64
70
|
? ` - ${label.name}`
|
@@ -74,8 +80,10 @@ export default {
|
|
74
80
|
},
|
75
81
|
async emitLabelsFromCardIds(cardIds) {
|
76
82
|
const cards = [];
|
77
|
-
for (const
|
78
|
-
const card = await this.
|
83
|
+
for (const cardId of cardIds) {
|
84
|
+
const card = await this.app.getCard({
|
85
|
+
cardId,
|
86
|
+
});
|
79
87
|
cards.push(card);
|
80
88
|
}
|
81
89
|
await this.emitLabelsFromCards(cards);
|
@@ -103,7 +111,9 @@ export default {
|
|
103
111
|
/** Record labelName & labelColor to use in generateMeta() */
|
104
112
|
this._setLabelName(labelName);
|
105
113
|
this._setLabelColor(labelColor);
|
106
|
-
return this.
|
114
|
+
return this.app.getCard({
|
115
|
+
cardId,
|
116
|
+
});
|
107
117
|
},
|
108
118
|
isRelevant({ result: card }) {
|
109
119
|
return (
|
@@ -5,13 +5,15 @@ export default {
|
|
5
5
|
key: "trello-new-list",
|
6
6
|
name: "New List (Instant)",
|
7
7
|
description: "Emit new event for each new list added to a board.",
|
8
|
-
version: "0.0
|
8
|
+
version: "0.1.0",
|
9
9
|
type: "source",
|
10
10
|
dedupe: "unique",
|
11
11
|
methods: {
|
12
12
|
...common.methods,
|
13
13
|
async getSampleEvents() {
|
14
|
-
const lists = await this.
|
14
|
+
const lists = await this.app.getLists({
|
15
|
+
boardId: this.board,
|
16
|
+
});
|
15
17
|
return {
|
16
18
|
sampleEvents: lists,
|
17
19
|
sortField: "id",
|
@@ -23,7 +25,9 @@ export default {
|
|
23
25
|
},
|
24
26
|
async getResult(event) {
|
25
27
|
const listId = event.body?.action?.data?.list?.id;
|
26
|
-
return await this.
|
28
|
+
return await this.app.getList({
|
29
|
+
listId,
|
30
|
+
});
|
27
31
|
},
|
28
32
|
},
|
29
33
|
};
|
@@ -5,13 +5,23 @@ export default {
|
|
5
5
|
key: "trello-new-member-on-card",
|
6
6
|
name: "New Member on Card (Instant)",
|
7
7
|
description: "Emit new event for each member that join in a card.",
|
8
|
-
version: "0.0
|
8
|
+
version: "0.1.0",
|
9
9
|
type: "source",
|
10
10
|
dedupe: "unique",
|
11
11
|
methods: {
|
12
12
|
...common.methods,
|
13
|
+
getMemberCards({
|
14
|
+
userId, ...args
|
15
|
+
} = {}) {
|
16
|
+
return this.app._makeRequest({
|
17
|
+
path: `/members/${userId}/cards`,
|
18
|
+
...args,
|
19
|
+
});
|
20
|
+
},
|
13
21
|
async getSampleEvents() {
|
14
|
-
const cards = await this.
|
22
|
+
const cards = await this.getMemberCards({
|
23
|
+
userId: "me",
|
24
|
+
});
|
15
25
|
return {
|
16
26
|
sampleEvents: cards,
|
17
27
|
sortField: "dateLastActivity",
|
@@ -23,7 +33,9 @@ export default {
|
|
23
33
|
},
|
24
34
|
async getResult(event) {
|
25
35
|
const cardId = event.body?.action?.data?.card?.id;
|
26
|
-
return this.
|
36
|
+
return this.app.getCard({
|
37
|
+
cardId,
|
38
|
+
});
|
27
39
|
},
|
28
40
|
generateMeta({
|
29
41
|
id, name: summary, dateLastActivity,
|