From 6a1c408210de585375861fedc874554707c3f469 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 31 Dec 2024 11:32:28 -0500 Subject: [PATCH 1/3] screenshot_fyi init --- .../create-screenshot/create-screenshot.mjs | 64 ++++++++++++ components/screenshot_fyi/package.json | 2 +- .../screenshot_fyi/screenshot_fyi.app.mjs | 97 ++++++++++++++++++- 3 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 components/screenshot_fyi/actions/create-screenshot/create-screenshot.mjs diff --git a/components/screenshot_fyi/actions/create-screenshot/create-screenshot.mjs b/components/screenshot_fyi/actions/create-screenshot/create-screenshot.mjs new file mode 100644 index 0000000000000..2f51e3b2d404d --- /dev/null +++ b/components/screenshot_fyi/actions/create-screenshot/create-screenshot.mjs @@ -0,0 +1,64 @@ +import screenshot_fyi from "../../screenshot_fyi.app.mjs"; + +export default { + key: "screenshot_fyi-create-screenshot", + name: "Create Screenshot", + description: "Takes a screenshot of a webpage using Screenshot.fyi. [See the documentation](https://www.screenshot.fyi/api-docs)", + version: "0.0.{{ts}}", + type: "action", + props: { + screenshot_fyi: { + type: "app", + app: "screenshot_fyi", + }, + url: { + propDefinition: [ + screenshot_fyi, + "url", + ], + }, + width: { + propDefinition: [ + screenshot_fyi, + "width", + ], + }, + height: { + propDefinition: [ + screenshot_fyi, + "height", + ], + }, + fullpage: { + propDefinition: [ + screenshot_fyi, + "fullpage", + ], + }, + format: { + propDefinition: [ + screenshot_fyi, + "format", + ], + }, + disableCookieBanners: { + propDefinition: [ + screenshot_fyi, + "disableCookieBanners", + ], + optional: true, + }, + darkMode: { + propDefinition: [ + screenshot_fyi, + "darkMode", + ], + optional: true, + }, + }, + async run({ $ }) { + const response = await this.screenshot_fyi.takeScreenshot(); + $.export("$summary", `Screenshot taken for ${this.url}`); + return response; + }, +}; diff --git a/components/screenshot_fyi/package.json b/components/screenshot_fyi/package.json index a84371047bbc4..7297858088c25 100644 --- a/components/screenshot_fyi/package.json +++ b/components/screenshot_fyi/package.json @@ -12,4 +12,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} diff --git a/components/screenshot_fyi/screenshot_fyi.app.mjs b/components/screenshot_fyi/screenshot_fyi.app.mjs index 50d14cb24d837..87869bbc3b655 100644 --- a/components/screenshot_fyi/screenshot_fyi.app.mjs +++ b/components/screenshot_fyi/screenshot_fyi.app.mjs @@ -1,11 +1,104 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "screenshot_fyi", - propDefinitions: {}, + propDefinitions: { + url: { + type: "string", + label: "URL", + description: "The URL of the webpage to capture", + }, + width: { + type: "integer", + label: "Width", + description: "The width of the screenshot", + optional: true, + }, + height: { + type: "integer", + label: "Height", + description: "The height of the screenshot", + optional: true, + }, + fullpage: { + type: "boolean", + label: "Full Page", + description: "Capture the full page of the webpage", + optional: true, + }, + format: { + type: "string", + label: "Format", + description: "The format of the screenshot (e.g., png, jpeg)", + optional: true, + }, + disableCookieBanners: { + type: "boolean", + label: "Disable Cookie Banners", + description: "Disable cookie banners in the screenshot", + optional: true, + }, + darkMode: { + type: "boolean", + label: "Dark Mode", + description: "Enable dark mode in the screenshot", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data authKeys() { console.log(Object.keys(this.$auth)); }, + _baseUrl() { + return "https://screenshot.fyi/api"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + method = "GET", + path = "/take", + headers, + params, + ...otherOpts + } = opts; + return axios($, { + method, + url: this._baseUrl() + path, + headers: { + ...headers, + Authorization: `Bearer ${this.$auth.api_key}`, + }, + params, + ...otherOpts, + }); + }, + async takeScreenshot() { + const params = { + url: this.url, + ...(this.width !== undefined && { + width: this.width, + }), + ...(this.height !== undefined && { + height: this.height, + }), + ...(this.fullpage !== undefined && { + fullpage: this.fullpage, + }), + ...(this.format && { + format: this.format, + }), + ...(this.disableCookieBanners !== undefined && { + disableCookieBanners: this.disableCookieBanners, + }), + ...(this.darkMode !== undefined && { + darkMode: this.darkMode, + }), + }; + return this._makeRequest({ + params, + }); + }, }, + version: "0.0.{{ts}}", }; From e30dcf4ac2dd11fa261f2ee7f0de179f6464e114 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 31 Dec 2024 11:48:57 -0500 Subject: [PATCH 2/3] new component --- .../create-screenshot/create-screenshot.mjs | 78 ++++++++------- components/screenshot_fyi/package.json | 5 +- .../screenshot_fyi/screenshot_fyi.app.mjs | 99 +++---------------- 3 files changed, 62 insertions(+), 120 deletions(-) diff --git a/components/screenshot_fyi/actions/create-screenshot/create-screenshot.mjs b/components/screenshot_fyi/actions/create-screenshot/create-screenshot.mjs index 2f51e3b2d404d..90b5a468a97d0 100644 --- a/components/screenshot_fyi/actions/create-screenshot/create-screenshot.mjs +++ b/components/screenshot_fyi/actions/create-screenshot/create-screenshot.mjs @@ -4,60 +4,70 @@ export default { key: "screenshot_fyi-create-screenshot", name: "Create Screenshot", description: "Takes a screenshot of a webpage using Screenshot.fyi. [See the documentation](https://www.screenshot.fyi/api-docs)", - version: "0.0.{{ts}}", + version: "0.0.1", type: "action", props: { - screenshot_fyi: { - type: "app", - app: "screenshot_fyi", - }, + screenshot_fyi, url: { - propDefinition: [ - screenshot_fyi, - "url", - ], + type: "string", + label: "URL", + description: "The URL of the webpage to capture", }, width: { - propDefinition: [ - screenshot_fyi, - "width", - ], + type: "integer", + label: "Width", + description: "Width of the viewport in pixels. Default: `1440`", + optional: true, }, height: { - propDefinition: [ - screenshot_fyi, - "height", - ], + type: "integer", + label: "Height", + description: "Height of the viewport in pixels. Default: `900`", + optional: true, }, - fullpage: { - propDefinition: [ - screenshot_fyi, - "fullpage", - ], + fullPage: { + type: "boolean", + label: "Full Page", + description: "Capture the full scrollable page. Default: `false`", + optional: true, }, format: { - propDefinition: [ - screenshot_fyi, - "format", + type: "string", + label: "Format", + description: "The format of the screenshot. Default: `jpg`", + options: [ + "png", + "jpg", + "jpeg", ], + optional: true, }, disableCookieBanners: { - propDefinition: [ - screenshot_fyi, - "disableCookieBanners", - ], + type: "boolean", + label: "Disable Cookie Banners", + description: "Attempt to remove cookie consent banners. Default: `true`", optional: true, }, darkMode: { - propDefinition: [ - screenshot_fyi, - "darkMode", - ], + type: "boolean", + label: "Dark Mode", + description: "Enable dark mode when taking the screenshot. Default: `false`", optional: true, }, }, async run({ $ }) { - const response = await this.screenshot_fyi.takeScreenshot(); + const response = await this.screenshot_fyi.takeScreenshot({ + $, + params: { + url: this.url, + width: this.width, + height: this.height, + fullPage: this.fullPage, + format: this.format, + disableCookieBanners: this.disableCookieBanners, + darkMode: this.darkMode, + }, + }); $.export("$summary", `Screenshot taken for ${this.url}`); return response; }, diff --git a/components/screenshot_fyi/package.json b/components/screenshot_fyi/package.json index 7297858088c25..db634ce53f182 100644 --- a/components/screenshot_fyi/package.json +++ b/components/screenshot_fyi/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/screenshot_fyi", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream screenshot.fyi Components", "main": "screenshot_fyi.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } diff --git a/components/screenshot_fyi/screenshot_fyi.app.mjs b/components/screenshot_fyi/screenshot_fyi.app.mjs index 87869bbc3b655..f68730d766788 100644 --- a/components/screenshot_fyi/screenshot_fyi.app.mjs +++ b/components/screenshot_fyi/screenshot_fyi.app.mjs @@ -3,102 +3,31 @@ import { axios } from "@pipedream/platform"; export default { type: "app", app: "screenshot_fyi", - propDefinitions: { - url: { - type: "string", - label: "URL", - description: "The URL of the webpage to capture", - }, - width: { - type: "integer", - label: "Width", - description: "The width of the screenshot", - optional: true, - }, - height: { - type: "integer", - label: "Height", - description: "The height of the screenshot", - optional: true, - }, - fullpage: { - type: "boolean", - label: "Full Page", - description: "Capture the full page of the webpage", - optional: true, - }, - format: { - type: "string", - label: "Format", - description: "The format of the screenshot (e.g., png, jpeg)", - optional: true, - }, - disableCookieBanners: { - type: "boolean", - label: "Disable Cookie Banners", - description: "Disable cookie banners in the screenshot", - optional: true, - }, - darkMode: { - type: "boolean", - label: "Dark Mode", - description: "Enable dark mode in the screenshot", - optional: true, - }, - }, + propDefinitions: {}, methods: { - authKeys() { - console.log(Object.keys(this.$auth)); - }, _baseUrl() { return "https://screenshot.fyi/api"; }, - async _makeRequest(opts = {}) { - const { - $ = this, - method = "GET", - path = "/take", - headers, - params, - ...otherOpts - } = opts; + _makeRequest({ + $ = this, + path, + params, + ...otherOpts + }) { return axios($, { - method, - url: this._baseUrl() + path, - headers: { - ...headers, - Authorization: `Bearer ${this.$auth.api_key}`, + url: `${this._baseUrl()}${path}`, + params: { + ...params, + accessKey: this.$auth.access_key, }, - params, ...otherOpts, }); }, - async takeScreenshot() { - const params = { - url: this.url, - ...(this.width !== undefined && { - width: this.width, - }), - ...(this.height !== undefined && { - height: this.height, - }), - ...(this.fullpage !== undefined && { - fullpage: this.fullpage, - }), - ...(this.format && { - format: this.format, - }), - ...(this.disableCookieBanners !== undefined && { - disableCookieBanners: this.disableCookieBanners, - }), - ...(this.darkMode !== undefined && { - darkMode: this.darkMode, - }), - }; + takeScreenshot(opts = {}) { return this._makeRequest({ - params, + path: "/take", + ...opts, }); }, }, - version: "0.0.{{ts}}", }; From 8e0b51affddab34d62086d49767d4da7ca3cdcce Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 31 Dec 2024 11:52:35 -0500 Subject: [PATCH 3/3] pnpm-lock.yaml --- pnpm-lock.yaml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c607001294094..c11de0b5281ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -94,8 +94,8 @@ importers: specifier: ^12.3.4 version: 12.5.0(enquirer@2.4.1) pnpm: - specifier: 9.14.3 - version: 9.14.3 + specifier: 9.14.2 + version: 9.14.2 putout: specifier: '>=36' version: 36.13.1(eslint@8.57.1)(typescript@5.6.3) @@ -8987,7 +8987,11 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/screenshot_fyi: {} + components/screenshot_fyi: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/screenshotone: dependencies: @@ -23118,8 +23122,8 @@ packages: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} - pnpm@9.14.3: - resolution: {integrity: sha512-wPU+6ZR37ZabgrKJrQEaXRa/FiPJV+fynqvo0MALV0wpuMf1T2xn7nEMc/KFyBVNB85EtG/iwO60dqkEQbrDcQ==} + pnpm@9.14.2: + resolution: {integrity: sha512-biuvd9Brk2IpQVLIUcTyeO3jerHro6Vf2jF6SheyCfTbuXP7JQp3q8Rjo0H8sfF/F8+iQJHE6zGc2g2bhCeDhw==} engines: {node: '>=18.12'} hasBin: true @@ -24579,22 +24583,22 @@ packages: superagent@3.8.1: resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . superagent@4.1.0: resolution: {integrity: sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==} engines: {node: '>= 6.0'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . superagent@5.3.1: resolution: {integrity: sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==} engines: {node: '>= 7.0.0'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . superagent@7.1.6: resolution: {integrity: sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==} engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please downgrade to v7.1.5 if you need IE/ActiveXObject support OR upgrade to v8.0.0 as we no longer support IE and published an incorrect patch version (see https://github.com/visionmedia/superagent/issues/1731) supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==} @@ -40518,7 +40522,7 @@ snapshots: pluralize@8.0.0: {} - pnpm@9.14.3: {} + pnpm@9.14.2: {} points-on-curve@0.2.0: {}