@pipedream/trello 0.4.1 → 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.
@@ -1,5 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
import fs from "fs";
|
1
|
+
import { getFileStreamAndMetadata } from "@pipedream/platform";
|
3
2
|
import FormData from "form-data";
|
4
3
|
import app from "../../trello.app.mjs";
|
5
4
|
|
@@ -7,7 +6,7 @@ export default {
|
|
7
6
|
key: "trello-add-attachment-to-card",
|
8
7
|
name: "Add Attachment To Card",
|
9
8
|
description: "Adds a file attachment on a card. [See the documentation](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-attachments-post)",
|
10
|
-
version: "0.0
|
9
|
+
version: "1.0.0",
|
11
10
|
type: "action",
|
12
11
|
props: {
|
13
12
|
app,
|
@@ -36,33 +35,16 @@ export default {
|
|
36
35
|
"name",
|
37
36
|
],
|
38
37
|
},
|
39
|
-
fileType: {
|
40
|
-
propDefinition: [
|
41
|
-
app,
|
42
|
-
"fileType",
|
43
|
-
],
|
44
|
-
reloadProps: true,
|
45
|
-
},
|
46
|
-
url: {
|
47
|
-
propDefinition: [
|
48
|
-
app,
|
49
|
-
"url",
|
50
|
-
],
|
51
|
-
hidden: true,
|
52
|
-
},
|
53
38
|
file: {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
],
|
58
|
-
hidden: true,
|
39
|
+
type: "string",
|
40
|
+
label: "File Path or URL",
|
41
|
+
description: "Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFile.pdf).",
|
59
42
|
},
|
60
43
|
mimeType: {
|
61
44
|
propDefinition: [
|
62
45
|
app,
|
63
46
|
"mimeType",
|
64
47
|
],
|
65
|
-
hidden: true,
|
66
48
|
},
|
67
49
|
setCover: {
|
68
50
|
type: "boolean",
|
@@ -72,20 +54,10 @@ export default {
|
|
72
54
|
optional: true,
|
73
55
|
},
|
74
56
|
},
|
75
|
-
async additionalProps(props) {
|
76
|
-
const attachmentIsPath = this.fileType === "path";
|
77
|
-
const attachmentIsUrl = this.fileType === "url";
|
78
|
-
props.file.hidden = !attachmentIsPath;
|
79
|
-
props.mimeType.hidden = !attachmentIsPath;
|
80
|
-
props.url.hidden = !attachmentIsUrl;
|
81
|
-
|
82
|
-
return {};
|
83
|
-
},
|
84
57
|
async run({ $ }) {
|
85
58
|
const {
|
86
59
|
cardId,
|
87
60
|
name,
|
88
|
-
url,
|
89
61
|
mimeType,
|
90
62
|
setCover,
|
91
63
|
file,
|
@@ -98,32 +70,24 @@ export default {
|
|
98
70
|
setCover,
|
99
71
|
};
|
100
72
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
if (file) {
|
106
|
-
const form = new FormData();
|
107
|
-
form.append("file", fs.createReadStream(file));
|
73
|
+
const form = new FormData();
|
74
|
+
const {
|
75
|
+
stream, metadata,
|
76
|
+
} = await getFileStreamAndMetadata(file);
|
108
77
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
data: form,
|
115
|
-
});
|
78
|
+
form.append("file", stream, {
|
79
|
+
contentType: metadata.contentType,
|
80
|
+
knownLength: metadata.size,
|
81
|
+
filename: metadata.name,
|
82
|
+
});
|
116
83
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
},
|
125
|
-
});
|
126
|
-
}
|
84
|
+
response = await this.app.addAttachmentToCard({
|
85
|
+
$,
|
86
|
+
cardId,
|
87
|
+
params,
|
88
|
+
headers: form.getHeaders(),
|
89
|
+
data: form,
|
90
|
+
});
|
127
91
|
|
128
92
|
$.export("$summary", `Successfully added attachement to card ${cardId}`);
|
129
93
|
return response;
|
@@ -1,14 +1,13 @@
|
|
1
1
|
import app from "../../trello.app.mjs";
|
2
|
-
import fs from "fs";
|
3
2
|
import FormData from "form-data";
|
4
|
-
import {
|
3
|
+
import { getFileStreamAndMetadata } from "@pipedream/platform";
|
5
4
|
import constants from "../../common/constants.mjs";
|
6
5
|
|
7
6
|
export default {
|
8
7
|
key: "trello-create-card",
|
9
8
|
name: "Create Card",
|
10
9
|
description: "Creates a new card. [See the documentation](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-post).",
|
11
|
-
version: "0.
|
10
|
+
version: "1.0.0",
|
12
11
|
type: "action",
|
13
12
|
props: {
|
14
13
|
app,
|
@@ -90,34 +89,18 @@ export default {
|
|
90
89
|
description: "Array of labelIDs to add to the card",
|
91
90
|
optional: true,
|
92
91
|
},
|
93
|
-
fileType: {
|
94
|
-
propDefinition: [
|
95
|
-
app,
|
96
|
-
"fileType",
|
97
|
-
],
|
98
|
-
optional: true,
|
99
|
-
reloadProps: true,
|
100
|
-
},
|
101
|
-
urlSource: {
|
102
|
-
propDefinition: [
|
103
|
-
app,
|
104
|
-
"url",
|
105
|
-
],
|
106
|
-
hidden: true,
|
107
|
-
},
|
108
92
|
file: {
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
hidden: true,
|
93
|
+
type: "string",
|
94
|
+
label: "File Path or URL",
|
95
|
+
description: "Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFile.pdf).",
|
96
|
+
optional: true,
|
114
97
|
},
|
115
98
|
mimeType: {
|
116
99
|
propDefinition: [
|
117
100
|
app,
|
118
101
|
"mimeType",
|
119
102
|
],
|
120
|
-
|
103
|
+
optional: true,
|
121
104
|
},
|
122
105
|
idCardSource: {
|
123
106
|
propDefinition: [
|
@@ -172,12 +155,6 @@ export default {
|
|
172
155
|
async additionalProps(existingProps) {
|
173
156
|
const props = {};
|
174
157
|
|
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
158
|
existingProps.keepFromSource.hidden = !this.idCardSource;
|
182
159
|
|
183
160
|
if (!this.customFieldIds?.length) {
|
@@ -237,7 +214,6 @@ export default {
|
|
237
214
|
idList,
|
238
215
|
idMembers,
|
239
216
|
idLabels,
|
240
|
-
urlSource,
|
241
217
|
mimeType,
|
242
218
|
file,
|
243
219
|
idCardSource,
|
@@ -266,14 +242,16 @@ export default {
|
|
266
242
|
coordinates,
|
267
243
|
};
|
268
244
|
|
269
|
-
if (file && !file?.startsWith("/tmp")) {
|
270
|
-
throw new ConfigurationError("The file path must be in the `/tmp` directory");
|
271
|
-
}
|
272
|
-
|
273
245
|
if (file) {
|
274
246
|
const form = new FormData();
|
275
|
-
|
276
|
-
|
247
|
+
const {
|
248
|
+
stream, metadata,
|
249
|
+
} = await getFileStreamAndMetadata(file);
|
250
|
+
form.append("fileSource", stream, {
|
251
|
+
contentType: metadata.contentType,
|
252
|
+
knownLength: metadata.size,
|
253
|
+
filename: metadata.name,
|
254
|
+
});
|
277
255
|
response = await this.app.createCard({
|
278
256
|
$,
|
279
257
|
params,
|
@@ -283,10 +261,7 @@ export default {
|
|
283
261
|
} else {
|
284
262
|
response = await this.app.createCard({
|
285
263
|
$,
|
286
|
-
params
|
287
|
-
...params,
|
288
|
-
urlSource,
|
289
|
-
},
|
264
|
+
params,
|
290
265
|
});
|
291
266
|
}
|
292
267
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pipedream/trello",
|
3
|
-
"version": "0.
|
3
|
+
"version": "1.0.0",
|
4
4
|
"description": "Pipedream Trello Components",
|
5
5
|
"main": "trello.app.mjs",
|
6
6
|
"keywords": [
|
@@ -10,7 +10,7 @@
|
|
10
10
|
"homepage": "https://pipedream.com/apps/trello",
|
11
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
12
12
|
"dependencies": {
|
13
|
-
"@pipedream/platform": "^3.0
|
13
|
+
"@pipedream/platform": "^3.1.0",
|
14
14
|
"crypto": "^1.0.1",
|
15
15
|
"form-data": "^4.0.0",
|
16
16
|
"lodash-es": "^4.17.21",
|