Skip to content

Commit c616b5a

Browse files
committed
[Components] pexels #16496
Sources - New Photo By Search - New Curated Photo Actions - Search Photos - Get Photo Details - Download Photo
1 parent b9a328b commit c616b5a

File tree

125 files changed

+329
-19486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+329
-19486
lines changed

common/constants.mjs

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
export const ORIENTATION_OPTIONS = [
2+
{
3+
label: "Landscape",
4+
value: "landscape",
5+
},
6+
{
7+
label: "Portrait",
8+
value: "portrait",
9+
},
10+
{
11+
label: "Square",
12+
value: "square",
13+
},
14+
];
15+
16+
export const SIZE_OPTIONS = [
17+
{
18+
label: "Large (24MP)",
19+
value: "large",
20+
},
21+
{
22+
label: "Medium (12MP)",
23+
value: "medium",
24+
},
25+
{
26+
label: "Small (4MP)",
27+
value: "small",
28+
},
29+
];
30+
31+
export const COLOR_OPTIONS = [
32+
{
33+
label: "Red",
34+
value: "red",
35+
},
36+
{
37+
label: "Orange",
38+
value: "orange",
39+
},
40+
{
41+
label: "Yellow",
42+
value: "yellow",
43+
},
44+
{
45+
label: "Green",
46+
value: "green",
47+
},
48+
{
49+
label: "Turquoise",
50+
value: "turquoise",
51+
},
52+
{
53+
label: "Blue",
54+
value: "blue",
55+
},
56+
{
57+
label: "Violet",
58+
value: "violet",
59+
},
60+
{
61+
label: "Pink",
62+
value: "pink",
63+
},
64+
{
65+
label: "Brown",
66+
value: "brown",
67+
},
68+
{
69+
label: "Black",
70+
value: "black",
71+
},
72+
{
73+
label: "Gray",
74+
value: "gray",
75+
},
76+
{
77+
label: "White",
78+
value: "white",
79+
},
80+
];
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import pexels from "../../pexels.app.mjs";
21
import { axios } from "@pipedream/platform";
32
import fs from "fs";
3+
import stream from "stream";
4+
import { promisify } from "util";
5+
import pexels from "../../pexels.app.mjs";
46

57
export default {
68
key: "pexels-download-photo",
@@ -16,22 +18,44 @@ export default {
1618
"photoId",
1719
],
1820
},
19-
desiredSize: {
20-
propDefinition: [
21-
pexels,
22-
"desiredSize",
23-
],
21+
filePath: {
22+
type: "string",
23+
label: "File Path",
24+
description: "The destination path in [`/tmp`](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory) for the downloaded the file (e.g., `/tmp/myFile.jpg`). Make sure to include the file extension.",
25+
},
26+
},
27+
methods: {
28+
getFileStream({
29+
$, downloadUrl,
30+
}) {
31+
return axios($, {
32+
url: downloadUrl,
33+
responseType: "stream",
34+
});
2435
},
2536
},
2637
async run({ $ }) {
27-
const filePath = await this.pexels.downloadPhoto({
38+
const response = await this.pexels.getPhoto({
39+
$,
2840
photoId: this.photoId,
29-
desiredSize: this.desiredSize,
3041
});
3142

32-
$.export("$summary", `Successfully downloaded photo with ID ${this.photoId} to ${filePath}`);
43+
const fileStream = await this.getFileStream({
44+
$,
45+
downloadUrl: response.src.original,
46+
});
47+
48+
const pipeline = promisify(stream.pipeline);
49+
const resp = await pipeline(
50+
fileStream,
51+
fs.createWriteStream(this.filePath.includes("/tmp")
52+
? this.filePath
53+
: `/tmp/${this.filePath}`),
54+
);
55+
56+
$.export("$summary", `Successfully downloaded photo with ID ${this.photoId} to ${this.filePath}`);
3357
return {
34-
filePath,
58+
resp,
3559
};
3660
},
3761
};

components/pexels/actions/get-photo-details/get-photo-details.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import pexels from "../../pexels.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "pexels-get-photo-details",
65
name: "Get Photo Details",
7-
description: "Retrieve detailed information about a specific photo by providing its photo ID. [See the documentation](https://www.pexels.com/api/documentation/)",
6+
description: "Retrieve detailed information about a specific photo by providing its photo ID. [See the documentation](https://www.pexels.com/api/documentation/#photos-show)",
87
version: "0.0.1",
98
type: "action",
109
props: {
@@ -18,6 +17,7 @@ export default {
1817
},
1918
async run({ $ }) {
2019
const response = await this.pexels.getPhoto({
20+
$,
2121
photoId: this.photoId,
2222
});
2323
$.export("$summary", `Successfully retrieved details for photo ID: ${this.photoId}`);

components/pexels/actions/search-photos/search-photos.mjs

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import pexels from "../../pexels.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "pexels-search-photos",
65
name: "Search Photos",
7-
description: "Search for photos on Pexels using a keyword or phrase. [See the documentation](https://www.pexels.com/api/documentation/)",
6+
description: "Search for photos on Pexels using a keyword or phrase. [See the documentation](https://www.pexels.com/api/documentation/#photos-search)",
87
version: "0.0.1",
98
type: "action",
109
props: {
@@ -33,13 +32,31 @@ export default {
3332
"color",
3433
],
3534
},
35+
page: {
36+
type: "Integer",
37+
label: "Page",
38+
description: "The page number you are requesting",
39+
optional: true,
40+
},
41+
perPage: {
42+
type: "Integer",
43+
label: "Per Page",
44+
description: "The number of results you are requesting per page",
45+
max: 80,
46+
optional: true,
47+
},
3648
},
3749
async run({ $ }) {
3850
const response = await this.pexels.searchPhotos({
39-
query: this.searchQuery,
40-
orientation: this.orientation,
41-
size: this.size,
42-
color: this.color,
51+
$,
52+
params: {
53+
query: this.searchQuery,
54+
orientation: this.orientation,
55+
size: this.size,
56+
color: this.color,
57+
page: this.page || 1,
58+
per_page: this.perPage || 15,
59+
},
4360
});
4461

4562
$.export("$summary", `Successfully retrieved ${response.photos.length} photos for the query "${this.searchQuery}".`);

components/pexels/node_modules/@pipedream/platform/.eslintignore

-1
This file was deleted.

components/pexels/node_modules/@pipedream/platform/LICENSE

-41
This file was deleted.

components/pexels/node_modules/@pipedream/platform/README.md

-3
This file was deleted.

0 commit comments

Comments
 (0)