@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
@@ -1,49 +1,60 @@
1
- // legacy_hash_id: a_Nqi0GV
2
- import { axios } from "@pipedream/platform";
1
+ import app from "../../trello.app.mjs";
2
+ import constants from "../../common/constants.mjs";
3
3
 
4
4
  export default {
5
5
  key: "trello-create-board",
6
6
  name: "Create a Board",
7
- description: "Creates a new Trello board.",
8
- version: "0.1.3",
7
+ description: "Create a new Trello board or copy from an existing one. [See the documentation](https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-post).",
8
+ version: "0.2.1",
9
9
  type: "action",
10
10
  props: {
11
- trello: {
12
- type: "app",
13
- app: "trello",
14
- },
11
+ app,
15
12
  name: {
16
13
  type: "string",
14
+ label: "Name",
17
15
  description: "The new name for the board. 1 to 16384 characters long.",
18
16
  },
19
17
  defaultLabels: {
20
18
  type: "boolean",
19
+ label: "Default Labels",
21
20
  description: "Determines whether to use the default set of labels.",
22
21
  optional: true,
23
22
  },
24
23
  defaultLists: {
25
24
  type: "boolean",
25
+ label: "Default Lists",
26
26
  description: "Determines whether to add the default set of lists to a board (To Do, Doing, Done). It is ignored if idBoardSource is provided.",
27
27
  optional: true,
28
28
  },
29
29
  desc: {
30
30
  type: "string",
31
+ label: "Description",
31
32
  description: "A new description for the board, 0 to 16384 characters long",
32
33
  optional: true,
33
34
  },
34
35
  idOrganization: {
35
36
  type: "string",
37
+ label: "Organization ID",
36
38
  description: "The id or name of the team the board should belong to.",
37
- optional: true,
39
+ optional: false,
40
+ propDefinition: [
41
+ app,
42
+ "idOrganizations",
43
+ ],
38
44
  },
39
45
  idBoardSource: {
40
- type: "string",
46
+ label: "Board Source ID",
41
47
  description: "The id of a board to copy into the new board.",
42
48
  optional: true,
49
+ propDefinition: [
50
+ app,
51
+ "board",
52
+ ],
43
53
  },
44
54
  keepFromSource: {
45
55
  type: "string",
46
- description: "To keep cards from the original board pass in the value \"cards\".",
56
+ label: "Keep From Source",
57
+ description: "To keep cards from the original board pass in the value `cards`.",
47
58
  optional: true,
48
59
  options: [
49
60
  "none",
@@ -52,124 +63,111 @@ export default {
52
63
  },
53
64
  powerUps: {
54
65
  type: "string",
55
- description: "The Power-Ups that should be enabled on the new board. One of: all, calendar, cardAging, recap, voting.",
66
+ label: "Power-Ups",
67
+ description: "The Power-Ups that should be enabled on the new board. One of: `all`, `calendar`, `cardAging`, `recap`, `voting`.",
56
68
  optional: true,
69
+ options: constants.POWER_UPS,
57
70
  },
58
- prefs_permissionLevel: {
71
+ prefsPermissionLevel: {
59
72
  type: "string",
60
73
  description: "The permissions level of the board. One of: org, private, public.",
74
+ label: "Prefs Permission Level",
61
75
  optional: true,
62
- options: [
63
- "org",
64
- "private",
65
- "public",
66
- ],
76
+ options: constants.PREFS_PERMISSION_LEVELS,
67
77
  },
68
- prefs_voting: {
78
+ prefsVoting: {
69
79
  type: "string",
70
80
  label: "Prefs Voting",
71
81
  description: "Who can vote on this board. One of disabled, members, observers, org, public.",
72
82
  optional: true,
73
- options: [
74
- "disabled",
75
- "members",
76
- "observers",
77
- "org",
78
- "public",
79
- ],
83
+ options: constants.PREFS_VOTING,
80
84
  },
81
- prefs_comments: {
85
+ prefsComments: {
82
86
  type: "string",
83
87
  label: "Prefs Comments",
84
88
  description: "Who can comment on cards on this board. One of: disabled, members, observers, org, public.",
85
89
  optional: true,
86
- options: [
87
- "disabled",
88
- "members",
89
- "observers",
90
- "org",
91
- "public",
92
- ],
90
+ options: constants.PREFS_COMMENTS,
93
91
  },
94
- prefs_invitations: {
92
+ prefsInvitations: {
95
93
  type: "string",
96
94
  label: "Prefs Invitations",
97
95
  description: "Determines what types of members can invite users to join. One of: admins, members.",
98
96
  optional: true,
99
- options: [
100
- "admins",
101
- "members",
102
- ],
97
+ options: constants.PREFS_INVITATIONS,
103
98
  },
104
- prefs_selfJoin: {
99
+ prefsSelfJoin: {
105
100
  type: "boolean",
101
+ label: "Prefs Self Join",
106
102
  description: "Determines whether users can join the boards themselves or whether they have to be invited.",
107
103
  optional: true,
108
104
  },
109
- prefs_cardCovers: {
105
+ prefsCardCovers: {
110
106
  type: "boolean",
107
+ label: "Prefs Card Covers",
111
108
  description: "Determines whether card covers are enabled.",
112
109
  optional: true,
113
110
  },
114
- prefs_background: {
111
+ prefsBackground: {
115
112
  type: "string",
116
113
  label: "Prefs Background",
117
- description: "The id of a custom background or one of: blue, orange, green, red, purple, pink, lime, sky, grey.",
114
+ description: "The id of a custom background or one of: `blue`, `orange`, `green`, `red`, `purple`, `pink`, `lime`, `sky`, `grey`.",
118
115
  optional: true,
116
+ options: constants.PREFS_BACKGROUNDS,
119
117
  },
120
- prefs_cardAging: {
118
+ prefsCardAging: {
121
119
  type: "string",
120
+ label: "Prefs Card Aging",
122
121
  description: "Determines the type of card aging that should take place on the board if card aging is enabled. One of: pirate, regular.",
123
122
  optional: true,
124
- options: [
125
- "pirate",
126
- "regular",
127
- ],
123
+ options: constants.PREFS_CARD_AGING,
128
124
  },
129
125
  },
130
126
  async run({ $ }) {
131
- const oauthSignerUri = this.trello.$auth.oauth_signer_uri;
132
-
133
- const trelloParams = [
134
- "name",
135
- "defaultLabels",
136
- "defaultLists",
137
- "desc",
138
- "idOrganization",
139
- "idBoardSource",
140
- "keepFromSource",
141
- "powerUps",
142
- "prefs_permissionLevel",
143
- "prefs_voting",
144
- "prefs_comments",
145
- "prefs_invitations",
146
- "prefs_selfJoin",
147
- "prefs_cardCovers",
148
- "prefs_background",
149
- "prefs_cardAging",
150
- ];
151
- let p = this;
152
-
153
- const queryString = trelloParams.filter((param) => p[param]).map((param) => `${param}=${p[param]}`)
154
- .join("&");
155
-
156
- const config = {
157
- url: `https://api.trello.com/1/boards?${queryString}`,
158
- method: "POST",
159
- data: "",
160
- };
127
+ const {
128
+ app,
129
+ name,
130
+ defaultLabels,
131
+ defaultLists,
132
+ desc,
133
+ idOrganization,
134
+ idBoardSource,
135
+ keepFromSource,
136
+ powerUps,
137
+ prefsPermissionLevel,
138
+ prefsVoting,
139
+ prefsComments,
140
+ prefsInvitations,
141
+ prefsSelfJoin,
142
+ prefsCardCovers,
143
+ prefsBackground,
144
+ prefsCardAging,
145
+ } = this;
161
146
 
162
- const token = {
163
- key: this.trello.$auth.oauth_access_token,
164
- secret: this.trello.$auth.oauth_refresh_token,
165
- };
147
+ const response = await app.createBoard({
148
+ $,
149
+ params: {
150
+ name,
151
+ defaultLabels,
152
+ defaultLists,
153
+ desc,
154
+ idOrganization,
155
+ idBoardSource,
156
+ keepFromSource,
157
+ powerUps,
158
+ prefs_permissionLevel: prefsPermissionLevel,
159
+ prefs_voting: prefsVoting,
160
+ prefs_comments: prefsComments,
161
+ prefs_invitations: prefsInvitations,
162
+ prefs_selfJoin: prefsSelfJoin,
163
+ prefs_cardCovers: prefsCardCovers,
164
+ prefs_background: prefsBackground,
165
+ prefs_cardAging: prefsCardAging,
166
+ },
167
+ });
166
168
 
167
- const signConfig = {
168
- token,
169
- oauthSignerUri,
170
- };
169
+ $.export("$summary", `Successfully created board with ID \`${response.id}\`.`);
171
170
 
172
- const resp = await axios($, config, signConfig);
173
- return resp;
171
+ return response;
174
172
  },
175
173
  };
@@ -1,23 +1,26 @@
1
- import common from "../common.mjs";
1
+ import app from "../../trello.app.mjs";
2
+ import fs from "fs";
3
+ import FormData from "form-data";
4
+ import { ConfigurationError } from "@pipedream/platform";
5
+ import constants from "../../common/constants.mjs";
2
6
 
3
7
  export default {
4
- ...common,
5
8
  key: "trello-create-card",
6
9
  name: "Create Card",
7
- description: "Creates a new card. [See the documentation](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-post)",
8
- version: "0.0.3",
10
+ description: "Creates a new card. [See the documentation](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-post).",
11
+ version: "0.1.1",
9
12
  type: "action",
10
13
  props: {
11
- ...common.props,
14
+ app,
12
15
  board: {
13
16
  propDefinition: [
14
- common.props.trello,
17
+ app,
15
18
  "board",
16
19
  ],
17
20
  },
18
21
  name: {
19
22
  propDefinition: [
20
- common.props.trello,
23
+ app,
21
24
  "name",
22
25
  ],
23
26
  description: "The name of the card.",
@@ -25,31 +28,32 @@ export default {
25
28
  },
26
29
  desc: {
27
30
  propDefinition: [
28
- common.props.trello,
31
+ app,
29
32
  "desc",
30
33
  ],
31
34
  },
32
35
  pos: {
33
36
  propDefinition: [
34
- common.props.trello,
37
+ app,
35
38
  "pos",
36
39
  ],
40
+ description: "The position of the new card. `top`, `bottom`, or a positive float",
37
41
  },
38
42
  due: {
39
43
  propDefinition: [
40
- common.props.trello,
44
+ app,
41
45
  "due",
42
46
  ],
43
47
  },
44
48
  dueComplete: {
45
49
  propDefinition: [
46
- common.props.trello,
50
+ app,
47
51
  "dueComplete",
48
52
  ],
49
53
  },
50
54
  idList: {
51
55
  propDefinition: [
52
- common.props.trello,
56
+ app,
53
57
  "lists",
54
58
  (c) => ({
55
59
  board: c.board,
@@ -62,7 +66,7 @@ export default {
62
66
  },
63
67
  idMembers: {
64
68
  propDefinition: [
65
- common.props.trello,
69
+ app,
66
70
  "member",
67
71
  (c) => ({
68
72
  board: c.board,
@@ -75,7 +79,7 @@ export default {
75
79
  },
76
80
  idLabels: {
77
81
  propDefinition: [
78
- common.props.trello,
82
+ app,
79
83
  "label",
80
84
  (c) => ({
81
85
  board: c.board,
@@ -86,28 +90,38 @@ export default {
86
90
  description: "Array of labelIDs to add to the card",
87
91
  optional: true,
88
92
  },
93
+ fileType: {
94
+ propDefinition: [
95
+ app,
96
+ "fileType",
97
+ ],
98
+ optional: true,
99
+ reloadProps: true,
100
+ },
89
101
  urlSource: {
90
102
  propDefinition: [
91
- common.props.trello,
103
+ app,
92
104
  "url",
93
105
  ],
94
- optional: true,
106
+ hidden: true,
95
107
  },
96
- fileSource: {
97
- type: "string",
98
- label: "File Attachment Contents",
99
- description: "Value must be in binary format",
100
- optional: true,
108
+ file: {
109
+ propDefinition: [
110
+ app,
111
+ "file",
112
+ ],
113
+ hidden: true,
101
114
  },
102
115
  mimeType: {
103
116
  propDefinition: [
104
- common.props.trello,
117
+ app,
105
118
  "mimeType",
106
119
  ],
120
+ hidden: true,
107
121
  },
108
122
  idCardSource: {
109
123
  propDefinition: [
110
- common.props.trello,
124
+ app,
111
125
  "cards",
112
126
  (c) => ({
113
127
  board: c.board,
@@ -115,45 +129,38 @@ export default {
115
129
  ],
116
130
  type: "string",
117
131
  label: "Copy Card",
118
- description: "Specify an existing card to copy contents from",
132
+ description: "Specify an existing card to copy contents from. Keep in mind that if you copy a card, the **File Attachment Path**, **File Attachment URL** and **File Attachment Type** fields will be ignored.",
133
+ reloadProps: true,
119
134
  },
120
135
  keepFromSource: {
121
136
  type: "string[]",
122
137
  label: "Copy From Source",
123
138
  description: "Specify which properties to copy from the source card",
124
- options: [
125
- "all",
126
- "attachments",
127
- "checklists",
128
- "comments",
129
- "due",
130
- "labels",
131
- "members",
132
- "stickers",
133
- ],
139
+ options: constants.CARD_KEEP_FROM_SOURCE_PROPERTIES,
134
140
  optional: true,
141
+ hidden: true,
135
142
  },
136
143
  address: {
137
144
  propDefinition: [
138
- common.props.trello,
145
+ app,
139
146
  "address",
140
147
  ],
141
148
  },
142
149
  locationName: {
143
150
  propDefinition: [
144
- common.props.trello,
151
+ app,
145
152
  "locationName",
146
153
  ],
147
154
  },
148
155
  coordinates: {
149
156
  propDefinition: [
150
- common.props.trello,
157
+ app,
151
158
  "coordinates",
152
159
  ],
153
160
  },
154
161
  customFieldIds: {
155
162
  propDefinition: [
156
- common.props.trello,
163
+ app,
157
164
  "customFieldIds",
158
165
  (c) => ({
159
166
  boardId: c.board,
@@ -162,13 +169,24 @@ export default {
162
169
  reloadProps: true,
163
170
  },
164
171
  },
165
- async additionalProps() {
172
+ async additionalProps(existingProps) {
166
173
  const props = {};
174
+
175
+ const attachmentIsPath = this.fileType === "path";
176
+ const attachmentIsUrl = this.fileType === "url";
177
+ existingProps.file.hidden = !attachmentIsPath;
178
+ existingProps.mimeType.hidden = !attachmentIsPath;
179
+ existingProps.urlSource.hidden = !attachmentIsUrl;
180
+
181
+ existingProps.keepFromSource.hidden = !this.idCardSource;
182
+
167
183
  if (!this.customFieldIds?.length) {
168
184
  return props;
169
185
  }
170
186
  for (const customFieldId of this.customFieldIds) {
171
- const customField = await this.trello.getCustomField(customFieldId);
187
+ const customField = await this.app.getCustomField({
188
+ customFieldId,
189
+ });
172
190
  props[customFieldId] = {
173
191
  type: "string",
174
192
  label: `Value for Custom Field - ${customField.name}`,
@@ -183,11 +201,13 @@ export default {
183
201
  return props;
184
202
  },
185
203
  methods: {
186
- ...common.methods,
187
204
  async getCustomFieldItems($) {
188
205
  const customFieldItems = [];
189
206
  for (const customFieldId of this.customFieldIds) {
190
- const customField = await this.trello.getCustomField(customFieldId, $);
207
+ const customField = await this.app.getCustomField({
208
+ $,
209
+ customFieldId,
210
+ });
191
211
  const customFieldItem = {
192
212
  idCustomField: customFieldId,
193
213
  };
@@ -218,8 +238,8 @@ export default {
218
238
  idMembers,
219
239
  idLabels,
220
240
  urlSource,
221
- fileSource,
222
241
  mimeType,
242
+ file,
223
243
  idCardSource,
224
244
  keepFromSource,
225
245
  address,
@@ -227,7 +247,9 @@ export default {
227
247
  coordinates,
228
248
  customFieldIds,
229
249
  } = this;
230
- const res = await this.trello.createCard({
250
+
251
+ let response;
252
+ const params = {
231
253
  name,
232
254
  desc,
233
255
  pos,
@@ -236,25 +258,52 @@ export default {
236
258
  idList,
237
259
  idMembers,
238
260
  idLabels,
239
- urlSource,
240
- fileSource,
241
261
  mimeType,
242
262
  idCardSource,
243
263
  keepFromSource: keepFromSource?.join(","),
244
264
  address,
245
265
  locationName,
246
266
  coordinates,
247
- }, $);
267
+ };
268
+
269
+ if (file && !file?.startsWith("/tmp")) {
270
+ throw new ConfigurationError("The file path must be in the `/tmp` directory");
271
+ }
272
+
273
+ if (file) {
274
+ const form = new FormData();
275
+ form.append("fileSource", fs.createReadStream(file));
276
+
277
+ response = await this.app.createCard({
278
+ $,
279
+ params,
280
+ headers: form.getHeaders(),
281
+ data: form,
282
+ });
283
+ } else {
284
+ response = await this.app.createCard({
285
+ $,
286
+ params: {
287
+ ...params,
288
+ urlSource,
289
+ },
290
+ });
291
+ }
248
292
 
249
293
  if (customFieldIds) {
250
294
  const customFieldItems = await this.getCustomFieldItems($);
251
- const customFields = await this.trello.updateCustomFields(res.id, {
252
- customFieldItems,
253
- }, $);
254
- res.customFields = customFields;
295
+ const customFields = await this.app.updateCustomFields({
296
+ $,
297
+ cardId: response.id,
298
+ data: {
299
+ customFieldItems,
300
+ },
301
+ });
302
+ response.customFields = customFields;
255
303
  }
256
304
 
257
- $.export("$summary", `Successfully created card ${res.id}`);
258
- return res;
305
+ $.export("$summary", `Successfully created card \`${response.id}\`.`);
306
+
307
+ return response;
259
308
  },
260
309
  };
@@ -1,67 +1,82 @@
1
- // legacy_hash_id: a_bKiP4j
2
- import { axios } from "@pipedream/platform";
1
+ import app from "../../trello.app.mjs";
3
2
 
4
3
  export default {
5
4
  key: "trello-create-checklist-item",
6
5
  name: "Create a Checklist Item",
7
- description: "Creates a new checklist item in a card.",
8
- version: "0.1.3",
6
+ description: "Creates a new checklist item in a card. [See the documentation](https://developer.atlassian.com/cloud/trello/rest/api-group-checklists/#api-checklists-id-checkitems-post).",
7
+ version: "0.2.1",
9
8
  type: "action",
10
9
  props: {
11
- trello: {
12
- type: "app",
13
- app: "trello",
10
+ app,
11
+ board: {
12
+ propDefinition: [
13
+ app,
14
+ "board",
15
+ ],
14
16
  },
15
- id: {
17
+ card: {
18
+ propDefinition: [
19
+ app,
20
+ "cards",
21
+ ({ board }) => ({
22
+ board,
23
+ checklistCardsOnly: true,
24
+ }),
25
+ ],
16
26
  type: "string",
27
+ label: "Card",
28
+ description: "The ID of the Card that the checklist item should be added to",
29
+ optional: false,
30
+ },
31
+ checklistId: {
32
+ label: "Checklist ID",
17
33
  description: "ID of a checklist.",
34
+ propDefinition: [
35
+ app,
36
+ "checklist",
37
+ ({ card }) => ({
38
+ card,
39
+ }),
40
+ ],
18
41
  },
19
42
  name: {
20
43
  type: "string",
44
+ label: "Name",
21
45
  description: "The name of the new check item on the checklist. Should be a string of length 1 to 16384.",
22
46
  },
23
47
  pos: {
24
- type: "string",
25
- description: "The position of the check item in the checklist. One of: top, bottom, or a positive number.",
26
- optional: true,
48
+ propDefinition: [
49
+ app,
50
+ "pos",
51
+ ],
27
52
  },
28
53
  checked: {
29
54
  type: "boolean",
55
+ label: "Checked",
30
56
  description: "Determines whether the check item is already checked when created.",
31
57
  optional: true,
32
58
  },
33
59
  },
34
60
  async run({ $ }) {
35
- const oauthSignerUri = this.trello.$auth.oauth_signer_uri;
36
-
37
- let id = this.id;
38
- const trelloParams = [
39
- "name",
40
- "pos",
41
- "checked",
42
- ];
43
- let p = this;
44
-
45
- const queryString = trelloParams.filter((param) => p[param]).map((param) => `${param}=${p[param]}`)
46
- .join("&");
47
-
48
- const config = {
49
- url: `https://api.trello.com/1/checklists/${id}/checkItems?${queryString}`,
50
- method: "POST",
51
- data: "",
52
- };
61
+ const {
62
+ checklistId,
63
+ name,
64
+ pos,
65
+ checked,
66
+ } = this;
53
67
 
54
- const token = {
55
- key: this.trello.$auth.oauth_access_token,
56
- secret: this.trello.$auth.oauth_refresh_token,
57
- };
68
+ const response = await this.app.createChecklistItem({
69
+ $,
70
+ checklistId,
71
+ params: {
72
+ name,
73
+ pos,
74
+ checked,
75
+ },
76
+ });
58
77
 
59
- const signConfig = {
60
- token,
61
- oauthSignerUri,
62
- };
78
+ $.export("$summary", `Successfully created a checklist item with ID: ${response.id}`);
63
79
 
64
- const resp = await axios($, config, signConfig);
65
- return resp;
80
+ return response;
66
81
  },
67
82
  };