@pipedream/trello 0.3.2 → 0.3.5
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-via-url/add-attachment-to-card-via-url.mjs +73 -0
- package/actions/add-checklist/add-checklist.mjs +68 -0
- package/actions/add-comment/add-comment.mjs +55 -0
- package/actions/add-existing-label-to-card/add-existing-label-to-card.mjs +48 -0
- package/actions/add-file-as-attachment-via-url/add-file-as-attachment-via-url.mjs +72 -0
- package/actions/add-image-attachment/add-image-attachment.mjs +75 -0
- package/actions/add-label-to-card/add-label-to-card.mjs +55 -0
- package/actions/add-member-to-card/add-member-to-card.mjs +48 -0
- package/actions/archive-card/archive-card.mjs +37 -0
- package/actions/close-board/close-board.mjs +25 -0
- package/actions/common.js +21 -0
- package/actions/complete-checklist-item/complete-checklist-item.mjs +49 -0
- package/actions/copy-board/copy-board.mjs +174 -0
- package/actions/create-board/create-board.mjs +175 -0
- package/actions/create-card/create-card.mjs +195 -0
- package/actions/create-checklist/create-checklist.mjs +66 -0
- package/actions/create-checklist-item/create-checklist-item.mjs +67 -0
- package/actions/create-comment-on-card/create-comment-on-card.mjs +42 -0
- package/actions/create-label/create-label.mjs +73 -0
- package/actions/create-list/create-list.mjs +67 -0
- package/actions/delete-checklist/delete-checklist.mjs +46 -0
- package/actions/find-labels/find-labels.mjs +44 -0
- package/actions/find-list/find-list.mjs +49 -0
- package/actions/get-card/get-card.mjs +37 -0
- package/actions/get-list/get-list.mjs +32 -0
- package/actions/move-card-to-list/move-card-to-list.mjs +53 -0
- package/actions/remove-label-from-card/remove-label-from-card.mjs +47 -0
- package/actions/rename-list/rename-list.mjs +47 -0
- package/actions/search-boards/search-boards.mjs +57 -0
- package/actions/search-cards/search-cards.mjs +59 -0
- package/actions/search-checklists/search-checklists.mjs +110 -0
- package/actions/search-members/search-members.mjs +61 -0
- package/actions/update-card/update-card.mjs +165 -0
- package/common/events.js +138 -0
- package/common/fields.js +50 -0
- package/package.json +23 -19
- package/sources/board-based.mjs +27 -0
- package/sources/card-archived/card-archived.mjs +54 -0
- package/sources/card-due-date-reminder/card-due-date-reminder.mjs +80 -0
- package/sources/card-moved/card-moved.mjs +84 -0
- package/sources/card-updates/card-updates.mjs +60 -0
- package/sources/common-polling.mjs +16 -0
- package/sources/common-webhook.mjs +90 -0
- package/sources/common.js +34 -0
- package/sources/custom-webhook-events/custom-webhook-events.mjs +110 -0
- package/sources/new-activity/new-activity.mjs +64 -0
- package/sources/new-attachment/new-attachment.mjs +60 -0
- package/sources/new-board/new-board.mjs +29 -0
- package/sources/new-card/new-card.mjs +58 -0
- package/sources/new-checklist/new-checklist.mjs +29 -0
- package/sources/new-comment-added-to-card/new-comment-added-to-card.mjs +94 -0
- package/sources/new-label/new-label.mjs +41 -0
- package/sources/new-label-added-to-card/new-label-added-to-card.mjs +138 -0
- package/sources/new-list/new-list.mjs +29 -0
- package/sources/new-member-on-card/new-member-on-card.mjs +38 -0
- package/sources/new-notification/new-notification.mjs +50 -0
- package/trello.app.js +647 -145
- package/sources/card-archived/card-archived.js +0 -75
- package/sources/card-due-date-reminder/card-due-date-reminder.js +0 -65
- package/sources/card-moved/card-moved.js +0 -84
- package/sources/card-updates/card-updates.js +0 -77
- package/sources/custom-webhook-events/custom-webhook-events.js +0 -72
- package/sources/new-board/new-board.js +0 -62
- package/sources/new-card/new-card.js +0 -77
- package/sources/new-checklist/new-checklist.js +0 -74
- package/sources/new-comment-added-to-card/new-comment-added-to-card.js +0 -86
- package/sources/new-label/new-label.js +0 -73
- package/sources/new-label-added-to-card/new-labels-added-to-card.js +0 -85
- package/sources/new-list/new-list.js +0 -74
- package/sources/new-member-on-card/new-member-on-card.js +0 -75
- package/sources/new-notification/new-notification.js +0 -45
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import common from "../common-polling.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "trello-card-due-date-reminder",
|
|
6
|
+
name: "Card Due Date Reminder",
|
|
7
|
+
description: "Emit new event at a specified time before a card is due.",
|
|
8
|
+
version: "0.0.5",
|
|
9
|
+
type: "source",
|
|
10
|
+
dedupe: "unique",
|
|
11
|
+
props: {
|
|
12
|
+
...common.props,
|
|
13
|
+
board: {
|
|
14
|
+
propDefinition: [
|
|
15
|
+
common.props.trello,
|
|
16
|
+
"board",
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
timeBefore: {
|
|
20
|
+
type: "integer",
|
|
21
|
+
label: "Time Before",
|
|
22
|
+
description: "How far before the due time the event should trigger.",
|
|
23
|
+
default: 5,
|
|
24
|
+
},
|
|
25
|
+
timeBeforeUnit: {
|
|
26
|
+
type: "integer",
|
|
27
|
+
label: "Time Before (Unit)",
|
|
28
|
+
description: "Unit of time for Time Before.",
|
|
29
|
+
options: [
|
|
30
|
+
{
|
|
31
|
+
label: "Minutes",
|
|
32
|
+
value: 60000,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: "Hours",
|
|
36
|
+
value: 3600000,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: "Days",
|
|
40
|
+
value: 86400000,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: "Weeks",
|
|
44
|
+
value: 604800000,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
default: 60000,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
methods: {
|
|
51
|
+
...common.methods,
|
|
52
|
+
generateMeta({
|
|
53
|
+
id, name: summary,
|
|
54
|
+
}, now) {
|
|
55
|
+
return {
|
|
56
|
+
id,
|
|
57
|
+
summary,
|
|
58
|
+
ts: now,
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
emitEvent(card, now) {
|
|
62
|
+
const meta = this.generateMeta(card, now);
|
|
63
|
+
this.$emit(card, meta);
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
async run(event) {
|
|
67
|
+
const boardId = this.board;
|
|
68
|
+
const now = event.timestamp * 1000;
|
|
69
|
+
|
|
70
|
+
const cards = await this.trello.getCards(boardId);
|
|
71
|
+
for (const card of cards) {
|
|
72
|
+
if (!card.due) continue;
|
|
73
|
+
const due = Date.parse(card.due);
|
|
74
|
+
const notifyAt = due - this.timeBefore * this.timeBeforeUnit;
|
|
75
|
+
if (notifyAt <= now) {
|
|
76
|
+
this.emitEvent(card, now);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import common from "../common-webhook.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "trello-card-moved",
|
|
6
|
+
name: "Card Moved (Instant)",
|
|
7
|
+
description: "Emit new event each time a card is moved to a list.",
|
|
8
|
+
version: "0.0.8",
|
|
9
|
+
type: "source",
|
|
10
|
+
props: {
|
|
11
|
+
...common.props,
|
|
12
|
+
board: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
common.props.trello,
|
|
15
|
+
"board",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
lists: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
common.props.trello,
|
|
21
|
+
"lists",
|
|
22
|
+
(c) => ({
|
|
23
|
+
board: c.board,
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
methods: {
|
|
29
|
+
...common.methods,
|
|
30
|
+
async getSampleEvents() {
|
|
31
|
+
const cards = this.lists && this.lists.length > 0
|
|
32
|
+
? await this.trello.getCardsInList(this.lists[0])
|
|
33
|
+
: await this.trello.getCards(this.board);
|
|
34
|
+
return {
|
|
35
|
+
sampleEvents: cards,
|
|
36
|
+
sortFilter: "dateLastActivity",
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
_getListAfter() {
|
|
40
|
+
return this.db.get("listAfter");
|
|
41
|
+
},
|
|
42
|
+
_setListAfter(listAfter) {
|
|
43
|
+
this.db.set("listAfter", listAfter);
|
|
44
|
+
},
|
|
45
|
+
isCorrectEventType(event) {
|
|
46
|
+
const eventTranslationKey = event.body?.action?.display?.translationKey;
|
|
47
|
+
return eventTranslationKey === "action_move_card_from_list_to_list";
|
|
48
|
+
},
|
|
49
|
+
async getResult(event) {
|
|
50
|
+
const cardId = event.body?.action?.data?.card?.id;
|
|
51
|
+
const listAfter = event.body?.action?.data?.listAfter?.name;
|
|
52
|
+
/** Record listAfter to use in generateMeta() */
|
|
53
|
+
this._setListAfter(listAfter);
|
|
54
|
+
return this.trello.getCard(cardId);
|
|
55
|
+
},
|
|
56
|
+
isRelevant({
|
|
57
|
+
result: card, event,
|
|
58
|
+
}) {
|
|
59
|
+
const listIdAfter = event.body?.action?.data?.listAfter?.id;
|
|
60
|
+
const listIdBefore = event.body?.action?.data?.listBefore?.id;
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
(!this.board || this.board === card.idBoard) &&
|
|
64
|
+
(!this.lists ||
|
|
65
|
+
this.lists.length === 0 ||
|
|
66
|
+
this.lists.includes(listIdAfter) ||
|
|
67
|
+
this.lists.includes(listIdBefore))
|
|
68
|
+
);
|
|
69
|
+
},
|
|
70
|
+
generateMeta({
|
|
71
|
+
id, name,
|
|
72
|
+
}) {
|
|
73
|
+
const listAfter = this._getListAfter();
|
|
74
|
+
const summary = listAfter
|
|
75
|
+
? `${name} - moved to ${listAfter}`
|
|
76
|
+
: name;
|
|
77
|
+
return {
|
|
78
|
+
id,
|
|
79
|
+
summary,
|
|
80
|
+
ts: Date.now(),
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import common from "../common-webhook.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "trello-card-updates",
|
|
6
|
+
name: "Card Updates (Instant)",
|
|
7
|
+
description: "Emit new event for each update to a Trello card.",
|
|
8
|
+
version: "0.0.8",
|
|
9
|
+
type: "source",
|
|
10
|
+
props: {
|
|
11
|
+
...common.props,
|
|
12
|
+
board: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
common.props.trello,
|
|
15
|
+
"board",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
cards: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
common.props.trello,
|
|
21
|
+
"cards",
|
|
22
|
+
(c) => ({
|
|
23
|
+
board: c.board,
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
methods: {
|
|
29
|
+
...common.methods,
|
|
30
|
+
async getSampleEvents() {
|
|
31
|
+
let cards = [];
|
|
32
|
+
if (this.cards && this.cards.length > 0) {
|
|
33
|
+
for (const cardId of this.cards) {
|
|
34
|
+
const card = await this.trello.getCard(cardId);
|
|
35
|
+
cards.push(card);
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
cards = await this.trello.getCards(this.board);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
sampleEvents: cards,
|
|
42
|
+
sortField: "dateLastActivity",
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
isCorrectEventType(event) {
|
|
46
|
+
const eventType = event.body?.action?.type;
|
|
47
|
+
return eventType === "updateCard";
|
|
48
|
+
},
|
|
49
|
+
async getResult(event) {
|
|
50
|
+
const cardId = event.body?.action?.data?.card?.id;
|
|
51
|
+
return this.trello.getCard(cardId);
|
|
52
|
+
},
|
|
53
|
+
isRelevant({ result: card }) {
|
|
54
|
+
return (
|
|
55
|
+
(!this.board || this.board === card.idBoard) &&
|
|
56
|
+
(!this.cards || this.cards.length === 0 || this.cards.includes(card.id))
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import common from "./common.js";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
props: {
|
|
6
|
+
...common.props,
|
|
7
|
+
timer: {
|
|
8
|
+
label: "Polling interval",
|
|
9
|
+
description: "Pipedream will poll the Trello API on this schedule",
|
|
10
|
+
type: "$.interface.timer",
|
|
11
|
+
default: {
|
|
12
|
+
intervalSeconds: 60 * 15,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import common from "./common.js";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
props: {
|
|
6
|
+
...common.props,
|
|
7
|
+
http: "$.interface.http",
|
|
8
|
+
},
|
|
9
|
+
hooks: {
|
|
10
|
+
async deploy() {
|
|
11
|
+
const {
|
|
12
|
+
sampleEvents, sortField,
|
|
13
|
+
} = await this.getSampleEvents();
|
|
14
|
+
sampleEvents.sort((a, b) => (Date.parse(a[sortField]) > Date.parse(b[sortField]))
|
|
15
|
+
? 1
|
|
16
|
+
: -1);
|
|
17
|
+
for (const event of sampleEvents.slice(-25)) {
|
|
18
|
+
this.emitEvent(event);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
async activate() {
|
|
22
|
+
const modelId = await this.getModelId();
|
|
23
|
+
const { id } = await this.trello.createHook({
|
|
24
|
+
id: modelId,
|
|
25
|
+
endpoint: this.http.endpoint,
|
|
26
|
+
});
|
|
27
|
+
this.db.set("hookId", id);
|
|
28
|
+
},
|
|
29
|
+
async deactivate() {
|
|
30
|
+
const hookId = this.db.get("hookId");
|
|
31
|
+
await this.trello.deleteHook({
|
|
32
|
+
hookId,
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
methods: {
|
|
37
|
+
...common.methods,
|
|
38
|
+
/**
|
|
39
|
+
* Returns the ID of the current board selected. If no board is selected, returns
|
|
40
|
+
* the id of the authenticated user.
|
|
41
|
+
*/
|
|
42
|
+
async getModelId() {
|
|
43
|
+
if (this.board) return this.board;
|
|
44
|
+
const member = await this.trello.getMember("me");
|
|
45
|
+
return member.id;
|
|
46
|
+
},
|
|
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
|
+
/**
|
|
58
|
+
* Default isCorrectEventType. Used in components to verify that the event received is
|
|
59
|
+
* of the type that the component is watching for.
|
|
60
|
+
*/
|
|
61
|
+
isCorrectEventType() {
|
|
62
|
+
return true;
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Default isRelevant. Used in components to verify that the event received matches the
|
|
66
|
+
* board, list and/or card specified in the component's props.
|
|
67
|
+
*/
|
|
68
|
+
isRelevant() {
|
|
69
|
+
return true;
|
|
70
|
+
},
|
|
71
|
+
getSampleEvents() {
|
|
72
|
+
throw new Error("getSampleEvents not implemented");
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
async run(event) {
|
|
76
|
+
if (!this.verifyEvent(event)) {
|
|
77
|
+
console.log("The event failed the verification. Skipping...");
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (!this.isCorrectEventType(event)) return;
|
|
81
|
+
|
|
82
|
+
const result = await this.getResult(event);
|
|
83
|
+
if (!(await this.isRelevant({
|
|
84
|
+
result,
|
|
85
|
+
event,
|
|
86
|
+
}))) return;
|
|
87
|
+
|
|
88
|
+
this.emitEvent(result);
|
|
89
|
+
},
|
|
90
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const trello = require("../trello.app.js");
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
props: {
|
|
5
|
+
trello,
|
|
6
|
+
db: "$.service.db",
|
|
7
|
+
},
|
|
8
|
+
methods: {
|
|
9
|
+
/**
|
|
10
|
+
* Default generateMeta. Components should overwrite this function if they require
|
|
11
|
+
* different meta to be emitted.
|
|
12
|
+
* @param {string} id - The id of the item being emitted.
|
|
13
|
+
* @param {string} name - The name of the item of the book.
|
|
14
|
+
*/
|
|
15
|
+
generateMeta({
|
|
16
|
+
id, name: summary,
|
|
17
|
+
}) {
|
|
18
|
+
return {
|
|
19
|
+
id,
|
|
20
|
+
summary,
|
|
21
|
+
ts: Date.now(),
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* Default emitEvent. Components should overwrite this function if something more
|
|
26
|
+
* needs to be emitted in the event.
|
|
27
|
+
* @param {object} result - The result object to be emitted
|
|
28
|
+
*/
|
|
29
|
+
emitEvent(result) {
|
|
30
|
+
const meta = this.generateMeta(result);
|
|
31
|
+
this.$emit(result, meta);
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import common from "../common-webhook.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "trello-custom-webhook-events",
|
|
6
|
+
name: "Custom Webhook Events (Instant)",
|
|
7
|
+
description: "Emit new events for activity matching a board, event types, lists and/or cards.",
|
|
8
|
+
version: "0.0.7",
|
|
9
|
+
type: "source",
|
|
10
|
+
props: {
|
|
11
|
+
...common.props,
|
|
12
|
+
board: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
common.props.trello,
|
|
15
|
+
"board",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
eventTypes: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
common.props.trello,
|
|
21
|
+
"eventTypes",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
lists: {
|
|
25
|
+
propDefinition: [
|
|
26
|
+
common.props.trello,
|
|
27
|
+
"lists",
|
|
28
|
+
(c) => ({
|
|
29
|
+
board: c.board,
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
cards: {
|
|
34
|
+
propDefinition: [
|
|
35
|
+
common.props.trello,
|
|
36
|
+
"cards",
|
|
37
|
+
(c) => ({
|
|
38
|
+
board: c.board,
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
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
|
+
methods: {
|
|
60
|
+
...common.methods,
|
|
61
|
+
async getSampleEvents() {
|
|
62
|
+
const eventTypes = this.eventTypes && this.eventTypes.length > 0
|
|
63
|
+
? this.eventTypes.join(",")
|
|
64
|
+
: null;
|
|
65
|
+
const actions = await this.trello.getBoardActivity(this.board, eventTypes);
|
|
66
|
+
return {
|
|
67
|
+
sampleEvents: actions,
|
|
68
|
+
sortField: "date",
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
isCorrectEventType(event) {
|
|
72
|
+
const eventType = event.body?.action?.type;
|
|
73
|
+
return (
|
|
74
|
+
(eventType) &&
|
|
75
|
+
(!this.eventTypes ||
|
|
76
|
+
this.eventTypes.length === 0 ||
|
|
77
|
+
this.eventTypes.includes(eventType))
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
async getResult(event) {
|
|
81
|
+
return event.body;
|
|
82
|
+
},
|
|
83
|
+
async isRelevant({ result: body }) {
|
|
84
|
+
let listId = body.action?.data?.list?.id;
|
|
85
|
+
const cardId = body.action?.data?.card?.id;
|
|
86
|
+
// If listId not returned, see if we can get it from the cardId
|
|
87
|
+
if (cardId && !listId)
|
|
88
|
+
listId = (await this.trello.getCardList(cardId)).id;
|
|
89
|
+
return (
|
|
90
|
+
(!this.lists ||
|
|
91
|
+
this.lists.length === 0 ||
|
|
92
|
+
!listId ||
|
|
93
|
+
this.lists.includes(listId)) &&
|
|
94
|
+
(!this.cards || this.cards.length === 0 || !cardId || this.cards.includes(cardId))
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
generateMeta({ action }) {
|
|
98
|
+
const {
|
|
99
|
+
id,
|
|
100
|
+
type: summary,
|
|
101
|
+
date,
|
|
102
|
+
} = action;
|
|
103
|
+
return {
|
|
104
|
+
id,
|
|
105
|
+
summary,
|
|
106
|
+
ts: Date.parse(date),
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import common from "../common-webhook.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "trello-new-activity",
|
|
6
|
+
name: "New Activity (Instant)",
|
|
7
|
+
description: "Emit new event for new activity on a board.",
|
|
8
|
+
version: "0.0.5",
|
|
9
|
+
type: "source",
|
|
10
|
+
props: {
|
|
11
|
+
...common.props,
|
|
12
|
+
board: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
common.props.trello,
|
|
15
|
+
"board",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
hooks: {
|
|
20
|
+
...common.hooks,
|
|
21
|
+
async deploy() {
|
|
22
|
+
const {
|
|
23
|
+
sampleEvents, sortField,
|
|
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
|
+
}
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
methods: {
|
|
36
|
+
...common.methods,
|
|
37
|
+
async getSampleEvents() {
|
|
38
|
+
const actions = await this.trello.getBoardActivity(this.board);
|
|
39
|
+
return {
|
|
40
|
+
sampleEvents: actions,
|
|
41
|
+
sortField: "date",
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
async getResult(event) {
|
|
45
|
+
return event.body;
|
|
46
|
+
},
|
|
47
|
+
isRelevant({ event }) {
|
|
48
|
+
const boardId = event.body?.action?.data?.board?.id;
|
|
49
|
+
return !this.board || this.board === boardId;
|
|
50
|
+
},
|
|
51
|
+
generateMeta({ action }) {
|
|
52
|
+
const {
|
|
53
|
+
id,
|
|
54
|
+
type: summary,
|
|
55
|
+
date,
|
|
56
|
+
} = action;
|
|
57
|
+
return {
|
|
58
|
+
id,
|
|
59
|
+
summary,
|
|
60
|
+
ts: Date.parse(date),
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import common from "../common-webhook.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "trello-new-attachment",
|
|
6
|
+
name: "New Attachment (Instant)",
|
|
7
|
+
description: "Emit new event for new attachment on a board.",
|
|
8
|
+
version: "0.0.5",
|
|
9
|
+
type: "source",
|
|
10
|
+
props: {
|
|
11
|
+
...common.props,
|
|
12
|
+
board: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
common.props.trello,
|
|
15
|
+
"board",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
hooks: {
|
|
20
|
+
...common.hooks,
|
|
21
|
+
async deploy() {
|
|
22
|
+
const {
|
|
23
|
+
sampleEvents, sortField,
|
|
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.$emit(action, {
|
|
30
|
+
id: action.id,
|
|
31
|
+
summary: action?.data?.attachment?.name,
|
|
32
|
+
ts: Date.parse(action.date),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
methods: {
|
|
38
|
+
...common.methods,
|
|
39
|
+
async getSampleEvents() {
|
|
40
|
+
const actions = await this.trello.getBoardActivity(this.board, "addAttachmentToCard");
|
|
41
|
+
return {
|
|
42
|
+
sampleEvents: actions,
|
|
43
|
+
sortField: "date",
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
isCorrectEventType(event) {
|
|
47
|
+
const eventType = event.body?.action?.type;
|
|
48
|
+
return eventType === "addAttachmentToCard";
|
|
49
|
+
},
|
|
50
|
+
async getResult(event) {
|
|
51
|
+
const cardId = event.body?.action?.data?.card?.id;
|
|
52
|
+
const attachmentId = event.body?.action?.data?.attachment?.id;
|
|
53
|
+
return this.trello.getAttachment(cardId, attachmentId);
|
|
54
|
+
},
|
|
55
|
+
isRelevant({ event }) {
|
|
56
|
+
const boardId = event.body?.action?.data?.board?.id;
|
|
57
|
+
return !this.board || this.board === boardId;
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import common from "../common-webhook.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "trello-new-board",
|
|
6
|
+
name: "New Board (Instant)",
|
|
7
|
+
description: "Emit new event for each new board added.",
|
|
8
|
+
version: "0.0.9",
|
|
9
|
+
type: "source",
|
|
10
|
+
dedupe: "unique",
|
|
11
|
+
methods: {
|
|
12
|
+
...common.methods,
|
|
13
|
+
async getSampleEvents() {
|
|
14
|
+
const boards = await this.trello.getBoards();
|
|
15
|
+
return {
|
|
16
|
+
sampleEvents: boards,
|
|
17
|
+
sortField: "dateLastView",
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
isCorrectEventType(event) {
|
|
21
|
+
const eventType = event.body?.action?.type;
|
|
22
|
+
return eventType === "createBoard";
|
|
23
|
+
},
|
|
24
|
+
async getResult(event) {
|
|
25
|
+
const boardId = event.body?.action?.data?.board?.id;
|
|
26
|
+
return this.trello.getBoard(boardId);
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import common from "../common-webhook.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "trello-new-card",
|
|
6
|
+
name: "New Card (Instant)",
|
|
7
|
+
description: "Emit new event for each new Trello card on a board.",
|
|
8
|
+
version: "0.0.8",
|
|
9
|
+
type: "source",
|
|
10
|
+
dedupe: "unique",
|
|
11
|
+
props: {
|
|
12
|
+
...common.props,
|
|
13
|
+
board: {
|
|
14
|
+
propDefinition: [
|
|
15
|
+
common.props.trello,
|
|
16
|
+
"board",
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
lists: {
|
|
20
|
+
propDefinition: [
|
|
21
|
+
common.props.trello,
|
|
22
|
+
"lists",
|
|
23
|
+
(c) => ({
|
|
24
|
+
board: c.board,
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
methods: {
|
|
30
|
+
...common.methods,
|
|
31
|
+
async getSampleEvents() {
|
|
32
|
+
const cards = this.lists && this.lists.length > 0
|
|
33
|
+
? await this.trello.getCardsInList(this.lists[0])
|
|
34
|
+
: await this.trello.getCards(this.board);
|
|
35
|
+
return {
|
|
36
|
+
sampleEvents: cards,
|
|
37
|
+
sortField: "dateLastActivity",
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
isCorrectEventType(event) {
|
|
41
|
+
const eventType = event.body?.action?.type;
|
|
42
|
+
return eventType === "createCard";
|
|
43
|
+
},
|
|
44
|
+
async getResult(event) {
|
|
45
|
+
const cardId = event.body?.action?.data?.card?.id;
|
|
46
|
+
return this.trello.getCard(cardId);
|
|
47
|
+
},
|
|
48
|
+
isRelevant({ result: card }) {
|
|
49
|
+
if (this.board && this.board !== card.idBoard) return false;
|
|
50
|
+
return (
|
|
51
|
+
(!this.board || this.board === card.idBoard) &&
|
|
52
|
+
(!this.lists ||
|
|
53
|
+
this.lists.length === 0 ||
|
|
54
|
+
this.lists.includes(card.idList))
|
|
55
|
+
);
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|