@pipedream/trello 0.4.0 → 1.0.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.
Files changed (65) hide show
  1. package/actions/add-attachment-to-card/add-attachment-to-card.mjs +29 -58
  2. package/actions/add-checklist/add-checklist.mjs +9 -19
  3. package/actions/add-comment/add-comment.mjs +4 -5
  4. package/actions/add-existing-label-to-card/add-existing-label-to-card.mjs +9 -19
  5. package/actions/add-member-to-card/add-member-to-card.mjs +9 -19
  6. package/actions/archive-card/archive-card.mjs +5 -6
  7. package/actions/{common.mjs → common/common.mjs} +1 -1
  8. package/actions/complete-checklist-item/complete-checklist-item.mjs +4 -14
  9. package/actions/create-board/create-board.mjs +10 -47
  10. package/actions/create-card/create-card.mjs +45 -65
  11. package/actions/create-checklist-item/create-checklist-item.mjs +4 -14
  12. package/actions/create-label/create-label.mjs +5 -18
  13. package/actions/create-list/create-list.mjs +4 -12
  14. package/actions/delete-checklist/delete-checklist.mjs +8 -18
  15. package/actions/find-labels/find-labels.mjs +2 -3
  16. package/actions/find-list/find-list.mjs +2 -2
  17. package/actions/get-card/get-card.mjs +2 -2
  18. package/actions/get-list/get-list.mjs +1 -1
  19. package/actions/move-card-to-list/move-card-to-list.mjs +2 -2
  20. package/actions/remove-label-from-card/remove-label-from-card.mjs +9 -18
  21. package/actions/rename-list/rename-list.mjs +2 -2
  22. package/actions/search-boards/search-boards.mjs +10 -8
  23. package/actions/search-cards/search-cards.mjs +11 -8
  24. package/actions/search-checklists/search-checklists.mjs +56 -75
  25. package/actions/search-members/search-members.mjs +13 -23
  26. package/actions/update-card/update-card.mjs +22 -21
  27. package/common/constants.mjs +128 -0
  28. package/common/fields.mjs +1 -0
  29. package/package.json +3 -2
  30. package/sources/card-archived/card-archived.mjs +16 -28
  31. package/sources/card-archived/test-event.mjs +64 -0
  32. package/sources/card-due-date-reminder/card-due-date-reminder.mjs +111 -33
  33. package/sources/card-due-date-reminder/test-event.mjs +75 -0
  34. package/sources/card-moved/card-moved.mjs +20 -23
  35. package/sources/card-moved/test-event.mjs +78 -0
  36. package/sources/card-updates/card-updates.mjs +20 -27
  37. package/sources/card-updates/test-event.mjs +86 -0
  38. package/sources/common/actions.mjs +206 -0
  39. package/sources/common/common-board-based.mjs +12 -7
  40. package/sources/common/common-webhook.mjs +27 -16
  41. package/sources/common/common.mjs +5 -2
  42. package/sources/custom-webhook-events/custom-webhook-events.mjs +17 -48
  43. package/sources/new-activity/new-activity.mjs +22 -31
  44. package/sources/new-attachment/new-attachment.mjs +40 -49
  45. package/sources/new-attachment/test-event.mjs +69 -0
  46. package/sources/new-board/new-board.mjs +18 -11
  47. package/sources/new-board/test-event.mjs +100 -0
  48. package/sources/new-card/new-card.mjs +20 -27
  49. package/sources/new-card/test-event.mjs +79 -0
  50. package/sources/new-checklist/new-checklist.mjs +39 -22
  51. package/sources/new-checklist/test-event.mjs +22 -0
  52. package/sources/new-comment-added-to-card/new-comment-added-to-card.mjs +38 -44
  53. package/sources/new-comment-added-to-card/test-event.mjs +298 -0
  54. package/sources/new-label/new-label.mjs +13 -14
  55. package/sources/new-label/test-event.mjs +7 -0
  56. package/sources/new-label-added-to-card/new-label-added-to-card.mjs +23 -24
  57. package/sources/new-label-added-to-card/test-event.mjs +85 -0
  58. package/sources/new-member-on-card/new-member-on-card.mjs +17 -26
  59. package/sources/new-member-on-card/test-event.mjs +83 -0
  60. package/sources/new-notification/new-notification.mjs +3 -12
  61. package/trello.app.mjs +211 -33
  62. package/actions/close-board/close-board.mjs +0 -31
  63. package/actions/create-checklist/create-checklist.mjs +0 -78
  64. package/actions/create-comment-on-card/create-comment-on-card.mjs +0 -59
  65. package/sources/new-list/new-list.mjs +0 -33
