Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
name: "Alcohol Label Recognition",
description: "Accurately identifies alcohol labels using advanced intelligent technologies. Powered by API4AI.",
key: "api4ai-alcohol-label-recognition",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
alert: {

Check warning on line 12 in components/api4ai/actions/alcohol-label-recognition/alcohol-label-recognition.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 12 in components/api4ai/actions/alcohol-label-recognition/alcohol-label-recognition.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "Subscribe to [API4AI Alcohol Label Recognition](https://rapidapi.com/api4ai-api4ai-default/api/alcohol-label-recognition/pricing) on the RapidAPI hub before you start using it.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
description:
"Automatically and quickly remove image background with high accuracy. Powered by API4AI.",
key: "api4ai-background-removal",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
alert: {

Check warning on line 15 in components/api4ai/actions/background-removal/background-removal.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 15 in components/api4ai/actions/background-removal/background-removal.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "Subscribe to [API4AI Background Removal](https://rapidapi.com/api4ai-api4ai-default/api/background-removal4/pricing) on the RapidAPI hub before you start using it.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
name: "Brand Recognition",
description: "The service processes input image and responds with a list of found brand logos. Powered by API4AI.",
key: "api4ai-brand-recognition",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
alert: {

Check warning on line 12 in components/api4ai/actions/brand-recognition/brand-recognition.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 12 in components/api4ai/actions/brand-recognition/brand-recognition.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "Subscribe to [API4AI Brand Recognition](https://rapidapi.com/api4ai-api4ai-default/api/brand-recognition/pricing) on the RapidAPI hub before you start using it.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
description:
"Remove Background for car images. Powered by API4AI.",
key: "api4ai-car-image-background-removal",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
alert: {

Check warning on line 15 in components/api4ai/actions/car-image-background-removal/car-image-background-removal.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 15 in components/api4ai/actions/car-image-background-removal/car-image-background-removal.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "Subscribe to [API4AI Cars Image Background Removal](https://rapidapi.com/api4ai-api4ai-default/api/cars-image-background-removal/pricing) on the RapidAPI hub before you start using it.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
name: "Furniture & Household Item Recognition",
description: "This API provides identification of furniture & household items with advanced intelligent detection, categorization, and counting technologies. Powered by API4AI.",
key: "api4ai-furniture-and-household-item-recognition",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
alert: {

Check warning on line 12 in components/api4ai/actions/furniture-and-household-item-recognition/furniture-and-household-item-recognition.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 12 in components/api4ai/actions/furniture-and-household-item-recognition/furniture-and-household-item-recognition.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "Subscribe to [API4AI Furniture and Household Items Recognition](https://rapidapi.com/api4ai-api4ai-default/api/furniture-and-household-items/pricing) on the RapidAPI hub before you start using it.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
name: "Image Anonymization",
description: "Performs actual image anonymization. Powered by API4AI.",
key: "api4ai-image-anonymization",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
description:
"Content moderation solution for NSFW (Not Safe For Work) sexual images identification. Powered by API4AI.",
key: "api4ai-nsfw-image-recognition",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand Down
66 changes: 13 additions & 53 deletions components/api4ai/api4ai.app.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { axios } from "@pipedream/platform";
import {
axios, getFileStreamAndMetadata,
} from "@pipedream/platform";
import FormData from "form-data";
import fs from "node:fs";

export default {
type: "app",
Expand All @@ -9,63 +10,22 @@ export default {
image: {
type: "string",
label: "Image",
description: "Input image. Various types are accepted:\n * a **path** to a file\n * a **URL** to a file\n * a file's content encoded as a **base64** string\n * a file's content as a **Buffer** encoded in JSON\n * a file's content as an **Array** of bytes",
description: "Input image. Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFlie.pdf).",
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
},

/**
* Make HTTP request.
*
* @param {Object} $ - Pipedream.
* @param {string} url - API Endpoint URL.
* @param {*} image - Input image.
* Various types are accepted:
* - a path to a file
* - a URL to a file
* - a file's content encoded as a base64 string
* - a file's content as a Buffer encoded in JSON
* - a file's content as an Array of bytes
* @param {Object} params - Query parameters.
* @returns Axios response.
*/
async makeRequest($, url, image, params = {}) {
// Prepare form data.
const base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
const urlregex = /^(http|ftp)s?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
const form = new FormData();
if (urlregex.test(image)) {
console.log("Input image considered as URL");
form.append("url", image);
}
else {
let buf;
if (image instanceof Buffer) {
console.log("Input image considered as Buffer");
buf = image;
}
else if ((image instanceof Object) && image.type === "Buffer") {
console.log("Input image considered as JSON object with Buffer");
buf = Buffer.from(image);
}
else if (image instanceof Array) {
console.log("Input image considered as Array");
buf = Buffer.from(image);
}
else if (base64regex.test(image)) {
console.log("Input image considered as base64 string");
buf = Buffer.from(image, "base64");
}
else {
console.log("Input image considered as file path");
buf = fs.readFileSync(image);
}
form.append("image", buf);
}
const {
stream, metadata,
} = await getFileStreamAndMetadata(image);

form.append("image", stream, {
contentType: metadata.contentType,
knownLength: metadata.size,
filename: metadata.name,
});

// Prepare headers.
const headers = {
Expand Down
4 changes: 2 additions & 2 deletions components/api4ai/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/api4ai",
"version": "0.1.0",
"version": "0.1.1",
"description": "Pipedream API4AI Components",
"main": "api4ai.app.mjs",
"keywords": [
Expand All @@ -27,7 +27,7 @@
"homepage": "https://pipedream.com/apps/api4ai",
"author": "API4AI Team <[email protected]> (https://api4.ai/)",
"dependencies": {
"@pipedream/platform": "^1.6.2",
"@pipedream/platform": "^3.1.0",
"form-data": "^4.0.0"
},
"publishConfig": {
Expand Down
26 changes: 5 additions & 21 deletions components/dropbox/actions/upload-file/upload-file.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { ConfigurationError } from "@pipedream/platform";
import fs from "fs";
import got from "got";
import { getFileStream } from "@pipedream/platform";
import consts from "../../common/consts.mjs";
import dropbox from "../../dropbox.app.mjs";

export default {
name: "Upload a File",
description: "Uploads a file to a selected folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
key: "dropbox-upload-file",
version: "0.0.14",
version: "1.0.0",
type: "action",
props: {
dropbox,
Expand All @@ -27,17 +25,10 @@ export default {
label: "File Name",
description: "The name of your new file (make sure to include the file extension).",
},
fileUrl: {
type: "string",
label: "File URL",
description: "The URL of the file you want to upload to Dropbox. Must specify either File URL or File Path.",
optional: true,
},
filePath: {
type: "string",
label: "File Path",
description: "The path to the file, e.g. /tmp/myFile.csv . Must specify either File URL or File Path.",
optional: true,
label: "File Path or URL",
description: "Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFlie.pdf).",
},
autorename: {
type: "boolean",
Expand Down Expand Up @@ -67,7 +58,6 @@ export default {
},
async run({ $ }) {
const {
fileUrl,
filePath,
path,
name,
Expand All @@ -78,13 +68,7 @@ export default {
clientModified,
} = this;

if (!fileUrl && !filePath) {
throw new ConfigurationError("Must specify either File URL or File Path.");
}

const contents = fileUrl
? await got.stream(fileUrl)
: fs.createReadStream(filePath);
const contents = await getFileStream(filePath);

let normalizedPath = this.dropbox.getNormalizedPath(path, true);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ConfigurationError } from "@pipedream/platform";
import fs from "fs";
import got from "got";
import {
getFileStream, ConfigurationError,
} from "@pipedream/platform";
import consts from "../../common/consts.mjs";
import dropbox from "../../dropbox.app.mjs";

export default {
name: "Upload Multiple Files",
description: "Uploads multiple file to a selected folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
key: "dropbox-upload-multiple-files",
version: "0.0.2",
version: "1.0.0",
type: "action",
props: {
dropbox,
Expand All @@ -22,19 +22,10 @@ export default {
],
description: "The folder to upload to. Type the folder name to search for it in the user's Dropbox.",
},
fileUrls: {
filesPaths: {
type: "string[]",
label: "File URLs",
description: "The URLs of the files you want to upload to Dropbox. Must specify either File URLs or File Paths.",
default: [],
optional: true,
},
filePaths: {
type: "string[]",
label: "File Paths",
description: "The paths to the files, e.g. /tmp/myFile.csv . Must specify either File URLs or File Paths.",
default: [],
optional: true,
label: "File Paths or URLs",
description: "Provide an array of either file URLs or paths to a files in the /tmp directory (for example, /tmp/myFlie.pdf).",
},
filenames: {
type: "string[]",
Expand Down Expand Up @@ -71,20 +62,15 @@ export default {
const {
dropbox,
path,
fileUrls,
filePaths,
filesPaths,
autorename,
mute,
strictConflict,
mode,
filenames,
} = this;

if (!fileUrls?.length && !filePaths?.length) {
throw new ConfigurationError("Must specify either File URLs or File Paths.");
}

const numFiles = fileUrls.length + filePaths.length;
const numFiles = filesPaths.length;
if (numFiles !== filenames.length) {
throw new ConfigurationError(`Number of filenames must match number of files. Detected ${numFiles} file(s) and ${filenames.length} filename(s)`);
}
Expand All @@ -93,24 +79,13 @@ export default {
const normalizedPath = dropbox.getNormalizedPath(path, true);
let i = 0;

if (fileUrls?.length) {
for (const url of fileUrls) {
fileInfo.push({
contents: await got.stream(url),
path: `${normalizedPath}${filenames[i]}`,
});
i++;
}
}

if (filePaths?.length) {
for (const filePath of filePaths) {
fileInfo.push({
contents: fs.createReadStream(filePath),
path: `${normalizedPath}${filenames[i]}`,
});
i++;
}
for (const file of filesPaths) {
const contents = await getFileStream(file);
fileInfo.push({
contents,
path: `${normalizedPath}${filenames[i]}`,
});
i++;
}

const responses = [];
Expand Down
3 changes: 2 additions & 1 deletion components/dropbox/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/dropbox",
"version": "0.4.1",
"version": "1.0.0",
"description": "Pipedream Dropbox Components",
"main": "dropbox.app.mjs",
"keywords": [
Expand All @@ -10,6 +10,7 @@
"homepage": "https://pipedream.com/apps/dropbox",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"dependencies": {
"@pipedream/platform": "^3.1.0",
"@types/node-fetch": "^2.5.7",
"dropbox": "^10.34.0",
"got": "^13.0.0",
Expand Down
22 changes: 14 additions & 8 deletions components/elevenlabs/actions/add-voice/add-voice.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import FormData from "form-data";
import fs from "fs";
import elevenlabs from "../../elevenlabs.app.mjs";
import { getFileStreamAndMetadata } from "@pipedream/platform";

export default {
key: "elevenlabs-add-voice",
name: "Add Voice",
version: "0.0.3",
version: "0.0.4",
description: "Add a voice from one or more audio files. [See the documentation](https://elevenlabs.io/docs/api-reference/add-voice)",
type: "action",
props: {
Expand All @@ -17,8 +17,8 @@ export default {
},
files: {
type: "string[]",
label: "Files",
description: "One or more audio files (in the `/tmp` folder) to clone the voice from. Example: `/tmp/voice.mp3`",
label: "File Paths or URLs",
description: "Provide either a n array of file URLs or an array of paths to a files in the /tmp directory (for example, /tmp/myFlie.pdf).",
},
description: {
type: "string",
Expand All @@ -45,10 +45,16 @@ export default {
const data = new FormData();
if (description) data.append("description", description);

files.forEach((file) => {
data.append("files", fs.createReadStream(file.includes("tmp/")
? file
: `/tmp/${file}`));});
for (const file of files) {
const {
stream, metadata,
} = await getFileStreamAndMetadata(file);
data.append("files", stream, {
contentType: metadata.contentType,
knownLength: metadata.size,
filename: metadata.name,
});
}

if (labels) data.append("labels", labels);
data.append("name", name);
Expand Down
4 changes: 2 additions & 2 deletions components/elevenlabs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/elevenlabs",
"version": "0.4.0",
"version": "0.4.1",
"description": "Pipedream ElevenLabs Components",
"main": "elevenlabs.app.mjs",
"keywords": [
Expand All @@ -13,7 +13,7 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3",
"@pipedream/platform": "^3.1.0",
"form-data": "^4.0.0"
}
}
Loading
Loading