@pipedream/trello 0.3.14 → 0.4.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/actions/add-attachment-to-card/add-attachment-to-card.mjs +131 -0
- package/actions/add-checklist/add-checklist.mjs +50 -42
- package/actions/add-comment/add-comment.mjs +44 -35
- package/actions/add-existing-label-to-card/add-existing-label-to-card.mjs +19 -14
- package/actions/add-member-to-card/add-member-to-card.mjs +19 -14
- package/actions/archive-card/archive-card.mjs +15 -10
- package/actions/{common.mjs → common/common.mjs} +2 -2
- package/actions/complete-checklist-item/complete-checklist-item.mjs +51 -31
- package/actions/create-board/create-board.mjs +86 -88
- package/actions/create-card/create-card.mjs +102 -53
- package/actions/create-checklist-item/create-checklist-item.mjs +54 -39
- package/actions/create-label/create-label.mjs +38 -50
- package/actions/create-list/create-list.mjs +43 -42
- package/actions/delete-checklist/delete-checklist.mjs +17 -14
- package/actions/find-labels/find-labels.mjs +14 -12
- package/actions/find-list/find-list.mjs +13 -10
- package/actions/get-card/get-card.mjs +13 -9
- package/actions/get-list/get-list.mjs +29 -15
- package/actions/move-card-to-list/move-card-to-list.mjs +17 -13
- package/actions/remove-label-from-card/remove-label-from-card.mjs +20 -13
- package/actions/rename-list/rename-list.mjs +24 -10
- package/actions/search-boards/search-boards.mjs +22 -18
- package/actions/search-cards/search-cards.mjs +23 -18
- package/actions/search-checklists/search-checklists.mjs +96 -59
- package/actions/search-members/search-members.mjs +44 -34
- package/actions/update-card/update-card.mjs +68 -50
- package/common/constants.mjs +128 -0
- package/common/fields.mjs +1 -0
- package/package.json +5 -3
- package/sources/card-archived/card-archived.mjs +22 -18
- package/sources/card-archived/test-event.mjs +64 -0
- package/sources/card-due-date-reminder/card-due-date-reminder.mjs +118 -39
- package/sources/card-due-date-reminder/test-event.mjs +75 -0
- package/sources/card-moved/card-moved.mjs +30 -27
- package/sources/card-moved/test-event.mjs +78 -0
- package/sources/card-updates/card-updates.mjs +29 -27
- package/sources/card-updates/test-event.mjs +86 -0
- package/sources/common/actions.mjs +206 -0
- package/sources/common/common-board-based.mjs +16 -9
- package/sources/common/common-webhook.mjs +86 -32
- package/sources/common/common.mjs +7 -4
- package/sources/custom-webhook-events/custom-webhook-events.mjs +37 -49
- package/sources/new-activity/new-activity.mjs +25 -32
- package/sources/new-attachment/new-attachment.mjs +42 -35
- package/sources/new-attachment/test-event.mjs +69 -0
- package/sources/new-board/new-board.mjs +21 -12
- package/sources/new-board/test-event.mjs +100 -0
- package/sources/new-card/new-card.mjs +29 -27
- package/sources/new-card/test-event.mjs +79 -0
- package/sources/new-checklist/new-checklist.mjs +42 -13
- package/sources/new-checklist/test-event.mjs +22 -0
- package/sources/new-comment-added-to-card/new-comment-added-to-card.mjs +49 -34
- package/sources/new-comment-added-to-card/test-event.mjs +298 -0
- package/sources/new-label/new-label.mjs +17 -14
- package/sources/new-label/test-event.mjs +7 -0
- package/sources/new-label-added-to-card/new-label-added-to-card.mjs +38 -29
- package/sources/new-label-added-to-card/test-event.mjs +85 -0
- package/sources/new-member-on-card/new-member-on-card.mjs +21 -18
- package/sources/new-member-on-card/test-event.mjs +83 -0
- package/sources/new-notification/new-notification.mjs +8 -7
- package/trello.app.mjs +454 -494
- 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/close-board/close-board.mjs +0 -25
- package/actions/copy-board/copy-board.mjs +0 -174
- package/actions/create-checklist/create-checklist.mjs +0 -66
- package/actions/create-comment-on-card/create-comment-on-card.mjs +0 -42
- package/sources/new-list/new-list.mjs +0 -29
- /package/{common → sources/common}/events.mjs +0 -0
@@ -1,84 +1,98 @@
|
|
1
1
|
import common from "../common/common-webhook.mjs";
|
2
|
+
import sampleEmit from "./test-event.mjs";
|
2
3
|
|
3
4
|
export default {
|
4
5
|
...common,
|
5
6
|
key: "trello-new-comment-added-to-card",
|
6
7
|
name: "New Comment Added to Card (Instant)",
|
7
8
|
description: "Emit new event for each new comment added to a card.",
|
8
|
-
version: "0.1
|
9
|
+
version: "0.2.1",
|
9
10
|
type: "source",
|
10
11
|
dedupe: "unique",
|
11
12
|
props: {
|
12
13
|
...common.props,
|
13
14
|
board: {
|
14
15
|
propDefinition: [
|
15
|
-
common.props.
|
16
|
+
common.props.app,
|
16
17
|
"board",
|
17
18
|
],
|
18
19
|
},
|
20
|
+
list: {
|
21
|
+
propDefinition: [
|
22
|
+
common.props.app,
|
23
|
+
"lists",
|
24
|
+
(c) => ({
|
25
|
+
board: c.board,
|
26
|
+
}),
|
27
|
+
],
|
28
|
+
type: "string",
|
29
|
+
label: "List",
|
30
|
+
description: "If specified, events will only be emitted when a comment is added to a card in the specified list",
|
31
|
+
},
|
19
32
|
cards: {
|
20
33
|
propDefinition: [
|
21
|
-
common.props.
|
34
|
+
common.props.app,
|
22
35
|
"cards",
|
23
36
|
(c) => ({
|
24
37
|
board: c.board,
|
38
|
+
list: c.list,
|
25
39
|
}),
|
26
40
|
],
|
27
|
-
|
28
|
-
},
|
29
|
-
hooks: {
|
30
|
-
...common.hooks,
|
31
|
-
async deploy() {
|
32
|
-
const {
|
33
|
-
sampleEvents, sortField,
|
34
|
-
} = await this.getSampleEvents();
|
35
|
-
sampleEvents.sort((a, b) => (Date.parse(a[sortField]) > Date.parse(b[sortField]))
|
36
|
-
? 1
|
37
|
-
: -1);
|
38
|
-
for (const action of sampleEvents.slice(-25)) {
|
39
|
-
this.emitEvent(action);
|
40
|
-
}
|
41
|
+
description: "If specified, events will only be emitted when a comment is added to one of the specified cards",
|
41
42
|
},
|
42
43
|
},
|
43
44
|
methods: {
|
44
45
|
...common.methods,
|
45
46
|
async getSampleEvents() {
|
46
|
-
const cards = this.cards
|
47
|
+
const cards = this.cards?.length
|
47
48
|
? this.cards
|
48
|
-
:
|
49
|
+
: this.list
|
50
|
+
? (await this.app.getCardsInList({
|
51
|
+
listId: this.list,
|
52
|
+
})).map((card) => card.id)
|
53
|
+
: (await this.app.getCards({
|
54
|
+
boardId: this.board,
|
55
|
+
})).map((card) => card.id);
|
49
56
|
const actions = [];
|
50
57
|
for (const card of cards) {
|
51
|
-
const activities = await this.
|
58
|
+
const activities = await this.app.getCardActivity({
|
59
|
+
cardId: card,
|
60
|
+
params: {
|
61
|
+
filter: "commentCard",
|
62
|
+
},
|
63
|
+
});
|
52
64
|
|
53
65
|
for (const activity of activities) {
|
54
66
|
actions.push(await this.getResult(activity));
|
55
67
|
}
|
56
68
|
}
|
57
|
-
return
|
58
|
-
|
59
|
-
|
60
|
-
|
69
|
+
return actions;
|
70
|
+
},
|
71
|
+
getSortField() {
|
72
|
+
return "date";
|
61
73
|
},
|
62
|
-
isCorrectEventType(
|
63
|
-
|
64
|
-
return eventType === "commentCard";
|
74
|
+
isCorrectEventType({ type }) {
|
75
|
+
return type === "commentCard";
|
65
76
|
},
|
66
|
-
async getResult(
|
67
|
-
const card = await this.
|
68
|
-
|
69
|
-
|
70
|
-
|
77
|
+
async getResult(action) {
|
78
|
+
const card = await this.app.getCard({
|
79
|
+
cardId: action?.data?.card?.id,
|
80
|
+
});
|
81
|
+
const member = await this.app.getMember({
|
82
|
+
memberId: action?.idMemberCreator,
|
83
|
+
});
|
71
84
|
|
72
85
|
return {
|
73
86
|
member,
|
74
87
|
card,
|
75
|
-
event:
|
88
|
+
event: action,
|
76
89
|
};
|
77
90
|
},
|
78
91
|
isRelevant({ result: { card } }) {
|
79
92
|
return (
|
80
93
|
(!this.board || this.board === card.idBoard) &&
|
81
|
-
(!this.
|
94
|
+
(!this.lists || this.list === card.idList) &&
|
95
|
+
(!this.cards?.length || this.cards.includes(card.id))
|
82
96
|
);
|
83
97
|
},
|
84
98
|
generateMeta({ event }) {
|
@@ -89,4 +103,5 @@ export default {
|
|
89
103
|
};
|
90
104
|
},
|
91
105
|
},
|
106
|
+
sampleEmit,
|
92
107
|
};
|
@@ -0,0 +1,298 @@
|
|
1
|
+
export default {
|
2
|
+
"member": {
|
3
|
+
"id": "5df149d4fa80be39e64c9a43",
|
4
|
+
"aaId": "5df149cf8998970e5b435642",
|
5
|
+
"activityBlocked": false,
|
6
|
+
"avatarHash": "5590d4f06fc7d09fc98b242248c9003e",
|
7
|
+
"avatarUrl": "https://trello-members.s3.amazonaws.com/5df149d4fa80be39e64c9a43/5590d4f06fc7d09fc98b242248c9003e",
|
8
|
+
"bio": "",
|
9
|
+
"bioData": null,
|
10
|
+
"confirmed": true,
|
11
|
+
"fullName": "Michelle Bergeron",
|
12
|
+
"idEnterprise": null,
|
13
|
+
"idEnterprisesDeactivated": [],
|
14
|
+
"idMemberReferrer": null,
|
15
|
+
"idPremOrgsAdmin": [],
|
16
|
+
"initials": "MB",
|
17
|
+
"memberType": "normal",
|
18
|
+
"nonPublic": {},
|
19
|
+
"nonPublicAvailable": true,
|
20
|
+
"products": [],
|
21
|
+
"url": "https://trello.com/michellebergeron6",
|
22
|
+
"username": "michellebergeron6",
|
23
|
+
"status": "disconnected",
|
24
|
+
"aaBlockSyncUntil": null,
|
25
|
+
"aaEmail": null,
|
26
|
+
"aaEnrolledDate": null,
|
27
|
+
"avatarSource": "none",
|
28
|
+
"credentialsRemovedCount": 0,
|
29
|
+
"dateLastImpression": "2024-10-01T19:54:58.087Z",
|
30
|
+
"dateLastActive": "2024-10-01T19:55:05.070Z",
|
31
|
+
"domainClaimed": null,
|
32
|
+
"email": null,
|
33
|
+
"gravatarHash": "010b11df3bb34c405912830655ee130c",
|
34
|
+
"idBoards": [
|
35
|
+
"5df14a131c0e51155e68ea62",
|
36
|
+
],
|
37
|
+
"idOrganizations": [
|
38
|
+
"6047c17c2f558003144e04d7"
|
39
|
+
],
|
40
|
+
"idEnterprisesAdmin": [],
|
41
|
+
"limits": {
|
42
|
+
"boards": {
|
43
|
+
"totalPerMember": {
|
44
|
+
"status": "ok",
|
45
|
+
"disableAt": 4500,
|
46
|
+
"warnAt": 3600
|
47
|
+
}
|
48
|
+
},
|
49
|
+
"orgs": {
|
50
|
+
"totalPerMember": {
|
51
|
+
"status": "ok",
|
52
|
+
"disableAt": 850,
|
53
|
+
"warnAt": 680
|
54
|
+
}
|
55
|
+
}
|
56
|
+
},
|
57
|
+
"loginTypes": null,
|
58
|
+
"marketingOptIn": {
|
59
|
+
"optedIn": true,
|
60
|
+
"date": "2019-12-11T19:56:05.741Z"
|
61
|
+
},
|
62
|
+
"messagesDismissed": [
|
63
|
+
{
|
64
|
+
"_id": "6082199aab18525bdcbe18f5",
|
65
|
+
"name": "team-join-cta-banner-6047c17c2f558003144e04d7",
|
66
|
+
"count": 5,
|
67
|
+
"lastDismissed": "2021-04-23T00:49:31.975Z"
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"_id": "6082199a190169402dc6130f",
|
71
|
+
"name": "team-join-cta-banner-6047c17c2f558003144e04d7",
|
72
|
+
"count": 1,
|
73
|
+
"lastDismissed": "2021-04-23T00:49:30.689Z"
|
74
|
+
}
|
75
|
+
],
|
76
|
+
"nodeId": "ari:cloud:trello::user/5df149d4fa80be39e64c9a43",
|
77
|
+
"oneTimeMessagesDismissed": [
|
78
|
+
"create-first-board",
|
79
|
+
"close-menu-of-first-board",
|
80
|
+
"nusku.views-switcher-upsell-default-open",
|
81
|
+
"teamify-post-migration",
|
82
|
+
"ack-new-feature-ButlerOnBoardsV2-1619852400000",
|
83
|
+
"workspace-nav-enabled",
|
84
|
+
"workspace-nav-spotlight",
|
85
|
+
"team-template-picker-6047c17c2f558003144e04d7",
|
86
|
+
"free-trial-banner-confetti-6047c17c2f558003144e04d7",
|
87
|
+
"team-table-views-switcher-new-pill",
|
88
|
+
"timeline-view-suggestion-6047c17c2f558003144e04d7",
|
89
|
+
"calendar-view-suggestion-6047c17c2f558003144e04d7",
|
90
|
+
"free-trial-banner-6047c17c2f558003144e04d7",
|
91
|
+
"workspace-user-limit-banner",
|
92
|
+
"atlassian-intelligence-admin-6047c17c2f558003144e04d7",
|
93
|
+
"your-items-on-home"
|
94
|
+
],
|
95
|
+
"sessionType": null,
|
96
|
+
"prefs": {
|
97
|
+
"sendSummaries": true,
|
98
|
+
"minutesBetweenSummaries": 60,
|
99
|
+
"minutesBeforeDeadlineToNotify": 60,
|
100
|
+
"colorBlind": false,
|
101
|
+
"locale": "en-US",
|
102
|
+
"privacy": {
|
103
|
+
"fullName": "public",
|
104
|
+
"avatar": "public"
|
105
|
+
}
|
106
|
+
},
|
107
|
+
"trophies": [],
|
108
|
+
"uploadedAvatarHash": null,
|
109
|
+
"uploadedAvatarUrl": null,
|
110
|
+
"premiumFeatures": [],
|
111
|
+
"isAaMastered": true,
|
112
|
+
"ixUpdate": "151"
|
113
|
+
},
|
114
|
+
"card": {
|
115
|
+
"id": "61818a303e545129af23695d",
|
116
|
+
"badges": {
|
117
|
+
"attachmentsByType": {
|
118
|
+
"trello": {
|
119
|
+
"board": 0,
|
120
|
+
"card": 2
|
121
|
+
}
|
122
|
+
},
|
123
|
+
"externalSource": null,
|
124
|
+
"location": false,
|
125
|
+
"votes": 0,
|
126
|
+
"viewingMemberVoted": false,
|
127
|
+
"subscribed": true,
|
128
|
+
"fogbugz": "",
|
129
|
+
"checkItems": 1,
|
130
|
+
"checkItemsChecked": 1,
|
131
|
+
"checkItemsEarliestDue": null,
|
132
|
+
"comments": 2,
|
133
|
+
"attachments": 3,
|
134
|
+
"description": false,
|
135
|
+
"due": "2024-10-01T19:20:00.000Z",
|
136
|
+
"dueComplete": false,
|
137
|
+
"start": null,
|
138
|
+
"lastUpdatedByAi": false
|
139
|
+
},
|
140
|
+
"checkItemStates": [
|
141
|
+
{
|
142
|
+
"idCheckItem": "6181a5f18e239e6aff9799a4",
|
143
|
+
"state": "complete"
|
144
|
+
}
|
145
|
+
],
|
146
|
+
"closed": false,
|
147
|
+
"dueComplete": false,
|
148
|
+
"dateLastActivity": "2024-10-01T20:12:35.627Z",
|
149
|
+
"desc": "",
|
150
|
+
"descData": {
|
151
|
+
"emoji": {}
|
152
|
+
},
|
153
|
+
"due": "2024-10-01T19:20:00.000Z",
|
154
|
+
"dueReminder": -1,
|
155
|
+
"email": null,
|
156
|
+
"idBoard": "5f4d7be6c45c22583f75fa02",
|
157
|
+
"idChecklists": [
|
158
|
+
"6181a5ef401ae66c357732b4"
|
159
|
+
],
|
160
|
+
"idList": "5f4d7f78bdd7ce4d2d25fdda",
|
161
|
+
"idMembers": [],
|
162
|
+
"idMembersVoted": [],
|
163
|
+
"idShort": 68,
|
164
|
+
"idAttachmentCover": "62c884dce32d46579ecfd5f0",
|
165
|
+
"labels": [],
|
166
|
+
"idLabels": [],
|
167
|
+
"manualCoverAttachment": false,
|
168
|
+
"name": "sfsfdsfd",
|
169
|
+
"pinned": false,
|
170
|
+
"pos": 131071,
|
171
|
+
"shortLink": "QVLahShU",
|
172
|
+
"shortUrl": "https://trello.com/c/QVLahShU",
|
173
|
+
"start": null,
|
174
|
+
"subscribed": true,
|
175
|
+
"url": "https://trello.com/c/QVLahShU/68-sfsfdsfd",
|
176
|
+
"cover": {
|
177
|
+
"idAttachment": "62c884dce32d46579ecfd5f0",
|
178
|
+
"color": null,
|
179
|
+
"idUploadedBackground": null,
|
180
|
+
"size": "normal",
|
181
|
+
"brightness": "dark",
|
182
|
+
"scaled": [
|
183
|
+
{
|
184
|
+
"id": "62c884dde32d46579ecfd5ff",
|
185
|
+
"_id": "62c884dde32d46579ecfd5ff",
|
186
|
+
"scaled": false,
|
187
|
+
"url": "",
|
188
|
+
"bytes": 1649,
|
189
|
+
"height": 50,
|
190
|
+
"width": 70
|
191
|
+
},
|
192
|
+
{
|
193
|
+
"id": "62c884dde32d46579ecfd601",
|
194
|
+
"_id": "62c884dde32d46579ecfd601",
|
195
|
+
"scaled": true,
|
196
|
+
"url": "",
|
197
|
+
"bytes": 4508,
|
198
|
+
"height": 98,
|
199
|
+
"width": 150
|
200
|
+
},
|
201
|
+
{
|
202
|
+
"id": "62c884dde32d46579ecfd600",
|
203
|
+
"_id": "62c884dde32d46579ecfd600",
|
204
|
+
"scaled": false,
|
205
|
+
"url": "",
|
206
|
+
"bytes": 9598,
|
207
|
+
"height": 150,
|
208
|
+
"width": 250
|
209
|
+
},
|
210
|
+
{
|
211
|
+
"id": "62c884dde32d46579ecfd602",
|
212
|
+
"_id": "62c884dde32d46579ecfd602",
|
213
|
+
"scaled": true,
|
214
|
+
"url": "",
|
215
|
+
"bytes": 13736,
|
216
|
+
"height": 195,
|
217
|
+
"width": 300
|
218
|
+
},
|
219
|
+
{
|
220
|
+
"id": "62c884dde32d46579ecfd603",
|
221
|
+
"_id": "62c884dde32d46579ecfd603",
|
222
|
+
"scaled": true,
|
223
|
+
"url": "",
|
224
|
+
"bytes": 20289,
|
225
|
+
"height": 260,
|
226
|
+
"width": 400
|
227
|
+
},
|
228
|
+
{
|
229
|
+
"id": "62c884dde32d46579ecfd604",
|
230
|
+
"_id": "62c884dde32d46579ecfd604",
|
231
|
+
"scaled": false,
|
232
|
+
"url": "",
|
233
|
+
"bytes": 18820,
|
234
|
+
"height": 260,
|
235
|
+
"width": 400
|
236
|
+
}
|
237
|
+
],
|
238
|
+
"edgeColor": "#bbac9c",
|
239
|
+
"idPlugin": null
|
240
|
+
},
|
241
|
+
"isTemplate": false,
|
242
|
+
"cardRole": null
|
243
|
+
},
|
244
|
+
"event": {
|
245
|
+
"id": "66fc17543e3458edb8b3070d",
|
246
|
+
"idMemberCreator": "5df149d4fa80be39e64c9a43",
|
247
|
+
"data": {
|
248
|
+
"text": "hello world",
|
249
|
+
"textData": {
|
250
|
+
"emoji": {}
|
251
|
+
},
|
252
|
+
"card": {
|
253
|
+
"id": "61818a303e545129af23695d",
|
254
|
+
"name": "card",
|
255
|
+
"idShort": 68,
|
256
|
+
"shortLink": "QVLahShU"
|
257
|
+
},
|
258
|
+
"board": {
|
259
|
+
"id": "5f4d7be6c45c22583f75fa02",
|
260
|
+
"name": "Board",
|
261
|
+
"shortLink": "tiA9sOeK"
|
262
|
+
},
|
263
|
+
"list": {
|
264
|
+
"id": "5f4d7f78bdd7ce4d2d25fdda",
|
265
|
+
"name": "List"
|
266
|
+
}
|
267
|
+
},
|
268
|
+
"appCreator": null,
|
269
|
+
"type": "commentCard",
|
270
|
+
"date": "2024-10-01T15:37:56.522Z",
|
271
|
+
"limits": {
|
272
|
+
"reactions": {
|
273
|
+
"perAction": {
|
274
|
+
"status": "ok",
|
275
|
+
"disableAt": 900,
|
276
|
+
"warnAt": 720
|
277
|
+
},
|
278
|
+
"uniquePerAction": {
|
279
|
+
"status": "ok",
|
280
|
+
"disableAt": 17,
|
281
|
+
"warnAt": 14
|
282
|
+
}
|
283
|
+
}
|
284
|
+
},
|
285
|
+
"memberCreator": {
|
286
|
+
"id": "5df149d4fa80be39e64c9a43",
|
287
|
+
"activityBlocked": false,
|
288
|
+
"avatarHash": "5590d4f06fc7d09fc98b242248c9003e",
|
289
|
+
"avatarUrl": "",
|
290
|
+
"fullName": "",
|
291
|
+
"idMemberReferrer": null,
|
292
|
+
"initials": "",
|
293
|
+
"nonPublic": {},
|
294
|
+
"nonPublicAvailable": true,
|
295
|
+
"username": ""
|
296
|
+
}
|
297
|
+
}
|
298
|
+
}
|
@@ -1,29 +1,31 @@
|
|
1
1
|
import common from "../common/common-board-based.mjs";
|
2
|
+
import sampleEmit from "./test-event.mjs";
|
2
3
|
|
3
4
|
export default {
|
4
5
|
...common,
|
5
6
|
key: "trello-new-label",
|
6
|
-
name: "New Label (Instant)",
|
7
|
+
name: "New Label Created (Instant)",
|
7
8
|
description: "Emit new event for each new label added to a board.",
|
8
|
-
version: "0.
|
9
|
+
version: "0.1.1",
|
9
10
|
type: "source",
|
10
11
|
dedupe: "unique",
|
11
12
|
methods: {
|
12
13
|
...common.methods,
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
getSampleEvents() {
|
15
|
+
return this.app.findLabel({
|
16
|
+
boardId: this.board,
|
17
|
+
});
|
18
|
+
},
|
19
|
+
getSortField() {
|
20
|
+
return "id";
|
19
21
|
},
|
20
|
-
isCorrectEventType(
|
21
|
-
|
22
|
-
return eventType === "createLabel";
|
22
|
+
isCorrectEventType({ type }) {
|
23
|
+
return type === "createLabel";
|
23
24
|
},
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
getResult({ data }) {
|
26
|
+
return this.app.getLabel({
|
27
|
+
labelId: data?.label?.id,
|
28
|
+
});
|
27
29
|
},
|
28
30
|
generateMeta({
|
29
31
|
id, name, color: summary,
|
@@ -38,4 +40,5 @@ export default {
|
|
38
40
|
};
|
39
41
|
},
|
40
42
|
},
|
43
|
+
sampleEmit,
|
41
44
|
};
|
@@ -1,54 +1,62 @@
|
|
1
1
|
import common from "../common/common-webhook.mjs";
|
2
|
+
import sampleEmit from "./test-event.mjs";
|
2
3
|
|
3
4
|
export default {
|
4
5
|
...common,
|
5
6
|
key: "trello-new-label-added-to-card",
|
6
7
|
name: "New Label Added To Card (Instant)",
|
7
8
|
description: "Emit new event for each label added to a card.",
|
8
|
-
version: "0.
|
9
|
+
version: "0.1.1",
|
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
|
+
list: {
|
19
20
|
propDefinition: [
|
20
|
-
common.props.
|
21
|
+
common.props.app,
|
21
22
|
"lists",
|
22
23
|
(c) => ({
|
23
24
|
board: c.board,
|
24
25
|
}),
|
25
26
|
],
|
27
|
+
type: "string",
|
28
|
+
label: "List",
|
29
|
+
description: "If specified, events will only be emitted when a label is added to a card in the specified lists",
|
26
30
|
},
|
27
31
|
cards: {
|
28
32
|
propDefinition: [
|
29
|
-
common.props.
|
33
|
+
common.props.app,
|
30
34
|
"cards",
|
31
35
|
(c) => ({
|
32
36
|
board: c.board,
|
37
|
+
list: c.list,
|
33
38
|
}),
|
34
39
|
],
|
40
|
+
description: "If specified, events will only be emitted when a label is added to one of the specified cards",
|
35
41
|
},
|
36
42
|
},
|
37
43
|
hooks: {
|
38
44
|
...common.hooks,
|
39
45
|
async deploy() {
|
40
|
-
if (this.cards
|
46
|
+
if (this.cards?.length) {
|
41
47
|
await this.emitLabelsFromCardIds(this.cards);
|
42
48
|
return;
|
43
49
|
}
|
44
|
-
if (this.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
50
|
+
if (this.list) {
|
51
|
+
const cards = await this.app.getCardsInList({
|
52
|
+
listId: this.list,
|
53
|
+
});
|
54
|
+
await this.emitLabelsFromCards(cards);
|
49
55
|
return;
|
50
56
|
}
|
51
|
-
const cards = await this.
|
57
|
+
const cards = await this.app.getCards({
|
58
|
+
boardId: this.board,
|
59
|
+
});
|
52
60
|
await this.emitLabelsFromCards(cards);
|
53
61
|
},
|
54
62
|
},
|
@@ -58,7 +66,9 @@ export default {
|
|
58
66
|
for (const card of cards) {
|
59
67
|
const labelIds = card.idLabels;
|
60
68
|
for (const labelId of labelIds) {
|
61
|
-
const label = await this.
|
69
|
+
const label = await this.app.getLabel({
|
70
|
+
labelId,
|
71
|
+
});
|
62
72
|
let summary = label.color;
|
63
73
|
summary += label.name
|
64
74
|
? ` - ${label.name}`
|
@@ -74,8 +84,10 @@ export default {
|
|
74
84
|
},
|
75
85
|
async emitLabelsFromCardIds(cardIds) {
|
76
86
|
const cards = [];
|
77
|
-
for (const
|
78
|
-
const card = await this.
|
87
|
+
for (const cardId of cardIds) {
|
88
|
+
const card = await this.app.getCard({
|
89
|
+
cardId,
|
90
|
+
});
|
79
91
|
cards.push(card);
|
80
92
|
}
|
81
93
|
await this.emitLabelsFromCards(cards);
|
@@ -92,26 +104,22 @@ export default {
|
|
92
104
|
_setLabelColor(labelColor) {
|
93
105
|
this.db.set("labelColor", labelColor);
|
94
106
|
},
|
95
|
-
isCorrectEventType(
|
96
|
-
|
97
|
-
return eventType === "addLabelToCard";
|
107
|
+
isCorrectEventType({ type }) {
|
108
|
+
return type === "addLabelToCard";
|
98
109
|
},
|
99
|
-
|
100
|
-
const cardId = event.body?.action?.data?.card?.id;
|
101
|
-
const labelName = event.body?.action?.data?.label?.name;
|
102
|
-
const labelColor = event.body?.action?.data?.label?.color;
|
110
|
+
getResult({ data }) {
|
103
111
|
/** Record labelName & labelColor to use in generateMeta() */
|
104
|
-
this._setLabelName(
|
105
|
-
this._setLabelColor(
|
106
|
-
return this.
|
112
|
+
this._setLabelName(data?.label?.name);
|
113
|
+
this._setLabelColor(data?.label?.color);
|
114
|
+
return this.app.getCard({
|
115
|
+
cardId: data?.card?.id,
|
116
|
+
});
|
107
117
|
},
|
108
118
|
isRelevant({ result: card }) {
|
109
119
|
return (
|
110
120
|
(!this.board || this.board === card.idBoard) &&
|
111
|
-
(!this.
|
112
|
-
|
113
|
-
this.lists.includes(card.idList)) &&
|
114
|
-
(!this.cards || this.cards.length === 0 || this.cards.includes(card.id))
|
121
|
+
(!this.list || this.list === card.idList) &&
|
122
|
+
(!this.cards?.length || this.cards.includes(card.id))
|
115
123
|
);
|
116
124
|
},
|
117
125
|
generateMeta({
|
@@ -135,4 +143,5 @@ export default {
|
|
135
143
|
this.$emit(card, meta);
|
136
144
|
},
|
137
145
|
},
|
146
|
+
sampleEmit,
|
138
147
|
};
|