diff --git a/components/getscreenshot/.gitignore b/components/getscreenshot/.gitignore deleted file mode 100644 index ec761ccab7595..0000000000000 --- a/components/getscreenshot/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.js -*.mjs -dist \ No newline at end of file diff --git a/components/getscreenshot/actions/get-account-api-usage/get-account-api-usage.mjs b/components/getscreenshot/actions/get-account-api-usage/get-account-api-usage.mjs new file mode 100644 index 0000000000000..cc7a1d95b3425 --- /dev/null +++ b/components/getscreenshot/actions/get-account-api-usage/get-account-api-usage.mjs @@ -0,0 +1,29 @@ +import rasterwise from "../../getscreenshot.app.mjs"; + +export default { + key: "getscreenshot-get-account-api-usage", + name: "Get Account API Usage", + description: + "Retrieve your current API usage and available quota. [See the documentation](https://docs.rasterwise.com/docs/getscreenshot/api-reference-1/)", + version: "0.0.1", + type: "action", + props: { + rasterwise, + email: { + type: "string", + label: "Email Address", + description: "The email address of this account.", + }, + }, + async run({ $ }) { + const { + rasterwise, ...params + } = this; + const response = await rasterwise.getApiUsage({ + $, + params, + }); + $.export("$summary", "Successfully retrieved API usage"); + return response; + }, +}; diff --git a/components/getscreenshot/actions/get-website-screenshot/get-website-screenshot.mjs b/components/getscreenshot/actions/get-website-screenshot/get-website-screenshot.mjs new file mode 100644 index 0000000000000..58cd85b44fb24 --- /dev/null +++ b/components/getscreenshot/actions/get-website-screenshot/get-website-screenshot.mjs @@ -0,0 +1,68 @@ +import getscreenshot from "../../getscreenshot.app.mjs"; + +export default { + key: "getscreenshot-get-website-screenshot", + name: "Get Website Screenshot", + description: "Capture a screenshot from a live website. [See the documentation](https://docs.rasterwise.com/docs/getscreenshot/api-reference-0/)", + version: "0.0.1", + type: "action", + props: { + getscreenshot, + url: { + type: "string", + label: "Website URL", + description: "URL of the website / page you want to screenshot. Should start with `http://` or `https://`", + }, + format: { + type: "string", + label: "Image Format", + 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.", + options: [ + "png", + "jpeg", + "pdf", + ], + default: "png", + optional: true, + }, + email: { + type: "string", + label: "Email Address", + description: "If specified, a formatted email will be sent to this email address, including the captured image and details of the capture.", + optional: true, + }, + element: { + type: "string", + label: "Element", + 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\".", + optional: true, + }, + additionalParams: { + type: "object", + label: "Additional Parameters", + 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.", + optional: true, + }, + }, + async run({ $ }) { + const { + getscreenshot, format, additionalParams, ...params + } = this; + const response = await getscreenshot.getScreenshot({ + $, + params: { + ...params, + ...(format === "pdf" + ? { + pdf: true, + } + : { + format, + }), + ...additionalParams, + }, + }); + $.export("$summary", `Successfully captured screenshot of "${this.url}"`); + return response; + }, +}; diff --git a/components/getscreenshot/app/getscreenshot.app.ts b/components/getscreenshot/app/getscreenshot.app.ts deleted file mode 100644 index 954585fe90be4..0000000000000 --- a/components/getscreenshot/app/getscreenshot.app.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { defineApp } from "@pipedream/types"; - -export default defineApp({ - type: "app", - app: "getscreenshot", - propDefinitions: {}, - methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); - }, - }, -}); diff --git a/components/getscreenshot/getscreenshot.app.mjs b/components/getscreenshot/getscreenshot.app.mjs new file mode 100644 index 0000000000000..15de276954484 --- /dev/null +++ b/components/getscreenshot/getscreenshot.app.mjs @@ -0,0 +1,36 @@ +import { axios } from "@pipedream/platform"; + +export default { + type: "app", + app: "getscreenshot", + propDefinitions: {}, + methods: { + _baseUrl() { + return "https://api.rasterwise.com/v1"; + }, + async _makeRequest({ + $, params, ...otherOpts + }) { + return axios($, { + ...otherOpts, + baseURL: this._baseUrl(), + params: { + ...params, + apikey: this.$auth.api_key, + }, + }); + }, + async getScreenshot(args) { + return this._makeRequest({ + url: "/get-screenshot", + ...args, + }); + }, + async getApiUsage(args) { + return this._makeRequest({ + url: "/usage", + ...args, + }); + }, + }, +}; diff --git a/components/getscreenshot/package.json b/components/getscreenshot/package.json index ddd7edcbb0056..1a2ec6ff4e18e 100644 --- a/components/getscreenshot/package.json +++ b/components/getscreenshot/package.json @@ -1,18 +1,18 @@ { "name": "@pipedream/getscreenshot", - "version": "0.0.3", + "version": "0.1.0", "description": "Pipedream GetScreenshot Components", - "main": "dist/app/getscreenshot.app.mjs", + "main": "getscreenshot.app.mjs", "keywords": [ "pipedream", "getscreenshot" ], - "files": [ - "dist" - ], "homepage": "https://pipedream.com/apps/getscreenshot", "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e96a2ebc3e871..030af1c6b33e0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5057,7 +5057,11 @@ importers: specifier: ^1.2.0 version: 1.6.6 - components/getscreenshot: {} + components/getscreenshot: + specifiers: + '@pipedream/platform': ^3.0.3 + dependencies: + '@pipedream/platform': 3.0.3 components/getswift: {}