AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(webscraping-ai): add AI actions and output schemas (#16349)
Kishan Parmara4d3cc08c0a0
diff --git a/bun.lock b/bun.lockindex 38e0b4ba347..8f529922704 100644--- a/bun.lock+++ b/bun.lock@@ -9845,7 +9845,7 @@},"packages/pieces/community/webscraping-ai": {"name": "@activepieces/piece-webscraping-ai",- "version": "0.1.7",+ "version": "0.2.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",diff --git a/packages/pieces/community/webscraping-ai/package.json b/packages/pieces/community/webscraping-ai/package.jsonindex 1317151ae39..2c1011339f9 100644--- a/packages/pieces/community/webscraping-ai/package.json+++ b/packages/pieces/community/webscraping-ai/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-webscraping-ai",- "version": "0.1.7",+ "version": "0.2.0","type": "commonjs","main": "./dist/src/index.js","types": "./dist/src/index.d.ts",diff --git a/packages/pieces/community/webscraping-ai/src/index.ts b/packages/pieces/community/webscraping-ai/src/index.tsindex 6e72e5e6bcc..f0ad9980968 100644--- a/packages/pieces/community/webscraping-ai/src/index.ts+++ b/packages/pieces/community/webscraping-ai/src/index.ts@@ -1,26 +1,35 @@-import { createPiece } from '@activepieces/pieces-framework';-import { askAQuestionAboutTheWebPage } from './lib/actions/ask-a-question-about-the-web-page';-import { extractStructuredData } from './lib/actions/extract-structured-data';-import { getAccountInformation } from './lib/actions/get-account-information';-import { getPageHtml } from './lib/actions/get-page-html';-import { scrapeWebsiteText } from './lib/actions/scrape-website-text';-import { webscrapingAiAuth } from './lib/common';-import { PieceCategory } from '@activepieces/pieces-framework';+import { createCustomApiCallAction } from '@activepieces/pieces-common';+import { createPiece, PieceCategory } from '@activepieces/pieces-framework';+import { webscrapingAiAiActions } from './lib/actions/ai';+import { askAQuestionAboutTheWebPageAction } from './lib/actions/ask-a-question-about-the-web-page';+import { extractStructuredDataAction } from './lib/actions/extract-structured-data';+import { getAccountInformationAction } from './lib/actions/get-account-information';+import { getPageHtmlAction } from './lib/actions/get-page-html';+import { scrapeWebsiteTextAction } from './lib/actions/scrape-website-text';+import { webscrapingAiAuth } from './lib/auth';+import { webscrapingAiClient } from './lib/common/client';export const webscrapingAi = createPiece({displayName: 'WebScraping AI',auth: webscrapingAiAuth,- minimumSupportedRelease: '0.36.1',+ minimumSupportedRelease: '0.88.2',description: 'WebScraping AI is a powerful tool that allows you to scrape websites and extract data.',categories: [PieceCategory.DEVELOPER_TOOLS, PieceCategory.ARTIFICIAL_INTELLIGENCE],logoUrl: 'https://cdn.activepieces.com/pieces/webscraping-ai.png',authors: ['LuizDMM', 'onyedikachi-david'],actions: [- askAQuestionAboutTheWebPage,- getPageHtml,- scrapeWebsiteText,- extractStructuredData,- getAccountInformation,+ askAQuestionAboutTheWebPageAction,+ getPageHtmlAction,+ scrapeWebsiteTextAction,+ extractStructuredDataAction,+ getAccountInformationAction,+ ...webscrapingAiAiActions,+ createCustomApiCallAction({+ auth: webscrapingAiAuth,+ baseUrl: () => webscrapingAiClient.baseUrl(),+ authLocation: 'queryParams',+ authMapping: async (auth) => ({ api_key: auth.secret_text }),+ }),],triggers: [],});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/ask-question.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/ask-question.tsnew file mode 100644index 00000000000..80e7bad184c--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/ask-question.ts@@ -0,0 +1,33 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { webscrapingAiAuth } from '../../auth';+import { webscrapingAiAiProps } from '../../common/ai-props';+import { webscrapingAiApi } from '../../common/api';+import { answerOutputSchema } from '../../output-schemas';++export const askQuestionAction = createAction({+ auth: webscrapingAiAuth,+ name: 'webscraping_ai_ask_question',+ outputSchema: answerOutputSchema,+ displayName: 'Ask a Question About a Page',+ description: 'Answers a question about a web page using an LLM.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Fetches a web page and has an LLM answer a natural-language question about its content, returned in result. Use it for one fact or a summary; use Extract Fields for several named values, or Get Page Text to read the page yourself. Read-only on the target site.',+ idempotent: true,+ },+ props: {+ question: Property.LongText({+ displayName: 'Question',+ description:+ 'Question or instructions for the LLM about the page, e.g. "What is the price of the Pro plan?".',+ required: true,+ }),+ ...webscrapingAiAiProps.scrapePage(),+ },+ async run({ auth, propsValue }) {+ return await webscrapingAiApi.answerQuestion({ auth, ...propsValue });+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/extract-fields.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/extract-fields.tsnew file mode 100644index 00000000000..6258d986104--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/extract-fields.ts@@ -0,0 +1,33 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { webscrapingAiAuth } from '../../auth';+import { webscrapingAiAiProps } from '../../common/ai-props';+import { webscrapingAiApi } from '../../common/api';+import { extractedFieldsOutputSchema } from '../../output-schemas';++export const extractFieldsAction = createAction({+ auth: webscrapingAiAuth,+ name: 'webscraping_ai_extract_fields',+ outputSchema: extractedFieldsOutputSchema,+ displayName: 'Extract Fields From a Page',+ description: 'Extracts named fields from a web page using an LLM.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Fetches a web page and has an LLM extract the requested fields, returned in result keyed by field name (null when the page lacks one). Use it for several structured values in one call; use Ask a Question for a single free-text answer. Read-only on the target site.',+ idempotent: true,+ },+ props: {+ fields: Property.Object({+ displayName: 'Fields',+ description:+ 'Fields to extract, as field name → what to extract, e.g. {"title": "Product title", "price": "Product price"}.',+ required: true,+ }),+ ...webscrapingAiAiProps.scrapePage(),+ },+ async run({ auth, propsValue }) {+ return await webscrapingAiApi.extractFields({ auth, ...propsValue });+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-account.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-account.tsnew file mode 100644index 00000000000..dd14e4454bd--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-account.ts@@ -0,0 +1,24 @@+import { createAction } from '@activepieces/pieces-framework';++import { webscrapingAiAuth } from '../../auth';+import { webscrapingAiApi } from '../../common/api';+import { accountOutputSchema } from '../../output-schemas';++export const getAccountAction = createAction({+ auth: webscrapingAiAuth,+ name: 'webscraping_ai_get_account',+ outputSchema: accountOutputSchema,+ displayName: 'Get Account Info',+ description: 'Returns the account email, remaining credits and concurrency.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Returns the account email, remaining monthly, pay-as-you-go and total credits, when the quota resets, and the free concurrency slots. Use it to check quota before a batch of scraping calls. Takes no inputs.',+ idempotent: true,+ },+ props: {},+ async run({ auth }) {+ return await webscrapingAiApi.getAccountInfo({ auth });+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-html.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-html.tsnew file mode 100644index 00000000000..ad80c8e637d--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-html.ts@@ -0,0 +1,28 @@+import { createAction } from '@activepieces/pieces-framework';++import { webscrapingAiAuth } from '../../auth';+import { webscrapingAiAiProps } from '../../common/ai-props';+import { webscrapingAiApi } from '../../common/api';+import { pageHtmlOutputSchema } from '../../output-schemas';++export const getHtmlAction = createAction({+ auth: webscrapingAiAuth,+ name: 'webscraping_ai_get_html',+ outputSchema: pageHtmlOutputSchema,+ displayName: 'Get Page HTML',+ description: 'Returns the rendered HTML of a web page.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ "Fetches a web page through a headless browser and returns its rendered HTML in result. Use it when you need the raw markup; prefer Get Page Text for readable content, or Get Selected HTML for one element. Optional JavaScript Code runs on the page first, and Return Script Result returns that script's value instead of the HTML. Read-only on the target site.",+ idempotent: true,+ },+ props: {+ ...webscrapingAiAiProps.scrapePage(),+ ...webscrapingAiAiProps.pageScript(),+ },+ async run({ auth, propsValue }) {+ return await webscrapingAiApi.scrapeHtml({ auth, ...propsValue });+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-selected-html.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-selected-html.tsnew file mode 100644index 00000000000..cd8654bf4d6--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-selected-html.ts@@ -0,0 +1,28 @@+import { createAction } from '@activepieces/pieces-framework';++import { webscrapingAiAuth } from '../../auth';+import { webscrapingAiAiProps } from '../../common/ai-props';+import { webscrapingAiApi } from '../../common/api';+import { pageHtmlOutputSchema } from '../../output-schemas';++export const getSelectedHtmlAction = createAction({+ auth: webscrapingAiAuth,+ name: 'webscraping_ai_get_selected_html',+ outputSchema: pageHtmlOutputSchema,+ displayName: 'Get Selected HTML',+ description: 'Returns the HTML of the first element matching a CSS selector on a web page.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Fetches a web page and returns, in result, the HTML of the element matching one CSS selector. Use it to grab one part of a page (a price, a table, an article body) without the full HTML; use Get Multiple Selected HTML for several selectors in one call. Read-only on the target site.',+ idempotent: true,+ },+ props: {+ selector: webscrapingAiAiProps.selector(),+ ...webscrapingAiAiProps.scrapePage(),+ },+ async run({ auth, propsValue }) {+ return await webscrapingAiApi.scrapeSelected({ auth, ...propsValue });+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-selected-multiple.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-selected-multiple.tsnew file mode 100644index 00000000000..a8eea82504b--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-selected-multiple.ts@@ -0,0 +1,33 @@+import { createAction } from '@activepieces/pieces-framework';++import { webscrapingAiAuth } from '../../auth';+import { webscrapingAiAiProps } from '../../common/ai-props';+import { webscrapingAiApi } from '../../common/api';+import { selectedMultipleOutputSchema } from '../../output-schemas';++export const getSelectedMultipleAction = createAction({+ auth: webscrapingAiAuth,+ name: 'webscraping_ai_get_selected_multiple',+ outputSchema: selectedMultipleOutputSchema,+ displayName: 'Get Multiple Selected HTML',+ description:+ 'Returns the HTML of every element matching each of several CSS selectors on a web page.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Fetches a web page once and returns results with the inner HTML of every element matching any of the selectors. The API currently returns all matches in one combined list rather than one list per selector, so do not rely on the position of a list to know which selector matched. Use it instead of several Get Selected HTML calls. Read-only on the target site.',+ idempotent: true,+ },+ props: {+ selectors: webscrapingAiAiProps.selectors(),+ ...webscrapingAiAiProps.scrapePage(),+ },+ async run({ auth, propsValue }) {+ const { selectors, ...page } = propsValue;+ if (!selectors.every((item): item is string => typeof item === 'string' && item !== '')) {+ throw new Error('Selectors must be a list of non-empty CSS selector strings.');+ }+ return await webscrapingAiApi.scrapeSelectedMultiple({ auth, ...page, selectors });+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-structured-data.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-structured-data.tsnew file mode 100644index 00000000000..19506d8fac8--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-structured-data.ts@@ -0,0 +1,50 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { webscrapingAiAuth } from '../../auth';+import { webscrapingAiApi } from '../../common/api';+import { siteDataOutputSchema } from '../../output-schemas';++export const getStructuredDataAction = createAction({+ auth: webscrapingAiAuth,+ name: 'webscraping_ai_get_structured_data',+ outputSchema: siteDataOutputSchema,+ displayName: 'Get Structured Data for a Page',+ description:+ 'Returns parsed structured data for a page on a supported site such as YouTube, Instagram, LinkedIn or Reddit.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Returns parsed structured data (title, author, counts, comments and similar) for a page on a supported site such as a YouTube video, an Instagram post or profile, a LinkedIn profile, company or job, or a Reddit post. Check parse_status: an unsupported or missing page still returns 200. Reddit pages cost 50 credits. Read-only on the target site.',+ idempotent: true,+ },+ props: {+ url: Property.ShortText({+ displayName: 'URL',+ description:+ 'URL of a page on a supported site, e.g. "https://www.youtube.com/watch?v=dQw4w9WgXcQ".',+ required: true,+ }),+ country: Property.ShortText({+ displayName: 'Proxy Country',+ description:+ 'Two-letter country code of the proxy used to fetch the page, one of the proxy countries (us, gb, de, it, fr, ca, es, ru, jp, kr, in, hk, tr). Defaults to "us".',+ required: false,+ }),+ transcript: Property.Checkbox({+ displayName: 'Include Transcript',+ description:+ 'YouTube videos only. Also fetch the video transcript into data.transcript. Defaults to false.',+ required: false,+ }),+ transcriptLanguage: Property.ShortText({+ displayName: 'Transcript Language',+ description:+ 'YouTube videos only, with Include Transcript. Caption language, e.g. "en" or "de".',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ return await webscrapingAiApi.getSiteData({ auth, ...propsValue });+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-text.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-text.tsnew file mode 100644index 00000000000..02b1a3714ce--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/get-text.ts@@ -0,0 +1,29 @@+import { createAction } from '@activepieces/pieces-framework';++import { webscrapingAiAuth } from '../../auth';+import { webscrapingAiAiProps } from '../../common/ai-props';+import { webscrapingAiApi } from '../../common/api';+import { pageTextOutputSchema } from '../../output-schemas';++export const getTextAction = createAction({+ auth: webscrapingAiAuth,+ name: 'webscraping_ai_get_text',+ outputSchema: pageTextOutputSchema,+ displayName: 'Get Page Text',+ description:+ 'Returns the visible text of a web page as Markdown, with its title and description.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ "Fetches a web page and returns its visible text as Markdown in content, plus title, description and, with Return Links, the page's links. Use it to read or summarize a page; prefer Ask a Question or Extract Fields when you want an LLM to pull specific facts. Read-only on the target site.",+ idempotent: true,+ },+ props: {+ ...webscrapingAiAiProps.scrapePage(),+ returnLinks: webscrapingAiAiProps.returnLinks(),+ },+ async run({ auth, propsValue }) {+ return await webscrapingAiApi.scrapeText({ auth, ...propsValue });+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/index.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/index.tsnew file mode 100644index 00000000000..0c48eb73b51--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/index.ts@@ -0,0 +1,29 @@+import { askQuestionAction } from './ask-question';+import { extractFieldsAction } from './extract-fields';+import { getAccountAction } from './get-account';+import { getHtmlAction } from './get-html';+import { getSelectedHtmlAction } from './get-selected-html';+import { getSelectedMultipleAction } from './get-selected-multiple';+import { getStructuredDataAction } from './get-structured-data';+import { getTextAction } from './get-text';+import { postHtmlAction } from './post-html';+import { postSelectedHtmlAction } from './post-selected-html';+import { postSelectedMultipleAction } from './post-selected-multiple';+import { postTextAction } from './post-text';+import { searchGoogleAction } from './search-google';++export const webscrapingAiAiActions = [+ getHtmlAction,+ postHtmlAction,+ getTextAction,+ postTextAction,+ getSelectedHtmlAction,+ postSelectedHtmlAction,+ getSelectedMultipleAction,+ postSelectedMultipleAction,+ askQuestionAction,+ extractFieldsAction,+ searchGoogleAction,+ getStructuredDataAction,+ getAccountAction,+];diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/post-html.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/post-html.tsnew file mode 100644index 00000000000..4580f83ddcb--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/post-html.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';++import { webscrapingAiAuth } from '../../auth';+import { webscrapingAiAiProps } from '../../common/ai-props';+import { webscrapingAiApi } from '../../common/api';+import { pageHtmlOutputSchema } from '../../output-schemas';++export const postHtmlAction = createAction({+ auth: webscrapingAiAuth,+ name: 'webscraping_ai_post_html',+ outputSchema: pageHtmlOutputSchema,+ displayName: 'POST to Page and Get HTML',+ description: 'Sends a POST request to a web page and returns the rendered HTML response.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Sends Request Body to the target URL as a POST (form submission, login, POST API) and returns the rendered HTML response in result. Use Get Page HTML for a plain GET. Optional JavaScript Code runs on the response page. The body is sent to the target site as a POST, so it can change state there (log in, submit a form); not idempotent.',+ idempotent: false,+ },+ props: {+ ...webscrapingAiAiProps.scrapePage(),+ ...webscrapingAiAiProps.pageScript(),+ ...webscrapingAiAiProps.postRequest(),+ },+ async run({ auth, propsValue }) {+ const { body, contentType, ...page } = propsValue;+ return await webscrapingAiApi.scrapeHtml({ auth, ...page, post: { body, contentType } });+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/post-selected-html.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/post-selected-html.tsnew file mode 100644index 00000000000..13e3ebdff98--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/post-selected-html.ts@@ -0,0 +1,31 @@+import { createAction } from '@activepieces/pieces-framework';++import { webscrapingAiAuth } from '../../auth';+import { webscrapingAiAiProps } from '../../common/ai-props';+import { webscrapingAiApi } from '../../common/api';+import { pageHtmlOutputSchema } from '../../output-schemas';++export const postSelectedHtmlAction = createAction({+ auth: webscrapingAiAuth,+ name: 'webscraping_ai_post_selected_html',+ outputSchema: pageHtmlOutputSchema,+ displayName: 'POST to Page and Get Selected HTML',+ description:+ 'Sends a POST request to a web page and returns the HTML of the element matching a CSS selector in the response.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Sends Request Body to the target URL as a POST and returns, in result, the HTML of the element matching one CSS selector in the response page. Use Get Selected HTML for a plain GET. The body is sent to the target site as a POST, so it can change state there (log in, submit a form); not idempotent.',+ idempotent: false,+ },+ props: {+ selector: webscrapingAiAiProps.selector(),+ ...webscrapingAiAiProps.scrapePage(),+ ...webscrapingAiAiProps.postRequest(),+ },+ async run({ auth, propsValue }) {+ const { body, contentType, ...page } = propsValue;+ return await webscrapingAiApi.scrapeSelected({ auth, ...page, post: { body, contentType } });+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/post-selected-multiple.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/post-selected-multiple.tsnew file mode 100644index 00000000000..f927008fb97--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/post-selected-multiple.ts@@ -0,0 +1,39 @@+import { createAction } from '@activepieces/pieces-framework';++import { webscrapingAiAuth } from '../../auth';+import { webscrapingAiAiProps } from '../../common/ai-props';+import { webscrapingAiApi } from '../../common/api';+import { selectedMultipleOutputSchema } from '../../output-schemas';++export const postSelectedMultipleAction = createAction({+ auth: webscrapingAiAuth,+ name: 'webscraping_ai_post_selected_multiple',+ outputSchema: selectedMultipleOutputSchema,+ displayName: 'POST to Page and Get Multiple Selected HTML',+ description:+ 'Sends a POST request to a web page and returns the HTML of every element matching each of several CSS selectors in the response.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Sends Request Body to the target URL as a POST and returns results with the inner HTML of every element in the response page matching any of the selectors. The API currently returns all matches in one combined list rather than one list per selector. Use Get Multiple Selected HTML for a plain GET. The body is sent to the target site as a POST, so it can change state there (log in, submit a form); not idempotent.',+ idempotent: false,+ },+ props: {+ selectors: webscrapingAiAiProps.selectors(),+ ...webscrapingAiAiProps.scrapePage(),+ ...webscrapingAiAiProps.postRequest(),+ },+ async run({ auth, propsValue }) {+ const { selectors, body, contentType, ...page } = propsValue;+ if (!selectors.every((item): item is string => typeof item === 'string' && item !== '')) {+ throw new Error('Selectors must be a list of non-empty CSS selector strings.');+ }+ return await webscrapingAiApi.scrapeSelectedMultiple({+ auth,+ ...page,+ selectors,+ post: { body, contentType },+ });+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/post-text.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/post-text.tsnew file mode 100644index 00000000000..e04c33a03ee--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/post-text.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';++import { webscrapingAiAuth } from '../../auth';+import { webscrapingAiAiProps } from '../../common/ai-props';+import { webscrapingAiApi } from '../../common/api';+import { pageTextOutputSchema } from '../../output-schemas';++export const postTextAction = createAction({+ auth: webscrapingAiAuth,+ name: 'webscraping_ai_post_text',+ outputSchema: pageTextOutputSchema,+ displayName: 'POST to Page and Get Text',+ description: 'Sends a POST request to a web page and returns the response text as Markdown.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ "Sends Request Body to the target URL as a POST and returns the response page's visible text as Markdown in content, plus title, description and optional links. Use Get Page Text for a plain GET. The body is sent to the target site as a POST, so it can change state there (log in, submit a form); not idempotent.",+ idempotent: false,+ },+ props: {+ ...webscrapingAiAiProps.scrapePage(),+ returnLinks: webscrapingAiAiProps.returnLinks(),+ ...webscrapingAiAiProps.postRequest(),+ },+ async run({ auth, propsValue }) {+ const { body, contentType, ...page } = propsValue;+ return await webscrapingAiApi.scrapeText({ auth, ...page, post: { body, contentType } });+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ai/search-google.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/search-google.tsnew file mode 100644index 00000000000..fd4b91973c5--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ai/search-google.ts@@ -0,0 +1,47 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { webscrapingAiAuth } from '../../auth';+import { webscrapingAiApi } from '../../common/api';+import { googleSearchOutputSchema } from '../../output-schemas';++export const searchGoogleAction = createAction({+ auth: webscrapingAiAuth,+ name: 'webscraping_ai_search_google',+ outputSchema: googleSearchOutputSchema,+ displayName: 'Search Google',+ description: 'Returns parsed Google search results for a query.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Runs a Google search and returns parsed organic results, related searches and pagination, 10 results per page. Use it to find pages, then pass a result link to Get Page Text or Ask a Question. Costs 15 credits per search.',+ idempotent: true,+ },+ props: {+ query: Property.ShortText({+ displayName: 'Query',+ description: 'Search query, e.g. "coffee machines".',+ required: true,+ }),+ countryCode: Property.ShortText({+ displayName: 'Country Code',+ description:+ 'Two-letter country code for the search location (Google gl), e.g. "us". Defaults to "us".',+ required: false,+ }),+ languageCode: Property.ShortText({+ displayName: 'Language Code',+ description:+ 'Two-letter language code for the results (Google hl), e.g. "en". Defaults to "en".',+ required: false,+ }),+ page: Property.Number({+ displayName: 'Page',+ description: 'Results page number, a whole number from 1 to 100. Defaults to 1.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ return await webscrapingAiApi.searchGoogle({ auth, ...propsValue });+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/ask-a-question-about-the-web-page.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/ask-a-question-about-the-web-page.tsindex 9243262eacd..05529f76515 100644--- a/packages/pieces/community/webscraping-ai/src/lib/actions/ask-a-question-about-the-web-page.ts+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/ask-a-question-about-the-web-page.ts@@ -1,41 +1,33 @@-import { createAction } from '@activepieces/pieces-framework';-import { webscrapingAiAuth, webscrapingAiCommon } from '../common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { webscrapingAiAuth } from '../auth';+import { webscrapingAiApi } from '../common/api';+import { webscrapingAiProps } from '../common/props';+import { humanResponseOutputSchema } from '../output-schemas';-export const askAQuestionAboutTheWebPage = createAction({+export const askAQuestionAboutTheWebPageAction = createAction({auth: webscrapingAiAuth,name: 'askAQuestionAboutTheWebPage',+ outputSchema: humanResponseOutputSchema,classification: 'READ',displayName: 'Ask a Question About the Web Page',description: 'Gets an answer to a question about a given webpage.',- audience: 'both',+ audience: 'human',aiMetadata: {description:'Fetches a web page (rendering JavaScript), then uses an LLM to answer a natural-language question about its content. Choose this to extract a specific fact or summary from a single URL without parsing HTML yourself, when you have a concrete question rather than needing the full page text or a structured record. Requires the target URL and the question; optional proxy/country/device/header controls tune how the page is fetched. Read-only and idempotent (a GET-style request that does not alter the target site).',idempotent: true,},- props: webscrapingAiCommon.askQuestionProperties,- async run({ auth: apiKey, propsValue }) {- const { device, format, question, ...rest } = propsValue;-- const allowedCountries = [- 'us', 'gb', 'de', 'it', 'fr', 'ca', 'es', 'ru', 'jp', 'kr', 'in'- ];-- const params: any = {- apiKey:apiKey.secret_text,- question,- ...rest,- format: (format === 'json' || format === 'text') ? format : undefined,- proxy: (rest.proxy === 'datacenter' || rest.proxy === 'residential') ? rest.proxy : undefined,- country: (rest.country && allowedCountries.includes(rest.country))- ? rest.country as typeof allowedCountries[number]- : undefined,- headers: rest.headers && Array.isArray(rest.headers)- ? Object.fromEntries(rest.headers.map((h: any) => [(h as any).name, (h as any).value]))- : undefined,- device: device as 'desktop' | 'mobile' | 'tablet' | undefined,- };-- return await webscrapingAiCommon.askQuestion(params);+ props: {+ question: Property.ShortText({+ displayName: 'Question',+ description: 'Question or instructions to ask the LLM model about the target page.',+ required: true,+ }),+ ...webscrapingAiProps.pageRequest(),+ ...webscrapingAiProps.pageOptions(),+ format: webscrapingAiProps.format(),+ },+ async run({ auth, propsValue }) {+ return await webscrapingAiApi.askQuestion({ auth, ...propsValue });},});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/extract-structured-data.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/extract-structured-data.tsindex d5083537881..4cd35279cec 100644--- a/packages/pieces/community/webscraping-ai/src/lib/actions/extract-structured-data.ts+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/extract-structured-data.ts@@ -1,43 +1,32 @@-import { createAction } from '@activepieces/pieces-framework';-import { webscrapingAiAuth, webscrapingAiCommon } from '../common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { webscrapingAiAuth } from '../auth';+import { webscrapingAiApi } from '../common/api';+import { webscrapingAiProps } from '../common/props';+import { humanExtractedFieldsOutputSchema } from '../output-schemas';-export const extractStructuredData = createAction({+export const extractStructuredDataAction = createAction({auth: webscrapingAiAuth,name: 'extractStructuredData',+ outputSchema: humanExtractedFieldsOutputSchema,classification: 'READ',displayName: 'Extract structured data',- description:- 'Returns structured data fields extracted from the webpage using an LLM model.',- audience: 'both',+ description: 'Returns structured data fields extracted from the webpage using an LLM model.',+ audience: 'human',aiMetadata: {description:'Fetches a web page (rendering JavaScript) and uses an LLM to extract a set of caller-defined fields from it, where each field is given as a name plus a natural-language description of what to pull. Choose this when you need specific structured values (e.g. price, title, author) rather than a free-text answer or the raw page. Requires the target URL and the fields map; optional proxy/country/device/header controls tune the fetch. Read-only and idempotent (a GET-style request that does not alter the target site).',idempotent: true,},- props: webscrapingAiCommon.getPageStructuredDataProperties,- async run({ auth: apiKey, propsValue }) {- const { fields, headers, ...rest } = propsValue;-- const allowedCountries = [- 'us', 'gb', 'de', 'it', 'fr', 'ca', 'es', 'ru', 'jp', 'kr', 'in'- ];-- const params: any = {- apiKey:apiKey.secret_text,- ...rest,- proxy: (rest.proxy === 'datacenter' || rest.proxy === 'residential') ? rest.proxy : undefined,- country: (rest.country && allowedCountries.includes(rest.country))- ? rest.country as typeof allowedCountries[number]- : undefined,- headers: headers && Array.isArray(headers)- ? Object.fromEntries(headers.map((h: any) => [(h as any).name, (h as any).value]))- : undefined,- fields: fields && typeof fields === 'object'- ? Object.fromEntries(Object.entries(fields).map(([k, v]) => [k, String(v)]))- : {},- device: rest.device as 'desktop' | 'mobile' | 'tablet' | undefined,- };-- return await webscrapingAiCommon.getPageStructuredData(params);+ props: {+ fields: Property.Object({+ displayName: 'Fields to Extract',+ description: 'Define fields to extract (e.g., {"title": "Product title", "price": "Product price"})',+ required: true,+ }),+ ...webscrapingAiProps.pageRequest(),+ ...webscrapingAiProps.pageOptions(),+ },+ async run({ auth, propsValue }) {+ return await webscrapingAiApi.getStructuredData({ auth, ...propsValue });},});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/get-account-information.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/get-account-information.tsindex 183e6acda73..fc6f76a98ac 100644--- a/packages/pieces/community/webscraping-ai/src/lib/actions/get-account-information.ts+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/get-account-information.ts@@ -1,20 +1,23 @@import { createAction } from '@activepieces/pieces-framework';-import { webscrapingAiAuth, webscrapingAiCommon } from '../common';+import { webscrapingAiAuth } from '../auth';+import { webscrapingAiApi } from '../common/api';+import { humanAccountOutputSchema } from '../output-schemas';-export const getAccountInformation = createAction({+export const getAccountInformationAction = createAction({auth: webscrapingAiAuth,name: 'getAccountInformation',+ outputSchema: humanAccountOutputSchema,classification: 'READ',displayName: 'Get Account Info',description: 'Get account usage information including remaining API credits and concurrent requests.',- audience: 'both',+ audience: 'human',aiMetadata: {description:'Looks up the WebScraping AI account status, including remaining API credits and concurrent-request limits. Choose this to check quota or capacity before running a batch of scraping calls, or to surface usage to the caller. Takes no inputs beyond the connection. Read-only and idempotent (a GET-style lookup).',idempotent: true,},props: {},- async run({ auth: apiKey }) {- return await webscrapingAiCommon.getAccountInformation({ apiKey:apiKey.secret_text });+ async run({ auth }) {+ return await webscrapingAiApi.getAccount({ auth });},});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/get-page-html.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/get-page-html.tsindex afabedee252..cd1a9ee5c62 100644--- a/packages/pieces/community/webscraping-ai/src/lib/actions/get-page-html.ts+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/get-page-html.ts@@ -1,43 +1,35 @@-import { createAction } from '@activepieces/pieces-framework';-import { webscrapingAiAuth, webscrapingAiCommon } from '../common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { webscrapingAiAuth } from '../auth';+import { webscrapingAiApi } from '../common/api';+import { webscrapingAiProps } from '../common/props';+import { humanResponseOutputSchema } from '../output-schemas';-export const getPageHtml = createAction({+export const getPageHtmlAction = createAction({auth: webscrapingAiAuth,name: 'getPageHtml',+ outputSchema: humanResponseOutputSchema,classification: 'READ',displayName: 'Get Page HTML',description: 'Retrieves the raw HTML markup of a web page.',- audience: 'both',+ audience: 'human',aiMetadata: {description:'Fetches a web page (rendering JavaScript) and returns its raw HTML markup. Choose this when you need the full document to parse yourself or feed into other tools, rather than an LLM-derived answer or extracted text. Requires the target URL; optional proxy/country/device/header controls tune the fetch, and flags can error on 404 or redirect or return JS execution results. Read-only and idempotent (a GET-style request that does not alter the target site).',idempotent: true,},- props: webscrapingAiCommon.getPageHtmlProperties,- async run({ auth: apiKey, propsValue }) {- const { format, headers, proxy, device, errorOn404, errorOnRedirect, returnScriptResult, ...rest } = propsValue;-- const allowedCountries = [- 'us', 'gb', 'de', 'it', 'fr', 'ca', 'es', 'ru', 'jp', 'kr', 'in'- ];-- const params: any = {- apiKey:apiKey.secret_text,- ...rest,- format: (format === 'json' || format === 'text') ? format : undefined,- proxy: (proxy === 'datacenter' || proxy === 'residential') ? proxy : undefined,- country: (rest.country && allowedCountries.includes(rest.country))- ? rest.country as typeof allowedCountries[number]- : undefined,- headers: headers && Array.isArray(headers)- ? Object.fromEntries(headers.map((h: any) => [(h as any).name, (h as any).value]))- : undefined,- device: device as 'desktop' | 'mobile' | 'tablet' | undefined,- errorOn404,- errorOnRedirect,- returnScriptResult,- };-- return await webscrapingAiCommon.getPageHtml(params);+ props: {+ ...webscrapingAiProps.pageRequest(),+ returnScriptResult: Property.Checkbox({+ displayName: 'Return JavaScript Result',+ description:+ 'Return result of the custom JavaScript code (js_script parameter) \+ execution on the target page (false by default, page HTML will be returned).',+ required: false,+ }),+ ...webscrapingAiProps.pageOptions(),+ format: webscrapingAiProps.format(),+ },+ async run({ auth, propsValue }) {+ return await webscrapingAiApi.getPageHtml({ auth, ...propsValue });},});diff --git a/packages/pieces/community/webscraping-ai/src/lib/actions/scrape-website-text.ts b/packages/pieces/community/webscraping-ai/src/lib/actions/scrape-website-text.tsindex a46dd751e3c..bbd5fee1854 100644--- a/packages/pieces/community/webscraping-ai/src/lib/actions/scrape-website-text.ts+++ b/packages/pieces/community/webscraping-ai/src/lib/actions/scrape-website-text.ts@@ -1,44 +1,45 @@-import { createAction } from '@activepieces/pieces-framework';-import { webscrapingAiAuth, webscrapingAiCommon } from '../common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { webscrapingAiAuth } from '../auth';+import { webscrapingAiApi } from '../common/api';+import { webscrapingAiProps } from '../common/props';+import { humanPageTextOutputSchema } from '../output-schemas';-export const scrapeWebsiteText = createAction({+export const scrapeWebsiteTextAction = createAction({auth: webscrapingAiAuth,name: 'scrapeWebsiteText',+ outputSchema: humanPageTextOutputSchema,classification: 'READ',displayName: 'Scrape Website Text',- description:- 'Returns the visible text content of a webpage specified by the URL.',- audience: 'both',+ description: 'Returns the visible text content of a webpage specified by the URL.',+ audience: 'human',aiMetadata: {description:'Fetches a web page (rendering JavaScript) and returns its visible text with HTML stripped out, in plain, JSON, or XML form. Choose this when you want clean readable content for summarizing or feeding to an LLM, rather than the raw HTML or a single extracted answer. Requires the target URL; optional proxy/country/device/header controls tune the fetch, and JSON output can additionally return extracted links. Read-only and idempotent (a GET-style request that does not alter the target site).',idempotent: true,},- props: webscrapingAiCommon.getPageTextProperties,- async run({ auth: apiKey, propsValue }) {- const { textFormat, headers, returnLinks, ...rest } = propsValue;-- const allowedCountries = [- 'us', 'gb', 'de', 'it', 'fr', 'ca', 'es', 'ru', 'jp', 'kr', 'in'- ];-- const params: any = {- apiKey:apiKey.secret_text,- ...rest,- textFormat: (textFormat === 'json' || textFormat === 'plain' || textFormat === 'xml')- ? textFormat- : undefined,- returnLinks: (textFormat === 'json') ? returnLinks : undefined,- proxy: (rest.proxy === 'datacenter' || rest.proxy === 'residential') ? rest.proxy : undefined,- country: (rest.country && allowedCountries.includes(rest.country))- ? rest.country as typeof allowedCountries[number]- : undefined,- headers: headers && Array.isArray(headers)- ? Object.fromEntries(headers.map((h: any) => [(h as any).name, (h as any).value]))- : undefined,- device: rest.device as 'desktop' | 'mobile' | 'tablet' | undefined,- };-- return await webscrapingAiCommon.getPageText(params);+ props: {+ ...webscrapingAiProps.pageRequest(),+ textFormat: Property.StaticDropdown({+ displayName: 'Text Format',+ description: 'Response format: Plain text, JSON (with title/description/content), or XML',+ required: false,+ defaultValue: 'plain',+ options: {+ options: [+ { label: 'Plain Text', value: 'plain' },+ { label: 'JSON', value: 'json' },+ { label: 'XML', value: 'xml' },+ ],+ },+ }),+ returnLinks: Property.Checkbox({+ displayName: 'Return Links',+ description: 'Include links in response (only works with JSON format)',+ required: false,+ }),+ ...webscrapingAiProps.pageOptions(),+ },+ async run({ auth, propsValue }) {+ return await webscrapingAiApi.getPageText({ auth, ...propsValue });},});diff --git a/packages/pieces/community/webscraping-ai/src/lib/auth.ts b/packages/pieces/community/webscraping-ai/src/lib/auth.tsnew file mode 100644index 00000000000..699e2600ac8--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/auth.ts@@ -0,0 +1,16 @@+import { AppConnectionType, PieceAuth, tryCatch } from '@activepieces/pieces-framework';++import { webscrapingAiApi } from './common/api';++export const webscrapingAiAuth = PieceAuth.SecretText({+ displayName: 'API Key',+ required: true,+ validate: async ({ auth }) => {+ const { error } = await tryCatch(() =>+ webscrapingAiApi.getAccount({+ auth: { type: AppConnectionType.SECRET_TEXT, secret_text: auth },+ }),+ );+ return error ? { valid: false, error: 'Invalid API Key' } : { valid: true };+ },+});diff --git a/packages/pieces/community/webscraping-ai/src/lib/common/ai-props.ts b/packages/pieces/community/webscraping-ai/src/lib/common/ai-props.tsnew file mode 100644index 00000000000..fc99ca448fe--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/common/ai-props.ts@@ -0,0 +1,176 @@+import { Property } from '@activepieces/pieces-framework';++function scrapePage() {+ return {+ url: Property.ShortText({+ displayName: 'URL',+ description:+ 'Full URL of the target page, including the scheme, e.g. "https://example.com/pricing".',+ required: true,+ }),+ headers: Property.Object({+ displayName: 'Headers',+ description:+ 'HTTP headers to send to the target page, as header name → value, e.g. {"Cookie": "session=abc"}.',+ required: false,+ }),+ timeout: Property.Number({+ displayName: 'Timeout',+ description: 'Maximum page load time in milliseconds, 1-25000. Defaults to 10000.',+ required: false,+ }),+ js: Property.Checkbox({+ displayName: 'Render JavaScript',+ description:+ 'Render the page in a headless browser. Defaults to true; set false for static pages to save credits.',+ required: false,+ defaultValue: true,+ }),+ jsTimeout: Property.Number({+ displayName: 'JavaScript Timeout',+ description: 'Maximum JavaScript rendering time in milliseconds, 1-20000. Defaults to 2000.',+ required: false,+ }),+ waitFor: Property.ShortText({+ displayName: 'Wait For',+ description: 'CSS selector to wait for before returning, e.g. ".content-loaded".',+ required: false,+ }),+ proxy: Property.StaticDropdown({+ displayName: 'Proxy Type',+ description:+ 'Proxy tier. "datacenter" (default, cheapest), "residential" for sites blocking datacenter IPs, "stealth" for heavily protected sites (most expensive), "auto" tries each tier in turn. "auto" cannot be combined with Custom Proxy.',+ required: false,+ options: {+ options: [+ { label: 'Datacenter', value: 'datacenter' },+ { label: 'Residential', value: 'residential' },+ { label: 'Stealth', value: 'stealth' },+ { label: 'Auto', value: 'auto' },+ ],+ },+ }),+ country: Property.StaticDropdown({+ displayName: 'Proxy Country',+ description: 'Country of the proxy used to fetch the page. Defaults to "us".',+ required: false,+ options: {+ options: [+ { label: 'United States', value: 'us' },+ { label: 'United Kingdom', value: 'gb' },+ { label: 'Germany', value: 'de' },+ { label: 'Italy', value: 'it' },+ { label: 'France', value: 'fr' },+ { label: 'Canada', value: 'ca' },+ { label: 'Spain', value: 'es' },+ { label: 'Russia', value: 'ru' },+ { label: 'Japan', value: 'jp' },+ { label: 'South Korea', value: 'kr' },+ { label: 'India', value: 'in' },+ { label: 'Hong Kong', value: 'hk' },+ { label: 'Turkey', value: 'tr' },+ ],+ },+ }),+ customProxy: Property.ShortText({+ displayName: 'Custom Proxy',+ description:+ 'Your own proxy URL, e.g. "http://user:password@host:port". Overrides Proxy Type.',+ required: false,+ }),+ device: Property.StaticDropdown({+ displayName: 'Device',+ description: 'Device to emulate. Defaults to "desktop".',+ required: false,+ options: {+ options: [+ { label: 'Desktop', value: 'desktop' },+ { label: 'Mobile', value: 'mobile' },+ { label: 'Tablet', value: 'tablet' },+ ],+ },+ }),+ errorOn404: Property.Checkbox({+ displayName: 'Error on 404',+ description: 'Fail when the target page returns 404. Defaults to false.',+ required: false,+ }),+ errorOnRedirect: Property.Checkbox({+ displayName: 'Error on Redirect',+ description: 'Fail when the target page redirects. Defaults to false.',+ required: false,+ }),+ };+}++function pageScript() {+ return {+ jsScript: Property.LongText({+ displayName: 'JavaScript Code',+ description:+ 'JavaScript to run on the page after it loads, e.g. document.querySelector("button").click(). The result is the value of the last expression; a top-level "return" is a syntax error.',+ required: false,+ }),+ returnScriptResult: Property.Checkbox({+ displayName: 'Return Script Result',+ description: 'Return the JavaScript Code result instead of the page HTML. Defaults to false.',+ required: false,+ }),+ };+}++function postRequest() {+ return {+ body: Property.LongText({+ displayName: 'Request Body',+ description:+ 'Raw body forwarded to the target URL as a POST, e.g. {"username": "test"}. For a form-encoded body, use Content Type "text/plain" and set the header "Content-Type: application/x-www-form-urlencoded".',+ required: true,+ }),+ contentType: Property.StaticDropdown({+ displayName: 'Content Type',+ description: 'Content type of the Request Body as sent to the target.',+ required: true,+ defaultValue: 'application/json',+ options: {+ options: [+ { label: 'JSON', value: 'application/json' },+ { label: 'Plain Text', value: 'text/plain' },+ ],+ },+ }),+ };+}++function returnLinks() {+ return Property.Checkbox({+ displayName: 'Return Links',+ description: 'Also return the links found in the page body. Defaults to false.',+ required: false,+ });+}++function selector() {+ return Property.ShortText({+ displayName: 'Selector',+ description: 'CSS selector of the element to return, e.g. "h1", ".price", "#main".',+ required: true,+ });+}++function selectors() {+ return Property.Array({+ displayName: 'Selectors',+ description: 'CSS selectors, one per item, e.g. ["h1", ".price"].',+ required: true,+ });+}++export const webscrapingAiAiProps = {+ scrapePage,+ pageScript,+ postRequest,+ returnLinks,+ selector,+ selectors,+};diff --git a/packages/pieces/community/webscraping-ai/src/lib/common/api.ts b/packages/pieces/community/webscraping-ai/src/lib/common/api.tsnew file mode 100644index 00000000000..c4afe5d9c9d--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/common/api.ts@@ -0,0 +1,382 @@+import { HttpMethod, HttpResponse } from '@activepieces/pieces-common';++import { webscrapingAiClient } from './client';++import type {+ WebscrapingAiAccount,+ WebscrapingAiAuthValue,+ WebscrapingAiDataResult,+ WebscrapingAiFieldsResult,+ WebscrapingAiPageParams,+ WebscrapingAiPageText,+ WebscrapingAiPost,+ WebscrapingAiQueryValue,+ WebscrapingAiResult,+ WebscrapingAiScrapeParams,+ WebscrapingAiSerpResult,+} from './types';++function pageQuery({+ url,+ headers,+ timeout,+ js,+ jsTimeout,+ waitFor,+ proxy,+ country,+ customProxy,+ jsScript,+ device,+ errorOn404,+ errorOnRedirect,+}: WebscrapingAiPageParams): Record<string, WebscrapingAiQueryValue> {+ return {+ url,+ headers:+ headers && headers.length > 0+ ? JSON.stringify(+ Object.fromEntries(+ headers.flatMap((h) =>+ typeof h === 'object' && h !== null && 'name' in h && 'value' in h+ ? [[h.name, h.value]]+ : [],+ ),+ ),+ )+ : undefined,+ timeout,+ js,+ js_timeout: jsTimeout,+ wait_for: waitFor,+ proxy: proxy && PROXIES.includes(proxy) ? proxy : undefined,+ country: country && COUNTRIES.includes(country) ? country : undefined,+ custom_proxy: customProxy,+ device,+ error_on_404: errorOn404,+ error_on_redirect: errorOnRedirect,+ js_script: jsScript,+ };+}++function responseFormat({ format }: { format?: string }): string | undefined {+ return format === 'json' || format === 'text' ? format : undefined;+}++async function askQuestion({+ auth,+ question,+ format,+ ...page+}: WebscrapingAiPageParams & {+ auth: WebscrapingAiAuthValue;+ question: string;+ format?: string;+}): Promise<HttpResponse<unknown>> {+ return await webscrapingAiClient.request<unknown>({+ auth,+ path: '/ai/question',+ query: { ...pageQuery(page), question, format: responseFormat({ format }) },+ });+}++async function getPageHtml({+ auth,+ returnScriptResult,+ format,+ ...page+}: WebscrapingAiPageParams & {+ auth: WebscrapingAiAuthValue;+ returnScriptResult?: boolean;+ format?: string;+}): Promise<HttpResponse<unknown>> {+ return await webscrapingAiClient.request<unknown>({+ auth,+ path: '/html',+ query: {+ ...pageQuery(page),+ return_script_result: returnScriptResult,+ format: responseFormat({ format }),+ },+ });+}++async function getPageText({+ auth,+ textFormat,+ returnLinks,+ ...page+}: WebscrapingAiPageParams & {+ auth: WebscrapingAiAuthValue;+ textFormat?: string;+ returnLinks?: boolean;+}): Promise<HttpResponse<unknown>> {+ return await webscrapingAiClient.request<unknown>({+ auth,+ path: '/text',+ query: {+ ...pageQuery(page),+ text_format: textFormat && TEXT_FORMATS.includes(textFormat) ? textFormat : undefined,+ return_links: textFormat === 'json' ? returnLinks : undefined,+ },+ });+}++async function getStructuredData({+ auth,+ fields,+ ...page+}: WebscrapingAiPageParams & {+ auth: WebscrapingAiAuthValue;+ fields?: Record<string, unknown>;+}): Promise<HttpResponse<unknown>> {+ return await webscrapingAiClient.request<unknown>({+ auth,+ path: '/ai/fields',+ query: {+ ...pageQuery(page),+ ...Object.fromEntries(+ Object.entries(fields ?? {}).map(([key, value]) => [`fields[${key}]`, String(value)]),+ ),+ },+ });+}++async function getAccount({+ auth,+}: {+ auth: WebscrapingAiAuthValue;+}): Promise<HttpResponse<unknown>> {+ return await webscrapingAiClient.request<unknown>({ auth, path: '/account' });+}++function scrapeQuery({+ url,+ headers,+ timeout,+ js,+ jsTimeout,+ waitFor,+ proxy,+ country,+ customProxy,+ device,+ errorOn404,+ errorOnRedirect,+}: WebscrapingAiScrapeParams): Record<string, WebscrapingAiQueryValue> {+ return {+ url,+ headers: headers === undefined ? undefined : JSON.stringify(headers),+ timeout,+ js,+ js_timeout: jsTimeout,+ wait_for: waitFor,+ proxy,+ country,+ custom_proxy: customProxy,+ device,+ error_on_404: errorOn404,+ error_on_redirect: errorOnRedirect,+ };+}++function postOptions({ post }: { post?: WebscrapingAiPost }) {+ return post+ ? { method: HttpMethod.POST, body: post.body, contentType: post.contentType }+ : { method: HttpMethod.GET };+}++async function scrapeHtml({+ auth,+ post,+ jsScript,+ returnScriptResult,+ ...page+}: WebscrapingAiScrapeParams & {+ auth: WebscrapingAiAuthValue;+ post?: WebscrapingAiPost;+ jsScript?: string;+ returnScriptResult?: boolean;+}): Promise<WebscrapingAiResult> {+ const response = await webscrapingAiClient.request<WebscrapingAiResult>({+ auth,+ ...postOptions({ post }),+ path: '/html',+ query: {+ ...scrapeQuery(page),+ js_script: jsScript,+ return_script_result: returnScriptResult,+ format: 'json',+ },+ });+ return response.body;+}++async function scrapeText({+ auth,+ post,+ returnLinks,+ ...page+}: WebscrapingAiScrapeParams & {+ auth: WebscrapingAiAuthValue;+ post?: WebscrapingAiPost;+ returnLinks?: boolean;+}): Promise<WebscrapingAiPageText> {+ const response = await webscrapingAiClient.request<WebscrapingAiPageText>({+ auth,+ ...postOptions({ post }),+ path: '/text',+ query: { ...scrapeQuery(page), text_format: 'json', return_links: returnLinks },+ });+ return response.body;+}++async function scrapeSelected({+ auth,+ post,+ selector,+ ...page+}: WebscrapingAiScrapeParams & {+ auth: WebscrapingAiAuthValue;+ post?: WebscrapingAiPost;+ selector: string;+}): Promise<WebscrapingAiResult> {+ const response = await webscrapingAiClient.request<WebscrapingAiResult>({+ auth,+ ...postOptions({ post }),+ path: '/selected',+ query: { ...scrapeQuery(page), selector, format: 'json' },+ });+ return response.body;+}++async function scrapeSelectedMultiple({+ auth,+ post,+ selectors,+ ...page+}: WebscrapingAiScrapeParams & {+ auth: WebscrapingAiAuthValue;+ post?: WebscrapingAiPost;+ selectors: string[];+}): Promise<{ results: string[][]; count: number }> {+ const response = await webscrapingAiClient.request<string[][]>({+ auth,+ ...postOptions({ post }),+ path: '/selected-multiple',+ query: { ...scrapeQuery(page), selectors },+ });+ return { results: response.body, count: response.body.length };+}++async function answerQuestion({+ auth,+ question,+ ...page+}: WebscrapingAiScrapeParams & {+ auth: WebscrapingAiAuthValue;+ question: string;+}): Promise<WebscrapingAiResult> {+ const response = await webscrapingAiClient.request<WebscrapingAiResult>({+ auth,+ path: '/ai/question',+ query: { ...scrapeQuery(page), question, format: 'json' },+ });+ return response.body;+}++async function extractFields({+ auth,+ fields,+ ...page+}: WebscrapingAiScrapeParams & {+ auth: WebscrapingAiAuthValue;+ fields: Record<string, unknown>;+}): Promise<WebscrapingAiFieldsResult> {+ const response = await webscrapingAiClient.request<WebscrapingAiFieldsResult>({+ auth,+ path: '/ai/fields',+ query: {+ ...scrapeQuery(page),+ ...Object.fromEntries(+ Object.entries(fields).map(([key, value]) => [`fields[${key}]`, String(value)]),+ ),+ },+ });+ return response.body;+}++async function searchGoogle({+ auth,+ query,+ countryCode,+ languageCode,+ page,+}: {+ auth: WebscrapingAiAuthValue;+ query: string;+ countryCode?: string;+ languageCode?: string;+ page?: number;+}): Promise<WebscrapingAiSerpResult> {+ const response = await webscrapingAiClient.request<WebscrapingAiSerpResult>({+ auth,+ path: '/serp',+ query: { q: query, engine: 'google', gl: countryCode, hl: languageCode, page },+ });+ return response.body;+}++async function getSiteData({+ auth,+ url,+ country,+ transcript,+ transcriptLanguage,+}: {+ auth: WebscrapingAiAuthValue;+ url: string;+ country?: string;+ transcript?: boolean;+ transcriptLanguage?: string;+}): Promise<WebscrapingAiDataResult> {+ const response = await webscrapingAiClient.request<WebscrapingAiDataResult>({+ auth,+ path: '/data',+ query: { url, country, transcript, transcript_language: transcriptLanguage },+ });+ return response.body;+}++async function getAccountInfo({+ auth,+}: {+ auth: WebscrapingAiAuthValue;+}): Promise<WebscrapingAiAccount> {+ const response = await webscrapingAiClient.request<WebscrapingAiAccount>({+ auth,+ path: '/account',+ });+ return response.body;+}++export const webscrapingAiApi = {+ askQuestion,+ getPageHtml,+ getPageText,+ getStructuredData,+ getAccount,+ scrapeHtml,+ scrapeText,+ scrapeSelected,+ scrapeSelectedMultiple,+ answerQuestion,+ extractFields,+ searchGoogle,+ getSiteData,+ getAccountInfo,+};++const PROXIES = ['datacenter', 'residential'];+const COUNTRIES = ['us', 'gb', 'de', 'it', 'fr', 'ca', 'es', 'ru', 'jp', 'kr', 'in'];+const TEXT_FORMATS = ['json', 'plain', 'xml'];diff --git a/packages/pieces/community/webscraping-ai/src/lib/common/client.ts b/packages/pieces/community/webscraping-ai/src/lib/common/client.tsnew file mode 100644index 00000000000..856f8346975--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/common/client.ts@@ -0,0 +1,45 @@+import { HttpMethod, HttpResponse, httpClient } from '@activepieces/pieces-common';++import type { WebscrapingAiAuthValue, WebscrapingAiQueryValue } from './types';++function baseUrl(): string {+ return 'https://api.webscraping.ai';+}++async function request<T>({+ auth,+ method = HttpMethod.GET,+ path,+ query = {},+ body,+ contentType,+}: RequestParams & { auth: WebscrapingAiAuthValue }): Promise<HttpResponse<T>> {+ const entries = Object.entries({ api_key: auth.secret_text, ...query }).filter(+ ([, value]) => value !== undefined,+ );+ const queryParams = Object.fromEntries(+ entries.flatMap(([key, value]) => (Array.isArray(value) ? [] : [[key, String(value)]])),+ );+ const repeated = new URLSearchParams(+ entries.flatMap(([key, value]) =>+ Array.isArray(value) ? value.map((item) => [key, item]) : [],+ ),+ ).toString();+ return await httpClient.sendRequest<T>({+ method,+ url: `${baseUrl()}${path}${repeated ? `?${repeated}` : ''}`,+ queryParams,+ headers: contentType ? { 'Content-Type': contentType } : undefined,+ body,+ });+}++export const webscrapingAiClient = { baseUrl, request };++type RequestParams = {+ method?: HttpMethod;+ path: string;+ query?: Record<string, WebscrapingAiQueryValue | string[]>;+ body?: string;+ contentType?: string;+};diff --git a/packages/pieces/community/webscraping-ai/src/lib/common/index.ts b/packages/pieces/community/webscraping-ai/src/lib/common/index.tsdeleted file mode 100644index 2aa624870f8..00000000000--- a/packages/pieces/community/webscraping-ai/src/lib/common/index.ts+++ /dev/null@@ -1,488 +0,0 @@-import {- httpClient,- HttpMethod,- QueryParams,-} from '@activepieces/pieces-common';-import { PieceAuth, Property } from '@activepieces/pieces-framework';-import { pickBy } from '@activepieces/pieces-framework';--const baseRequestProperties = {- url: Property.ShortText({- displayName: 'URL',- description: 'URL of the target page.',- required: true,- }),- headers: Property.Array({- displayName: 'Custom Headers',- description: 'Add custom HTTP headers (optional)',- required: false,- properties: {- name: Property.ShortText({- displayName: 'Header Name',- description: 'Header name (e.g., User-Agent, Authorization)',- required: true,- }),- value: Property.ShortText({- displayName: 'Header Value',- description: 'Header value',- required: true,- }),- },- }),- timeout: Property.Number({- displayName: 'Timeout',- description: 'Maximum page load time in milliseconds (default: 10000, max: 30000)',- required: false,- defaultValue: 10000,- }),- js: Property.Checkbox({- displayName: 'Enable JavaScript',- description: 'Execute JavaScript for dynamic content (recommended)',- defaultValue: true,- required: false,- }),- jsTimeout: Property.Number({- displayName: 'JavaScript Timeout',- description: 'Maximum JavaScript execution time in milliseconds (default: 2000)',- required: false,- defaultValue: 2000,- }),- waitFor: Property.ShortText({- displayName: 'Wait For',- description: 'CSS selector to wait for dynamic content (e.g., ".content-loaded")',- required: false,- }),- proxy: Property.StaticDropdown({- displayName: 'Proxy Type',- description: 'Use residential proxies for sites that block datacenter IPs (more expensive)',- required: false,- defaultValue: 'datacenter',- options: {- options: [- { label: '🏢 Datacenter (Fast)', value: 'datacenter' },- { label: '🏠 Residential (Stealth)', value: 'residential' },- ],- },- }),- country: Property.StaticDropdown({- displayName: 'Proxy Country',- description: 'Geographic location of the proxy server',- required: false,- defaultValue: 'us',- options: {- options: [- { label: 'United States', value: 'us' },- { label: 'Canada', value: 'ca' },- { label: 'United Kingdom', value: 'gb' },- { label: 'Germany', value: 'de' },- { label: 'France', value: 'fr' },- { label: 'Italy', value: 'it' },- { label: 'Spain', value: 'es' },- { label: 'Russia', value: 'ru' },- { label: 'Japan', value: 'jp' },- { label: 'South Korea', value: 'kr' },- { label: 'India', value: 'in' },- ],- },- }),- customProxy: Property.ShortText({- displayName: 'Custom Proxy',- description: 'Your proxy URL in format: http://user:password@host:port',- required: false,- }),- jsScript: Property.LongText({- displayName: 'JavaScript Code',- description: 'Custom JavaScript to execute (e.g., document.querySelector("button").click())',- required: false,- }),-};--export const webscrapingAiAuth = PieceAuth.SecretText({- displayName: 'API Key',- required: true,-});--export const webscrapingAiCommon = {- baseUrl: 'https://api.webscraping.ai',- endpoints: {- askQuestion: '/ai/question',- getPageHtml: '/html',- getPageText: '/text',- getStructuredData: '/ai/fields',- getAccountInfo: '/account',- },- askQuestionProperties: {- question: Property.ShortText({- displayName: 'Question',- description:- 'Question or instructions to ask the LLM model about the target page.',- required: true,- }),- ...baseRequestProperties,- device: Property.StaticDropdown({- displayName: 'Device Type',- description: 'Emulate specific device for responsive design testing',- required: false,- options: {- options: [- { label: 'Desktop', value: 'desktop' },- { label: 'Mobile', value: 'mobile' },- { label: 'Tablet', value: 'tablet' },- ],- },- }),- errorOn404: Property.Checkbox({- displayName: 'Error on 404',- description: 'Fail the action if the page returns a 404 error',- required: false,- }),- errorOnRedirect: Property.Checkbox({- displayName: 'Error on Redirect',- description: 'Fail the action if the page redirects to another URL',- required: false,- }),- format: Property.StaticDropdown({- displayName: 'Response Format',- description: 'Response format: Text (simple) or JSON (structured)',- required: false,- defaultValue: 'text',- options: {- options: [- { label: 'Text', value: 'text' },- { label: 'JSON', value: 'json' },- ],- },- }),- },- getPageHtmlProperties: {- ...baseRequestProperties,- returnScriptResult: Property.Checkbox({- displayName: 'Return JavaScript Result',- description:- 'Return result of the custom JavaScript code (js_script parameter) \- execution on the target page (false by default, page HTML will be returned).',- required: false,- }),- device: Property.StaticDropdown({- displayName: 'Device Type',- description: 'Emulate specific device for responsive design testing',- required: false,- options: {- options: [- { label: 'Desktop', value: 'desktop' },- { label: 'Mobile', value: 'mobile' },- { label: 'Tablet', value: 'tablet' },- ],- },- }),- errorOn404: Property.Checkbox({- displayName: 'Error on 404',- description: 'Fail the action if the page returns a 404 error',- required: false,- }),- errorOnRedirect: Property.Checkbox({- displayName: 'Error on Redirect',- description: 'Fail the action if the page redirects to another URL',- required: false,- }),- format: Property.StaticDropdown({- displayName: 'Response Format',- description: 'Response format: Text (simple) or JSON (structured)',- required: false,- defaultValue: 'text',- options: {- options: [- { label: 'Text', value: 'text' },- { label: 'JSON', value: 'json' },- ],- },- }),- },- getPageTextProperties: {- ...baseRequestProperties,- textFormat: Property.StaticDropdown({- displayName: 'Text Format',- description: 'Response format: Plain text, JSON (with title/description/content), or XML',- required: false,- defaultValue: 'plain',- options: {- options: [- { label: 'Plain Text', value: 'plain' },- { label: 'JSON', value: 'json' },- { label: 'XML', value: 'xml' },- ],- },- }),- returnLinks: Property.Checkbox({- displayName: 'Return Links',- description: 'Include links in response (only works with JSON format)',- required: false,- }),- device: Property.StaticDropdown({- displayName: 'Device Type',- description: 'Emulate specific device for responsive design testing',- required: false,- options: {- options: [- { label: 'Desktop', value: 'desktop' },- { label: 'Mobile', value: 'mobile' },- { label: 'Tablet', value: 'tablet' },- ],- },- }),- errorOn404: Property.Checkbox({- displayName: 'Error on 404',- description: 'Fail the action if the page returns a 404 error',- required: false,- }),- errorOnRedirect: Property.Checkbox({- displayName: 'Error on Redirect',- description: 'Fail the action if the page redirects to another URL',- required: false,- }),- },- getPageStructuredDataProperties: {- fields: Property.Object({- displayName: 'Fields to Extract',- description: 'Define fields to extract (e.g., {"title": "Product title", "price": "Product price"})',- required: true,- }),- ...baseRequestProperties,- device: Property.StaticDropdown({- displayName: 'Device Type',- description: 'Emulate specific device for responsive design testing',- required: false,- options: {- options: [- { label: 'Desktop', value: 'desktop' },- { label: 'Mobile', value: 'mobile' },- { label: 'Tablet', value: 'tablet' },- ],- },- }),- errorOn404: Property.Checkbox({- displayName: 'Error on 404',- description: 'Fail the action if the page returns a 404 error',- required: false,- }),- errorOnRedirect: Property.Checkbox({- displayName: 'Error on Redirect',- description: 'Fail the action if the page redirects to another URL',- required: false,- }),- },- askQuestion: async (params: askQuestionParams) => {- const rawParams: Record<string, string | number | boolean | undefined> = {- api_key: params.apiKey,- url: params.url,- question: params.question,- timeout: params.timeout,- js: params.js,- js_timeout: params.jsTimeout,- wait_for: params.waitFor,- proxy: params.proxy,- country: params.country,- custom_proxy: params.customProxy,- device: params.device,- error_on_404: params.errorOn404,- error_on_redirect: params.errorOnRedirect,- js_script: params.jsScript,- format: params.format,- headers: params.headers && Array.isArray(params.headers)- ? JSON.stringify(Object.fromEntries(params.headers.map(h => [h.name, h.value])))- : undefined,- };-- const filtered = pickBy(- rawParams,- (value) => value !== undefined- ) as Record<string, string | number | boolean>;- const queryParams: QueryParams = Object.fromEntries(- Object.entries(filtered).map(([k, v]) => [k, String(v)])- ) as QueryParams;- return await httpClient.sendRequest({- method: HttpMethod.GET,- url: `${webscrapingAiCommon.baseUrl}${webscrapingAiCommon.endpoints.askQuestion}`,- queryParams,- });- },- getPageHtml: async (params: getPageHtmlParams) => {- const rawParams: Record<string, string | number | boolean | undefined> = {- api_key: params.apiKey,- url: params.url,- headers: params.headers && Array.isArray(params.headers)- ? JSON.stringify(Object.fromEntries(params.headers.map(h => [h.name, h.value])))- : undefined,- timeout: params.timeout,- js: params.js,- js_timeout: params.jsTimeout,- wait_for: params.waitFor,- proxy: params.proxy,- country: params.country,- custom_proxy: params.customProxy,- device: params.device,- error_on_404: params.errorOn404,- error_on_redirect: params.errorOnRedirect,- js_script: params.jsScript,- return_script_result: params.returnScriptResult,- format: params.format,- };- const filtered = pickBy(- rawParams,- (value) => value !== undefined- ) as Record<string, string | number | boolean>;- const queryParams: QueryParams = Object.fromEntries(- Object.entries(filtered).map(([k, v]) => [k, String(v)])- ) as QueryParams;- return await httpClient.sendRequest({- method: HttpMethod.GET,- url: `${webscrapingAiCommon.baseUrl}${webscrapingAiCommon.endpoints.getPageHtml}`,- queryParams,- });- },- getPageText: async (params: getPageTextParams) => {- const rawParams: Record<string, string | number | boolean | undefined> = {- api_key: params.apiKey,- text_format: params.textFormat,- return_links: params.returnLinks,- url: params.url,- headers: params.headers && Array.isArray(params.headers)- ? JSON.stringify(Object.fromEntries(params.headers.map(h => [h.name, h.value])))- : undefined,- timeout: params.timeout,- js: params.js,- js_timeout: params.jsTimeout,- wait_for: params.waitFor,- proxy: params.proxy,- country: params.country,- custom_proxy: params.customProxy,- device: params.device,- error_on_404: params.errorOn404,- error_on_redirect: params.errorOnRedirect,- js_script: params.jsScript,- };- const filtered = pickBy(- rawParams,- (value) => value !== undefined- ) as Record<string, string | number | boolean>;- const queryParams: QueryParams = Object.fromEntries(- Object.entries(filtered).map(([k, v]) => [k, String(v)])- ) as QueryParams;- return await httpClient.sendRequest({- method: HttpMethod.GET,- url: `${webscrapingAiCommon.baseUrl}${webscrapingAiCommon.endpoints.getPageText}`,- queryParams,- });- },- getPageStructuredData: async (params: getPageStructuredDataParams) => {- const rawParams: Record<string, string | number | boolean | undefined> = {- api_key: params.apiKey,- url: params.url,- headers: params.headers && Array.isArray(params.headers)- ? JSON.stringify(Object.fromEntries(params.headers.map(h => [h.name, h.value])))- : undefined,- timeout: params.timeout,- js: params.js,- js_timeout: params.jsTimeout,- wait_for: params.waitFor,- proxy: params.proxy,- country: params.country,- custom_proxy: params.customProxy,- device: params.device,- error_on_404: params.errorOn404,- error_on_redirect: params.errorOnRedirect,- js_script: params.jsScript,- };-- const filtered = pickBy(- rawParams,- (value) => value !== undefined- ) as Record<string, string | number | boolean>;-- const expandedFields: Record<string, string> = Object.fromEntries(- Object.entries(params.fields || {}).map(([key, value]) => [- `fields[${key}]`,- value,- ])- );-- const queryParams: QueryParams = {- ...Object.fromEntries(- Object.entries(filtered).map(([k, v]) => [k, String(v)])- ),- ...expandedFields,- } as QueryParams;- return await httpClient.sendRequest({- method: HttpMethod.GET,- url: `${webscrapingAiCommon.baseUrl}${webscrapingAiCommon.endpoints.getStructuredData}`,- queryParams,- });- },- getAccountInformation: async ({ apiKey }: AuthenticationRequired) => {- return await httpClient.sendRequest({- method: HttpMethod.GET,- url: `${webscrapingAiCommon.baseUrl}${webscrapingAiCommon.endpoints.getAccountInfo}`,- queryParams: { api_key: apiKey },- });- },-};---type AuthenticationRequired = {- apiKey: string;-};--interface baseRequestParams extends AuthenticationRequired {- url: string;- headers?: Array<{name: string, value: string}>;- timeout?: number;- js?: boolean;- jsTimeout?: number;- waitFor?: string;- proxy?: 'datacenter' | 'residential';- country?:- | 'us'- | 'gb'- | 'de'- | 'it'- | 'fr'- | 'ca'- | 'es'- | 'ru'- | 'jp'- | 'kr'- | 'in';- customProxy?: string;- jsScript?: string;-}--interface askQuestionParams extends baseRequestParams {- question: string;- device?: 'desktop' | 'mobile' | 'tablet';- errorOn404?: boolean;- errorOnRedirect?: boolean;- format?: 'json' | 'text';-}--interface getPageHtmlParams extends baseRequestParams {- returnScriptResult?: boolean;- device?: 'desktop' | 'mobile' | 'tablet';- errorOn404?: boolean;- errorOnRedirect?: boolean;- format?: 'json' | 'text';-}--interface getPageTextParams extends baseRequestParams {- textFormat?: 'plain' | 'xml' | 'json';- returnLinks?: boolean;- device?: 'desktop' | 'mobile' | 'tablet';- errorOn404?: boolean;- errorOnRedirect?: boolean;-}--interface getPageStructuredDataParams extends baseRequestParams {- fields: Record<string, string>;- device?: 'desktop' | 'mobile' | 'tablet';- errorOn404?: boolean;- errorOnRedirect?: boolean;-}diff --git a/packages/pieces/community/webscraping-ai/src/lib/common/props.ts b/packages/pieces/community/webscraping-ai/src/lib/common/props.tsnew file mode 100644index 00000000000..fa828c102eb--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/common/props.ts@@ -0,0 +1,138 @@+import { Property } from '@activepieces/pieces-framework';++function pageRequest() {+ return {+ url: Property.ShortText({+ displayName: 'URL',+ description: 'URL of the target page.',+ required: true,+ }),+ headers: Property.Array({+ displayName: 'Custom Headers',+ description: 'Add custom HTTP headers (optional)',+ required: false,+ properties: {+ name: Property.ShortText({+ displayName: 'Header Name',+ description: 'Header name (e.g., User-Agent, Authorization)',+ required: true,+ }),+ value: Property.ShortText({+ displayName: 'Header Value',+ description: 'Header value',+ required: true,+ }),+ },+ }),+ timeout: Property.Number({+ displayName: 'Timeout',+ description: 'Maximum page load time in milliseconds (default: 10000, max: 30000)',+ required: false,+ defaultValue: 10000,+ }),+ js: Property.Checkbox({+ displayName: 'Enable JavaScript',+ description: 'Execute JavaScript for dynamic content (recommended)',+ defaultValue: true,+ required: false,+ }),+ jsTimeout: Property.Number({+ displayName: 'JavaScript Timeout',+ description: 'Maximum JavaScript execution time in milliseconds (default: 2000)',+ required: false,+ defaultValue: 2000,+ }),+ waitFor: Property.ShortText({+ displayName: 'Wait For',+ description: 'CSS selector to wait for dynamic content (e.g., ".content-loaded")',+ required: false,+ }),+ proxy: Property.StaticDropdown({+ displayName: 'Proxy Type',+ description: 'Use residential proxies for sites that block datacenter IPs (more expensive)',+ required: false,+ defaultValue: 'datacenter',+ options: {+ options: [+ { label: '🏢 Datacenter (Fast)', value: 'datacenter' },+ { label: '🏠 Residential (Stealth)', value: 'residential' },+ ],+ },+ }),+ country: Property.StaticDropdown({+ displayName: 'Proxy Country',+ description: 'Geographic location of the proxy server',+ required: false,+ defaultValue: 'us',+ options: {+ options: [+ { label: 'United States', value: 'us' },+ { label: 'Canada', value: 'ca' },+ { label: 'United Kingdom', value: 'gb' },+ { label: 'Germany', value: 'de' },+ { label: 'France', value: 'fr' },+ { label: 'Italy', value: 'it' },+ { label: 'Spain', value: 'es' },+ { label: 'Russia', value: 'ru' },+ { label: 'Japan', value: 'jp' },+ { label: 'South Korea', value: 'kr' },+ { label: 'India', value: 'in' },+ ],+ },+ }),+ customProxy: Property.ShortText({+ displayName: 'Custom Proxy',+ description: 'Your proxy URL in format: http://user:password@host:port',+ required: false,+ }),+ jsScript: Property.LongText({+ displayName: 'JavaScript Code',+ description: 'Custom JavaScript to execute (e.g., document.querySelector("button").click())',+ required: false,+ }),+ };+}++function pageOptions() {+ return {+ device: Property.StaticDropdown({+ displayName: 'Device Type',+ description: 'Emulate specific device for responsive design testing',+ required: false,+ options: {+ options: [+ { label: 'Desktop', value: 'desktop' },+ { label: 'Mobile', value: 'mobile' },+ { label: 'Tablet', value: 'tablet' },+ ],+ },+ }),+ errorOn404: Property.Checkbox({+ displayName: 'Error on 404',+ description: 'Fail the action if the page returns a 404 error',+ required: false,+ }),+ errorOnRedirect: Property.Checkbox({+ displayName: 'Error on Redirect',+ description: 'Fail the action if the page redirects to another URL',+ required: false,+ }),+ };+}++function format() {+ return Property.StaticDropdown({+ displayName: 'Response Format',+ description: 'Response format: Text (simple) or JSON (structured)',+ required: false,+ defaultValue: 'text',+ options: {+ options: [+ { label: 'Text', value: 'text' },+ { label: 'JSON', value: 'json' },+ ],+ },+ });+}++export const webscrapingAiProps = { pageRequest, pageOptions, format };diff --git a/packages/pieces/community/webscraping-ai/src/lib/common/types.ts b/packages/pieces/community/webscraping-ai/src/lib/common/types.tsnew file mode 100644index 00000000000..a08d0f16926--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/common/types.ts@@ -0,0 +1,73 @@+import type { AppConnectionType } from '@activepieces/pieces-framework';++export type WebscrapingAiAuthValue = { type: AppConnectionType.SECRET_TEXT; secret_text: string };++export type WebscrapingAiQueryValue = string | number | boolean | null | undefined;++export type WebscrapingAiPageParams = {+ url: string;+ headers?: unknown[];+ timeout?: number;+ js?: boolean;+ jsTimeout?: number;+ waitFor?: string;+ proxy?: string;+ country?: string;+ customProxy?: string;+ jsScript?: string;+ device?: string;+ errorOn404?: boolean;+ errorOnRedirect?: boolean;+};++export type WebscrapingAiScrapeParams = {+ url: string;+ headers?: Record<string, unknown>;+ timeout?: number;+ js?: boolean;+ jsTimeout?: number;+ waitFor?: string;+ proxy?: string;+ country?: string;+ customProxy?: string;+ device?: string;+ errorOn404?: boolean;+ errorOnRedirect?: boolean;+};++export type WebscrapingAiPost = { body: string; contentType: string };++export type WebscrapingAiResult = { result?: string };++export type WebscrapingAiFieldsResult = { result?: Record<string, string | null> };++export type WebscrapingAiPageText = {+ title?: string;+ description?: string;+ content?: string;+ links?: string[];+};++export type WebscrapingAiSerpResult = {+ search_parameters?: Record<string, unknown>;+ search_information?: Record<string, unknown>;+ organic_results?: Record<string, unknown>[];+ related_searches?: Record<string, unknown>[];+ pagination?: Record<string, unknown>;+};++export type WebscrapingAiDataResult = {+ request_parameters?: Record<string, unknown>;+ parse_status?: string;+ data?: Record<string, unknown>;+};++export type WebscrapingAiAccount = {+ email?: string;+ remaining_api_calls?: number;+ remaining_monthly_credits?: number;+ remaining_payg_credits?: number;+ remaining_total_credits?: number;+ resets_at?: number;+ remaining_concurrency?: number;+};diff --git a/packages/pieces/community/webscraping-ai/src/lib/output-schemas.ts b/packages/pieces/community/webscraping-ai/src/lib/output-schemas.tsnew file mode 100644index 00000000000..4e795da106c--- /dev/null+++ b/packages/pieces/community/webscraping-ai/src/lib/output-schemas.ts@@ -0,0 +1,182 @@+import { OutputSchema } from '@activepieces/pieces-framework';++const accountFields: OutputSchema['fields'] = [+ { key: 'email', label: 'Email', format: 'email' },+ { key: 'remaining_api_calls', label: 'Remaining API Calls', format: 'number' },+ { key: 'remaining_monthly_credits', label: 'Remaining Monthly Credits', format: 'number' },+ { key: 'remaining_payg_credits', label: 'Remaining Pay-As-You-Go Credits', format: 'number' },+ { key: 'remaining_total_credits', label: 'Remaining Total Credits', format: 'number' },+ {+ key: 'resets_at',+ label: 'Quota Resets At',+ format: 'number',+ description: 'Unix timestamp in seconds when the monthly quota resets.',+ },+ { key: 'remaining_concurrency', label: 'Remaining Concurrency', format: 'number' },+];++const pageTextFields: OutputSchema['fields'] = [+ { key: 'title', label: 'Title' },+ { key: 'description', label: 'Description' },+ { key: 'content', label: 'Content', description: 'Visible page text as Markdown.' },+];++export const accountOutputSchema: OutputSchema = { fields: accountFields };++export const pageHtmlOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'result',+ label: 'Result',+ format: 'html',+ description: 'Page HTML, or the JavaScript Code result when Return Script Result is set.',+ },+ { key: 'cookies', label: 'Cookies', description: 'Cookies set by the target page.' },+ ],+};++export const pageTextOutputSchema: OutputSchema = {+ fields: [+ ...pageTextFields,+ {+ key: 'links',+ label: 'Links',+ description: 'Links in the page body, when Return Links is set.',+ },+ ],+};++export const selectedMultipleOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'results',+ label: 'Results',+ description: 'Lists of inner HTML of the matched elements.',+ },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const answerOutputSchema: OutputSchema = {+ fields: [{ key: 'result', label: 'Answer' }],+};++export const extractedFieldsOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'result',+ label: 'Extracted Fields',+ dynamicKey: true,+ description: 'One value per requested field name; null when the page lacks it.',+ },+ ],+};++export const googleSearchOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'search_parameters',+ label: 'Search Parameters',+ children: [+ { key: 'engine', label: 'Engine' },+ { key: 'q', label: 'Query' },+ { key: 'gl', label: 'Country Code' },+ { key: 'hl', label: 'Language Code' },+ { key: 'page', label: 'Page', format: 'number' },+ ],+ },+ {+ key: 'search_information',+ label: 'Search Information',+ children: [+ { key: 'query_displayed', label: 'Query Displayed' },+ { key: 'organic_results_state', label: 'Organic Results State' },+ ],+ },+ { key: 'organic_results', label: 'Organic Results' },+ {+ key: 'related_searches',+ label: 'Related Searches',+ labelKey: 'query',+ listItems: [{ key: 'query', label: 'Query' }],+ },+ {+ key: 'pagination',+ label: 'Pagination',+ children: [+ { key: 'current', label: 'Current Page', format: 'number' },+ { key: 'next', label: 'Next Page', format: 'number' },+ ],+ },+ ],+};++export const siteDataOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'request_parameters',+ label: 'Request Parameters',+ children: [+ { key: 'url', label: 'URL', format: 'url' },+ { key: 'provider', label: 'Provider' },+ { key: 'type', label: 'Type' },+ ],+ },+ { key: 'parse_status', label: 'Parse Status' },+ {+ key: 'data',+ label: 'Data',+ description:+ 'Site-specific fields, e.g. title, views and channel for a YouTube video, or posts and comments for a Reddit thread.',+ },+ ],+};++export const humanAccountOutputSchema: OutputSchema = {+ fields: [+ { key: 'status', label: 'Status', format: 'number' },+ { key: 'body', label: 'Body', children: accountFields },+ ],+};++export const humanResponseOutputSchema: OutputSchema = {+ fields: [+ { key: 'status', label: 'Status', format: 'number' },+ {+ key: 'body',+ label: 'Body',+ description: 'Response text, or an object with a result key when Response Format is JSON.',+ },+ ],+};++export const humanPageTextOutputSchema: OutputSchema = {+ fields: [+ { key: 'status', label: 'Status', format: 'number' },+ {+ key: 'body',+ label: 'Body',+ description:+ 'Page text; an object with title, description and content when Text Format is JSON.',+ children: pageTextFields,+ },+ ],+};++export const humanExtractedFieldsOutputSchema: OutputSchema = {+ fields: [+ { key: 'status', label: 'Status', format: 'number' },+ {+ key: 'body',+ label: 'Body',+ children: [+ {+ key: 'result',+ label: 'Extracted Fields',+ dynamicKey: true,+ description: 'One value per requested field name; null when the page lacks it.',+ },+ ],+ },+ ],+};