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(youform): let AI agents read forms and list submissions (#16703)
Kishan Parmar68e09203075d
diff --git a/bun.lock b/bun.lockindex b135b3e7beb..05c8076ec94 100644--- a/bun.lock+++ b/bun.lock@@ -167,7 +167,7 @@},"packages/core/shared": {"name": "@activepieces/shared",- "version": "0.202.1",+ "version": "0.203.0","dependencies": {"@activepieces/core-execution": "workspace:*","@activepieces/core-formula": "workspace:*",@@ -718,7 +718,7 @@},"packages/pieces/community/apify": {"name": "@activepieces/piece-apify",- "version": "0.4.0",+ "version": "0.4.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -1105,7 +1105,7 @@},"packages/pieces/community/baserow": {"name": "@activepieces/piece-baserow",- "version": "0.12.0",+ "version": "0.12.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -1516,7 +1516,7 @@},"packages/pieces/community/calendly": {"name": "@activepieces/piece-calendly",- "version": "0.7.0",+ "version": "0.7.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2183,7 +2183,7 @@},"packages/pieces/community/confluence": {"name": "@activepieces/piece-confluence",- "version": "0.4.0",+ "version": "0.4.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3085,7 +3085,7 @@},"packages/pieces/community/facebook-leads": {"name": "@activepieces/piece-facebook-leads",- "version": "0.5.0",+ "version": "0.5.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3250,7 +3250,7 @@},"packages/pieces/community/firecrawl": {"name": "@activepieces/piece-firecrawl",- "version": "0.7.0",+ "version": "0.7.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3316,7 +3316,7 @@},"packages/pieces/community/flow-helper": {"name": "@activepieces/piece-flow-helper",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3858,7 +3858,7 @@},"packages/pieces/community/google-calendar": {"name": "@activepieces/piece-google-calendar",- "version": "0.13.0",+ "version": "0.13.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4276,7 +4276,7 @@},"packages/pieces/community/groq": {"name": "@activepieces/piece-groq",- "version": "0.5.0",+ "version": "0.5.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4467,7 +4467,7 @@},"packages/pieces/community/hubspot": {"name": "@activepieces/piece-hubspot",- "version": "0.13.0",+ "version": "0.13.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4677,7 +4677,7 @@},"packages/pieces/community/instagram-business": {"name": "@activepieces/piece-instagram-business",- "version": "1.1.0",+ "version": "1.1.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -4775,7 +4775,7 @@},"packages/pieces/community/jira-cloud": {"name": "@activepieces/piece-jira-cloud",- "version": "0.6.0",+ "version": "0.6.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -5297,7 +5297,7 @@},"packages/pieces/community/linkedin": {"name": "@activepieces/piece-linkedin",- "version": "0.6.0",+ "version": "0.6.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -5497,7 +5497,7 @@},"packages/pieces/community/magical-api": {"name": "@activepieces/piece-magical-api",- "version": "0.3.0",+ "version": "0.3.1","dependencies": {"@activepieces/pieces-common": "workspace:*","@activepieces/pieces-framework": "workspace:*",@@ -5552,7 +5552,7 @@},"packages/pieces/community/mailer-lite": {"name": "@activepieces/piece-mailer-lite",- "version": "0.10.0",+ "version": "0.10.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -6515,7 +6515,7 @@},"packages/pieces/community/notion": {"name": "@activepieces/piece-notion",- "version": "0.8.0",+ "version": "0.8.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -6989,7 +6989,7 @@},"packages/pieces/community/pdfcrowd": {"name": "@activepieces/piece-pdfcrowd",- "version": "0.3.0",+ "version": "0.3.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7127,7 +7127,7 @@},"packages/pieces/community/pinecone": {"name": "@activepieces/piece-pinecone",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7493,7 +7493,7 @@},"packages/pieces/community/pushover": {"name": "@activepieces/piece-pushover",- "version": "0.3.0",+ "version": "0.3.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7842,7 +7842,7 @@},"packages/pieces/community/resend": {"name": "@activepieces/piece-resend",- "version": "0.6.0",+ "version": "0.6.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7894,7 +7894,7 @@},"packages/pieces/community/retell-ai": {"name": "@activepieces/piece-retell-ai",- "version": "0.3.0",+ "version": "0.3.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -8336,7 +8336,7 @@},"packages/pieces/community/serp-api": {"name": "@activepieces/piece-serp-api",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -8418,7 +8418,7 @@},"packages/pieces/community/shopify": {"name": "@activepieces/piece-shopify",- "version": "0.10.0",+ "version": "0.10.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9268,7 +9268,7 @@},"packages/pieces/community/tidycal": {"name": "@activepieces/piece-tidycal",- "version": "0.3.0",+ "version": "0.3.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9380,7 +9380,7 @@},"packages/pieces/community/trello": {"name": "@activepieces/piece-trello",- "version": "0.8.0",+ "version": "0.8.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -9493,7 +9493,7 @@},"packages/pieces/community/typeform": {"name": "@activepieces/piece-typeform",- "version": "0.7.0",+ "version": "0.7.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10070,7 +10070,7 @@},"packages/pieces/community/woocommerce": {"name": "@activepieces/piece-woocommerce",- "version": "0.5.0",+ "version": "0.5.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10110,7 +10110,7 @@},"packages/pieces/community/wordpress": {"name": "@activepieces/piece-wordpress",- "version": "0.9.0",+ "version": "0.9.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10235,7 +10235,7 @@},"packages/pieces/community/youform": {"name": "@activepieces/piece-youform",- "version": "0.1.8",+ "version": "0.2.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10261,7 +10261,7 @@},"packages/pieces/community/youtube": {"name": "@activepieces/piece-youtube",- "version": "0.9.0",+ "version": "0.9.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10500,7 +10500,7 @@},"packages/pieces/core/connections": {"name": "@activepieces/piece-connections",- "version": "0.6.0",+ "version": "0.6.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10513,7 +10513,7 @@},"packages/pieces/core/crypto": {"name": "@activepieces/piece-crypto",- "version": "0.1.0",+ "version": "0.1.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -10841,7 +10841,7 @@},"packages/pieces/core/tables": {"name": "@activepieces/piece-tables",- "version": "0.6.0",+ "version": "0.6.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -11940,6 +11940,7 @@"@activepieces/piece-goodmem": ["@activepieces/piece-goodmem@workspace:packages/pieces/community/goodmem"],"@activepieces/piece-google-ads": ["@activepieces/piece-google-ads@workspace:packages/pieces/community/google-ads"],+"@activepieces/piece-google-bigquery": ["@activepieces/piece-google-bigquery@workspace:packages/pieces/community/google-bigquery"],"@activepieces/piece-google-calendar": ["@activepieces/piece-google-calendar@workspace:packages/pieces/community/google-calendar"],diff --git a/packages/pieces/community/youform/package.json b/packages/pieces/community/youform/package.jsonindex 51f2c62aede..6fb4f6a96ae 100644--- a/packages/pieces/community/youform/package.json+++ b/packages/pieces/community/youform/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-youform",- "version": "0.1.8",+ "version": "0.2.0","type": "commonjs","main": "./dist/src/index.js","types": "./dist/src/index.d.ts",diff --git a/packages/pieces/community/youform/src/i18n/translation.json b/packages/pieces/community/youform/src/i18n/translation.jsonindex cfc23ed00b5..9090514e430 100644--- a/packages/pieces/community/youform/src/i18n/translation.json+++ b/packages/pieces/community/youform/src/i18n/translation.json@@ -1,5 +1,50 @@{"You can obtain API token from [Account Settings](https://app.youform.com/account).": "You can obtain API token from [Account Settings](https://app.youform.com/account).",+ "List Forms": "List Forms",+ "Get Form": "Get Form",+ "List Submissions": "List Submissions",+ "Custom API Call": "Custom API Call",+ "Lists one page of forms in the account.": "Lists one page of forms in the account.",+ "Gets a form by its slug, including its questions and settings.": "Gets a form by its slug, including its questions and settings.",+ "Lists one page of submissions for a form.": "Lists one page of submissions for a form.",+ "Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",+ "Page": "Page",+ "Form Slug": "Form Slug",+ "Limit": "Limit",+ "Sort Order": "Sort Order",+ "Completion": "Completion",+ "Method": "Method",+ "Headers": "Headers",+ "Query Parameters": "Query Parameters",+ "Body Type": "Body Type",+ "Body": "Body",+ "Response is Binary": "Response is Binary",+ "Return Error as Output": "Return Error as Output",+ "Timeout": "Timeout",+ "Follow redirects": "Follow redirects",+ "Page number to return, starting at 1. Defaults to 1. Use the returned `current_page` and `last_page` to page through.": "Page number to return, starting at 1. Defaults to 1. Use the returned `current_page` and `last_page` to page through.",+ "The form's slug, e.g. \"kyir3qrg\" (the `slug` field from List Forms, also the last part of the form's share link).": "The form's slug, e.g. \"kyir3qrg\" (the `slug` field from List Forms, also the last part of the form's share link).",+ "Submissions per page, 1-100. Defaults to 20.": "Submissions per page, 1-100. Defaults to 20.",+ "Order by submission time. Defaults to oldest first.": "Order by submission time. Defaults to oldest first.",+ "Complete or partial submissions only. Partial needs Pro. Unset returns all.": "Complete or partial submissions only. Partial needs Pro. Unset returns all.",+ "Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",+ "Appended to the URL as ?key=value.": "Appended to the URL as ?key=value.",+ "Enable for files like PDFs, images, etc.": "Enable for files like PDFs, images, etc.",+ "On a failed request, output the error instead of failing the step.": "On a failed request, output the error instead of failing the step.",+ "Seconds to wait for a response. Empty: up to the flow limit (10 min).": "Seconds to wait for a response. Empty: up to the flow limit (10 min).",+ "Follow 3xx redirects instead of returning them as the response.": "Follow 3xx redirects instead of returning them as the response.",+ "Oldest first": "Oldest first",+ "Newest first": "Newest first",+ "Complete only": "Complete only",+ "Partial only": "Partial only",+ "GET": "GET",+ "POST": "POST",+ "PATCH": "PATCH",+ "PUT": "PUT",+ "DELETE": "DELETE",+ "HEAD": "HEAD",+ "Request": "Request",+ "Data to send": "Data to send","New Submission": "New Submission","Triggers When a new submission is recieved.": "Triggers When a new submission is recieved.","Form": "Form"diff --git a/packages/pieces/community/youform/src/index.ts b/packages/pieces/community/youform/src/index.tsindex c1392e0db9b..9624d44ba3e 100644--- a/packages/pieces/community/youform/src/index.ts+++ b/packages/pieces/community/youform/src/index.ts@@ -1,15 +1,27 @@+import { createCustomApiCallAction } from '@activepieces/pieces-common';import { createPiece } from '@activepieces/pieces-framework';-import { youformAuth } from './lib/common/auth';+import { youformAiActions } from './lib/actions/ai';+import { youformAuth } from './lib/auth';import { PieceCategory } from '@activepieces/pieces-framework';+import { youformClient } from './lib/common/client';import { newSubmissionTrigger } from './lib/triggers/new-form-submission';export const youform = createPiece({displayName: 'Youform',auth: youformAuth,- minimumSupportedRelease: '0.36.1',+ minimumSupportedRelease: '0.88.2',logoUrl: 'https://cdn.activepieces.com/pieces/youform.png',authors: ['kishanprmr'],categories: [PieceCategory.FORMS_AND_SURVEYS],- actions: [],+ actions: [+ ...youformAiActions,+ createCustomApiCallAction({+ auth: youformAuth,+ baseUrl: () => youformClient.baseUrl(),+ authMapping: async (auth) => ({+ Authorization: `Bearer ${auth.secret_text}`,+ }),+ }),+ ],triggers: [newSubmissionTrigger],});diff --git a/packages/pieces/community/youform/src/lib/actions/ai/get-form.ts b/packages/pieces/community/youform/src/lib/actions/ai/get-form.tsnew file mode 100644index 00000000000..c11dfc86f88--- /dev/null+++ b/packages/pieces/community/youform/src/lib/actions/ai/get-form.ts@@ -0,0 +1,31 @@+import { createAction } from '@activepieces/pieces-framework';++import { youformAuth } from '../../auth';+import { youformAiProps } from '../../common/ai-props';+import { youformApi } from '../../common/api';+import { youformGetFormOutputSchema } from '../../output-schemas';++export const youformGetFormAction = createAction({+ auth: youformAuth,+ name: 'youform_get_form',+ outputSchema: youformGetFormOutputSchema,+ displayName: 'Get Form',+ description: 'Gets a form by its slug, including its questions and settings.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets one form by slug (from List Forms), including its published questions (`fields.blocks`, whose block ids are the answer keys in List Submissions; `draft_fields` holds unpublished edits), settings, hidden fields and submission count. Returns found: false when no form has that slug.',+ idempotent: true,+ },+ props: {+ formSlug: youformAiProps.formSlug({ required: true }),+ },+ async run(context) {+ const form = await youformApi.getForm({+ auth: context.auth,+ formSlug: context.propsValue.formSlug,+ });+ return { found: form !== null, form };+ },+});diff --git a/packages/pieces/community/youform/src/lib/actions/ai/index.ts b/packages/pieces/community/youform/src/lib/actions/ai/index.tsnew file mode 100644index 00000000000..ac288ff40c5--- /dev/null+++ b/packages/pieces/community/youform/src/lib/actions/ai/index.ts@@ -0,0 +1,9 @@+import { youformGetFormAction } from './get-form';+import { youformListFormsAction } from './list-forms';+import { youformListSubmissionsAction } from './list-submissions';++export const youformAiActions = [+ youformListFormsAction,+ youformGetFormAction,+ youformListSubmissionsAction,+];diff --git a/packages/pieces/community/youform/src/lib/actions/ai/list-forms.ts b/packages/pieces/community/youform/src/lib/actions/ai/list-forms.tsnew file mode 100644index 00000000000..431eaa1377d--- /dev/null+++ b/packages/pieces/community/youform/src/lib/actions/ai/list-forms.ts@@ -0,0 +1,42 @@+import { createAction } from '@activepieces/pieces-framework';++import { youformAuth } from '../../auth';+import { youformAiProps } from '../../common/ai-props';+import { youformApi } from '../../common/api';+import { youformListFormsOutputSchema } from '../../output-schemas';++export const youformListFormsAction = createAction({+ auth: youformAuth,+ name: 'youform_list_forms',+ outputSchema: youformListFormsOutputSchema,+ displayName: 'List Forms',+ description: 'Lists one page of forms in the account.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ "Lists one page of the account's forms with their ID, slug, name, closed state and submission count. Use it to find the form slug that Get Form and List Submissions take. Page through with Page.",+ idempotent: true,+ },+ props: {+ page: youformAiProps.page({ required: false }),+ },+ async run(context) {+ const response = await youformApi.listForms({+ auth: context.auth,+ page: context.propsValue.page,+ });+ return {+ ...response.data,+ data: response.data.data.map((form) => ({+ id: form.id,+ slug: form.slug,+ name: form.name,+ closed: form.closed,+ submissions_count: form.submissions_count,+ created_at: form.created_at,+ updated_at: form.updated_at,+ })),+ };+ },+});diff --git a/packages/pieces/community/youform/src/lib/actions/ai/list-submissions.ts b/packages/pieces/community/youform/src/lib/actions/ai/list-submissions.tsnew file mode 100644index 00000000000..f90a174cea2--- /dev/null+++ b/packages/pieces/community/youform/src/lib/actions/ai/list-submissions.ts@@ -0,0 +1,61 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { youformAuth } from '../../auth';+import { youformAiProps } from '../../common/ai-props';+import { youformApi } from '../../common/api';+import { youformListSubmissionsOutputSchema } from '../../output-schemas';++export const youformListSubmissionsAction = createAction({+ auth: youformAuth,+ name: 'youform_list_submissions',+ outputSchema: youformListSubmissionsOutputSchema,+ displayName: 'List Submissions',+ description: 'Lists one page of submissions for a form.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ "Lists one page of a form's submissions (form slug from List Forms) with each submission's ID, answers, completion state and refill-link state, oldest first unless Sort Order says otherwise. Partial only needs a Youform Pro plan; other plans get an error for it. Page through with Page using the returned `current_page` and `last_page`.",+ idempotent: true,+ },+ props: {+ formSlug: youformAiProps.formSlug({ required: true }),+ page: youformAiProps.page({ required: false }),+ limit: Property.Number({+ displayName: 'Limit',+ description: 'Submissions per page, 1-100. Defaults to 20.',+ required: false,+ }),+ sortOrder: Property.StaticDropdown({+ displayName: 'Sort Order',+ description: 'Order by submission time. Defaults to oldest first.',+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Oldest first', value: 'asc' },+ { label: 'Newest first', value: 'desc' },+ ],+ },+ }),+ isComplete: Property.StaticDropdown({+ displayName: 'Completion',+ description:+ 'Complete or partial submissions only. Partial needs Pro. Unset returns all.',+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Complete only', value: 'true' },+ { label: 'Partial only', value: 'false' },+ ],+ },+ }),+ },+ async run(context) {+ return await youformApi.listSubmissions({+ auth: context.auth,+ ...context.propsValue,+ });+ },+});diff --git a/packages/pieces/community/youform/src/lib/auth.ts b/packages/pieces/community/youform/src/lib/auth.tsnew file mode 100644index 00000000000..c0491c450c1--- /dev/null+++ b/packages/pieces/community/youform/src/lib/auth.ts@@ -0,0 +1,36 @@+import {+ AppConnectionType,+ PieceAuth,+ tryCatch,+} from '@activepieces/pieces-framework';++import { youformApi } from './common/api';++export const youformAuth = PieceAuth.SecretText({+ displayName: 'API Token',+ description: `You can obtain API token from [Account Settings](https://app.youform.com/account).`,+ required: true,+ validate: async ({ auth }) => {+ const { error } = await tryCatch(() =>+ youformApi.getMe({+ auth: { type: AppConnectionType.SECRET_TEXT, secret_text: auth },+ })+ );+ return error+ ? {+ valid: false,+ error: 'Invalid API Token',+ }+ : {+ valid: true,+ };+ },+ getConnectionIdentifier: async ({ auth }) => {+ const { data } = await tryCatch(() =>+ youformApi.getMe({+ auth: { type: AppConnectionType.SECRET_TEXT, secret_text: auth },+ })+ );+ return data?.data.email;+ },+});diff --git a/packages/pieces/community/youform/src/lib/common/ai-props.ts b/packages/pieces/community/youform/src/lib/common/ai-props.tsnew file mode 100644index 00000000000..9d388664299--- /dev/null+++ b/packages/pieces/community/youform/src/lib/common/ai-props.ts@@ -0,0 +1,21 @@+import { Property } from '@activepieces/pieces-framework';++import type { PropParams } from './props';++function formSlug<R extends boolean>({+ required,+ displayName = 'Form Slug',+ description = 'The form\'s slug, e.g. "kyir3qrg" (the `slug` field from List Forms, also the last part of the form\'s share link).',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function page<R extends boolean>({+ required,+ displayName = 'Page',+ description = 'Page number to return, starting at 1. Defaults to 1. Use the returned `current_page` and `last_page` to page through.',+}: PropParams<R>) {+ return Property.Number({ displayName, description, required });+}++export const youformAiProps = { formSlug, page };diff --git a/packages/pieces/community/youform/src/lib/common/api.ts b/packages/pieces/community/youform/src/lib/common/api.tsnew file mode 100644index 00000000000..8e3b3b85ac7--- /dev/null+++ b/packages/pieces/community/youform/src/lib/common/api.ts@@ -0,0 +1,152 @@+import {+ HttpError,+ HttpMethod,+ QueryParams,+} from '@activepieces/pieces-common';++import { youformClient } from './client';++import type {+ YouformAuthValue,+ YouformCreateWebhookResponse,+ YouformForm,+ YouformFormDetail,+ YouformPage,+ YouformPaginator,+ YouformSubmission,+ YouformUser,+} from './types';++async function getMe({+ auth,+}: {+ auth: YouformAuthValue;+}): Promise<{ data: YouformUser }> {+ return await youformClient.request<{ data: YouformUser }>({+ auth,+ method: HttpMethod.GET,+ path: '/me',+ });+}++async function listForms({+ auth,+ page,+}: {+ auth: YouformAuthValue;+ page?: number;+}): Promise<YouformPage<YouformForm>> {+ return await youformClient.request<YouformPage<YouformForm>>({+ auth,+ method: HttpMethod.GET,+ path: '/forms',+ query: page !== undefined ? { page: String(page) } : undefined,+ });+}++async function getForm({+ auth,+ formSlug,+}: {+ auth: YouformAuthValue;+ formSlug: string;+}): Promise<YouformFormDetail | null> {+ try {+ const response = await youformClient.request<{ data: YouformFormDetail }>({+ auth,+ method: HttpMethod.GET,+ path: `/forms/${encodeURIComponent(formSlug)}`,+ });+ return response.data;+ } catch (error) {+ if (error instanceof HttpError && error.response.status === 404) {+ return null;+ }+ throw error;+ }+}++async function listSubmissions({+ auth,+ formSlug,+ page,+ limit,+ sortOrder,+ isComplete,+}: ListSubmissionsParams & {+ auth: YouformAuthValue;+}): Promise<YouformPaginator<YouformSubmission>> {+ const query: QueryParams = {};+ if (page !== undefined) {+ query['page'] = String(page);+ }+ if (limit !== undefined) {+ query['per_page'] = String(limit);+ }+ if (sortOrder !== undefined) {+ query['sort_by'] = 'created_at';+ query['sort_by_order'] = sortOrder;+ }+ if (isComplete !== undefined) {+ query['is_complete'] = isComplete;+ }+ const response = await youformClient.request<YouformPage<YouformSubmission>>({+ auth,+ method: HttpMethod.GET,+ path: `/forms/${encodeURIComponent(formSlug)}/submissions`,+ query,+ });+ return response.data;+}++async function createWebhook({+ auth,+ formId,+ webhookUrl,+}: {+ auth: YouformAuthValue;+ formId: string;+ webhookUrl: string;+}): Promise<YouformCreateWebhookResponse> {+ return await youformClient.request<YouformCreateWebhookResponse>({+ auth,+ method: HttpMethod.POST,+ path: '/webhooks',+ body: {},+ query: {+ form_id: formId,+ webhook_url: webhookUrl,+ },+ });+}++async function deleteWebhook({+ auth,+ webhookId,+}: {+ auth: YouformAuthValue;+ webhookId: number;+}): Promise<void> {+ await youformClient.request<unknown>({+ auth,+ method: HttpMethod.DELETE,+ path: `/webhooks/${webhookId}`,+ });+}++export const youformApi = {+ getMe,+ listForms,+ getForm,+ listSubmissions,+ createWebhook,+ deleteWebhook,+};++type ListSubmissionsParams = {+ formSlug: string;+ page?: number;+ limit?: number;+ sortOrder?: string;+ isComplete?: string;+};diff --git a/packages/pieces/community/youform/src/lib/common/auth.ts b/packages/pieces/community/youform/src/lib/common/auth.tsdeleted file mode 100644index 2918d8f5000..00000000000--- a/packages/pieces/community/youform/src/lib/common/auth.ts+++ /dev/null@@ -1,33 +0,0 @@-import { PieceAuth } from '@activepieces/pieces-framework';-import {- AuthenticationType,- httpClient,- HttpMethod,-} from '@activepieces/pieces-common';-import { BASE_URL } from './constants';--export const youformAuth = PieceAuth.SecretText({- displayName: 'API Token',- description: `You can obtain API token from [Account Settings](https://app.youform.com/account).`,- required: true,- validate: async ({ auth }) => {- try {- await httpClient.sendRequest({- method: HttpMethod.GET,- url: BASE_URL + '/me',- authentication: {- type: AuthenticationType.BEARER_TOKEN,- token: auth,- },- });- return {- valid: true,- };- } catch {- return {- valid: false,- error: 'Invalid API Token',- };- }- },-});diff --git a/packages/pieces/community/youform/src/lib/common/client.ts b/packages/pieces/community/youform/src/lib/common/client.tsnew file mode 100644index 00000000000..0d089adf569--- /dev/null+++ b/packages/pieces/community/youform/src/lib/common/client.ts@@ -0,0 +1,43 @@+import {+ AuthenticationType,+ HttpMethod,+ httpClient,+ QueryParams,+} from '@activepieces/pieces-common';++import type { YouformAuthValue } from './types';++function baseUrl(): string {+ return BASE_URL;+}++async function request<T>({+ auth,+ method,+ path,+ query,+ body,+}: RequestParams & { auth: YouformAuthValue }): Promise<T> {+ const response = await httpClient.sendRequest<T>({+ method,+ url: `${BASE_URL}${path}`,+ authentication: {+ type: AuthenticationType.BEARER_TOKEN,+ token: auth.secret_text,+ },+ queryParams: query,+ body,+ });+ return response.body;+}++export const youformClient = { baseUrl, request };++const BASE_URL = 'https://app.youform.com/api';++type RequestParams = {+ method: HttpMethod;+ path: string;+ query?: QueryParams;+ body?: unknown;+};diff --git a/packages/pieces/community/youform/src/lib/common/constants.ts b/packages/pieces/community/youform/src/lib/common/constants.tsdeleted file mode 100644index 23a7bcf8de6..00000000000--- a/packages/pieces/community/youform/src/lib/common/constants.ts+++ /dev/null@@ -1 +0,0 @@-export const BASE_URL = 'https://app.youform.com/api'\ No newline at end of filediff --git a/packages/pieces/community/youform/src/lib/common/props.ts b/packages/pieces/community/youform/src/lib/common/props.tsindex 4cc5df6202b..325582e23e5 100644--- a/packages/pieces/community/youform/src/lib/common/props.ts+++ b/packages/pieces/community/youform/src/lib/common/props.ts@@ -1,42 +1,50 @@-import {- AuthenticationType,- httpClient,- HttpMethod,-} from '@activepieces/pieces-common';-import { Property } from '@activepieces/pieces-framework';-import { BASE_URL } from './constants';-import { ListFormsResponse } from './types';-import { youformAuth } from './auth';+import { DropdownState, Property } from '@activepieces/pieces-framework';+import { youformAuth } from '../auth';+import { youformApi } from './api';++function formId<R extends boolean>({+ required,+ displayName = 'Form',+ description,+}: PropParams<R>) {+ return Property.Dropdown({+ auth: youformAuth,+ displayName,+ description,+ refreshers: [],+ required,+ options: async ({ auth }) => {+ if (!auth) {+ return disabledOptions({+ placeholder: 'Please connect your account first.',+ });+ }++ const response = await youformApi.listForms({ auth });-export const formIdDropdown = Property.Dropdown({- auth: youformAuth,- displayName: 'Form',- refreshers: [],- required: true,- options: async ({ auth }) => {- if (!auth) {return {- placeholder: 'Please connect your account first.',- options: [],disabled: false,+ options: response.data.data.map((form) => ({+ label: form.name,+ value: form.slug,+ })),};- }+ },+ });+}++function disabledOptions({+ placeholder,+}: {+ placeholder: string;+}): DropdownState<never> {+ return { disabled: true, options: [], placeholder };+}- const response = await httpClient.sendRequest<ListFormsResponse>({- method: HttpMethod.GET,- url: BASE_URL + '/forms',- authentication: {- type: AuthenticationType.BEARER_TOKEN,- token: auth.secret_text,- },- });+export const youformProps = { formId };- return {- disabled: false,- options: response.body.data.data.map((form) => ({- label: form.name,- value: form.slug,- })),- };- },-});+export type PropParams<R extends boolean> = {+ required: R;+ displayName?: string;+ description?: string;+};diff --git a/packages/pieces/community/youform/src/lib/common/types.ts b/packages/pieces/community/youform/src/lib/common/types.tsindex 4769b177bd4..b2a256d698a 100644--- a/packages/pieces/community/youform/src/lib/common/types.ts+++ b/packages/pieces/community/youform/src/lib/common/types.ts@@ -1,15 +1,36 @@-export type ListFormsResponse = {- data:{- data: {- id: number;- name: string;- slug:string- }[];}-};+import type { AppConnectionType } from '@activepieces/pieces-framework';+export type YouformAuthValue = { type: AppConnectionType.SECRET_TEXT; secret_text: string };-export type CreateWebhookResponse = {- data:{- id:number- }-}\ No newline at end of file+export type YouformUser = { id: number; first_name?: string; last_name?: string; email?: string };+export type YouformForm = {+ id: number;+ name: string;+ slug: string;+ closed?: unknown;+ submissions_count?: number | null;+ created_at?: string;+ updated_at?: string;+};+export type YouformFormDetail = YouformForm & Record<string, unknown>;+export type YouformSubmission = {+ id: number;+ uid?: string;+ form_id?: number;+ data?: Record<string, unknown>;+ is_complete?: number;+ completed_at?: string | null;+ refill_link_enabled?: unknown;+ created_at?: string;+ updated_at?: string;+};+export type YouformPaginator<T> = {+ current_page?: number;+ data: T[];+ last_page?: number;+ per_page?: number;+ total?: number;+ next_page_url?: string | null;+};+export type YouformPage<T> = { data: YouformPaginator<T> };+export type YouformCreateWebhookResponse = { data: { id: number } };diff --git a/packages/pieces/community/youform/src/lib/output-schemas.ts b/packages/pieces/community/youform/src/lib/output-schemas.tsnew file mode 100644index 00000000000..9a02c0fe1ba--- /dev/null+++ b/packages/pieces/community/youform/src/lib/output-schemas.ts@@ -0,0 +1,217 @@+import { OutputSchema } from '@activepieces/pieces-framework';++const blockFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Block ID' },+ { key: 'type', label: 'Type' },+ { key: 'title', label: 'Title' },+ { key: 'question', label: 'Question' },+ { key: 'description', label: 'Description' },+ { key: 'placeholder', label: 'Placeholder' },+ { key: 'position', label: 'Position', format: 'number' },+ { key: 'is_email', label: 'Is Email', format: 'boolean' },+ { key: 'validate_email', label: 'Validate Email', format: 'boolean' },+ { key: 'is_last', label: 'Is Last', format: 'boolean' },+ { key: 'cta_text', label: 'Button Text' },+ { key: 'cta_link', label: 'Button Link' },+ { key: 'post_submission_action', label: 'Post Submission Action' },+];++const paginationFields: OutputSchema['fields'] = [+ { key: 'current_page', label: 'Current Page', format: 'number' },+ { key: 'last_page', label: 'Last Page', format: 'number' },+ { key: 'per_page', label: 'Per Page', format: 'number' },+ { key: 'total', label: 'Total', format: 'number' },+ { key: 'from', label: 'From', format: 'number' },+ { key: 'to', label: 'To', format: 'number' },+ { key: 'next_page_url', label: 'Next Page URL', format: 'url' },+ { key: 'prev_page_url', label: 'Previous Page URL', format: 'url' },+];++export const youformGetFormOutputSchema: OutputSchema = {+ fields: [+ { key: 'found', label: 'Found', format: 'boolean' },+ {+ key: 'form',+ label: 'Form',+ children: [+ { key: 'id', label: 'Form ID' },+ { key: 'slug', label: 'Slug' },+ { key: 'name', label: 'Name' },+ { key: 'description', label: 'Description' },+ { key: 'type', label: 'Type' },+ { key: 'user_id', label: 'User ID' },+ { key: 'workspace_id', label: 'Workspace ID' },+ {+ key: 'fields',+ label: 'Published Questions',+ children: [+ {+ key: 'blocks',+ label: 'Blocks',+ labelKey: 'title',+ listItems: blockFields,+ },+ ],+ },+ {+ key: 'draft_fields',+ label: 'Draft Questions',+ children: [+ {+ key: 'blocks',+ label: 'Blocks',+ labelKey: 'title',+ listItems: blockFields,+ },+ ],+ },+ { key: 'variables', label: 'Variables' },+ { key: 'hidden_fields', label: 'Hidden Fields' },+ { key: 'messages', label: 'Messages' },+ { key: 'default_language', label: 'Default Language' },+ {+ key: 'settings',+ label: 'Settings',+ children: [+ {+ key: 'reply_to',+ label: 'Reply To',+ children: [{ key: 'block_id', label: 'Block ID' }],+ },+ ],+ },+ { key: 'closed', label: 'Closed' },+ { key: 'close_by_date', label: 'Close By Date', format: 'datetime' },+ {+ key: 'close_by_submissions',+ label: 'Close By Submissions',+ format: 'number',+ },+ { key: 'is_published', label: 'Is Published', format: 'boolean' },+ { key: 'never_published', label: 'Never Published', format: 'boolean' },+ { key: 'published_at', label: 'Published At', format: 'datetime' },+ { key: 'page_url', label: 'Page URL', format: 'url' },+ { key: 'custom_url', label: 'Custom URL', format: 'url' },+ { key: 'webhook_url', label: 'Webhook URL', format: 'url' },+ {+ key: 'submissions_count',+ label: 'Submissions Count',+ format: 'number',+ },+ {+ key: 'analytics',+ label: 'Analytics',+ children: [+ { key: 'views', label: 'Views', format: 'number' },+ { key: 'starts', label: 'Starts', format: 'number' },+ { key: 'submissions', label: 'Submissions', format: 'number' },+ {+ key: 'avg_completion_time',+ label: 'Average Completion Time',+ format: 'number',+ },+ ],+ },+ { key: 'refill_link_enabled', label: 'Refill Link Enabled' },+ {+ key: 'report_sharing_enabled',+ label: 'Report Sharing Enabled',+ format: 'number',+ },+ { key: 'email_notification', label: 'Email Notification' },+ { key: 'google_sheet_id', label: 'Google Sheet ID' },+ { key: 'slack_channel', label: 'Slack Channel' },+ { key: 'notion_database_id', label: 'Notion Database ID' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },+ { key: 'deleted_at', label: 'Deleted At', format: 'datetime' },+ ],+ },+ ],+};++export const youformListFormsOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'data',+ label: 'Forms',+ labelKey: 'name',+ listItems: [+ { key: 'id', label: 'Form ID' },+ { key: 'slug', label: 'Slug' },+ { key: 'name', label: 'Name' },+ { key: 'closed', label: 'Closed' },+ {+ key: 'submissions_count',+ label: 'Submissions Count',+ format: 'number',+ },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },+ ],+ },+ ...paginationFields,+ ],+};++export const youformListSubmissionsOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'data',+ label: 'Submissions',+ labelKey: 'id',+ listItems: [+ { key: 'id', label: 'Submission ID' },+ { key: 'uid', label: 'Submission UID' },+ { key: 'form_id', label: 'Form ID' },+ { key: 'data', label: 'Answers', dynamicKey: true },+ { key: 'is_complete', label: 'Is Complete', format: 'number' },+ { key: 'is_test', label: 'Is Test', format: 'number' },+ { key: 'refill_link_enabled', label: 'Refill Link Enabled' },+ { key: 'started_at', label: 'Started At', format: 'datetime' },+ { key: 'completed_at', label: 'Completed At', format: 'datetime' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },+ { key: 'deleted_at', label: 'Deleted At', format: 'datetime' },+ { key: 'session_id', label: 'Session ID' },+ { key: 'country_code', label: 'Country Code' },+ { key: 'device_type', label: 'Device Type' },+ { key: 'platform', label: 'Platform' },+ { key: 'platform_version', label: 'Platform Version' },+ { key: 'browser', label: 'Browser' },+ { key: 'browser_version', label: 'Browser Version' },+ { key: 'user_agent', label: 'User Agent' },+ ],+ },+ ...paginationFields,+ ],+};++export const newSubmissionOutputSchema: OutputSchema = {+ fields: [+ { key: 'event_id', label: 'Event ID' },+ { key: 'event_type', label: 'Event Type' },+ { key: 'form_id', label: 'Form ID' },+ { key: 'form_name', label: 'Form Name' },+ { key: 'submission_id', label: 'Submission ID' },+ { key: 'started_at', label: 'Started At', format: 'datetime' },+ { key: 'completed_at', label: 'Completed At', format: 'datetime' },+ { key: 'answers', label: 'Answers by Question', dynamicKey: true },+ {+ key: 'fields',+ label: 'Fields',+ labelKey: 'question',+ listItems: [+ { key: 'id', label: 'Block ID' },+ { key: 'type', label: 'Type' },+ { key: 'question', label: 'Question' },+ { key: 'description', label: 'Description' },+ { key: 'position', label: 'Position', format: 'number' },+ { key: 'answer', label: 'Answer' },+ { key: 'answer_text', label: 'Answer Text' },+ { key: 'is_email', label: 'Is Email', format: 'boolean' },+ { key: 'validate_email', label: 'Validate Email', format: 'boolean' },+ ],+ },+ ],+};diff --git a/packages/pieces/community/youform/src/lib/triggers/new-form-submission.ts b/packages/pieces/community/youform/src/lib/triggers/new-form-submission.tsindex 6c775ad6e31..667cf5e9929 100644--- a/packages/pieces/community/youform/src/lib/triggers/new-form-submission.ts+++ b/packages/pieces/community/youform/src/lib/triggers/new-form-submission.ts@@ -1,19 +1,15 @@import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';-import { youformAuth } from '../common/auth';-import { formIdDropdown } from '../common/props';-import {- AuthenticationType,- httpClient,- HttpMethod,-} from '@activepieces/pieces-common';-import { BASE_URL } from '../common/constants';-import { CreateWebhookResponse } from '../common/types';+import { youformAuth } from '../auth';+import { youformProps } from '../common/props';+import { youformApi } from '../common/api';import { isNil } from '@activepieces/pieces-framework';+import { newSubmissionOutputSchema } from '../output-schemas';const TRIGGER_KEY = 'youform-new-submission-trigger';export const newSubmissionTrigger = createTrigger({name: 'new-submission',+ outputSchema: newSubmissionOutputSchema,classification: 'READ',auth: youformAuth,displayName: 'New Submission',@@ -24,26 +20,18 @@ export const newSubmissionTrigger = createTrigger({},type: TriggerStrategy.WEBHOOK,props: {- formId: formIdDropdown,+ formId: youformProps.formId({ required: true }),},async onEnable(context) {const { formId } = context.propsValue;- const response = await httpClient.sendRequest<CreateWebhookResponse>({- method: HttpMethod.POST,- url: BASE_URL + '/webhooks',- authentication: {- type: AuthenticationType.BEARER_TOKEN,- token: context.auth.secret_text,- },- body:{},- queryParams: {- form_id: formId.toString(),- webhook_url: context.webhookUrl,- },+ const response = await youformApi.createWebhook({+ auth: context.auth,+ formId: formId.toString(),+ webhookUrl: context.webhookUrl,});- const webhookId = response.body.data.id;+ const webhookId = response.data.id;await context.store.put<number>(TRIGGER_KEY, webhookId);},@@ -51,13 +39,9 @@ export const newSubmissionTrigger = createTrigger({const webhookId = await context.store.get<number>(TRIGGER_KEY);if (!isNil(webhookId)) {- await httpClient.sendRequest<CreateWebhookResponse>({- method: HttpMethod.DELETE,- url: BASE_URL + `/webhooks/${webhookId}`,- authentication: {- type: AuthenticationType.BEARER_TOKEN,- token: context.auth.secret_text,- },+ await youformApi.deleteWebhook({+ auth: context.auth,+ webhookId,});}},