diff --git a/components/screenshotbase/actions/capture/capture.mjs b/components/screenshotbase/actions/capture/capture.mjs new file mode 100644 index 0000000000000..700a7e1620748 --- /dev/null +++ b/components/screenshotbase/actions/capture/capture.mjs @@ -0,0 +1,73 @@ +import screenshotbase from "../../screenshotbase.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "screenshotbase-take", + name: "Take Screenshot", + description: "Render a website screenshot or PDF via Screenshotbase.", + version: "0.1.1", + type: "action", + props: { + screenshotbase, + url: { + label: "URL", + type: "string", + description: "Website to render", + optional: false, + }, + width: { + type: "integer", + label: "Width", + optional: true, + default: 1280, + }, + height: { + type: "integer", + label: "Height", + optional: true, + default: 800, + }, + format: { + type: "string", + label: "Format", + description: "png | jpeg | pdf", + optional: true, + options: ["png", "jpeg", "pdf"], + }, + fullPage: { + type: "boolean", + label: "Full Page", + optional: true, + }, + waitForSelector: { + type: "string", + label: "Wait for CSS Selector", + optional: true, + }, + omitBackground: { + type: "boolean", + label: "Transparent Background", + optional: true, + }, + }, + async run({ steps, $ }) { + const base = this.screenshotbase.baseUrl(); + const params = { + url: this.url, + viewport_width: this.width, + viewport_height: this.height, + format: this.format, + full_page: this.fullPage ? 1 : undefined, + }; + const res = await axios($, { + method: "GET", + url: `${base}/v1/take`, + headers: { apikey: this.screenshotbase.$auth.api_key }, + params, + }); + $.export("result", res); + return res; + }, +}; + + diff --git a/components/screenshotbase/actions/take_advanced/take_advanced.mjs b/components/screenshotbase/actions/take_advanced/take_advanced.mjs new file mode 100644 index 0000000000000..1afcd6e7ffedd --- /dev/null +++ b/components/screenshotbase/actions/take_advanced/take_advanced.mjs @@ -0,0 +1,40 @@ +import screenshotbase from "../../screenshotbase.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "screenshotbase-take-advanced", + name: "Take Screenshot (Advanced)", + description: "Render a website with full set of parameters (format, quality, full_page, viewport)", + version: "0.1.0", + type: "action", + props: { + screenshotbase, + url: { label: "URL", type: "string", optional: false }, + format: { label: "Format", type: "string", optional: true, options: ["jpg", "jpeg", "png", "gif"] }, + quality: { label: "Quality (jpg/jpeg only)", type: "integer", optional: true }, + full_page: { label: "Full Page", type: "boolean", optional: true }, + viewport_width: { label: "Viewport Width", type: "integer", optional: true, default: 1280 }, + viewport_height: { label: "Viewport Height", type: "integer", optional: true, default: 800 }, + }, + async run({ $ }) { + const base = this.screenshotbase.baseUrl(); + const params = { + url: this.url, + format: this.format, + quality: this.quality, + full_page: this.full_page ? 1 : undefined, + viewport_width: this.viewport_width, + viewport_height: this.viewport_height, + }; + const res = await axios($, { + method: "GET", + url: `${base}/v1/take`, + headers: { apikey: this.screenshotbase.$auth.api_key }, + params, + }); + $.export("result", res); + return res; + }, +}; + + diff --git a/components/screenshotbase/actions/take_html/take_html.mjs b/components/screenshotbase/actions/take_html/take_html.mjs new file mode 100644 index 0000000000000..7164716824d49 --- /dev/null +++ b/components/screenshotbase/actions/take_html/take_html.mjs @@ -0,0 +1,36 @@ +import screenshotbase from "../../screenshotbase.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "screenshotbase-take-html", + name: "Take from HTML", + description: "Render a screenshot from raw HTML (served by Screenshotbase)", + version: "0.1.0", + type: "action", + props: { + screenshotbase, + html: { label: "HTML", type: "string", optional: false }, + viewport_width: { label: "Viewport Width", type: "integer", optional: true, default: 800 }, + viewport_height: { label: "Viewport Height", type: "integer", optional: true, default: 400 }, + format: { label: "Format", type: "string", optional: true, options: ["jpg", "jpeg", "png", "gif"] }, + }, + async run({ $ }) { + const base = this.screenshotbase.baseUrl(); + const params = { + html: this.html, + format: this.format, + viewport_width: this.viewport_width, + viewport_height: this.viewport_height, + }; + const res = await axios($, { + method: "GET", + url: `${base}/v1/take`, + headers: { apikey: this.screenshotbase.$auth.api_key }, + params, + }); + $.export("result", res); + return res; + }, +}; + + diff --git a/components/screenshotbase/actions/take_pdf/take_pdf.mjs b/components/screenshotbase/actions/take_pdf/take_pdf.mjs new file mode 100644 index 0000000000000..0eea7e641ee59 --- /dev/null +++ b/components/screenshotbase/actions/take_pdf/take_pdf.mjs @@ -0,0 +1,35 @@ +import screenshotbase from "../../screenshotbase.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "screenshotbase-take-pdf", + name: "Take PDF", + description: "Render a PDF from a website URL", + version: "0.1.0", + type: "action", + props: { + screenshotbase, + url: { label: "URL", type: "string", optional: false }, + viewport_width: { label: "Viewport Width", type: "integer", optional: true, default: 1280 }, + viewport_height: { label: "Viewport Height", type: "integer", optional: true, default: 800 }, + }, + async run({ $ }) { + const base = this.screenshotbase.baseUrl(); + const params = { + url: this.url, + format: "pdf", + viewport_width: this.viewport_width, + viewport_height: this.viewport_height, + }; + const res = await axios($, { + method: "GET", + url: `${base}/v1/take`, + headers: { apikey: this.screenshotbase.$auth.api_key }, + params, + }); + $.export("result", res); + return res; + }, +}; + + diff --git a/components/screenshotbase/screenshotbase.app.mjs b/components/screenshotbase/screenshotbase.app.mjs new file mode 100644 index 0000000000000..5cdb8def07877 --- /dev/null +++ b/components/screenshotbase/screenshotbase.app.mjs @@ -0,0 +1,38 @@ +export default { + type: "app", + app: "screenshotbase", + name: "Screenshotbase", + propDefinitions: {}, + auth: { + type: "custom", + fields: { + api_key: { + label: "API Key", + description: "Get your key from the Screenshotbase dashboard.", + type: "string", + }, + base_url: { + label: "Base URL (optional)", + type: "string", + optional: true, + description: "Override API base, defaults to https://api.screenshotbase.com", + }, + }, + test: { + request: { + url: "https://api.screenshotbase.com/status", + headers: { + apikey: "{{auth.api_key}}", + }, + }, + }, + connectionLabel: "Screenshotbase", + }, + methods: { + baseUrl() { + return this.$auth.base_url?.trim() || "https://api.screenshotbase.com"; + }, + }, +}; + +