@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.
Files changed (71) hide show
  1. package/actions/add-attachment-to-card/add-attachment-to-card.mjs +131 -0
  2. package/actions/add-checklist/add-checklist.mjs +50 -42
  3. package/actions/add-comment/add-comment.mjs +44 -35
  4. package/actions/add-existing-label-to-card/add-existing-label-to-card.mjs +19 -14
  5. package/actions/add-member-to-card/add-member-to-card.mjs +19 -14
  6. package/actions/archive-card/archive-card.mjs +15 -10
  7. package/actions/{common.mjs → common/common.mjs} +2 -2
  8. package/actions/complete-checklist-item/complete-checklist-item.mjs +51 -31
  9. package/actions/create-board/create-board.mjs +86 -88
  10. package/actions/create-card/create-card.mjs +102 -53
  11. package/actions/create-checklist-item/create-checklist-item.mjs +54 -39
  12. package/actions/create-label/create-label.mjs +38 -50
  13. package/actions/create-list/create-list.mjs +43 -42
  14. package/actions/delete-checklist/delete-checklist.mjs +17 -14
  15. package/actions/find-labels/find-labels.mjs +14 -12
  16. package/actions/find-list/find-list.mjs +13 -10
  17. package/actions/get-card/get-card.mjs +13 -9
  18. package/actions/get-list/get-list.mjs +29 -15
  19. package/actions/move-card-to-list/move-card-to-list.mjs +17 -13
  20. package/actions/remove-label-from-card/remove-label-from-card.mjs +20 -13
  21. package/actions/rename-list/rename-list.mjs +24 -10
  22. package/actions/search-boards/search-boards.mjs +22 -18
  23. package/actions/search-cards/search-cards.mjs +23 -18
  24. package/actions/search-checklists/search-checklists.mjs +96 -59
  25. package/actions/search-members/search-members.mjs +44 -34
  26. package/actions/update-card/update-card.mjs +68 -50
  27. package/common/constants.mjs +128 -0
  28. package/common/fields.mjs +1 -0
  29. package/package.json +5 -3
  30. package/sources/card-archived/card-archived.mjs +22 -18
  31. package/sources/card-archived/test-event.mjs +64 -0
  32. package/sources/card-due-date-reminder/card-due-date-reminder.mjs +118 -39
  33. package/sources/card-due-date-reminder/test-event.mjs +75 -0
  34. package/sources/card-moved/card-moved.mjs +30 -27
  35. package/sources/card-moved/test-event.mjs +78 -0
  36. package/sources/card-updates/card-updates.mjs +29 -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 +16 -9
  40. package/sources/common/common-webhook.mjs +86 -32
  41. package/sources/common/common.mjs +7 -4
  42. package/sources/custom-webhook-events/custom-webhook-events.mjs +37 -49
  43. package/sources/new-activity/new-activity.mjs +25 -32
  44. package/sources/new-attachment/new-attachment.mjs +42 -35
  45. package/sources/new-attachment/test-event.mjs +69 -0
  46. package/sources/new-board/new-board.mjs +21 -12
  47. package/sources/new-board/test-event.mjs +100 -0
  48. package/sources/new-card/new-card.mjs +29 -27
  49. package/sources/new-card/test-event.mjs +79 -0
  50. package/sources/new-checklist/new-checklist.mjs +42 -13
  51. package/sources/new-checklist/test-event.mjs +22 -0
  52. package/sources/new-comment-added-to-card/new-comment-added-to-card.mjs +49 -34
  53. package/sources/new-comment-added-to-card/test-event.mjs +298 -0
  54. package/sources/new-label/new-label.mjs +17 -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 +38 -29
  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 +21 -18
  59. package/sources/new-member-on-card/test-event.mjs +83 -0
  60. package/sources/new-notification/new-notification.mjs +8 -7
  61. package/trello.app.mjs +454 -494
  62. package/actions/add-attachment-to-card-via-url/add-attachment-to-card-via-url.mjs +0 -73
  63. package/actions/add-file-as-attachment-via-url/add-file-as-attachment-via-url.mjs +0 -72
  64. package/actions/add-image-attachment/add-image-attachment.mjs +0 -75
  65. package/actions/add-label-to-card/add-label-to-card.mjs +0 -55
  66. package/actions/close-board/close-board.mjs +0 -25
  67. package/actions/copy-board/copy-board.mjs +0 -174
  68. package/actions/create-checklist/create-checklist.mjs +0 -66
  69. package/actions/create-comment-on-card/create-comment-on-card.mjs +0 -42
  70. package/sources/new-list/new-list.mjs +0 -29
  71. /package/{common → sources/common}/events.mjs +0 -0
package/trello.app.mjs CHANGED
@@ -1,44 +1,57 @@
1
1
  import { axios } from "@pipedream/platform";
2
- import crypto from "crypto";
3
- import events from "./common/events.mjs";
4
2
  import fields from "./common/fields.mjs";
5
- import mime from "mime";
3
+ import constants from "./common/constants.mjs";
4
+ import mime from "mime/types/standard.js";
6
5
 