@@ -1,11 +1,12 @@
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-attachment",
6
7
  name: "New Attachment (Instant)",
7
- description: "Emit new event for new attachment on a board.",
8
- version: "0.1.0",
8
+ description: "Emit new event when a new attachment is added on a board.",
9
+ version: "0.1.1",
9
10
  type: "source",
10
11
  props: {
11
12
  ...common.props,
@@ -15,62 +16,52 @@ export default {
15
16
  "board",
16
17
  ],
17
18
  },
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
- }
19
+ lists: {
20
+ propDefinition: [
21
+ common.props.app,
22
+ "lists",
23
+ (c) => ({
24
+ board: c.board,
25
+ }),
26
+ ],
27
+ description: "If specified, events will only be emitted when an attachment is added to a card in one of the specified lists",
35
28
  },
36
29
  },
37
30
  methods: {
38
31
  ...common.methods,
39
- getAttachment({
40
- cardId, attachmentId, ...args
41
- } = {}) {
42
- return this.app._makeRequest({
43
- path: `/cards/${cardId}/attachments/${attachmentId}`,
44
- ...args,
45
- });
46
- },
47
32
  async getSampleEvents() {
48
- const actions = await this.app.getBoardActivity({
49
- boardId: this.board,
50
- params: {
51
- filter: "addAttachmentToCard",
52
- },
53
- });
54
- return {
55
- sampleEvents: actions,
56
- sortField: "date",
57
- };
33
+ const cards = this.lists?.length
34
+ ? await this.app.getCardsInList({
35
+ listId: this.lists[0],
36
+ })
37
+ : await this.app.getCards({
38
+ boardId: this.board,
39
+ });
40
+ const attachments = [];
41
+ for (const card of cards) {
42
+ const cardAttachments = await this.app.listCardAttachments({
43
+ cardId: card.id,
44
+ });
45
+ attachments.push(...cardAttachments);
46
+ }
47
+ return attachments;
48
+ },
49
+ getSortField() {
50
+ return "date";
58
51
  },
59
- isCorrectEventType(event) {
60
- const eventType = event.body?.action?.type;
61
- return eventType === "addAttachmentToCard";
52
+ isCorrectEventType({ type }) {
53
+ return type === "addAttachmentToCard";
62
54
  },
63
- async getResult(event) {
64
- const cardId = event.body?.action?.data?.card?.id;
65
- const attachmentId = event.body?.action?.data?.attachment?.id;
66
- return this.getAttachment({
67
- cardId,
68
- attachmentId,
55
+ getResult({ data }) {
56
+ return this.app.getAttachment({
57
+ cardId: data?.card?.id,
58
+ attachmentId: data?.attachment?.id,
69
59
  });
70
60
  },
71
- isRelevant({ event }) {
72
- const boardId = event.body?.action?.data?.board?.id;
73
- return !this.board || this.board === boardId;
61
+ isRelevant({ action }) {
62
+ return (!this.board || this.board === action?.data?.board?.id)
63
+ && (!this.lists?.length || this.lists.includes(action?.data?.list?.id));
74
64
  },
75
65
  },
66
+ sampleEmit,
76
67
  };
@@ -0,0 +1,69 @@
1
+ export default {
2
+ "id": "608b1310a52eed3b040d98ca",
3
+ "bytes": 18820,
4
+ "date": "2021-04-29T20:12:00.760Z",
5
+ "edgeColor": "#bbac9c",
6
+ "idMember": "5df149d4fa80be39e64c9a43",
7
+ "isUpload": true,
8
+ "mimeType": "image/jpeg",
9
+ "name": "meowsalot.jpg",
10
+ "previews": [
11
+ {
12
+ "id": "608b1311a52eed3b040d98d6",
13
+ "_id": "608b1311a52eed3b040d98d6",
14
+ "scaled": false,
15
+ "url": "",
16
+ "bytes": 1649,
17
+ "height": 50,
18
+ "width": 70
19
+ },
20
+ {
21
+ "id": "608b1311a52eed3b040d98d7",
22
+ "_id": "608b1311a52eed3b040d98d7",
23
+ "scaled": false,
24
+ "url": "",
25
+ "bytes": 9598,
26
+ "height": 150,
27
+ "width": 250
28
+ },
29
+ {
30
+ "id": "608b1311a52eed3b040d98d8",
31
+ "_id": "608b1311a52eed3b040d98d8",
32
+ "scaled": true,
33
+ "url": "",
34
+ "bytes": 4508,
35
+ "height": 98,
36
+ "width": 150
37
+ },
38
+ {
39
+ "id": "608b1311a52eed3b040d98d9",
40
+ "_id": "608b1311a52eed3b040d98d9",
41
+ "scaled": true,
42
+ "url": "",
43
+ "bytes": 13736,
44
+ "height": 195,
45
+ "width": 300
46
+ },
47
+ {
48
+ "id": "608b1311a52eed3b040d98da",
49
+ "_id": "608b1311a52eed3b040d98da",
50
+ "scaled": true,
51
+ "url": "",
52
+ "bytes": 20289,
53
+ "height": 260,
54
+ "width": 400
55
+ },
56
+ {
57
+ "id": "608b1311a52eed3b040d98db",
58
+ "_id": "608b1311a52eed3b040d98db",
59
+ "scaled": false,
60
+ "url": "",
61
+ "bytes": 18820,
62
+ "height": 260,
63
+ "width": 400
64
+ }
65
+ ],
66
+ "url": "",
67
+ "pos": 16384,
68
+ "fileName": "meowsalot.jpg"
69
+ }
@@ -1,31 +1,38 @@
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-board",
6
7
  name: "New Board (Instant)",
7
8
  description: "Emit new event for each new board added.",
8
- version: "0.1.0",
9
+ version: "0.1.1",
9
10
  type: "source",
10
11
  dedupe: "unique",
11
12
  methods: {
12
13
  ...common.methods,
13
14
  async getSampleEvents() {
14
15
  const boards = await this.app.getBoards();
15
- return {
16
- sampleEvents: boards,
17
- sortField: "dateLastView",
18
- };
16
+ const allBoards = [];
17
+ for (const board of boards) {
18
+ const b = await this.app.getBoard({
19
+ boardId: board.id,
20
+ });
21
+ allBoards.push(b);
22
+ }
23
+ return allBoards;
19
24
  },
20
- isCorrectEventType(event) {
21
- const eventType = event.body?.action?.type;
22
- return eventType === "createBoard";
25
+ getSortField() {
26
+ return "dateLastView";
23
27
  },
24
- async getResult(event) {
25
- const boardId = event.body?.action?.data?.board?.id;
28
+ isCorrectEventType({ type }) {
29
+ return type === "createBoard";
30
+ },
31
+ getResult({ data }) {
26
32
  return this.app.getBoard({
27
- boardId,
33
+ boardId: data?.board?.id,
28
34
  });
29
35
  },
30
36
  },
37
+ sampleEmit,
31
38
  };
@@ -0,0 +1,100 @@
1
+ export default {
2
+ "id": "608b147275ba1f27e956a696",
3
+ "name": "New Board",
4
+ "desc": "",
5
+ "descData": null,
6
+ "closed": true,
7
+ "idOrganization": "6047c17c2f558003144e04d7",
8
+ "idEnterprise": null,
9
+ "pinned": false,
10
+ "url": "https://trello.com/b/RoxOjLDb/new-board",
11
+ "shortUrl": "https://trello.com/b/RoxOjLDb",
12
+ "prefs": {
13
+ "permissionLevel": "org",
14
+ "hideVotes": false,
15
+ "voting": "disabled",
16
+ "comments": "members",
17
+ "invitations": "members",
18
+ "selfJoin": true,
19
+ "cardCovers": true,
20
+ "cardCounts": false,
21
+ "isTemplate": false,
22
+ "cardAging": "regular",
23
+ "calendarFeedEnabled": false,
24
+ "hiddenPluginBoardButtons": [],
25
+ "switcherViews": [
26
+ {
27
+ "viewType": "Board",
28
+ "enabled": true
29
+ },
30
+ ],
31
+ "background": "608af97d7a474e8d98c2eef2",
32
+ "backgroundColor": null,
33
+ "backgroundImage": "",
34
+ "backgroundTile": false,
35
+ "backgroundBrightness": "dark",
36
+ "sharedSourceUrl": "",
37
+ "backgroundImageScaled": [
38
+ {
39
+ "width": 140,
40
+ "height": 79,
41
+ "url": ""
42
+ },
43
+ {
44
+ "width": 256,
45
+ "height": 144,
46
+ "url": ""
47
+ },
48
+ {
49
+ "width": 480,
50
+ "height": 270,
51
+ "url": ""
52
+ },
53
+ {
54
+ "width": 960,
55
+ "height": 540,
56
+ "url": ""
57
+ },
58
+ {
59
+ "width": 1024,
60
+ "height": 576,
61
+ "url": ""
62
+ },
63
+ {
64
+ "width": 1280,
65
+ "height": 720,
66
+ "url": ""
67
+ },
68
+ {
69
+ "width": 1920,
70
+ "height": 1080,
71
+ "url": ""
72
+ },
73
+ {
74
+ "width": 2048,
75
+ "height": 1152,
76
+ "url": ""
77
+ },
78
+ {
79
+ "width": 2560,
80
+ "height": 1440,
81
+ "url": ""
82
+ }
83
+ ],
84
+ "backgroundBottomColor": "#231a15",
85
+ "backgroundTopColor": "#626667",
86
+ "canBePublic": true,
87
+ "canBeEnterprise": true,
88
+ "canBeOrg": true,
89
+ "canBePrivate": true,
90
+ "canInvite": true
91
+ },
92
+ "labelNames": {
93
+ "green": "",
94
+ "yellow": "",
95
+ "orange": "",
96
+ "red": "",
97
+ "purple": "",
98
+ "blue": "",
99
+ }
100
+ }
@@ -1,11 +1,12 @@
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-card",
6
7
  name: "New Card (Instant)",
7
8
  description: "Emit new event for each new Trello card on a board.",
8
- version: "0.1.0",
9
+ version: "0.1.1",
9
10
  type: "source",
10
11
  dedupe: "unique",
11
12
  props: {
@@ -24,45 +25,37 @@ export default {
24
25
  board: c.board,
25
26
  }),
26
27
  ],
27
- },
28
- customFieldItems: {
29
- propDefinition: [
30
- common.props.app,
31
- "customFieldItems",
32
- ],
28
+ description: "If specified, events will only be emitted when a card is created in one of the specified lists",
33
29
  },
34
30
  },
35
31
  methods: {
36
32
  ...common.methods,
37
33
  async getSampleEvents() {
38
- const cards = this.lists && this.lists.length > 0
34
+ const params = {
35
+ customFieldItems: true,
36
+ };
37
+ const cards = this.lists?.length
39
38
  ? await this.app.getCardsInList({
40
39
  listId: this.lists[0],
41
- params: {
42
- customFieldItems: this.customFieldItems,
43
- },
40
+ params,
44
41
  })
45
42
  : await this.app.getCards({
46
43
  boardId: this.board,
47
- params: {
48
- customFieldItems: this.customFieldItems,
49
- },
44
+ params,
50
45
  });
51
- return {
52
- sampleEvents: cards,
53
- sortField: "dateLastActivity",
54
- };
46
+ return cards;
47
+ },
48
+ getSortField() {
49
+ return "dateLastActivity";
55
50
  },
56
- isCorrectEventType(event) {
57
- const eventType = event.body?.action?.type;
58
- return eventType === "createCard";
51
+ isCorrectEventType({ type }) {
52
+ return type === "createCard";
59
53
  },
60
- async getResult(event) {
61
- const cardId = event.body?.action?.data?.card?.id;
54
+ getResult({ data }) {
62
55
  return this.app.getCard({
63
- cardId,
56
+ cardId: data?.card?.id,
64
57
  params: {
65
- customFieldItems: this.customFieldItems,
58
+ customFieldItems: true,
66
59
  },
67
60
  });
68
61
  },
@@ -70,10 +63,10 @@ export default {
70
63
  if (this.board && this.board !== card.idBoard) return false;
71
64
  return (
72
65
  (!this.board || this.board === card.idBoard) &&
73
- (!this.lists ||
74
- this.lists.length === 0 ||
66
+ (!this.lists?.length ||
75
67
  this.lists.includes(card.idList))
76
68
  );
77
69
  },
78
70
  },
71
+ sampleEmit,
79
72
  };
@@ -0,0 +1,79 @@
1
+ export default {
2
+ "id": "60836bac2ed2ef78f4cf850d",
3
+ "badges": {
4
+ "attachmentsByType": {
5
+ "trello": {
6
+ "board": 0,
7
+ "card": 0
8
+ }
9
+ },
10
+ "externalSource": null,
11
+ "location": false,
12
+ "votes": 0,
13
+ "viewingMemberVoted": false,
14
+ "subscribed": true,
15
+ "fogbugz": "",
16
+ "checkItems": 1,
17
+ "checkItemsChecked": 0,
18
+ "checkItemsEarliestDue": null,
19
+ "comments": 3,
20
+ "attachments": 1,
21
+ "description": false,
22
+ "due": "2021-05-10T21:50:00.000Z",
23
+ "dueComplete": false,
24
+ "start": null,
25
+ "lastUpdatedByAi": false
26
+ },
27
+ "checkItemStates": [],
28
+ "closed": false,
29
+ "dueComplete": false,
30
+ "dateLastActivity": "2021-11-02T23:02:44.876Z",
31
+ "desc": "",
32
+ "descData": null,
33
+ "due": "2021-05-10T21:50:00.000Z",
34
+ "dueReminder": 1440,
35
+ "email": null,
36
+ "idBoard": "5f4d7be6c45c22583f75fa02",
37
+ "idChecklists": [
38
+ "608b2037ea7ac07da59c17be"
39
+ ],
40
+ "idList": "5f4ec9f69028408fed04c0b1",
41
+ "idMembers": [],
42
+ "idMembersVoted": [],
43
+ "idShort": 54,
44
+ "idAttachmentCover": "6099aece406c0b7a97e71535",
45
+ "labels": [
46
+ {
47
+ "id": "608b2273586147300cc73046",
48
+ "idBoard": "5f4d7be6c45c22583f75fa02",
49
+ "idOrganization": "6047c17c2f558003144e04d7",
50
+ "name": "orange",
51
+ "nodeId": "ari:cloud:trello::label/workspace/6047c17c2f558003144e04d7/608b2273586147300cc73046",
52
+ "color": "orange",
53
+ "uses": 4
54
+ },
55
+ ],
56
+ "idLabels": [
57
+ "608b2273586147300cc73046",
58
+ ],
59
+ "manualCoverAttachment": false,
60
+ "name": "new card",
61
+ "pinned": false,
62
+ "pos": 655359,
63
+ "shortLink": "fo2GH2y2",
64
+ "shortUrl": "https://trello.com/c/fo2GH2y2",
65
+ "start": null,
66
+ "subscribed": true,
67
+ "url": "https://trello.com/c/fo2GH2y2/54-new-card",
68
+ "cover": {
69
+ "idAttachment": "6099aece406c0b7a97e71535",
70
+ "color": null,
71
+ "idUploadedBackground": null,
72
+ "size": "normal",
73
+ "brightness": "dark",
74
+ "idPlugin": null
75
+ },
76
+ "isTemplate": false,
77
+ "cardRole": null,
78
+ "customFieldItems": []
79
+ }
@@ -1,41 +1,58 @@
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-checklist",
6
7
  name: "New Checklist (Instant)",
7
8
  description: "Emit new event for each new checklist added to a board.",
8
- version: "0.1.0",
9
+ version: "0.1.1",
9
10
  type: "source",
10
11
  dedupe: "unique",
12
+ props: {
13
+ ...common.props,
14
+ board: {
15
+ propDefinition: [
16
+ common.props.app,
17
+ "board",
18
+ ],
19
+ },
20
+ lists: {
21
+ propDefinition: [
22
+ common.props.app,
23
+ "lists",
24
+ (c) => ({
25
+ board: c.board,
26
+ }),
27
+ ],
28
+ description: "If specified, events will only be emitted when a checklist is added to a card in one of the specified lists",
29
+ },
30
+ onlyEventsRelatedWithAuthenticatedUser: {
31
+ label: "Only Events Related To Me",
32
+ description: "Only will emit events from the cards related with the authenticated user",
33
+ type: "boolean",
34
+ default: false,
35
+ optional: true,
36
+ },
37
+ },
11
38
  methods: {
12
39
  ...common.methods,
13
- getChecklist({
14
- checklistId, ...args
15
- } = {}) {
16
- return this.app._makeRequest({
17
- path: `/checklists/${checklistId}`,
18
- ...args,
19
- });
20
- },
21
- async getSampleEvents() {
22
- const checklists = await this.app.listBoardChecklists({
40
+ getSampleEvents() {
41
+ return this.app.listBoardChecklists({
23
42
  boardId: this.board,
24
43
  });
25
- return {
26
- sampleEvents: checklists,
27
- sortField: "id",
28
- };
29
44
  },
30
- isCorrectEventType(event) {
31
- const eventType = event.body?.action?.type;
32
- return eventType === "addChecklistToCard";
45
+ getSortField() {
46
+ return "id";
47
+ },
48
+ isCorrectEventType({ type }) {
49
+ return type === "addChecklistToCard";
33
50
  },
34
- async getResult(event) {
35
- const checklistId = event.body?.action?.data?.checklist?.id;
36
- return this.getChecklist({
37
- checklistId,
51
+ getResult({ data }) {
52
+ return this.app.getChecklist({
53
+ checklistId: data?.checklist?.id,
38
54
  });
39
55
  },
40
56
  },
57
+ sampleEmit,
41
58
  };
@@ -0,0 +1,22 @@
1
+ export default {
2
+ "id": "6181a5c4b843ed8eb8fc1482",
3
+ "name": "Checklist",
4
+ "idBoard": "5f4d7be6c45c22583f75fa02",
5
+ "idCard": "6099aff7ab0cc929f640e06e",
6
+ "pos": 16384,
7
+ "checkItems": [
8
+ {
9
+ "id": "6181a5c685e54137db6951f5",
10
+ "name": "item",
11
+ "nameData": {
12
+ "emoji": {}
13
+ },
14
+ "pos": 17027,
15
+ "state": "complete",
16
+ "due": null,
17
+ "dueReminder": null,
18
+ "idMember": null,
19
+ "idChecklist": "6181a5c4b843ed8eb8fc1482"
20
+ }
21
+ ]
22
+ }