@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
@@ -0,0 +1,206 @@
|
|
1
|
+
export default [
|
2
|
+
{
|
3
|
+
label: "Accept Enterprise Join Request",
|
4
|
+
value: "acceptEnterpriseJoinRequest",
|
5
|
+
},
|
6
|
+
{
|
7
|
+
label: "Add Attachment To Card",
|
8
|
+
value: "addAttachmentToCard",
|
9
|
+
},
|
10
|
+
{
|
11
|
+
label: "Add Checklist To Card",
|
12
|
+
value: "addChecklistToCard",
|
13
|
+
},
|
14
|
+
{
|
15
|
+
label: "Add Member To Board",
|
16
|
+
value: "addMemberToBoard",
|
17
|
+
},
|
18
|
+
{
|
19
|
+
label: "Add Member To Card",
|
20
|
+
value: "addMemberToCard",
|
21
|
+
},
|
22
|
+
{
|
23
|
+
label: "Add Member To Organization",
|
24
|
+
value: "addMemberToOrganization",
|
25
|
+
},
|
26
|
+
{
|
27
|
+
label: "Add Organization To Enterprise",
|
28
|
+
value: "addOrganizationToEnterprise",
|
29
|
+
},
|
30
|
+
{
|
31
|
+
label: "Add To Enterprise Plugin Whitelist",
|
32
|
+
value: "addToEnterprisePluginWhitelist",
|
33
|
+
},
|
34
|
+
{
|
35
|
+
label: "Add To Organization Board",
|
36
|
+
value: "addToOrganizationBoard",
|
37
|
+
},
|
38
|
+
{
|
39
|
+
label: "Comment Card",
|
40
|
+
value: "commentCard",
|
41
|
+
},
|
42
|
+
{
|
43
|
+
label: "Convert To Card From Check Item",
|
44
|
+
value: "convertToCardFromCheckItem",
|
45
|
+
},
|
46
|
+
{
|
47
|
+
label: "Copy Board",
|
48
|
+
value: "copyBoard",
|
49
|
+
},
|
50
|
+
{
|
51
|
+
label: "Copy Card",
|
52
|
+
value: "copyCard",
|
53
|
+
},
|
54
|
+
{
|
55
|
+
label: "Copy Comment Card",
|
56
|
+
value: "copyCommentCard",
|
57
|
+
},
|
58
|
+
{
|
59
|
+
label: "Create Board",
|
60
|
+
value: "createBoard",
|
61
|
+
},
|
62
|
+
{
|
63
|
+
label: "Create Card",
|
64
|
+
value: "createCard",
|
65
|
+
},
|
66
|
+
{
|
67
|
+
label: "Create List",
|
68
|
+
value: "createList",
|
69
|
+
},
|
70
|
+
{
|
71
|
+
label: "Create Organization",
|
72
|
+
value: "createOrganization",
|
73
|
+
},
|
74
|
+
{
|
75
|
+
label: "Delete Board Invitation",
|
76
|
+
value: "deleteBoardInvitation",
|
77
|
+
},
|
78
|
+
{
|
79
|
+
label: "Delete Card",
|
80
|
+
value: "deleteCard",
|
81
|
+
},
|
82
|
+
{
|
83
|
+
label: "Delete Organization Invitation",
|
84
|
+
value: "deleteOrganizationInvitation",
|
85
|
+
},
|
86
|
+
{
|
87
|
+
label: "Disable Enterprise Plugin Whitelist",
|
88
|
+
value: "disableEnterprisePluginWhitelist",
|
89
|
+
},
|
90
|
+
{
|
91
|
+
label: "Disable Plugin",
|
92
|
+
value: "disablePlugin",
|
93
|
+
},
|
94
|
+
{
|
95
|
+
label: "Disable Power Up",
|
96
|
+
value: "disablePowerUp",
|
97
|
+
},
|
98
|
+
{
|
99
|
+
label: "Email Card",
|
100
|
+
value: "emailCard",
|
101
|
+
},
|
102
|
+
{
|
103
|
+
label: "Enable Enterprise Plugin Whitelist",
|
104
|
+
value: "enableEnterprisePluginWhitelist",
|
105
|
+
},
|
106
|
+
{
|
107
|
+
label: "Enable Plugin",
|
108
|
+
value: "enablePlugin",
|
109
|
+
},
|
110
|
+
{
|
111
|
+
label: "Enable Power Up",
|
112
|
+
value: "enablePowerUp",
|
113
|
+
},
|
114
|
+
{
|
115
|
+
label: "Make Admin Of Board",
|
116
|
+
value: "makeAdminOfBoard",
|
117
|
+
},
|
118
|
+
{
|
119
|
+
label: "Make Normal Member Of Board",
|
120
|
+
value: "makeNormalMemberOfBoard",
|
121
|
+
},
|
122
|
+
{
|
123
|
+
label: "Make Normal Member Of Organization",
|
124
|
+
value: "makeNormalMemberOfOrganization",
|
125
|
+
},
|
126
|
+
{
|
127
|
+
label: "Make Observer Of Board",
|
128
|
+
value: "makeObserverOfBoard",
|
129
|
+
},
|
130
|
+
{
|
131
|
+
label: "Member Joined Trello",
|
132
|
+
value: "memberJoinedTrello",
|
133
|
+
},
|
134
|
+
{
|
135
|
+
label: "Move Card From Board",
|
136
|
+
value: "moveCardFromBoard",
|
137
|
+
},
|
138
|
+
{
|
139
|
+
label: "Move Card To Board",
|
140
|
+
value: "moveCardToBoard",
|
141
|
+
},
|
142
|
+
{
|
143
|
+
label: "Move List From Board",
|
144
|
+
value: "moveListFromBoard",
|
145
|
+
},
|
146
|
+
{
|
147
|
+
label: "Move List To Board",
|
148
|
+
value: "moveListToBoard",
|
149
|
+
},
|
150
|
+
{
|
151
|
+
label: "Remove Checklist From Card",
|
152
|
+
value: "removeChecklistFromCard",
|
153
|
+
},
|
154
|
+
{
|
155
|
+
label: "Remove From Enterprise Plugin Whitelist",
|
156
|
+
value: "removeFromEnterprisePluginWhitelist",
|
157
|
+
},
|
158
|
+
{
|
159
|
+
label: "Remove From Organization Board",
|
160
|
+
value: "removeFromOrganizationBoard",
|
161
|
+
},
|
162
|
+
{
|
163
|
+
label: "Remove Member From Card",
|
164
|
+
value: "removeMemberFromCard",
|
165
|
+
},
|
166
|
+
{
|
167
|
+
label: "Remove Organization From Enterprise",
|
168
|
+
value: "removeOrganizationFromEnterprise",
|
169
|
+
},
|
170
|
+
{
|
171
|
+
label: "Unconfirmed Board Invitation",
|
172
|
+
value: "unconfirmedBoardInvitation",
|
173
|
+
},
|
174
|
+
{
|
175
|
+
label: "Unconfirmed Organization Invitation",
|
176
|
+
value: "unconfirmedOrganizationInvitation",
|
177
|
+
},
|
178
|
+
{
|
179
|
+
label: "Update Board",
|
180
|
+
value: "updateBoard",
|
181
|
+
},
|
182
|
+
{
|
183
|
+
label: "Update Card",
|
184
|
+
value: "updateCard",
|
185
|
+
},
|
186
|
+
{
|
187
|
+
label: "Update Check Item State On Card",
|
188
|
+
value: "updateCheckItemStateOnCard",
|
189
|
+
},
|
190
|
+
{
|
191
|
+
label: "Update Checklist",
|
192
|
+
value: "updateChecklist",
|
193
|
+
},
|
194
|
+
{
|
195
|
+
label: "Update List",
|
196
|
+
value: "updateList",
|
197
|
+
},
|
198
|
+
{
|
199
|
+
label: "Update Member",
|
200
|
+
value: "updateMember",
|
201
|
+
},
|
202
|
+
{
|
203
|
+
label: "Update Organization",
|
204
|
+
value: "updateOrganization",
|
205
|
+
},
|
206
|
+
];
|
@@ -9,12 +9,12 @@ export default {
|
|
9
9
|
...base.props,
|
10
10
|
board: {
|
11
11
|
propDefinition: [
|
12
|
-
base.props.
|
12
|
+
base.props.app,
|
13
13
|
"board",
|
14
14
|
],
|
15
15
|
},
|
16
16
|
onlyEventsRelatedWithAuthenticatedUser: {
|
17
|
-
label: "Only Events Related
|
17
|
+
label: "Only Events Related To Me",
|
18
18
|
description: "Only will emit events from the cards related with the authenticated user",
|
19
19
|
type: "boolean",
|
20
20
|
default: false,
|
@@ -32,17 +32,24 @@ export default {
|
|
32
32
|
return false;
|
33
33
|
}
|
34
34
|
|
35
|
-
|
35
|
+
if (this.lists?.length) {
|
36
|
+
const list = await this.app.getCardList({
|
37
|
+
cardId: result.idCard,
|
38
|
+
});
|
39
|
+
if (!this.lists.includes(list.id)) {
|
40
|
+
return false;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
const member = await this.app.getMember({
|
45
|
+
memberId: "me",
|
46
|
+
});
|
36
47
|
|
37
|
-
|
48
|
+
return !(
|
38
49
|
this.onlyEventsRelatedWithAuthenticatedUser &&
|
39
50
|
result?.idMembers?.length &&
|
40
51
|
!result.idMembers.includes(member.id)
|
41
|
-
)
|
42
|
-
return false;
|
43
|
-
}
|
44
|
-
|
45
|
-
return true;
|
52
|
+
);
|
46
53
|
},
|
47
54
|
},
|
48
55
|
};
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { createHmac } from "crypto";
|
1
2
|
import common from "./common.mjs";
|
2
3
|
|
3
4
|
export default {
|
@@ -8,52 +9,83 @@ export default {
|
|
8
9
|
},
|
9
10
|
hooks: {
|
10
11
|
async deploy() {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
sampleEvents.sort((a, b) => (Date.parse(a[sortField]) > Date.parse(b[sortField]))
|
15
|
-
? 1
|
16
|
-
: -1);
|
12
|
+
let sampleEvents = await this.getSampleEvents();
|
13
|
+
const sortField = this.getSortField();
|
14
|
+
sampleEvents = this.sortItemsByDate(sampleEvents, sortField);
|
17
15
|
for (const event of sampleEvents.slice(-25)) {
|
18
16
|
this.emitEvent(event);
|
19
17
|
}
|
20
18
|
},
|
21
19
|
async activate() {
|
22
20
|
const modelId = await this.getModelId();
|
23
|
-
const { id } = await this.
|
24
|
-
|
25
|
-
|
21
|
+
const { id } = await this.createHook({
|
22
|
+
params: {
|
23
|
+
idModel: modelId,
|
24
|
+
description: "Pipedream Source ID",
|
25
|
+
callbackURL: this.http.endpoint,
|
26
|
+
},
|
26
27
|
});
|
27
|
-
this.
|
28
|
+
this._setHookId(id);
|
28
29
|
},
|
29
30
|
async deactivate() {
|
30
|
-
const hookId = this.
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
const hookId = this._getHookId();
|
32
|
+
if (hookId) {
|
33
|
+
await this.deleteHook({
|
34
|
+
hookId,
|
35
|
+
});
|
36
|
+
}
|
34
37
|
},
|
35
38
|
},
|
36
39
|
methods: {
|
37
40
|
...common.methods,
|
41
|
+
_getHookId() {
|
42
|
+
return this.db.get("hookId");
|
43
|
+
},
|
44
|
+
_setHookId(hookId) {
|
45
|
+
this.db.set("hookId", hookId);
|
46
|
+
},
|
47
|
+
getBase64Digest(data) {
|
48
|
+
const { secret } = this.app.getToken();
|
49
|
+
return createHmac("sha1", secret)
|
50
|
+
.update(data)
|
51
|
+
.digest("base64");
|
52
|
+
},
|
53
|
+
// Do not remove the async keyword from this function
|
54
|
+
async isValidSignature({
|
55
|
+
body, bodyRaw, headers,
|
56
|
+
}) {
|
57
|
+
const data = bodyRaw + body.webhook?.callbackURL;
|
58
|
+
const doubleHash = this.getBase64Digest(data);
|
59
|
+
const headerHash = headers["x-trello-webhook"];
|
60
|
+
return doubleHash === headerHash;
|
61
|
+
},
|
62
|
+
createHook(args = {}) {
|
63
|
+
return this.app.post({
|
64
|
+
...args,
|
65
|
+
path: "/webhooks/",
|
66
|
+
});
|
67
|
+
},
|
68
|
+
deleteHook({
|
69
|
+
hookId, ...args
|
70
|
+
} = {}) {
|
71
|
+
return this.app.delete({
|
72
|
+
...args,
|
73
|
+
path: `/webhooks/${hookId}`,
|
74
|
+
});
|
75
|
+
},
|
38
76
|
/**
|
39
77
|
* Returns the ID of the current board selected. If no board is selected, returns
|
40
78
|
* the id of the authenticated user.
|
41
79
|
*/
|
42
80
|
async getModelId() {
|
43
|
-
if (this.board)
|
44
|
-
|
81
|
+
if (this.board) {
|
82
|
+
return this.board;
|
83
|
+
}
|
84
|
+
const member = await this.app.getMember({
|
85
|
+
memberId: "me",
|
86
|
+
});
|
45
87
|
return member.id;
|
46
88
|
},
|
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
89
|
/**
|
58
90
|
* Default isCorrectEventType. Used in components to verify that the event received is
|
59
91
|
* of the type that the component is watching for.
|
@@ -68,22 +100,44 @@ export default {
|
|
68
100
|
isRelevant() {
|
69
101
|
return true;
|
70
102
|
},
|
103
|
+
getResult(action) {
|
104
|
+
return action;
|
105
|
+
},
|
71
106
|
getSampleEvents() {
|
72
107
|
throw new Error("getSampleEvents not implemented");
|
73
108
|
},
|
109
|
+
getSortField() {
|
110
|
+
throw new Error("getSortField is not implemented");
|
111
|
+
},
|
74
112
|
},
|
75
113
|
async run(event) {
|
76
|
-
if (
|
114
|
+
if (event.body === undefined) {
|
115
|
+
console.log("Event body is undefined. Skipping...");
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
|
119
|
+
if (!this.isValidSignature(event)) {
|
77
120
|
console.log("The event failed the verification. Skipping...");
|
78
121
|
return;
|
79
122
|
}
|
80
|
-
if (!this.isCorrectEventType(event)) return;
|
81
123
|
|
82
|
-
const
|
83
|
-
|
124
|
+
const { action } = event.body;
|
125
|
+
|
126
|
+
if (!this.isCorrectEventType(action)) {
|
127
|
+
console.log("The event is not of the correct type. Skipping...");
|
128
|
+
return;
|
129
|
+
}
|
130
|
+
|
131
|
+
const result = await this.getResult(action);
|
132
|
+
const isRelevant = await this.isRelevant({
|
84
133
|
result,
|
85
|
-
|
86
|
-
})
|
134
|
+
action,
|
135
|
+
});
|
136
|
+
|
137
|
+
if (!isRelevant) {
|
138
|
+
console.log("The event is not relevant. Skipping...");
|
139
|
+
return;
|
140
|
+
}
|
87
141
|
|
88
142
|
this.emitEvent(result);
|
89
143
|
},
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import
|
1
|
+
import app from "../../trello.app.mjs";
|
2
2
|
|
3
3
|
export default {
|
4
4
|
props: {
|
5
|
-
|
5
|
+
app,
|
6
6
|
db: "$.service.db",
|
7
7
|
},
|
8
8
|
methods: {
|
@@ -13,11 +13,11 @@ export default {
|
|
13
13
|
* @param {string} name - The name of the item of the book.
|
14
14
|
*/
|
15
15
|
generateMeta({
|
16
|
-
id, name
|
16
|
+
id, name,
|
17
17
|
}) {
|
18
18
|
return {
|
19
19
|
id,
|
20
|
-
summary
|
20
|
+
summary: name || `${id}`,
|
21
21
|
ts: Date.now(),
|
22
22
|
};
|
23
23
|
},
|
@@ -30,5 +30,8 @@ export default {
|
|
30
30
|
const meta = this.generateMeta(result);
|
31
31
|
this.$emit(result, meta);
|
32
32
|
},
|
33
|
+
sortItemsByDate(items, sortField) {
|
34
|
+
return items.sort((a, b) => (Date.parse(a[sortField]) > Date.parse(b[sortField])));
|
35
|
+
},
|
33
36
|
},
|
34
37
|
};
|
@@ -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
|
-
name: "Custom Webhook Events (Instant)",
|
7
|
+
name: "Custom Webhook Events (Instant)", /* eslint-disable-line pipedream/source-name */
|
7
8
|
description: "Emit new events for activity matching a board, event types, lists and/or cards.",
|
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
|
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,
|
@@ -40,69 +42,55 @@ export default {
|
|
40
42
|
],
|
41
43
|
},
|
42
44
|
},
|
43
|
-
hooks: {
|
44
|
-
...common.hooks,
|
45
|
-
async deploy() {
|
46
|
-
const {
|
47
|
-
sampleEvents, sortField,
|
48
|
-
} = await this.getSampleEvents();
|
49
|
-
sampleEvents.sort((a, b) => (Date.parse(a[sortField]) > Date.parse(b[sortField]))
|
50
|
-
? 1
|
51
|
-
: -1);
|
52
|
-
for (const action of sampleEvents.slice(-25)) {
|
53
|
-
this.emitEvent({
|
54
|
-
action,
|
55
|
-
});
|
56
|
-
}
|
57
|
-
},
|
58
|
-
},
|
59
45
|
methods: {
|
60
46
|
...common.methods,
|
61
|
-
|
62
|
-
const eventTypes = this.eventTypes
|
47
|
+
getSampleEvents() {
|
48
|
+
const eventTypes = this.eventTypes?.length
|
63
49
|
? this.eventTypes.join(",")
|
64
50
|
: null;
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
51
|
+
return this.app.getBoardActivity({
|
52
|
+
boardId: this.board,
|
53
|
+
params: {
|
54
|
+
filter: eventTypes,
|
55
|
+
},
|
56
|
+
});
|
57
|
+
},
|
58
|
+
getSortField() {
|
59
|
+
return "date";
|
70
60
|
},
|
71
|
-
isCorrectEventType(
|
72
|
-
const eventType = event.body?.action?.type;
|
61
|
+
isCorrectEventType({ type }) {
|
73
62
|
return (
|
74
|
-
(
|
75
|
-
(!this.eventTypes ||
|
76
|
-
this.eventTypes.
|
77
|
-
this.eventTypes.includes(eventType))
|
63
|
+
(type) &&
|
64
|
+
(!this.eventTypes?.length ||
|
65
|
+
this.eventTypes.includes(type))
|
78
66
|
);
|
79
67
|
},
|
80
|
-
async getResult(event) {
|
81
|
-
return event.body;
|
82
|
-
},
|
83
68
|
async isRelevant({ result: body }) {
|
84
69
|
let listId = body.action?.data?.list?.id;
|
85
70
|
const cardId = body.action?.data?.card?.id;
|
86
71
|
// If listId not returned, see if we can get it from the cardId
|
87
|
-
if (cardId && !listId)
|
88
|
-
|
72
|
+
if (cardId && !listId) {
|
73
|
+
const res = await this.app.getCardList({
|
74
|
+
cardId,
|
75
|
+
});
|
76
|
+
listId = res.id;
|
77
|
+
}
|
89
78
|
return (
|
90
|
-
(!this.lists ||
|
91
|
-
this.lists.length === 0 ||
|
79
|
+
(!this.lists?.length ||
|
92
80
|
!listId ||
|
93
81
|
this.lists.includes(listId)) &&
|
94
|
-
(!this.cards
|
82
|
+
(!this.cards?.length || !cardId || this.cards.includes(cardId))
|
95
83
|
);
|
96
84
|
},
|
97
|
-
generateMeta(
|
85
|
+
generateMeta(action) {
|
98
86
|
const {
|
99
87
|
id,
|
100
|
-
type
|
88
|
+
type,
|
101
89
|
date,
|
102
90
|
} = action;
|
103
91
|
return {
|
104
92
|
id,
|
105
|
-
summary
|
93
|
+
summary: `New ${type} event`,
|
106
94
|
ts: Date.parse(date),
|
107
95
|
};
|
108
96
|
},
|
@@ -1,62 +1,55 @@
|
|
1
1
|
import common from "../common/common-webhook.mjs";
|
2
|
+
import actions from "../common/actions.mjs";
|
2
3
|
|
3
4
|
export default {
|
4
5
|
...common,
|
5
6
|
key: "trello-new-activity",
|
6
|
-
name: "New Activity (Instant)",
|
7
|
+
name: "New Board Activity (Instant)",
|
7
8
|
description: "Emit new event for new activity on a board.",
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
} = await this.getSampleEvents();
|
25
|
-
sampleEvents.sort((a, b) => (Date.parse(a[sortField]) > Date.parse(b[sortField]))
|
26
|
-
? 1
|
27
|
-
: -1);
|
28
|
-
for (const action of sampleEvents.slice(-25)) {
|
29
|
-
this.emitEvent({
|
30
|
-
action,
|
31
|
-
});
|
32
|
-
}
|
19
|
+
activityTypes: {
|
20
|
+
type: "string[]",
|
21
|
+
label: "Activity Types",
|
22
|
+
description: "Filter incoming events by the activity type",
|
23
|
+
options: actions,
|
24
|
+
optional: true,
|
33
25
|
},
|
34
26
|
},
|
35
27
|
methods: {
|
36
28
|
...common.methods,
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
sortField: "date",
|
42
|
-
};
|
29
|
+
getSampleEvents() {
|
30
|
+
return this.app.getBoardActivity({
|
31
|
+
boardId: this.board,
|
32
|
+
});
|
43
33
|
},
|
44
|
-
|
45
|
-
return
|
34
|
+
getSortField() {
|
35
|
+
return "date";
|
46
36
|
},
|
47
|
-
isRelevant({
|
48
|
-
const
|
49
|
-
|
37
|
+
isRelevant({ action }) {
|
38
|
+
const {
|
39
|
+
data, type,
|
40
|
+
} = action;
|
41
|
+
return ((!this.board || this.board === data?.board?.id)
|
42
|
+
&& (!this.activityTypes?.length || this.activityTypes.includes(type)));
|
50
43
|
},
|
51
|
-
generateMeta(
|
44
|
+
generateMeta(action) {
|
52
45
|
const {
|
53
46
|
id,
|
54
|
-
type
|
47
|
+
type,
|
55
48
|
date,
|
56
49
|
} = action;
|
57
50
|
return {
|
58
51
|
id,
|
59
|
-
summary
|
52
|
+
summary: `New ${type} activity`,
|
60
53
|
ts: Date.parse(date),
|
61
54
|
};
|
62
55
|
},
|