Skip to content

Commit 371c5d4

Browse files
committed
AI-generated set
1 parent 9053265 commit 371c5d4

File tree

13 files changed

+77
-115
lines changed

13 files changed

+77
-115
lines changed

components/roboflow/actions/classify-image/classify-image.mjs

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import roboflow from "../../roboflow.app.mjs";
2-
import { ConfigurationError } from "@pipedream/platform";
3-
import fs from "fs";
2+
import { getFileStream } from "@pipedream/platform";
43

54
export default {
65
key: "roboflow-classify-image",
76
name: "Classify Image",
87
description: "Run inference on classification models hosted on Roboflow. [See the documentation](https://docs.roboflow.com/deploy/hosted-api/classification).",
9-
version: "0.0.1",
8+
version: "0.1.0",
109
type: "action",
1110
props: {
1211
roboflow,
@@ -31,36 +30,23 @@ export default {
3130
"filePath",
3231
],
3332
},
34-
fileUrl: {
35-
propDefinition: [
36-
roboflow,
37-
"fileUrl",
38-
],
39-
},
4033
},
4134
async run({ $ }) {
42-
if ((!this.filePath && !this.fileUrl) || (this.filePath && this.fileUrl)) {
43-
throw new ConfigurationError("Exactly one of file Path or File URL must be specified.");
35+
const stream = getFileStream(this.filePath);
36+
const chunks = [];
37+
for await (const chunk of stream) {
38+
chunks.push(chunk);
4439
}
40+
const data = Buffer.concat(chunks).toString("base64");
4541

4642
const args = {
4743
datasetId: this.datasetId,
4844
$,
49-
};
50-
51-
if (this.filePath) {
52-
args.data = fs.readFileSync(this.filePath, {
53-
encoding: "base64",
54-
});
55-
args.headers = {
45+
data,
46+
headers: {
5647
"Content-Type": "application/x-www-form-urlencoded",
57-
};
58-
}
59-
if (this.fileUrl) {
60-
args.params = {
61-
image: this.fileUrl,
62-
};
63-
}
48+
},
49+
};
6450

6551
const response = await this.roboflow.classifyImage(args);
6652

components/roboflow/actions/detect-object-from-image/detect-object-from-image.mjs

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import roboflow from "../../roboflow.app.mjs";
2-
import { ConfigurationError } from "@pipedream/platform";
3-
import fs from "fs";
2+
import { getFileStream } from "@pipedream/platform";
43

54
export default {
65
key: "roboflow-detect-object-from-image",
76
name: "Detect Object From Image",
87
description: "Run inference on your object detection models hosted on Roboflow. [See the documentation](https://docs.roboflow.com/deploy/hosted-api/object-detection).",
9-
version: "0.0.1",
8+
version: "0.1.0",
109
type: "action",
1110
props: {
1211
roboflow,
@@ -31,36 +30,23 @@ export default {
3130
"filePath",
3231
],
3332
},
34-
fileUrl: {
35-
propDefinition: [
36-
roboflow,
37-
"fileUrl",
38-
],
39-
},
4033
},
4134
async run({ $ }) {
42-
if ((!this.filePath && !this.fileUrl) || (this.filePath && this.fileUrl)) {
43-
throw new ConfigurationError("Exactly one of file Path or File URL must be specified.");
35+
const stream = getFileStream(this.filePath);
36+
const chunks = [];
37+
for await (const chunk of stream) {
38+
chunks.push(chunk);
4439
}
40+
const data = Buffer.concat(chunks).toString("base64");
4541

4642
const args = {
4743
datasetId: this.datasetId,
4844
$,
49-
};
50-
51-
if (this.filePath) {
52-
args.data = fs.readFileSync(this.filePath, {
53-
encoding: "base64",
54-
});
55-
args.headers = {
45+
data,
46+
headers: {
5647
"Content-Type": "application/x-www-form-urlencoded",
57-
};
58-
}
59-
if (this.fileUrl) {
60-
args.params = {
61-
image: this.fileUrl,
62-
};
63-
}
48+
},
49+
};
6450

6551
const response = await this.roboflow.detectObject(args);
6652

components/roboflow/actions/upload-image/upload-image.mjs

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import roboflow from "../../roboflow.app.mjs";
2-
import { ConfigurationError } from "@pipedream/platform";
2+
import { getFileStream } from "@pipedream/platform";
33
import utils from "../../common/utils.mjs";
4-
import fs from "fs";
54
import FormData from "form-data";
65

76
export default {
87
key: "roboflow-upload-image",
98
name: "Upload Image",
109
description: "Upload an image to a project on the Roboflow platform. [See the documentation](https://docs.roboflow.com/datasets/adding-data/upload-api).",
11-
version: "0.0.1",
10+
version: "0.1.0",
1211
type: "action",
1312
props: {
1413
roboflow,
@@ -24,12 +23,6 @@ export default {
2423
"filePath",
2524
],
2625
},
27-
fileUrl: {
28-
propDefinition: [
29-
roboflow,
30-
"fileUrl",
31-
],
32-
},
3326
name: {
3427
type: "string",
3528
label: "Name",
@@ -38,33 +31,26 @@ export default {
3831
},
3932
},
4033
async run({ $ }) {
41-
if ((!this.filePath && !this.fileUrl) || (this.filePath && this.fileUrl)) {
42-
throw new ConfigurationError("Exactly one of file Path or File URL must be specified.");
43-
}
44-
4534
const args = {
4635
projectId: utils.extractSubstringAfterSlash(this.projectId),
4736
$,
4837
};
4938

50-
if (this.filePath) {
51-
const formData = new FormData();
52-
if (this.name) {
53-
formData.append("name", this.name);
54-
}
55-
formData.append("file", fs.createReadStream(this.filePath));
56-
57-
args.data = formData;
58-
args.headers = formData.getHeaders();
39+
const formData = new FormData();
40+
if (this.name) {
41+
formData.append("name", this.name);
5942
}
6043

61-
if (this.fileUrl) {
62-
const params = {
63-
image: this.fileUrl,
44+
if (this.filePath.startsWith("http")) {
45+
args.params = {
46+
image: this.filePath,
6447
name: this.name,
6548
};
66-
67-
args.params = params;
49+
} else {
50+
const stream = getFileStream(this.filePath);
51+
formData.append("file", stream);
52+
args.data = formData;
53+
args.headers = formData.getHeaders();
6854
}
6955

7056
const response = await this.roboflow.uploadImage(args);

components/roboflow/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/roboflow",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Roboflow Components",
55
"main": "roboflow.app.mjs",
66
"keywords": [
@@ -13,6 +13,6 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^1.5.1"
16+
"@pipedream/platform": "^3.1.0"
1717
}
1818
}

components/roboflow/roboflow.app.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ export default {
3737
},
3838
filePath: {
3939
type: "string",
40-
label: "File Path",
41-
description: "The path to the image file saved to the `/tmp` directory (e.g. `/tmp/image.png`). [See the documentation](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory).",
42-
optional: true,
40+
label: "File Path or URL",
41+
description: "The file to process. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.jpg`)",
4342
},
4443
fileUrl: {
4544
type: "string",

components/salesforce_rest_api/actions/create-attachment/create-attachment.mjs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import common, { getProps } from "../common/base-create-update.mjs";
22
import attachment from "../../common/sobjects/attachment.mjs";
3-
import fs from "fs";
3+
import { getFileStream } from "@pipedream/platform";
44

55
const docsLink = "https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_attachment.htm";
66

@@ -18,7 +18,7 @@ export default {
1818
key: "salesforce_rest_api-create-attachment",
1919
name: "Create Attachment",
2020
description: `Creates an Attachment on a parent object. [See the documentation](${docsLink})`,
21-
version: "0.4.1",
21+
version: "0.5.0",
2222
type: "action",
2323
props,
2424
async run({ $ }) {
@@ -34,9 +34,17 @@ export default {
3434
} = this;
3535
/* eslint-enable no-unused-vars */
3636

37-
const body = filePathOrContent.includes("tmp/")
38-
? (await fs.promises.readFile(filePathOrContent)).toString("base64")
39-
: filePathOrContent;
37+
let body;
38+
if (filePathOrContent.startsWith("http") || filePathOrContent.includes("tmp/")) {
39+
const stream = getFileStream(filePathOrContent);
40+
const chunks = [];
41+
for await (const chunk of stream) {
42+
chunks.push(chunk);
43+
}
44+
body = Buffer.concat(chunks).toString("base64");
45+
} else {
46+
body = filePathOrContent;
47+
}
4048

4149
const response = await salesforce.createRecord("Attachment", {
4250
$,

components/salesforce_rest_api/common/sobjects/attachment.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export default {
99
},
1010
filePathOrContent: {
1111
type: "string",
12-
label: "File Path or Content",
13-
description: "The path to a file in the `tmp` folder [(see the documentation)](https://pipedream.com/docs/code/nodejs/working-with-files). Alternatively, you can provide the base64-encoded file data.",
12+
label: "File Path or URL",
13+
description: "The file to attach. Provide either a file URL, a path to a file in the `/tmp` directory (for example, `/tmp/myFile.txt`), or base64-encoded file data.",
1414
},
1515
ContentType: {
1616
type: "string",

components/salesforce_rest_api/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/salesforce_rest_api",
3-
"version": "1.5.0",
3+
"version": "1.6.0",
44
"description": "Pipedream Salesforce (REST API) Components",
55
"main": "salesforce_rest_api.app.mjs",
66
"keywords": [
@@ -10,7 +10,7 @@
1010
"homepage": "https://pipedream.com/apps/salesforce_rest_api",
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"dependencies": {
13-
"@pipedream/platform": "^3.0.0",
13+
"@pipedream/platform": "^3.1.0",
1414
"fast-xml-parser": "^4.3.2",
1515
"handlebars": "^4.7.7",
1616
"lodash": "^4.17.21",

components/scoredetect/actions/create-timestamp-file/create-timestamp-file.mjs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import scoreDetect from "../../scoredetect.app.mjs";
2-
import fs from "fs";
3-
import { axios } from "@pipedream/platform";
2+
import { getFileStream } from "@pipedream/platform";
43

54
export default {
65
key: "scoredetect-create-timestamp-file",
76
name: "Create Certificate from File",
87
description: "Creates a timestamped blockchain certificate using a provided file (local or URL). [See the documentation](https://api.scoredetect.com/docs/routes#create-certificate)",
9-
version: "0.0.1",
8+
version: "0.1.0",
109
type: "action",
1110
props: {
1211
scoreDetect,
@@ -18,19 +17,10 @@ export default {
1817
},
1918
},
2019
async run({ $ }) {
21-
const { fileOrUrl } = this;
22-
const file = fileOrUrl.startsWith("http")
23-
? await axios($, {
24-
url: fileOrUrl,
25-
responseType: "arraybuffer",
26-
})
27-
: fs.createReadStream(fileOrUrl.includes("tmp/")
28-
? fileOrUrl
29-
: `/tmp/${fileOrUrl}`);
30-
20+
const stream = getFileStream(this.fileOrUrl);
3121
const response = await this.scoreDetect.createCertificate({
3222
$,
33-
file,
23+
file: stream,
3424
});
3525

3626
$.export("$summary", "Successfully created certificate");

components/scoredetect/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/scoredetect",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream ScoreDetect Components",
55
"main": "scoredetect.app.mjs",
66
"keywords": [
@@ -13,7 +13,7 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^1.6.0",
16+
"@pipedream/platform": "^3.1.0",
1717
"form-data": "^4.0.0"
1818
}
1919
}

0 commit comments

Comments
 (0)