Skip to content

Commit e12786e

Browse files
authored
GetScreenshot new components (#14070)
* Initial AI-generated code (w/o dead imports) * Package updates * App file adjustments * Creating 'get account api usage' * pnpm * Get Website Screenshot action * Syntax fixes * Object fix * Request fixes
1 parent 556dc7b commit e12786e

File tree

7 files changed

+143
-22
lines changed

7 files changed

+143
-22
lines changed

components/getscreenshot/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import rasterwise from "../../getscreenshot.app.mjs";
2+
3+
export default {
4+
key: "getscreenshot-get-account-api-usage",
5+
name: "Get Account API Usage",
6+
description:
7+
"Retrieve your current API usage and available quota. [See the documentation](https://docs.rasterwise.com/docs/getscreenshot/api-reference-1/)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
rasterwise,
12+
email: {
13+
type: "string",
14+
label: "Email Address",
15+
description: "The email address of this account.",
16+
},
17+
},
18+
async run({ $ }) {
19+
const {
20+
rasterwise, ...params
21+
} = this;
22+
const response = await rasterwise.getApiUsage({
23+
$,
24+
params,
25+
});
26+
$.export("$summary", "Successfully retrieved API usage");
27+
return response;
28+
},
29+
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import getscreenshot from "../../getscreenshot.app.mjs";
2+
3+
export default {
4+
key: "getscreenshot-get-website-screenshot",
5+
name: "Get Website Screenshot",
6+
description: "Capture a screenshot from a live website. [See the documentation](https://docs.rasterwise.com/docs/getscreenshot/api-reference-0/)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
getscreenshot,
11+
url: {
12+
type: "string",
13+
label: "Website URL",
14+
description: "URL of the website / page you want to screenshot. Should start with `http://` or `https://`",
15+
},
16+
format: {
17+
type: "string",
18+
label: "Image Format",
19+
description: "The file type/format in which you want to get your capture. If `pdf` is selected, an A4 PDF of the passed website will be generated, rendered the same as if you were printing it from your browser.",
20+
options: [
21+
"png",
22+
"jpeg",
23+
"pdf",
24+
],
25+
default: "png",
26+
optional: true,
27+
},
28+
email: {
29+
type: "string",
30+
label: "Email Address",
31+
description: "If specified, a formatted email will be sent to this email address, including the captured image and details of the capture.",
32+
optional: true,
33+
},
34+
element: {
35+
type: "string",
36+
label: "Element",
37+
description: "If you need to target specific DOM elements instead of taking dimension-based screenshots, you can specify an element DOM selector, e.g. `#colordiv` to target a div with the id \"colordiv\".",
38+
optional: true,
39+
},
40+
additionalParams: {
41+
type: "object",
42+
label: "Additional Parameters",
43+
description: "Additional parameters (key/value pairs) to send in this request. [See the documentation](https://docs.rasterwise.com/docs/getscreenshot/api-reference-0/) for all available parameters.",
44+
optional: true,
45+
},
46+
},
47+
async run({ $ }) {
48+
const {
49+
getscreenshot, format, additionalParams, ...params
50+
} = this;
51+
const response = await getscreenshot.getScreenshot({
52+
$,
53+
params: {
54+
...params,
55+
...(format === "pdf"
56+
? {
57+
pdf: true,
58+
}
59+
: {
60+
format,
61+
}),
62+
...additionalParams,
63+
},
64+
});
65+
$.export("$summary", `Successfully captured screenshot of "${this.url}"`);
66+
return response;
67+
},
68+
};

components/getscreenshot/app/getscreenshot.app.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { axios } from "@pipedream/platform";
2+
3+
export default {
4+
type: "app",
5+
app: "getscreenshot",
6+
propDefinitions: {},
7+
methods: {
8+
_baseUrl() {
9+
return "https://api.rasterwise.com/v1";
10+
},
11+
async _makeRequest({
12+
$, params, ...otherOpts
13+
}) {
14+
return axios($, {
15+
...otherOpts,
16+
baseURL: this._baseUrl(),
17+
params: {
18+
...params,
19+
apikey: this.$auth.api_key,
20+
},
21+
});
22+
},
23+
async getScreenshot(args) {
24+
return this._makeRequest({
25+
url: "/get-screenshot",
26+
...args,
27+
});
28+
},
29+
async getApiUsage(args) {
30+
return this._makeRequest({
31+
url: "/usage",
32+
...args,
33+
});
34+
},
35+
},
36+
};

components/getscreenshot/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"name": "@pipedream/getscreenshot",
3-
"version": "0.0.3",
3+
"version": "0.1.0",
44
"description": "Pipedream GetScreenshot Components",
5-
"main": "dist/app/getscreenshot.app.mjs",
5+
"main": "getscreenshot.app.mjs",
66
"keywords": [
77
"pipedream",
88
"getscreenshot"
99
],
10-
"files": [
11-
"dist"
12-
],
1310
"homepage": "https://pipedream.com/apps/getscreenshot",
1411
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1512
"publishConfig": {
1613
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1717
}
1818
}

pnpm-lock.yaml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)