7
6
  export default {
8
7
  type: "app",
9
8
  app: "trello",
10
9
  description: "Pipedream Trello Components",
11
10
  propDefinitions: {
12
- cards: {
13
- type: "string[]",
14
- label: "Cards",
15
- description: "The Trello cards you wish to select",
16
- optional: true,
17
- async options(opts) {
18
- const cards = await this.getCards(opts.board);
19
- return cards.map((card) => ({
20
- label: card.name,
21
- value: card.id,
22
- }));
23
- },
24
- },
25
11
  board: {
26
12
  type: "string",
27
13
  label: "Board",
28
14
  description: "The Trello board you wish to select",
29
15
  async options() {
30
16
  const boards = await this.getBoards();
31
- const activeBoards = boards.filter((board) => board.closed === false);
32
- return activeBoards.map((board) => ({
33
- label: board.name,
34
- value: board.id,
17
+ return boards.filter(({ closed }) => closed === false)
18
+ .map(({
19
+ id: value, name: label,
20
+ }) => ({
21
+ label,
22
+ value,
23
+ }));
24
+ },
25
+ },
26
+ cards: {
27
+ type: "string[]",
28
+ label: "Cards",
29
+ description: "The Trello cards you wish to select",
30
+ optional: true,
31
+ async options({
32
+ board, list, checklistCardsOnly,
33
+ }) {
34
+ let cards = await this.getCards({
35
+ boardId: board,
36
+ });
37
+ if (list) {
38
+ cards = cards.filter(({ idList }) => idList === list);
39
+ }
40
+ if (checklistCardsOnly) {
41
+ cards = cards.filter(({ idChecklists }) => idChecklists?.length);
42
+ }
43
+ return cards.map(({
44
+ id: value, name: label,
45
+ }) => ({
46
+ label,
47
+ value,
35
48
  }));
36
49
  },
37
50
  },
38
51
  boardFields: {
39
52
  type: "string[]",
40
53
  label: "Boards Fields",
41
- description: "`all` or a list of board [fields](https://developer.atlassian.com/cloud/trello/guides/rest-api/object-definitions/#board-object)",
54
+ description: "`all` or a list of board [fields](https://developer.atlassian.com/cloud/trello/guides/rest-api/object-definitions/#board-object) to be returned in the results",
42
55
  options: fields.board,
43
56
  default: [
44
57
  "name",
@@ -48,26 +61,21 @@ export default {
48
61
  cardFields: {
49
62
  type: "string[]",
50
63
  label: "Cards Fields",
51
- description: "`all` or a list of card [fields](https://developer.atlassian.com/cloud/trello/guides/rest-api/object-definitions/#card-object)",
64
+ description: "`all` or a list of card [fields](https://developer.atlassian.com/cloud/trello/guides/rest-api/object-definitions/#card-object) to be returned in the results",
52
65
  options: fields.card,
53
66
  default: [
54
67
  "all",
55
68
  ],
56
69
  },
57
- eventTypes: {
58
- type: "string[]",
59
- label: "Event Types",
60
- optional: true,
61
- description: "Only emit events for the selected event types (e.g., `updateCard`).",
62
- options: events,
63
- },
64
70
  lists: {
65
71
  type: "string[]",
66
72
  label: "Lists",
67
73
  description: "The Trello lists you wish to select",
68
74
  optional: true,
69
- async options(opts) {
70
- const lists = await this.getLists(opts.board);
75
+ async options({ board }) {
76
+ const lists = await this.getLists({
77
+ boardId: board,
78
+ });
71
79
  return lists.map((list) => ({
72
80
  label: list.name,
73
81
  value: list.id,
@@ -84,9 +92,14 @@ export default {
84
92
  label: "Organization IDs",
85
93
  description: "Specify the organizations to search for boards in",
86
94
  async options() {
87
- const orgs = await this.listOrganizations(this.$auth.oauth_uid);
95
+ const orgs = await this.listOrganizations({
96
+ memberId: this.$auth.oauth_uid,
97
+ params: {
98
+ fields: "all",
99
+ },
100
+ });
88
101
  return orgs.map((org) => ({
89
- label: org.name || org.id,
102
+ label: org.displayName ?? org.name ?? org.id,
90
103
  value: org.id,
91
104
  }));
92
105
  },
@@ -108,11 +121,28 @@ export default {
108
121
  type: "string",
109
122
  label: "Label",
110
123
  description: "The ID of the Label to be added to the card",
111
- async options(opts) {
112
- const labels = await this.findLabel(opts.board);
113
- return labels.map((label) => ({
114
- label: label.name,
115
- value: label.id,
124
+ async options({
125
+ board, card, excludeCardLabels, cardLabelsOnly,
126
+ }) {
127
+ let labels = await this.findLabel({
128
+ boardId: board,
129
+ });
130
+ if (card) {
131
+ const { idLabels } = await this.getCard({
132
+ cardId: card,
133
+ });
134
+ if (excludeCardLabels) {
135
+ labels = labels.filter(({ id }) => !idLabels.includes(id));
136
+ }
137
+ if (cardLabelsOnly) {
138
+ labels = labels.filter(({ id }) => idLabels.includes(id));
139
+ }
140
+ }
141
+ return labels.map(({
142
+ name, color, id: value,
143
+ }) => ({
144
+ label: name || color,
145
+ value,
116
146
  }));
117
147
  },
118
148
  },
@@ -120,8 +150,18 @@ export default {
120
150
  type: "string",
121
151
  label: "Member",
122
152
  description: "The ID of the Member to be added to the card",
123
- async options(opts) {
124
- const members = await this.listMembers(opts.board);
153
+ async options({
154
+ board, card, excludeCardMembers,
155
+ }) {
156
+ let members = await this.listMembers({
157
+ boardId: board,
158
+ });
159
+ if (card && excludeCardMembers) {
160
+ const { idMembers } = await this.getCard({
161
+ cardId: card,
162
+ });
163
+ members = members.filter(({ id }) => !idMembers.includes(id));
164
+ }
125
165
  return members.map((member) => ({
126
166
  label: member.fullName,
127
167
  value: member.id,
@@ -132,14 +172,16 @@ export default {
132
172
  type: "string",
133
173
  label: "Checklist",
134
174
  description: "The ID of a checklist to copy into the new checklist",
135
- async options(opts) {
136
- const {
137
- board,
138
- card,
139
- } = opts;
175
+ async options({
176
+ board, card,
177
+ }) {
140
178
  const checklists = card ?
141
- await this.listCardChecklists(card) :
142
- await this.listBoardChecklists(board);
179
+ await this.listCardChecklists({
180
+ cardId: card,
181
+ }) :
182
+ await this.listBoardChecklists({
183
+ boardId: board,
184
+ });
143
185
  return checklists.map((checklist) => ({
144
186
  label: checklist.name,
145
187
  value: checklist.id,
@@ -152,7 +194,9 @@ export default {
152
194
  description: "An array of custom field Ids to create/update",
153
195
  optional: true,
154
196
  async options({ boardId }) {
155
- const customFields = await this.listCustomFields(boardId);
197
+ const customFields = await this.listCustomFields({
198
+ boardId,
199
+ });
156
200
  return customFields?.map(({
157
201
  id: value, name: label,
158
202
  }) => ({
@@ -161,15 +205,6 @@ export default {
161
205
  })) || [];
162
206
  },
163
207
  },
164
- mimeType: {
165
- type: "string",
166
- label: "File Attachment Type",
167
- description: "Not required for URL attachment",
168
- optional: true,
169
- options() {
170
- return Object.values(mime._types);
171
- },
172
- },
173
208
  name: {
174
209
  type: "string",
175
210
  label: "Name",
@@ -181,6 +216,19 @@ export default {
181
216
  label: "File Attachment URL",
182
217
  description: "URL must start with `http://` or `https://`",
183
218
  },
219
+ mimeType: {
220
+ type: "string",
221
+ label: "Mime Type",
222
+ description: "Mime type of the attached file. Eg. `application/pdf`",
223
+ options() {
224
+ return Object.keys(mime);
225
+ },
226
+ },
227
+ file: {
228
+ type: "string",
229
+ label: "File Attachment Path",
230
+ description: "The path to the file saved to the `/tmp` directory (e.g. `/tmp/example.pdf`). [See the documentation](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory)",
231
+ },
184
232
  desc: {
185
233
  type: "string",
186
234
  label: "Description",
@@ -190,11 +238,8 @@ export default {
190
238
  pos: {
191
239
  type: "string",
192
240
  label: "Position",
193
- description: "The position of the new card, can be `top`, `bottom`, or a positive number",
194
- options: [
195
- "top",
196
- "bottom",
197
- ],
241
+ description: "The position of the checklist on the card. One of: top, bottom, or a positive number.",
242
+ options: constants.POSITIONS,
198
243
  optional: true,
199
244
  },
200
245
  due: {
@@ -231,25 +276,14 @@ export default {
231
276
  type: "string",
232
277
  label: "Card Filter",
233
278
  description: "Filter to apply to Cards. Valid values: `all`, `closed`, `none`, `open`, `visible`",
234
- options: [
235
- "all",
236
- "closed",
237
- "none",
238
- "open",
239
- "visible",
240
- ],
279
+ options: constants.CARD_FILTERS,
241
280
  default: "all",
242
281
  },
243
282
  listFilter: {
244
283
  type: "string",
245
284
  label: "List Filter",
246
285
  description: "Type of list to search for",
247
- options: [
248
- "all",
249
- "closed",
250
- "none",
251
- "open",
252
- ],
286
+ options: constants.LIST_FILTERS,
253
287
  default: "all",
254
288
  },
255
289
  customFieldItems: {
@@ -259,421 +293,273 @@ export default {
259
293
  default: false,
260
294
  optional: true,
261
295
  },
296
+ checklistItemId: {
297
+ type: "string",
298
+ label: "Checklist Item ID",
299
+ description: "The ID of the checklist item.",
300
+ async options({ checklistId }) {
301
+ const checkItems = await this.listCheckItems({
302
+ checklistId,
303
+ });
304
+ return checkItems.map(({
305
+ name: label, id: value,
306
+ }) => ({
307
+ label,
308
+ value,
309
+ }));
310
+ },
311
+ },
312
+ cardAttachmentId: {
313
+ type: "string",
314
+ label: "Cover Attachment ID",
315
+ description: "Assign an attachment id to be the cover image for the card",
316
+ optional: true,
317
+ async options({
318
+ cardId, params,
319
+ }) {
320
+ const attachments = await this.listCardAttachments({
321
+ cardId,
322
+ params,
323
+ });
324
+ return attachments.map(({
325
+ name, url, id: value,
326
+ }) => ({
327
+ label: name || url,
328
+ value,
329
+ }));
330
+ },
331
+ },
332
+ fileType: {
333
+ type: "string",
334
+ label: "File Attachment Type",
335
+ description: "Select whether to attach file from a path or URL",
336
+ options: [
337
+ "path",
338
+ "url",
339
+ ],
340
+ },
262
341
  },
263
342
  methods: {
264
- _getBaseUrl() {
265
- return "https://api.trello.com/1/";
266
- },
267
- async _getAuthorizationHeader({
268
- data, method, url,
269
- }, $) {
270
- const requestData = {
271
- data,
272
- method,
273
- url,
274
- };
275
- const token = {
276
- key: this.$auth.oauth_access_token,
277
- secret: this.$auth.oauth_refresh_token,
278
- };
279
- return axios($ ?? this, {
280
- method: "POST",
281
- url: this.$auth.oauth_signer_uri,
282
- data: {
283
- requestData,
284
- token,
285
- },
286
- });
343
+ getSignerUri() {
344
+ return this.$auth.oauth_signer_uri;
287
345
  },
288
- async _makeRequest(args, $) {
346
+ getToken() {
289
347
  const {
290
- method = "GET",
291
- path,
292
- ...otherArgs
293
- } = args;
294
- const config = {
295
- method,
296
- url: `${this._getBaseUrl()}${path}`,
297
- ...otherArgs,
298
- };
299
- const authorization = await this._getAuthorizationHeader(config, $);
300
- config.headers = {
301
- ...config.headers,
302
- authorization,
303
- };
304
- try {
305
- return await axios($ ?? this, config);
306
- } catch (err) {
307
- console.log(err);
308
- }
309
- },
310
- /**
311
- * Archives a card.
312
- *
313
- * @param {string} idCard - the ID of the Card to archive.
314
- * @returns an updated card object with `closed` (archived) property set to true.
315
- * See more at the API docs:
316
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-put
317
- */
318
- async archiveCard(idCard, $) {
319
- const config = {
320
- path: `cards/${idCard}`,
321
- method: "PUT",
322
- data: {
323
- closed: true,
324
- },
348
+ oauth_access_token: key,
349
+ oauth_refresh_token: secret,
350
+ } = this.$auth;
351
+ return {
352
+ key,
353
+ secret,
325
354
  };
326
- return this._makeRequest(config, $);
327
355
  },
328
- /**
329
- * Create an Attachment to a Card
330
- *
331
- * @param {string} idCard - the ID of the Card to move.
332
- * @param {Object} params - an object containing parameters for the API request
333
- * @returns {array} an string array with the ID of all the Card's Attachments.
334
- * See more at the API docs:
335
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-attachments-post
336
- */
337
- async addAttachmentToCardViaUrl(idCard, params, $) {
338
- const config = {
339
- path: `cards/${idCard}/attachments`,
340
- method: "POST",
341
- params,
342
- };
343
- return this._makeRequest(config, $);
344
- },
345
- /**
346
- * Adds an existing label to the specified card.
347
- *
348
- * @param {string} idCard - the ID of the Card to move.
349
- * @param {Object} params - an object containing parameters for the API request
350
- * @returns {array} an string array with the ID of all the Card's Labels.
351
- * See more at the API docs:
352
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-idlabels-post
353
- */
354
- async addExistingLabelToCard(idCard, params, $) {
355
- const config = {
356
- path: `cards/${idCard}/idLabels`,
357
- method: "POST",
358
- params,
359
- };
360
- return this._makeRequest(config, $);
356
+ getUrl(path) {
357
+ return `https://api.trello.com/1${path}`;
361
358
  },
362
- /**
363
- * Add a member to a card
364
- *
365
- * @param {string} idCard - the ID of the Card to move.
366
- * @param {Object} params - an object containing parameters for the API request
367
- * @returns {array} an string array with the ID of all the Card's Members.
368
- * See more at the API docs:
369
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-idmembers-post
370
- */
371
- async addMemberToCard(idCard, params, $) {
372
- const config = {
373
- path: `cards/${idCard}/idMembers`,
374
- method: "POST",
375
- params,
359
+ _makeRequest({
360
+ $ = this, path, ...args
361
+ } = {}) {
362
+ const signConfig = {
363
+ token: this.getToken(),
364
+ oauthSignerUri: this.getSignerUri(),
376
365
  };
377
- return this._makeRequest(config, $);
378
- },
379
- /**
380
- * Creates a checklist on the specified card.
381
- *
382
- * @param {Object} params - an object containing parameters for the API request
383
- * @returns an object with the created checklist.
384
- * See more at the API docs:
385
- * https://developer.atlassian.com/cloud/trello/rest/api-group-checklists/#api-checklists-post
386
- */
387
- async createChecklist(params, $) {
366
+
388
367
  const config = {
389
- path: "checklists",
390
- method: "POST",
391
- params,
368
+ ...args,
369
+ url: this.getUrl(path),
392
370
  };
393
- return this._makeRequest(config, $);
371
+
372
+ return axios($, config, signConfig);
394
373
  },
395
- /**
396
- * Creates a comment on a card.
397
- *
398
- * @param {string} idCard - the ID of the Card that the comment should be created on.
399
- * @param {Object} params - an object containing parameters for the API request
400
- * @returns a object containing a summary of the related card, members, and other Trello
401
- * entities related to the newly created comment.
402
- * See more at the API docs:
403
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-actions-comments-post
404
- */
405
- async createCommentOnCard(idCard, comment, $) {
406
- const config = {
407
- path: `cards/${idCard}/actions/comments`,
374
+ post(args = {}) {
375
+ return this._makeRequest({
408
376
  method: "POST",
409
- params: {
410
- text: comment,
411
- },
412
- };
413
- return this._makeRequest(config, $);
377
+ ...args,
378
+ });
414
379
  },
415
- /**
416
- * Closes a board.
417
- *
418
- * @param {string} boardId - the ID of the Board to close.
419
- * @returns the updated board object with the `closed` property set to true.
420
- * See more at the API docs:
421
- * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-put
422
- */
423
- async closeBoard(boardId, $) {
424
- const config = {
425
- path: `boards/${boardId}`,
380
+ put(args = {}) {
381
+ return this._makeRequest({
426
382
  method: "PUT",
427
- data: {
428
- closed: true,
429
- },
430
- };
431
- return this._makeRequest(config, $);
432
- },
433
- /**
434
- * Creates a new card.
435
- *
436
- * @param {Object} opts - an object containing data for the API request
437
- * @returns the created card object. See more at the API docs:
438
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-post
439
- */
440
- async createCard(opts, $) {
441
- const config = {
442
- path: "cards",
443
- method: "post",
444
- data: opts,
445
- };
446
- return this._makeRequest(config, $);
383
+ ...args,
384
+ });
447
385
  },
448
- /**
449
- * Deletes the specified checklist.
450
- *
451
- * @param {string} idChecklist - the ID of the checklist to delete.
452
- * @returns {object} an empty `limits` object indicating the operation completed successfully.
453
- */
454
- async deleteChecklist(idChecklist, $) {
455
- const config = {
456
- path: `checklists/${idChecklist}`,
386
+ delete(args = {}) {
387
+ return this._makeRequest({
457
388
  method: "DELETE",
458
- };
459
- return this._makeRequest(config, $);
389
+ ...args,
390
+ });
460
391
  },
461
- /**
462
- * Finds a label on a specific board.
463
- *
464
- * @param {string} boardId - unique identifier of the board to search for labels.
465
- * @param {Object} params - an object containing parameters for the API request
466
- * @returns {array} an array with label objects complying with the specified parameters.
467
- */
468
- async findLabel(boardId, params, $) {
469
- const config = {
470
- path: `boards/${boardId}/labels`,
471
- params,
472
- };
473
- return this._makeRequest(config, $);
392
+ createBoard(args = {}) {
393
+ return this.post({
394
+ path: "/boards",
395
+ ...args,
396
+ });
474
397
  },
475
- /**
476
- * Finds a list in the specified board.
477
- *
478
- * @param {string} - boardId unique identifier of the board to search for lists.
479
- * @param {Object} params - an object containing parameters for the API request
480
- * @returns {array} an array with list objects conforming with the specified parameters.
481
- */
482
- async findList(boardId, params, $) {
483
- const config = {
484
- path: `boards/${boardId}/lists`,
485
- params,
486
- };
487
- return this._makeRequest(config, $);
398
+ updateBoard({
399
+ boardId, ...args
400
+ } = {}) {
401
+ return this.put({
402
+ path: `/boards/${boardId}`,
403
+ ...args,
404
+ });
488
405
  },
489
- /**
490
- * Moves a card to the specified board/list pair.
491
- *
492
- * @param {string} idCard the ID of the Card to move.
493
- * @param {Object} data - an object containing data for the API request
494
- * @returns an updated card object set to the specified board and list ids.
495
- * See more at the API docs:
496
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-put
497
- */
498
- async moveCardToList(idCard, data, $) {
499
- const config = {
500
- path: `cards/${idCard}`,
501
- method: "PUT",
502
- data,
503
- };
504
- return this._makeRequest(config, $);
406
+ createCard(args = {}) {
407
+ return this.post({
408
+ path: "/cards",
409
+ ...args,
410
+ });
505
411
  },
506
- async verifyTrelloWebhookRequest(request, callbackURL) {
507
- let secret = this.$auth.oauth_refresh_token;
508
- const base64Digest = function (s) {
509
- return crypto.createHmac("sha1", secret).update(s)
510
- .digest("base64");
511
- };
512
- const content = JSON.stringify(request.body) + callbackURL;
513
- const doubleHash = base64Digest(content);
514
- const headerHash = request.headers["x-trello-webhook"];
515
- return doubleHash === headerHash;
412
+ updateCard({
413
+ cardId, ...args
414
+ } = {}) {
415
+ return this.put({
416
+ path: `/cards/${cardId}`,
417
+ ...args,
418
+ });
516
419
  },
517
- async getBoardActivity(boardId, filter = null) {
420
+ findLabel({
421
+ boardId, ...args
422
+ } = {}) {
518
423
  return this._makeRequest({
519
- path: `boards/${boardId}/actions`,
520
- params: {
521
- filter,
522
- },
424
+ path: `/boards/${boardId}/labels`,
425
+ ...args,
523
426
  });
524
427
  },
525
- async getCardActivity(cardId, filter = null) {
428
+ getCardActivity({
429
+ cardId, ...args
430
+ } = {}) {
526
431
  return this._makeRequest({
527
- path: `cards/${cardId}/actions`,
528
- params: {
529
- filter,
530
- },
432
+ path: `/cards/${cardId}/actions`,
433
+ ...args,
531
434
  });
532
435
  },
533
- async getBoard(id) {
436
+ getBoardActivity({
437
+ boardId, ...args
438
+ } = {}) {
534
439
  return this._makeRequest({
535
- path: `boards/${id}`,
440
+ path: `/boards/${boardId}/actions`,
441
+ ...args,
536
442
  });
537
443
  },
538
- async getBoards(id = this.$auth.oauth_uid) {
444
+ getBoard({
445
+ boardId, ...args
446
+ } = {}) {
539
447
  return this._makeRequest({
540
- path: `members/${id}/boards`,
448
+ path: `/boards/${boardId}`,
449
+ ...args,
541
450
  });
542
451
  },
543
- /**
544
- * Gets details of a card.
545
- *
546
- * @param {string} id - the ID of the card to get details of.
547
- * @returns {object} a card object. See more at the API docs:
548
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-post
549
- */
550
- async getCard(id, params = {}, $) {
452
+ getBoards({
453
+ boardId = this.$auth.oauth_uid, ...args
454
+ } = {}) {
551
455
  return this._makeRequest({
552
- path: `cards/${id}`,
553
- params,
554
- }, $);
456
+ path: `/members/${boardId}/boards`,
457
+ ...args,
458
+ });
555
459
  },
556
- async getCards(id, params = {}, $) {
460
+ getCard({
461
+ cardId, ...args
462
+ } = {}) {
557
463
  return this._makeRequest({
558
- path: `boards/${id}/cards`,
559
- params,
560
- }, $);
464
+ path: `/cards/${cardId}`,
465
+ ...args,
466
+ });
561
467
  },
562
- async getFilteredCards(boardId, filter) {
468
+ getCards({
469
+ boardId, ...args
470
+ } = {}) {
563
471
  return this._makeRequest({
564
- path: `boards/${boardId}/cards`,
565
- params: {
566
- filter,
567
- },
472
+ path: `/boards/${boardId}/cards`,
473
+ ...args,
568
474
  });
569
475
  },
570
- async getCardsInList(listId, params = {}, $) {
476
+ getChecklist({
477
+ checklistId, ...args
478
+ } = {}) {
571
479
  return this._makeRequest({
572
- path: `lists/${listId}/cards`,
573
- params,
574
- }, $);
480
+ path: `/checklists/${checklistId}`,
481
+ ...args,
482
+ });
575
483
  },
576
- async getMemberCards(userId) {
484
+ getFilteredCards({
485
+ boardId, filter, ...args
486
+ } = {}) {
577
487
  return this._makeRequest({
578
- path: `members/${userId}/cards`,
488
+ path: `/boards/${boardId}/cards/${filter}`,
489
+ ...args,
579
490
  });
580
491
  },
581
- async getChecklist(id) {
492
+ getCardList({
493
+ cardId, ...args
494
+ } = {}) {
582
495
  return this._makeRequest({
583
- path: `checklists/${id}`,
496
+ path: `/cards/${cardId}/list`,
497
+ ...args,
584
498
  });
585
499
  },
586
- async getLabel(id) {
500
+ getCardsInList({
501
+ listId, ...args
502
+ } = {}) {
587
503
  return this._makeRequest({
588
- path: `labels/${id}`,
504
+ path: `/lists/${listId}/cards`,
505
+ ...args,
589
506
  });
590
507
  },
591
- async getList(id) {
508
+ getLabel({
509
+ labelId, ...args
510
+ } = {}) {
592
511
  return this._makeRequest({
593
- path: `lists/${id}`,
512
+ path: `/labels/${labelId}`,
513
+ ...args,
594
514
  });
595
515
  },
596
- async getLists(id) {
516
+ getLists({
517
+ boardId, ...args
518
+ } = {}) {
597
519
  return this._makeRequest({
598
- path: `boards/${id}/lists`,
520
+ path: `/boards/${boardId}/lists`,
521
+ ...args,
599
522
  });
600
523
  },
601
- async getNotifications(id, params) {
524
+ getList({
525
+ listId, ...args
526
+ } = {}) {
602
527
  return this._makeRequest({
603
- path: `members/${id}/notifications`,
604
- params,
528
+ path: `/lists/${listId}`,
529
+ ...args,
605
530
  });
606
531
  },
607
- async getMember(id) {
532
+ getMember({
533
+ memberId, ...args
534
+ } = {}) {
608
535
  return this._makeRequest({
609
- path: `members/${id}`,
536
+ path: `/members/${memberId}`,
537
+ ...args,
610
538
  });
611
539
  },
612
- async getAttachment(cardId, attachmentId) {
540
+ getMemberCards({
541
+ userId, ...args
542
+ } = {}) {
613
543
  return this._makeRequest({
614
- path: `cards/${cardId}/attachments/${attachmentId}`,
544
+ path: `/members/${userId}/cards`,
545
+ ...args,
615
546
  });
616
547
  },
617
- async getCardList(cardId) {
618
- return this._makeRequest({
619
- path: `cards/${cardId}/list`,
620
- });
621
- },
622
- async createHook({
623
- id, endpoint,
624
- }) {
625
- const resp = await this._makeRequest({
626
- method: "post",
627
- path: "webhooks/",
628
- headers: {
629
- "Content-Type": "applicaton/json",
630
- },
631
- params: {
632
- idModel: id,
633
- description: "Pipedream Source ID", //todo add ID
634
- callbackURL: endpoint,
635
- },
636
- });
637
- return resp;
638
- },
639
- async deleteHook({ hookId }) {
548
+ getAttachment({
549
+ cardId, attachmentId, ...args
550
+ } = {}) {
640
551
  return this._makeRequest({
641
- method: "delete",
642
- path: `webhooks/${hookId}`,
552
+ path: `/cards/${cardId}/attachments/${attachmentId}`,
553
+ ...args,
643
554
  });
644
555
  },
645
- /**
646
- * Removes an existing label from the specified card.
647
- *
648
- * @param {string} idCard - the ID of the Card to remove the Label from.
649
- * @param {string} idLabel - the ID of the Label to be removed from the card.
650
- * @returns {object} an object with the null valued property `_value` indicating that
651
- * there were no errors
652
- */
653
- async removeLabelFromCard(idCard, idLabel, $) {
654
- const config = {
655
- path: `cards/${idCard}/idLabels/${idLabel}`,
656
- method: "DELETE",
657
- };
658
- return this._makeRequest(config, $);
659
- },
660
- /**
661
- * Renames the specified list
662
- *
663
- * @param {string} listId - the ID of the List to rename.
664
- * @param {Object} data - an object containing data for the API request
665
- * @returns {object} a list object with the `closed` property, indicated if the list is
666
- * closed or archived, `id` the id of the renamed List, `idBoard` the id of the Board parent
667
- * to the List, `name` with the new name of the List, and `pos` with the position of the List
668
- * in the Board.
669
- */
670
- async renameList(listId, data, $) {
671
- const config = {
672
- path: `lists/${listId}`,
673
- method: "PUT",
674
- data,
675
- };
676
- return this._makeRequest(config, $);
556
+ getNotifications({
557
+ notificationId, ...args
558
+ } = {}) {
559
+ return this._makeRequest({
560
+ path: `/members/${notificationId}/notifications`,
561
+ ...args,
562
+ });
677
563
  },
678
564
  /**
679
565
  * Searches for members, cards, boards, and/or organizations matching the specified query.
@@ -684,99 +570,173 @@ export default {
684
570
  * this case "cards"), `partial` the search `terms` as included in `query`, and other
685
571
  * `modifiers`.
686
572
  */
687
- async search(params, $) {
688
- const config = {
689
- path: "search",
690
- params,
691
- };
692
- return this._makeRequest(config, $);
693
- },
694
- /**
695
- * Searches for boards matching the specified query.
696
- *
697
- * @param {Object} opts - an object containing data for the API request
698
- * @returns {cards: array, options: object} an array with the `cards` objects matching the
699
- * specified `query`, and an object with the `options` for the search, such as `modelTypes` (in
700
- * this case "cards"), `partial` the search `terms` as included in `query`, and other
701
- * `modifiers`.
702
- */
703
- async searchBoards(opts, $) {
704
- const params = {
705
- ...opts,
706
- idOrganizations: opts.idOrganizations?.join(","),
707
- };
708
- return this.search(params, $);
573
+ search(args = {}) {
574
+ return this._makeRequest({
575
+ path: "/search",
576
+ ...args,
577
+ });
709
578
  },
710
- /**
711
- * Searches for cards matching the specified query.
712
- *
713
- * @param {Object} opts - an object containing data for the API request
714
- * @returns {cards: array, options: object} an array with the `cards` objects matching the
715
- * specified `query`, and an object with the `options` for the search, such as `modelTypes` (in
716
- * this case "cards"), `partial` the search `terms` as included in `query`, and other
717
- * `modifiers`.
718
- */
719
- async searchCards(opts, $) {
720
- const params = {
721
- ...opts,
722
- idOrganizations: opts.idOrganizations?.join(","),
723
- idCards: opts.idCards?.join(","),
724
- };
725
- return this.search(params, $);
579
+ listMembers({
580
+ boardId, ...args
581
+ } = {}) {
582
+ return this._makeRequest({
583
+ path: `/boards/${boardId}/members`,
584
+ ...args,
585
+ });
726
586
  },
727
- /**
728
- * Updates a card.
729
- *
730
- * @param {string} idCard - the ID of the card to update
731
- * @param {Object} params - an object containing parameters for the API request
732
- * @returns the updated card object. See more at the API docs:
733
- * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-post
734
- */
735
- async updateCard(idCard,
736
- params, $) {
737
- const config = {
738
- path: `cards/${idCard}`,
739
- method: "PUT",
740
- params,
741
- };
742
- return this._makeRequest(config, $);
587
+ listBoardChecklists({
588
+ boardId, ...args
589
+ } = {}) {
590
+ return this._makeRequest({
591
+ path: `/boards/${boardId}/checklists`,
592
+ ...args,
593
+ });
743
594
  },
744
- async listMembers(board) {
595
+ listCardChecklists({
596
+ cardId, ...args
597
+ } = {}) {
745
598
  return this._makeRequest({
746
- path: `boards/${board}/members`,
599
+ path: `/cards/${cardId}/checklists`,
600
+ ...args,
747
601
  });
748
602
  },
749
- async listBoardChecklists(board) {
603
+ listOrganizations({
604
+ memberId, ...args
605
+ } = {}) {
750
606
  return this._makeRequest({
751
- path: `boards/${board}/checklists`,
607
+ path: `/members/${memberId}/organizations`,
608
+ ...args,
752
609
  });
753
610
  },
754
- async listCardChecklists(card) {
611
+ getCustomField({
612
+ customFieldId, ...args
613
+ } = {}) {
755
614
  return this._makeRequest({
756
- path: `cards/${card}/checklists`,
615
+ path: `/customFields/${customFieldId}`,
616
+ ...args,
757
617
  });
758
618
  },
759
- async listOrganizations(id) {
619
+ listCustomFields({
620
+ boardId, ...args
621
+ } = {}) {
760
622
  return this._makeRequest({
761
- path: `members/${id}/organizations?fields="id,name"`,
623
+ path: `/boards/${boardId}/customFields`,
624
+ ...args,
625
+ });
626
+ },
627
+ updateCustomFields({
628
+ cardId, ...args
629
+ } = {}) {
630
+ return this.put({
631
+ path: `/cards/${cardId}/customFields`,
632
+ ...args,
762
633
  });
763
634
  },
764
- getCustomField(customFieldId, $) {
635
+ listCheckItems({
636
+ checklistId, ...args
637
+ } = {}) {
765
638
  return this._makeRequest({
766
- path: `customFields/${customFieldId}`,
767
- }, $);
639
+ path: `/checklists/${checklistId}/checkItems`,
640
+ ...args,
641
+ });
768
642
  },
769
- listCustomFields(boardId, $) {
643
+ listCardAttachments({
644
+ cardId, ...args
645
+ } = {}) {
770
646
  return this._makeRequest({
771
- path: `boards/${boardId}/customFields`,
772
- }, $);
647
+ path: `/cards/${cardId}/attachments`,
648
+ ...args,
649
+ });
650
+ },
651
+ addAttachmentToCard({
652
+ cardId, ...args
653
+ } = {}) {
654
+ return this.post({
655
+ path: `/cards/${cardId}/attachments`,
656
+ ...args,
657
+ });
658
+ },
659
+ addChecklist({
660
+ cardId, ...args
661
+ } = {}) {
662
+ return this.post({
663
+ path: `/cards/${cardId}/checklists`,
664
+ ...args,
665
+ });
666
+ },
667
+ addComment({
668
+ cardId, ...args
669
+ } = {}) {
670
+ return this.post({
671
+ path: `/cards/${cardId}/actions/comments`,
672
+ ...args,
673
+ });
674
+ },
675
+ addExistingLabelToCard({
676
+ cardId, ...args
677
+ } = {}) {
678
+ return this.post({
679
+ path: `/cards/${cardId}/idLabels`,
680
+ ...args,
681
+ });
682
+ },
683
+ removeLabelFromCard({
684
+ cardId, labelId, ...args
685
+ } = {}) {
686
+ return this.delete({
687
+ path: `/cards/${cardId}/idLabels/${labelId}`,
688
+ ...args,
689
+ });
690
+ },
691
+ addMemberToCard({
692
+ cardId, ...args
693
+ } = {}) {
694
+ return this.post({
695
+ path: `/cards/${cardId}/idMembers`,
696
+ ...args,
697
+ });
698
+ },
699
+ completeChecklistItem({
700
+ cardId, checklistItemId, ...args
701
+ } = {}) {
702
+ return this.put({
703
+ path: `/cards/${cardId}/checkItem/${checklistItemId}`,
704
+ ...args,
705
+ });
706
+ },
707
+ createChecklistItem({
708
+ checklistId, ...args
709
+ } = {}) {
710
+ return this.post({
711
+ path: `/checklists/${checklistId}/checkItems`,
712
+ ...args,
713
+ });
773
714
  },
774
- updateCustomFields(cardId, data, $) {
715
+ createLabel(args = {}) {
716
+ return this.post({
717
+ path: "/labels",
718
+ ...args,
719
+ });
720
+ },
721
+ createList(args = {}) {
722
+ return this.post({
723
+ path: "/lists",
724
+ ...args,
725
+ });
726
+ },
727
+ deleteChecklist({
728
+ checklistId, ...args
729
+ } = {}) {
730
+ return this.delete({
731
+ path: `/checklists/${checklistId}`,
732
+ ...args,
733
+ });
734
+ },
735
+ searchMembers(args = {}) {
775
736
  return this._makeRequest({
776
- method: "PUT",
777
- path: `cards/${cardId}/customFields`,
778
- data,
779
- }, $);
737
+ path: "/search/members",
738
+ ...args,
739
+ });
780
740
  },
781
741
  },
782
742
  };