Skip to content

Commit e30dcf4

Browse files
committed
new component
1 parent 6a1c408 commit e30dcf4

File tree

3 files changed

+62
-120
lines changed

3 files changed

+62
-120
lines changed

components/screenshot_fyi/actions/create-screenshot/create-screenshot.mjs

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,70 @@ export default {
44
key: "screenshot_fyi-create-screenshot",
55
name: "Create Screenshot",
66
description: "Takes a screenshot of a webpage using Screenshot.fyi. [See the documentation](https://www.screenshot.fyi/api-docs)",
7-
version: "0.0.{{ts}}",
7+
version: "0.0.1",
88
type: "action",
99
props: {
10-
screenshot_fyi: {
11-
type: "app",
12-
app: "screenshot_fyi",
13-
},
10+
screenshot_fyi,
1411
url: {
15-
propDefinition: [
16-
screenshot_fyi,
17-
"url",
18-
],
12+
type: "string",
13+
label: "URL",
14+
description: "The URL of the webpage to capture",
1915
},
2016
width: {
21-
propDefinition: [
22-
screenshot_fyi,
23-
"width",
24-
],
17+
type: "integer",
18+
label: "Width",
19+
description: "Width of the viewport in pixels. Default: `1440`",
20+
optional: true,
2521
},
2622
height: {
27-
propDefinition: [
28-
screenshot_fyi,
29-
"height",
30-
],
23+
type: "integer",
24+
label: "Height",
25+
description: "Height of the viewport in pixels. Default: `900`",
26+
optional: true,
3127
},
32-
fullpage: {
33-
propDefinition: [
34-
screenshot_fyi,
35-
"fullpage",
36-
],
28+
fullPage: {
29+
type: "boolean",
30+
label: "Full Page",
31+
description: "Capture the full scrollable page. Default: `false`",
32+
optional: true,
3733
},
3834
format: {
39-
propDefinition: [
40-
screenshot_fyi,
41-
"format",
35+
type: "string",
36+
label: "Format",
37+
description: "The format of the screenshot. Default: `jpg`",
38+
options: [
39+
"png",
40+
"jpg",
41+
"jpeg",
4242
],
43+
optional: true,
4344
},
4445
disableCookieBanners: {
45-
propDefinition: [
46-
screenshot_fyi,
47-
"disableCookieBanners",
48-
],
46+
type: "boolean",
47+
label: "Disable Cookie Banners",
48+
description: "Attempt to remove cookie consent banners. Default: `true`",
4949
optional: true,
5050
},
5151
darkMode: {
52-
propDefinition: [
53-
screenshot_fyi,
54-
"darkMode",
55-
],
52+
type: "boolean",
53+
label: "Dark Mode",
54+
description: "Enable dark mode when taking the screenshot. Default: `false`",
5655
optional: true,
5756
},
5857
},
5958
async run({ $ }) {
60-
const response = await this.screenshot_fyi.takeScreenshot();
59+
const response = await this.screenshot_fyi.takeScreenshot({
60+
$,
61+
params: {
62+
url: this.url,
63+
width: this.width,
64+
height: this.height,
65+
fullPage: this.fullPage,
66+
format: this.format,
67+
disableCookieBanners: this.disableCookieBanners,
68+
darkMode: this.darkMode,
69+
},
70+
});
6171
$.export("$summary", `Screenshot taken for ${this.url}`);
6272
return response;
6373
},

components/screenshot_fyi/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/screenshot_fyi",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream screenshot.fyi Components",
55
"main": "screenshot_fyi.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
1518
}

components/screenshot_fyi/screenshot_fyi.app.mjs

Lines changed: 14 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -3,102 +3,31 @@ import { axios } from "@pipedream/platform";
33
export default {
44
type: "app",
55
app: "screenshot_fyi",
6-
propDefinitions: {
7-
url: {
8-
type: "string",
9-
label: "URL",
10-
description: "The URL of the webpage to capture",
11-
},
12-
width: {
13-
type: "integer",
14-
label: "Width",
15-
description: "The width of the screenshot",
16-
optional: true,
17-
},
18-
height: {
19-
type: "integer",
20-
label: "Height",
21-
description: "The height of the screenshot",
22-
optional: true,
23-
},
24-
fullpage: {
25-
type: "boolean",
26-
label: "Full Page",
27-
description: "Capture the full page of the webpage",
28-
optional: true,
29-
},
30-
format: {
31-
type: "string",
32-
label: "Format",
33-
description: "The format of the screenshot (e.g., png, jpeg)",
34-
optional: true,
35-
},
36-
disableCookieBanners: {
37-
type: "boolean",
38-
label: "Disable Cookie Banners",
39-
description: "Disable cookie banners in the screenshot",
40-
optional: true,
41-
},
42-
darkMode: {
43-
type: "boolean",
44-
label: "Dark Mode",
45-
description: "Enable dark mode in the screenshot",
46-
optional: true,
47-
},
48-
},
6+
propDefinitions: {},
497
methods: {
50-
authKeys() {
51-
console.log(Object.keys(this.$auth));
52-
},
538
_baseUrl() {
549
return "https://screenshot.fyi/api";
5510
},
56-
async _makeRequest(opts = {}) {
57-
const {
58-
$ = this,
59-
method = "GET",
60-
path = "/take",
61-
headers,
62-
params,
63-
...otherOpts
64-
} = opts;
11+
_makeRequest({
12+
$ = this,
13+
path,
14+
params,
15+
...otherOpts
16+
}) {
6517
return axios($, {
66-
method,
67-
url: this._baseUrl() + path,
68-
headers: {
69-
...headers,
70-
Authorization: `Bearer ${this.$auth.api_key}`,
18+
url: `${this._baseUrl()}${path}`,
19+
params: {
20+
...params,
21+
accessKey: this.$auth.access_key,
7122
},
72-
params,
7323
...otherOpts,
7424
});
7525
},
76-
async takeScreenshot() {
77-
const params = {
78-
url: this.url,
79-
...(this.width !== undefined && {
80-
width: this.width,
81-
}),
82-
...(this.height !== undefined && {
83-
height: this.height,
84-
}),
85-
...(this.fullpage !== undefined && {
86-
fullpage: this.fullpage,
87-
}),
88-
...(this.format && {
89-
format: this.format,
90-
}),
91-
...(this.disableCookieBanners !== undefined && {
92-
disableCookieBanners: this.disableCookieBanners,
93-
}),
94-
...(this.darkMode !== undefined && {
95-
darkMode: this.darkMode,
96-
}),
97-
};
26+
takeScreenshot(opts = {}) {
9827
return this._makeRequest({
99-
params,
28+
path: "/take",
29+
...opts,
10030
});
10131
},
10232
},
103-
version: "0.0.{{ts}}",
10433
};

0 commit comments

Comments
 (0)