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(typeform): manage forms, responses, workspaces, themes and images (#15734)
Kishan Parmar07f10819dd99
diff --git a/bun.lock b/bun.lockindex efe97ce9f77..941863274f0 100644--- a/bun.lock+++ b/bun.lock@@ -9286,7 +9286,7 @@},"packages/pieces/community/typeform": {"name": "@activepieces/piece-typeform",- "version": "0.5.0",+ "version": "0.6.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",diff --git a/packages/pieces/community/typeform/package.json b/packages/pieces/community/typeform/package.jsonindex f76daeb7a61..1a85ab47068 100644--- a/packages/pieces/community/typeform/package.json+++ b/packages/pieces/community/typeform/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-typeform",- "version": "0.5.0",+ "version": "0.6.0","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {diff --git a/packages/pieces/community/typeform/src/index.ts b/packages/pieces/community/typeform/src/index.tsindex bfc26daa19f..a31bb824ecb 100644--- a/packages/pieces/community/typeform/src/index.ts+++ b/packages/pieces/community/typeform/src/index.ts@@ -1,27 +1,72 @@import { createCustomApiCallAction } from '@activepieces/pieces-common';-import {- OAuth2PropertyValue,- PieceAuth,- createPiece,-} from '@activepieces/pieces-framework';-import { PieceCategory } from '@activepieces/pieces-framework';+import { createPiece, PieceCategory } from '@activepieces/pieces-framework';+import { typeformAuth } from './lib/auth';import { typeformNewSubmission } from './lib/trigger/new-submission';+import { createFormAction } from './lib/actions/create-form';+import { createThemeAction } from './lib/actions/create-theme';+import { createWorkspaceAction } from './lib/actions/create-workspace';+import { deleteFormAction } from './lib/actions/delete-form';+import { deleteImageAction } from './lib/actions/delete-image';+import { deleteResponsesAction } from './lib/actions/delete-responses';+import { deleteThemeAction } from './lib/actions/delete-theme';+import { deleteWorkspaceAction } from './lib/actions/delete-workspace';+import { duplicateFormAction } from './lib/actions/duplicate-form';+import { getFormMessagesAction } from './lib/actions/get-form-messages';+import { getFormAction } from './lib/actions/get-form';+import { getImageAction } from './lib/actions/get-image';+import { getMeAction } from './lib/actions/get-me';+import { getThemeAction } from './lib/actions/get-theme';+import { getWorkspaceAction } from './lib/actions/get-workspace';+import { listFormsAction } from './lib/actions/list-forms';+import { listImagesAction } from './lib/actions/list-images';+import { listResponsesAction } from './lib/actions/list-responses';+import { listThemesAction } from './lib/actions/list-themes';+import { listWorkspacesAction } from './lib/actions/list-workspaces';+import { replaceFormAction } from './lib/actions/replace-form';+import { updateChoiceOptionsAction } from './lib/actions/update-choice-options';+import { updateFormMessagesAction } from './lib/actions/update-form-messages';+import { updateFormAction } from './lib/actions/update-form';+import { updateThemeAction } from './lib/actions/update-theme';+import { updateWorkspaceAction } from './lib/actions/update-workspace';+import { uploadImageAction } from './lib/actions/upload-image';-export const typeformAuth = PieceAuth.OAuth2({- required: true,- tokenUrl: 'https://api.typeform.com/oauth/token',- authUrl: 'https://admin.typeform.com/oauth/authorize',- scope: ['webhooks:write', 'forms:read'],-});+export { typeformAuth };export const typeform = createPiece({displayName: 'Typeform',description: 'Create beautiful online forms and surveys',- minimumSupportedRelease: '0.30.0',+ minimumSupportedRelease: '0.87.0',logoUrl: 'https://cdn.activepieces.com/pieces/typeform.png',categories: [PieceCategory.FORMS_AND_SURVEYS],actions: [+ getMeAction,+ listFormsAction,+ getFormAction,+ createFormAction,+ updateFormAction,+ replaceFormAction,+ duplicateFormAction,+ updateChoiceOptionsAction,+ deleteFormAction,+ getFormMessagesAction,+ updateFormMessagesAction,+ listResponsesAction,+ deleteResponsesAction,+ listWorkspacesAction,+ getWorkspaceAction,+ createWorkspaceAction,+ updateWorkspaceAction,+ deleteWorkspaceAction,+ listThemesAction,+ getThemeAction,+ createThemeAction,+ updateThemeAction,+ deleteThemeAction,+ listImagesAction,+ getImageAction,+ uploadImageAction,+ deleteImageAction,createCustomApiCallAction({baseUrl: () => 'https://api.typeform.com',auth: typeformAuth,diff --git a/packages/pieces/community/typeform/src/lib/actions/create-form.ts b/packages/pieces/community/typeform/src/lib/actions/create-form.tsnew file mode 100644index 00000000000..1aa4d315fa8--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/create-form.ts@@ -0,0 +1,51 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { formOutputSchema } from '../output-schemas';++export const createFormAction = createAction({+ auth: typeformAuth,+ name: 'create_form',+ classification: 'WRITE',+ displayName: 'Create Form',+ description: 'Creates a new form, empty or with questions.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Create a new Typeform form with a title, optionally in a workspace, with a theme and with questions. Questions are a JSON array of Typeform field objects, for example [{"title":"Your email?","type":"email","validations":{"required":true}}]; leave empty for an empty form. Returns the new form with its ID and share link. Each call creates another form.',+ idempotent: false,+ },+ outputSchema: formOutputSchema,+ props: {+ title: Property.ShortText({+ displayName: 'Title',+ required: true,+ }),+ workspace: typeformCommon.workspace,+ theme: typeformCommon.theme,+ fields: Property.Json({+ displayName: 'Questions',+ description:+ 'JSON array of Typeform field objects, as documented in the Typeform Create API. Leave empty for an empty form.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ const { title, workspace, theme, fields } = propsValue;+ if (fields !== undefined && fields !== null && !Array.isArray(fields)) {+ throw new Error('Questions must be a JSON array of field objects.');+ }+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.POST,+ path: '/forms',+ body: {+ title,+ ...(typeformCommon.isProvided(workspace) ? { workspace: typeformCommon.toHref({ resource: 'workspaces', id: workspace }) } : {}),+ ...(typeformCommon.isProvided(theme) ? { theme: typeformCommon.toHref({ resource: 'themes', id: theme }) } : {}),+ ...(Array.isArray(fields) && fields.length > 0 ? { fields } : {}),+ },+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/create-theme.ts b/packages/pieces/community/typeform/src/lib/actions/create-theme.tsnew file mode 100644index 00000000000..2b6d52d4410--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/create-theme.ts@@ -0,0 +1,64 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { themeOutputSchema } from '../output-schemas';++export const createThemeAction = createAction({+ auth: typeformAuth,+ name: 'create_theme',+ classification: 'WRITE',+ displayName: 'Create Theme',+ description: 'Creates a custom theme.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Create a private Typeform theme with a name, font, the four colors (question, answer, button, background, as hex like #3D3D3D) and alignment and font size for questions and screens. Alignment defaults to left and font size to medium. Apply it to a form with Update Form. Each call creates another theme.',+ idempotent: false,+ },+ outputSchema: themeOutputSchema,+ props: {+ ...typeformCommon.themeFields,+ name: Property.ShortText({+ displayName: 'Name',+ required: true,+ }),+ questionColor: Property.ShortText({+ displayName: 'Question Color',+ description: 'Hex color, for example #3D3D3D.',+ required: true,+ }),+ answerColor: Property.ShortText({+ displayName: 'Answer Color',+ description: 'Hex color.',+ required: true,+ }),+ buttonColor: Property.ShortText({+ displayName: 'Button Color',+ description: 'Hex color.',+ required: true,+ }),+ backgroundColor: Property.ShortText({+ displayName: 'Background Color',+ description: 'Hex color.',+ required: true,+ }),+ },+ async run({ auth, propsValue }) {+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.POST,+ path: '/themes',+ body: typeformCommon.themeBody({+ values: {+ ...propsValue,+ fieldAlignment: propsValue.fieldAlignment ?? 'left',+ fieldFontSize: propsValue.fieldFontSize ?? 'medium',+ screenAlignment: propsValue.screenAlignment ?? 'left',+ screenFontSize: propsValue.screenFontSize ?? 'medium',+ },+ current: {},+ }),+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/create-workspace.ts b/packages/pieces/community/typeform/src/lib/actions/create-workspace.tsnew file mode 100644index 00000000000..cc721f3ae03--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/create-workspace.ts@@ -0,0 +1,42 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { workspaceOutputSchema } from '../output-schemas';++export const createWorkspaceAction = createAction({+ auth: typeformAuth,+ name: 'create_workspace',+ classification: 'WRITE',+ displayName: 'Create Workspace',+ description: 'Creates a new workspace.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Create a Typeform workspace to group forms. By default it goes in the account the connected user owns; set Account ID (account_id from List Workspaces) to create it in another account the user belongs to. Returns the new workspace with its ID. Each call creates another workspace.',+ idempotent: false,+ },+ outputSchema: workspaceOutputSchema,+ props: {+ name: Property.ShortText({+ displayName: 'Name',+ required: true,+ }),+ accountId: Property.ShortText({+ displayName: 'Account ID',+ description: 'account_id from List Workspaces. Leave empty for your own account.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ const { name, accountId } = propsValue;+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.POST,+ path: typeformCommon.isProvided(accountId)+ ? `/accounts/${encodeURIComponent(accountId.trim())}/workspaces`+ : '/workspaces',+ body: { name },+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/delete-form.ts b/packages/pieces/community/typeform/src/lib/actions/delete-form.tsnew file mode 100644index 00000000000..85d619fea97--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/delete-form.ts@@ -0,0 +1,31 @@+import { createAction } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon } from '../common';+import { deleteFormOutputSchema } from '../output-schemas';++export const deleteFormAction = createAction({+ auth: typeformAuth,+ name: 'delete_form',+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Form',+ description: 'Permanently deletes a form and all of its responses.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Permanently delete a Typeform form together with all of its responses. Cannot be undone; confirm with the user first. To stop new responses without losing data, use Update Form with Public set to Closed instead.',+ idempotent: false,+ },+ outputSchema: deleteFormOutputSchema,+ props: {+ form_id: typeformCommon.formId,+ },+ async run({ auth, propsValue }) {+ await typeformCommon.typeformRequest<unknown>({+ token: auth.access_token,+ method: HttpMethod.DELETE,+ path: `/forms/${encodeURIComponent(propsValue.form_id)}`,+ });+ return { deleted: true, form_id: propsValue.form_id };+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/delete-image.ts b/packages/pieces/community/typeform/src/lib/actions/delete-image.tsnew file mode 100644index 00000000000..9bb2892cdd1--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/delete-image.ts@@ -0,0 +1,36 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon } from '../common';+import { deleteImageOutputSchema } from '../output-schemas';++export const deleteImageAction = createAction({+ auth: typeformAuth,+ name: 'delete_image',+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Image',+ description: 'Deletes an image from the Typeform account.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Delete an image from the Typeform account by ID. Forms and themes that use it may show it missing. Cannot be undone; confirm with the user first.',+ idempotent: false,+ },+ outputSchema: deleteImageOutputSchema,+ props: {+ imageId: Property.ShortText({+ displayName: 'Image ID',+ description: 'Image ID, from List Images.',+ required: true,+ }),+ },+ async run({ auth, propsValue }) {+ const imageId = propsValue.imageId.trim();+ await typeformCommon.typeformRequest<unknown>({+ token: auth.access_token,+ method: HttpMethod.DELETE,+ path: `/images/${encodeURIComponent(imageId)}`,+ });+ return { deleted: true, image_id: imageId };+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/delete-responses.ts b/packages/pieces/community/typeform/src/lib/actions/delete-responses.tsnew file mode 100644index 00000000000..16422f97faf--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/delete-responses.ts@@ -0,0 +1,40 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon } from '../common';+import { deleteResponsesOutputSchema } from '../output-schemas';++export const deleteResponsesAction = createAction({+ auth: typeformAuth,+ name: 'delete_responses',+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Responses',+ description: 'Permanently deletes responses from a form.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Permanently delete up to 1000 responses from a Typeform form by response ID (the response_id or token from Find Responses). Typeform deletes them in the background, so the result only means the request was accepted; unknown IDs are ignored. Check with Find Responses afterwards. Cannot be undone; confirm with the user first.',+ idempotent: false,+ },+ outputSchema: deleteResponsesOutputSchema,+ props: {+ form_id: typeformCommon.formId,+ responseIds: Property.Array({+ displayName: 'Response IDs',+ required: true,+ }),+ },+ async run({ auth, propsValue }) {+ const ids = typeformCommon.toStringList({ values: propsValue.responseIds });+ if (ids.length === 0 || ids.length > 1000) {+ throw new Error('Response IDs must contain between 1 and 1000 IDs.');+ }+ await typeformCommon.typeformRequest<unknown>({+ token: auth.access_token,+ method: HttpMethod.DELETE,+ path: `/forms/${encodeURIComponent(propsValue.form_id)}/responses`,+ queryParams: { included_response_ids: ids.join(',') },+ });+ return { registered: true, form_id: propsValue.form_id, response_ids: ids, count: ids.length };+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/delete-theme.ts b/packages/pieces/community/typeform/src/lib/actions/delete-theme.tsnew file mode 100644index 00000000000..de5c0472797--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/delete-theme.ts@@ -0,0 +1,40 @@+import { createAction } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { deleteThemeOutputSchema } from '../output-schemas';++export const deleteThemeAction = createAction({+ auth: typeformAuth,+ name: 'delete_theme',+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Theme',+ description: 'Deletes a custom theme.',+ audience: 'ai',+ aiMetadata: {+ description:+ "Delete a private Typeform theme. Typeform's public preset themes cannot be deleted. Cannot be undone; confirm with the user first.",+ idempotent: false,+ },+ outputSchema: deleteThemeOutputSchema,+ props: {+ themeId: typeformCommon.requiredThemeId,+ },+ async run({ auth, propsValue }) {+ const path = `/themes/${encodeURIComponent(propsValue.themeId.trim())}`;+ const current = await typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path,+ });+ if (current['visibility'] === 'public') {+ throw new Error("This is one of Typeform's public themes and cannot be deleted.");+ }+ await typeformCommon.typeformRequest<unknown>({+ token: auth.access_token,+ method: HttpMethod.DELETE,+ path,+ });+ return { deleted: true, theme_id: propsValue.themeId.trim() };+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/delete-workspace.ts b/packages/pieces/community/typeform/src/lib/actions/delete-workspace.tsnew file mode 100644index 00000000000..f771626669b--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/delete-workspace.ts@@ -0,0 +1,47 @@+import { createAction } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { deleteWorkspaceOutputSchema } from '../output-schemas';++export const deleteWorkspaceAction = createAction({+ auth: typeformAuth,+ name: 'delete_workspace',+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Workspace',+ description: 'Deletes an empty workspace.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Delete an empty Typeform workspace. Typeform would delete every form in a workspace and all their responses along with it, so this action refuses workspaces that still contain forms; move them with Update Form or delete them first. The default workspace cannot be deleted. Cannot be undone; confirm with the user first.',+ idempotent: false,+ },+ outputSchema: deleteWorkspaceOutputSchema,+ props: {+ workspace: typeformCommon.requiredWorkspaceId,+ },+ async run({ auth, propsValue }) {+ const path = `/workspaces/${encodeURIComponent(propsValue.workspace)}`;+ const current = await typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path,+ });+ if (current['default'] === true) {+ throw new Error('The default workspace cannot be deleted.');+ }+ const forms = current['forms'];+ const formCount = typeformCommon.isRecord(forms) && typeof forms['count'] === 'number' ? forms['count'] : 0;+ if (formCount > 0) {+ throw new Error(+ `This workspace still contains ${formCount} form(s), and deleting it would delete them and all their responses. Move them to another workspace with Update Form, or delete them first.`+ );+ }+ await typeformCommon.typeformRequest<unknown>({+ token: auth.access_token,+ method: HttpMethod.DELETE,+ path,+ });+ return { deleted: true, workspace_id: propsValue.workspace };+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/duplicate-form.ts b/packages/pieces/community/typeform/src/lib/actions/duplicate-form.tsnew file mode 100644index 00000000000..d0fb7e67392--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/duplicate-form.ts@@ -0,0 +1,45 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { formOutputSchema } from '../output-schemas';++export const duplicateFormAction = createAction({+ auth: typeformAuth,+ name: 'duplicate_form',+ classification: 'WRITE',+ displayName: 'Duplicate Form',+ description: 'Creates a copy of an existing form.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Create a copy of a Typeform form with the same questions, screens, logic, settings and theme, optionally with a new title and in another workspace. Responses, translations and webhooks are not copied. Returns the new form. Each call creates another copy.',+ idempotent: false,+ },+ outputSchema: formOutputSchema,+ props: {+ form_id: typeformCommon.form,+ title: Property.ShortText({+ displayName: 'New Title',+ description: 'Defaults to "Copy of" and the original title.',+ required: false,+ }),+ workspace: typeformCommon.workspace,+ },+ async run({ auth, propsValue }) {+ const { form_id, title, workspace } = propsValue;+ const source = await typeformCommon.getForm({ token: auth.access_token, formId: form_id });+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.POST,+ path: '/forms',+ body: {+ ...typeformCommon.toDuplicatePayload({ form: source }),+ title: typeformCommon.isProvided(title) ? title : `Copy of ${String(source['title'] ?? '')}`.trim(),+ ...(typeformCommon.isProvided(workspace)+ ? { workspace: typeformCommon.toHref({ resource: 'workspaces', id: workspace }) }+ : {}),+ },+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/get-form-messages.ts b/packages/pieces/community/typeform/src/lib/actions/get-form-messages.tsnew file mode 100644index 00000000000..d3ffc6192e8--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/get-form-messages.ts@@ -0,0 +1,28 @@+import { createAction } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';++export const getFormMessagesAction = createAction({+ auth: typeformAuth,+ name: 'get_form_messages',+ classification: 'READ',+ displayName: 'Get Form Messages',+ description: 'Gets the button labels, error messages and other texts of a form.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Get the custom interface texts of a Typeform form (button labels, error messages, placeholders), keyed like "label.buttonHint.default". Use it to see the keys before Update Form Messages. Read-only.',+ idempotent: true,+ },+ props: {+ form_id: typeformCommon.formId,+ },+ async run({ auth, propsValue }) {+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path: `/forms/${encodeURIComponent(propsValue.form_id)}/messages`,+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/get-form.ts b/packages/pieces/community/typeform/src/lib/actions/get-form.tsnew file mode 100644index 00000000000..eee71dd5715--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/get-form.ts@@ -0,0 +1,25 @@+import { createAction } from '@activepieces/pieces-framework';+import { typeformAuth } from '../auth';+import { typeformCommon } from '../common';+import { formOutputSchema } from '../output-schemas';++export const getFormAction = createAction({+ auth: typeformAuth,+ name: 'get_form',+ classification: 'READ',+ displayName: 'Get Form',+ description: 'Gets a form with its questions, logic and settings.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Get one Typeform form by ID with its questions (fields, with IDs, refs, types and choices), welcome and thank-you screens, logic, hidden fields, settings, theme and workspace. Use it before Replace Form or Update Choice Options, and to read field IDs for response answers. Read-only.',+ idempotent: true,+ },+ outputSchema: formOutputSchema,+ props: {+ form_id: typeformCommon.formId,+ },+ async run({ auth, propsValue }) {+ return typeformCommon.getForm({ token: auth.access_token, formId: propsValue.form_id });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/get-image.ts b/packages/pieces/community/typeform/src/lib/actions/get-image.tsnew file mode 100644index 00000000000..b5b0dca0f81--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/get-image.ts@@ -0,0 +1,35 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { imageOutputSchema } from '../output-schemas';++export const getImageAction = createAction({+ auth: typeformAuth,+ name: 'get_image',+ classification: 'READ',+ displayName: 'Get Image',+ description: 'Gets an image with its link and details.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Get one Typeform image by ID with its file name, media type, width, height and link (src). Read-only.',+ idempotent: true,+ },+ outputSchema: imageOutputSchema,+ props: {+ imageId: Property.ShortText({+ displayName: 'Image ID',+ description: 'Image ID, from List Images.',+ required: true,+ }),+ },+ async run({ auth, propsValue }) {+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path: `/images/${encodeURIComponent(propsValue.imageId.trim())}`,+ headers: { Accept: 'application/json' },+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/get-me.ts b/packages/pieces/community/typeform/src/lib/actions/get-me.tsnew file mode 100644index 00000000000..25b2a42058e--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/get-me.ts@@ -0,0 +1,28 @@+import { createAction } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { accountOutputSchema } from '../output-schemas';++export const getMeAction = createAction({+ auth: typeformAuth,+ name: 'get_me',+ classification: 'READ',+ displayName: 'Get Account',+ description: 'Gets the connected Typeform account.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Get the connected Typeform account: alias, email and language. Use it to confirm which account is connected. It does not return the account ID; use List Workspaces for that. Read-only.',+ idempotent: true,+ },+ outputSchema: accountOutputSchema,+ props: {},+ async run({ auth }) {+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path: '/me',+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/get-theme.ts b/packages/pieces/community/typeform/src/lib/actions/get-theme.tsnew file mode 100644index 00000000000..4c16c16a5de--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/get-theme.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { themeOutputSchema } from '../output-schemas';++export const getThemeAction = createAction({+ auth: typeformAuth,+ name: 'get_theme',+ classification: 'READ',+ displayName: 'Get Theme',+ description: 'Gets a theme with its colors, font and layout.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Get one Typeform theme by ID with its name, font, colors, question and screen alignment and font size, background and visibility. Read-only.',+ idempotent: true,+ },+ outputSchema: themeOutputSchema,+ props: {+ themeId: typeformCommon.requiredThemeId,+ },+ async run({ auth, propsValue }) {+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path: `/themes/${encodeURIComponent(propsValue.themeId.trim())}`,+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/get-workspace.ts b/packages/pieces/community/typeform/src/lib/actions/get-workspace.tsnew file mode 100644index 00000000000..3a41273beec--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/get-workspace.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { workspaceOutputSchema } from '../output-schemas';++export const getWorkspaceAction = createAction({+ auth: typeformAuth,+ name: 'get_workspace',+ classification: 'READ',+ displayName: 'Get Workspace',+ description: 'Gets a workspace with its members.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Get one Typeform workspace by ID with its name, account ID, default and shared flags, form count and members with their roles. Use List Forms with this workspace to see its forms. Read-only.',+ idempotent: true,+ },+ outputSchema: workspaceOutputSchema,+ props: {+ workspace: typeformCommon.requiredWorkspaceId,+ },+ async run({ auth, propsValue }) {+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path: `/workspaces/${encodeURIComponent(propsValue.workspace)}`,+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/list-forms.ts b/packages/pieces/community/typeform/src/lib/actions/list-forms.tsnew file mode 100644index 00000000000..006a234289e--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/list-forms.ts@@ -0,0 +1,68 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformPage, TypeformRecord } from '../common';+import { formsOutputSchema } from '../output-schemas';++export const listFormsAction = createAction({+ auth: typeformAuth,+ name: 'list_forms',+ classification: 'SEARCH',+ displayName: 'List Forms',+ description: 'Lists forms in the Typeform account.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'List Typeform forms with each ID, title, public status, created and updated time and share link. Filter by title text and workspace, sort by created or updated time. Paginated with Page and Page Size (up to 200); total_items and page_count show how many pages exist. Use Get Form for the questions. Read-only.',+ idempotent: true,+ },+ outputSchema: formsOutputSchema,+ props: {+ search: Property.ShortText({+ displayName: 'Search',+ description: 'Only forms whose title contains this text.',+ required: false,+ }),+ workspace: typeformCommon.workspaceId,+ sortBy: Property.StaticDropdown({+ displayName: 'Sort By',+ required: false,+ options: {+ options: [+ { label: 'Created at', value: 'created_at' },+ { label: 'Last updated at', value: 'last_updated_at' },+ ],+ },+ }),+ orderBy: Property.StaticDropdown({+ displayName: 'Order',+ required: false,+ options: {+ options: [+ { label: 'Ascending', value: 'asc' },+ { label: 'Descending', value: 'desc' },+ ],+ },+ }),+ page: typeformCommon.page,+ pageSize: typeformCommon.pageSize,+ },+ async run({ auth, propsValue }) {+ return typeformCommon.typeformRequest<TypeformPage<TypeformRecord>>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path: '/forms',+ queryParams: {+ search: propsValue.search?.trim(),+ workspace_id: propsValue.workspace,+ sort_by: propsValue.sortBy,+ order_by: propsValue.orderBy,+ ...typeformCommon.pageQuery({+ page: propsValue.page,+ pageSize: propsValue.pageSize,+ maxPageSize: typeformCommon.maxPageSize,+ }),+ },+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/list-images.ts b/packages/pieces/community/typeform/src/lib/actions/list-images.tsnew file mode 100644index 00000000000..197d095700e--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/list-images.ts@@ -0,0 +1,37 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { imagesOutputSchema } from '../output-schemas';++export const listImagesAction = createAction({+ auth: typeformAuth,+ name: 'list_images',+ classification: 'SEARCH',+ displayName: 'List Images',+ description: 'Lists images uploaded to the Typeform account.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'List images uploaded to the Typeform account, newest first, with each ID, file name and link. Typeform returns them all at once; Limit caps how many are returned. Read-only.',+ idempotent: true,+ },+ outputSchema: imagesOutputSchema,+ props: {+ limit: Property.Number({+ displayName: 'Limit',+ description: 'Maximum number of images to return. Default 50.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ const images = await typeformCommon.typeformRequest<TypeformRecord[]>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path: '/images',+ });+ const limit = Math.max(1, Math.floor(propsValue.limit ?? 50));+ const items = images.slice(0, limit);+ return { items, count: items.length, total_items: images.length };+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/list-responses.ts b/packages/pieces/community/typeform/src/lib/actions/list-responses.tsnew file mode 100644index 00000000000..4361993a076--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/list-responses.ts@@ -0,0 +1,96 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformPage, TypeformRecord } from '../common';+import { responsesOutputSchema } from '../output-schemas';++export const listResponsesAction = createAction({+ auth: typeformAuth,+ name: 'list_responses',+ classification: 'SEARCH',+ displayName: 'Find Responses',+ description: 'Looks up responses to a form.',+ audience: 'both',+ aiMetadata: {+ description:+ 'List responses to one Typeform form, newest first by default, with answers (each tied to a field ID from Get Form), hidden fields, score, submitted and landed time. Filter by text in the answers, a submitted time range, response type and response IDs. Responses from the last ~30 minutes may be missing; use the New Submission trigger for real-time data. Page Size up to 1000; for the next page pass the last token as Before. Read-only.',+ idempotent: true,+ },+ outputSchema: responsesOutputSchema,+ props: {+ form_id: typeformCommon.form,+ query: Property.ShortText({+ displayName: 'Search',+ description: 'Only responses containing this text in any answer or hidden field.',+ required: false,+ }),+ since: Property.DateTime({+ displayName: 'Submitted After',+ required: false,+ }),+ until: Property.DateTime({+ displayName: 'Submitted Before',+ required: false,+ }),+ responseType: Property.StaticDropdown({+ displayName: 'Response Type',+ required: false,+ options: {+ options: [+ { label: 'Completed', value: 'completed' },+ { label: 'Partial', value: 'partial' },+ { label: 'Started', value: 'started' },+ ],+ },+ }),+ includedResponseIds: Property.Array({+ displayName: 'Response IDs',+ description: 'Only these responses.',+ required: false,+ }),+ sort: Property.StaticDropdown({+ displayName: 'Sort',+ required: false,+ options: {+ options: [+ { label: 'Submitted, newest first', value: 'submitted_at,desc' },+ { label: 'Submitted, oldest first', value: 'submitted_at,asc' },+ ],+ },+ }),+ pageSize: Property.Number({+ displayName: 'Page Size',+ description: 'How many responses to return, from 1 to 1000. Default 25.',+ required: false,+ }),+ before: Property.ShortText({+ displayName: 'Before',+ description: 'Token of a response. Returns responses older than it, for the next page.',+ required: false,+ }),+ after: Property.ShortText({+ displayName: 'After',+ description: 'Token of a response. Returns responses newer than it.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ const ids = typeformCommon.toStringList({ values: propsValue.includedResponseIds });+ return typeformCommon.typeformRequest<TypeformPage<TypeformRecord>>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path: `/forms/${encodeURIComponent(propsValue.form_id)}/responses`,+ queryParams: {+ query: propsValue.query?.trim(),+ since: propsValue.since,+ until: propsValue.until,+ response_type: propsValue.responseType,+ included_response_ids: ids.length > 0 ? ids.join(',') : undefined,+ sort: propsValue.sort,+ before: propsValue.before?.trim(),+ after: propsValue.after?.trim(),+ page_size: typeformCommon.pageQuery({ page: undefined, pageSize: propsValue.pageSize, maxPageSize: 1000 })['page_size'],+ },+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/list-themes.ts b/packages/pieces/community/typeform/src/lib/actions/list-themes.tsnew file mode 100644index 00000000000..f3a5c51a4d4--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/list-themes.ts@@ -0,0 +1,36 @@+import { createAction } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformPage, TypeformRecord } from '../common';+import { themesOutputSchema } from '../output-schemas';++export const listThemesAction = createAction({+ auth: typeformAuth,+ name: 'list_themes',+ classification: 'SEARCH',+ displayName: 'List Themes',+ description: 'Lists themes available to the Typeform account.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'List Typeform themes with each ID, name, font, colors and visibility: private themes belong to the account and can be edited, public ones are Typeform presets. Paginated with Page and Page Size (up to 200). Read-only.',+ idempotent: true,+ },+ outputSchema: themesOutputSchema,+ props: {+ page: typeformCommon.page,+ pageSize: typeformCommon.pageSize,+ },+ async run({ auth, propsValue }) {+ return typeformCommon.typeformRequest<TypeformPage<TypeformRecord>>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path: '/themes',+ queryParams: typeformCommon.pageQuery({+ page: propsValue.page,+ pageSize: propsValue.pageSize,+ maxPageSize: typeformCommon.maxPageSize,+ }),+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/list-workspaces.ts b/packages/pieces/community/typeform/src/lib/actions/list-workspaces.tsnew file mode 100644index 00000000000..c0f35cbf0b3--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/list-workspaces.ts@@ -0,0 +1,48 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformPage, TypeformRecord } from '../common';+import { workspacesOutputSchema } from '../output-schemas';++export const listWorkspacesAction = createAction({+ auth: typeformAuth,+ name: 'list_workspaces',+ classification: 'SEARCH',+ displayName: 'List Workspaces',+ description: 'Lists workspaces in the Typeform account.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'List Typeform workspaces with each ID, name, account ID, whether it is the default or shared workspace, and its form count. This is where the account ID for Create Workspace comes from. Filter by name, or by Account ID to list one account. Paginated with Page and Page Size (up to 200). Read-only.',+ idempotent: true,+ },+ outputSchema: workspacesOutputSchema,+ props: {+ search: Property.ShortText({+ displayName: 'Search',+ description: 'Only workspaces whose name contains this text.',+ required: false,+ }),+ accountId: Property.ShortText({+ displayName: 'Account ID',+ description: 'Only workspaces of this account (account_id from a workspace).',+ required: false,+ }),+ page: typeformCommon.page,+ pageSize: typeformCommon.pageSize,+ },+ async run({ auth, propsValue }) {+ const { search, accountId, page, pageSize } = propsValue;+ return typeformCommon.typeformRequest<TypeformPage<TypeformRecord>>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path: typeformCommon.isProvided(accountId)+ ? `/accounts/${encodeURIComponent(accountId.trim())}/workspaces`+ : '/workspaces',+ queryParams: {+ search: search?.trim(),+ ...typeformCommon.pageQuery({ page, pageSize, maxPageSize: typeformCommon.maxPageSize }),+ },+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/replace-form.ts b/packages/pieces/community/typeform/src/lib/actions/replace-form.tsnew file mode 100644index 00000000000..0d064061f09--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/replace-form.ts@@ -0,0 +1,63 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { formOutputSchema } from '../output-schemas';++export const replaceFormAction = createAction({+ auth: typeformAuth,+ name: 'replace_form',+ classification: 'DESTRUCTIVE',+ displayName: 'Replace Form',+ description: "Replaces a form's whole definition, including its questions.",+ audience: 'ai',+ aiMetadata: {+ description:+ "Replace a Typeform form's whole definition (title, fields, screens, logic, settings) with the JSON you send. Call Get Form first and edit that result: any existing field missing from the definition, or sent without its original id, is deleted together with all its answers. The action refuses to delete fields unless Allow Field Deletion is on. The current theme is kept when the definition has none. For title, theme, workspace or public status use Update Form instead.",+ idempotent: true,+ },+ outputSchema: formOutputSchema,+ props: {+ form_id: typeformCommon.formId,+ definition: Property.Json({+ displayName: 'Form Definition',+ description: 'The full form JSON from Get Form, with your changes. Must include title.',+ required: true,+ }),+ allowFieldDeletion: Property.Checkbox({+ displayName: 'Allow Field Deletion',+ description: 'Allow removing existing questions. Their responses are deleted too.',+ required: false,+ defaultValue: false,+ }),+ },+ async run({ auth, propsValue }) {+ const { form_id, definition, allowFieldDeletion } = propsValue;+ if (!typeformCommon.isRecord(definition)) {+ throw new Error('Form Definition must be a JSON object.');+ }+ if (typeof definition['title'] !== 'string' || definition['title'].trim().length === 0) {+ throw new Error('Form Definition must include a title.');+ }+ const current = await typeformCommon.getForm({ token: auth.access_token, formId: form_id });+ const keptIds = typeformCommon.fieldIds({ fields: definition['fields'] });+ const removed = typeformCommon+ .flattenFields({ fields: current['fields'] })+ .filter((field) => typeof field['id'] === 'string' && !keptIds.includes(field['id']));+ if (removed.length > 0 && allowFieldDeletion !== true) {+ const names = removed.map((field) => `"${String(field['title'] ?? field['id'])}" (${String(field['id'])})`);+ throw new Error(+ `This would delete ${removed.length} question(s) and their responses: ${names.join(', ')}. Keep their ids in the definition, or turn on Allow Field Deletion.`+ );+ }+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.PUT,+ path: `/forms/${encodeURIComponent(form_id)}`,+ body: {+ ...typeformCommon.toFormPayload({ form: definition }),+ ...(definition['theme'] === undefined && current['theme'] !== undefined ? { theme: current['theme'] } : {}),+ },+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/update-choice-options.ts b/packages/pieces/community/typeform/src/lib/actions/update-choice-options.tsnew file mode 100644index 00000000000..d8767fc9216--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/update-choice-options.ts@@ -0,0 +1,91 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { formOutputSchema } from '../output-schemas';++export const updateChoiceOptionsAction = createAction({+ auth: typeformAuth,+ name: 'update_choice_options',+ classification: 'WRITE',+ displayName: 'Update Choice Options',+ description: 'Replaces the options of a dropdown, multiple choice or ranking question.',+ audience: 'both',+ aiMetadata: {+ description:+ 'Replace the list of options of one dropdown, multiple choice, ranking or picture choice question in a Typeform form; the question is found by field ID or ref from Get Form, including inside question groups. Options whose label already exists keep their id, so their past answers stay linked. The rest of the form is unchanged, but an edit made in Typeform at the same moment can be lost. Returns the updated form.',+ idempotent: true,+ },+ outputSchema: formOutputSchema,+ props: {+ form_id: typeformCommon.form,+ field: typeformCommon.choiceField,+ choices: Property.Array({+ displayName: 'Options',+ description: 'The full new list of option labels, in order.',+ required: true,+ }),+ },+ async run({ auth, propsValue }) {+ const { form_id, field, choices } = propsValue;+ const labels = typeformCommon.toStringList({ values: choices });+ if (labels.length === 0) {+ throw new Error('Options must contain at least one label.');+ }+ const form = await typeformCommon.getForm({ token: auth.access_token, formId: form_id });+ const target = typeformCommon+ .flattenFields({ fields: form['fields'] })+ .find((item) => item['id'] === field.trim() || item['ref'] === field.trim());+ if (target === undefined) {+ throw new Error(`No question with field ID or ref "${field}" in this form.`);+ }+ if (!typeformCommon.choiceFieldTypes.includes(String(target['type']))) {+ throw new Error(`Question "${String(target['title'])}" is a ${String(target['type'])} question, not a choice question.`);+ }+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.PUT,+ path: `/forms/${encodeURIComponent(form_id)}`,+ body: typeformCommon.toFormPayload({+ form: {+ ...form,+ fields: replaceChoices({ fields: form['fields'], targetId: target['id'], labels }),+ },+ }),+ });+ },+});++function replaceChoices({+ fields,+ targetId,+ labels,+}: {+ fields: unknown;+ targetId: unknown;+ labels: string[];+}): unknown {+ if (!Array.isArray(fields)) {+ return fields;+ }+ return fields.map((field) => {+ if (!typeformCommon.isRecord(field) || !typeformCommon.isRecord(field['properties'])) {+ return field;+ }+ const properties = field['properties'];+ if (field['id'] === targetId) {+ const existing = Array.isArray(properties['choices']) ? properties['choices'].filter(typeformCommon.isRecord) : [];+ return {+ ...field,+ properties: {+ ...properties,+ choices: labels.map((label) => existing.find((choice) => choice['label'] === label) ?? { label }),+ },+ };+ }+ if (Array.isArray(properties['fields'])) {+ return { ...field, properties: { ...properties, fields: replaceChoices({ fields: properties['fields'], targetId, labels }) } };+ }+ return field;+ });+}diff --git a/packages/pieces/community/typeform/src/lib/actions/update-form-messages.ts b/packages/pieces/community/typeform/src/lib/actions/update-form-messages.tsnew file mode 100644index 00000000000..427c123804d--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/update-form-messages.ts@@ -0,0 +1,46 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';++export const updateFormMessagesAction = createAction({+ auth: typeformAuth,+ name: 'update_form_messages',+ classification: 'WRITE',+ displayName: 'Update Form Messages',+ description: 'Changes button labels, error messages and other texts of a form.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Change some of the interface texts of a Typeform form. Send only the keys to change, as a JSON object like {"label.button.submit":"Send"}; keys come from Get Form Messages and the other texts stay as they are. Plain text only, no HTML. Returns all messages after the change.',+ idempotent: true,+ },+ props: {+ form_id: typeformCommon.formId,+ messages: Property.Json({+ displayName: 'Messages',+ description: 'JSON object of message keys and their new text.',+ required: true,+ }),+ },+ async run({ auth, propsValue }) {+ const { form_id, messages } = propsValue;+ if (!typeformCommon.isRecord(messages) || Object.keys(messages).length === 0) {+ throw new Error('Messages must be a JSON object with at least one key.');+ }+ const path = `/forms/${encodeURIComponent(form_id)}/messages`;+ const current = await typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path,+ });+ const merged = { ...current, ...messages };+ await typeformCommon.typeformRequest<unknown>({+ token: auth.access_token,+ method: HttpMethod.PUT,+ path,+ body: merged,+ });+ return merged;+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/update-form.ts b/packages/pieces/community/typeform/src/lib/actions/update-form.tsnew file mode 100644index 00000000000..0c001f3211e--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/update-form.ts@@ -0,0 +1,63 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon } from '../common';+import { formOutputSchema } from '../output-schemas';++export const updateFormAction = createAction({+ auth: typeformAuth,+ name: 'update_form',+ classification: 'WRITE',+ displayName: 'Update Form',+ description: "Changes a form's title, public status, theme or workspace.",+ audience: 'ai',+ aiMetadata: {+ description:+ "Change a Typeform form's title, public status (whether it accepts responses), theme or workspace. Only the fields you set change; questions are untouched. To change questions use Replace Form or Update Choice Options. Returns the updated form.",+ idempotent: true,+ },+ outputSchema: formOutputSchema,+ props: {+ form_id: typeformCommon.formId,+ title: Property.ShortText({+ displayName: 'Title',+ required: false,+ }),+ isPublic: Property.StaticDropdown({+ displayName: 'Public',+ description: 'Whether the form is open and accepts responses.',+ required: false,+ options: {+ options: [+ { label: 'Public', value: 'true' },+ { label: 'Closed', value: 'false' },+ ],+ },+ }),+ theme: typeformCommon.themeId,+ workspace: typeformCommon.workspaceId,+ },+ async run({ auth, propsValue }) {+ const { form_id, title, isPublic, theme, workspace } = propsValue;+ const operations = [+ ...(typeformCommon.isProvided(title) ? [{ op: 'replace', path: '/title', value: title }] : []),+ ...(typeformCommon.isProvided(isPublic) ? [{ op: 'replace', path: '/settings/is_public', value: isPublic === 'true' }] : []),+ ...(typeformCommon.isProvided(theme)+ ? [{ op: 'replace', path: '/theme', value: typeformCommon.toHref({ resource: 'themes', id: theme }) }]+ : []),+ ...(typeformCommon.isProvided(workspace)+ ? [{ op: 'replace', path: '/workspace', value: typeformCommon.toHref({ resource: 'workspaces', id: workspace }) }]+ : []),+ ];+ if (operations.length === 0) {+ throw new Error('Set at least one of Title, Public, Theme or Workspace.');+ }+ await typeformCommon.typeformRequest<unknown>({+ token: auth.access_token,+ method: HttpMethod.PATCH,+ path: `/forms/${encodeURIComponent(form_id)}`,+ body: operations,+ });+ return typeformCommon.getForm({ token: auth.access_token, formId: form_id });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/update-theme.ts b/packages/pieces/community/typeform/src/lib/actions/update-theme.tsnew file mode 100644index 00000000000..647bd2963ac--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/update-theme.ts@@ -0,0 +1,51 @@+import { createAction } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { themeOutputSchema } from '../output-schemas';++const THEME_KEYS = ['name', 'font', 'colors', 'fields', 'screens', 'background', 'has_transparent_button', 'rounded_corners'];++export const updateThemeAction = createAction({+ auth: typeformAuth,+ name: 'update_theme',+ classification: 'WRITE',+ displayName: 'Update Theme',+ description: 'Changes some settings of a custom theme.',+ audience: 'ai',+ aiMetadata: {+ description:+ "Change a private Typeform theme's name, font, colors, alignment or font sizes; only the settings you set change. Typeform's public preset themes cannot be edited. All forms using the theme change with it. Returns the updated theme.",+ idempotent: true,+ },+ outputSchema: themeOutputSchema,+ props: {+ themeId: typeformCommon.requiredThemeId,+ ...typeformCommon.themeFields,+ },+ async run({ auth, propsValue }) {+ const path = `/themes/${encodeURIComponent(propsValue.themeId.trim())}`;+ const current = await typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path,+ });+ if (current['visibility'] === 'public') {+ throw new Error("This is one of Typeform's public themes and cannot be edited. Create your own with Create Theme.");+ }+ const changes = typeformCommon.themeBody({ values: propsValue, current });+ if (Object.keys(changes).length === 0) {+ throw new Error('Set at least one setting to change.');+ }+ const body = {+ ...Object.fromEntries(Object.entries(current).filter(([key]) => THEME_KEYS.includes(key))),+ ...changes,+ };+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.PATCH,+ path,+ body,+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/update-workspace.ts b/packages/pieces/community/typeform/src/lib/actions/update-workspace.tsnew file mode 100644index 00000000000..f18d9d05b81--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/update-workspace.ts@@ -0,0 +1,42 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { workspaceOutputSchema } from '../output-schemas';++export const updateWorkspaceAction = createAction({+ auth: typeformAuth,+ name: 'update_workspace',+ classification: 'WRITE',+ displayName: 'Rename Workspace',+ description: 'Renames a workspace.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Rename a Typeform workspace. Its forms and members are unchanged. Returns the updated workspace.',+ idempotent: true,+ },+ outputSchema: workspaceOutputSchema,+ props: {+ workspace: typeformCommon.requiredWorkspaceId,+ name: Property.ShortText({+ displayName: 'Name',+ required: true,+ }),+ },+ async run({ auth, propsValue }) {+ const { workspace, name } = propsValue;+ const path = `/workspaces/${encodeURIComponent(workspace)}`;+ await typeformCommon.typeformRequest<unknown>({+ token: auth.access_token,+ method: HttpMethod.PATCH,+ path,+ body: [{ op: 'replace', path: '/name', value: name }],+ });+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.GET,+ path,+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/actions/upload-image.ts b/packages/pieces/community/typeform/src/lib/actions/upload-image.tsnew file mode 100644index 00000000000..59fbfa5cb86--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/actions/upload-image.ts@@ -0,0 +1,44 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { typeformAuth } from '../auth';+import { typeformCommon, TypeformRecord } from '../common';+import { imageOutputSchema } from '../output-schemas';++export const uploadImageAction = createAction({+ auth: typeformAuth,+ name: 'upload_image',+ classification: 'WRITE',+ displayName: 'Upload Image',+ description: 'Uploads an image to the Typeform account.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Upload an image to the Typeform account from a file or a public URL, to use in forms and themes. Returns the new image with its ID and link. Each call uploads another copy.',+ idempotent: false,+ },+ outputSchema: imageOutputSchema,+ props: {+ image: Property.File({+ displayName: 'Image',+ description: 'The image file, or a public URL to it.',+ required: true,+ }),+ fileName: Property.ShortText({+ displayName: 'File Name',+ description: "Defaults to the file's own name.",+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ const { image, fileName } = propsValue;+ return typeformCommon.typeformRequest<TypeformRecord>({+ token: auth.access_token,+ method: HttpMethod.POST,+ path: '/images',+ body: {+ file_name: typeformCommon.isProvided(fileName) ? fileName.trim() : image.filename,+ image: image.base64,+ },+ });+ },+});diff --git a/packages/pieces/community/typeform/src/lib/auth.ts b/packages/pieces/community/typeform/src/lib/auth.tsnew file mode 100644index 00000000000..c6c6d2669c3--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/auth.ts@@ -0,0 +1,22 @@+import { PieceAuth } from '@activepieces/pieces-framework';++export const typeformAuth = PieceAuth.OAuth2({+ required: true,+ tokenUrl: 'https://api.typeform.com/oauth/token',+ authUrl: 'https://admin.typeform.com/oauth/authorize',+ scope: [+ 'webhooks:write',+ 'forms:read',+ 'forms:write',+ 'accounts:read',+ 'responses:read',+ 'responses:write',+ 'workspaces:read',+ 'workspaces:write',+ 'themes:read',+ 'themes:write',+ 'images:read',+ 'images:write',+ 'offline',+ ],+});diff --git a/packages/pieces/community/typeform/src/lib/common/index.ts b/packages/pieces/community/typeform/src/lib/common/index.tsindex abca58029ae..555351f95b1 100644--- a/packages/pieces/community/typeform/src/lib/common/index.ts+++ b/packages/pieces/community/typeform/src/lib/common/index.ts@@ -1,25 +1,285 @@import {Property,- OAuth2PropertyValue,DropdownOption,- AppConnectionValueForAuthProperty,+ DropdownState,} from '@activepieces/pieces-framework';import {HttpRequest,HttpMethod,+ HttpError,AuthenticationType,httpClient,} from '@activepieces/pieces-common';-import { typeformAuth } from '../..';+import { typeformAuth } from '../auth';-type FormListResponse = {- page_count: number;- total_items: number;- items: {- id: string;- title: string;- }[];-};+async function typeformRequest<T>({+ token,+ method,+ path,+ queryParams,+ body,+ headers,+}: TypeformRequest): Promise<T> {+ const response = await httpClient+ .sendRequest<T>({+ method,+ url: `${BASE_URL}${path}`,+ queryParams: compactQuery({ query: queryParams ?? {} }),+ body,+ headers,+ authentication: { type: AuthenticationType.BEARER_TOKEN, token },+ })+ .catch((error: unknown) => {+ throw toTypeformError({ error });+ });+ return response.body;+}++async function fetchAllPages<T>({+ token,+ path,+ queryParams,+}: {+ token: string;+ path: string;+ queryParams?: Record<string, string | undefined>;+}): Promise<T[]> {+ const fetchPage = async (page: number): Promise<T[]> => {+ const response = await typeformRequest<TypeformPage<T>>({+ token,+ method: HttpMethod.GET,+ path,+ queryParams: { ...queryParams, page: String(page), page_size: String(MAX_PAGE_SIZE) },+ });+ const items = response.items ?? [];+ if (response.page_count === undefined || page >= response.page_count) {+ return items;+ }+ return [...items, ...(await fetchPage(page + 1))];+ };+ return fetchPage(1);+}++async function getForm({ token, formId }: { token: string; formId: string }): Promise<TypeformRecord> {+ return typeformRequest<TypeformRecord>({+ token,+ method: HttpMethod.GET,+ path: `/forms/${encodeURIComponent(formId)}`,+ });+}++function pageQuery({+ page,+ pageSize,+ maxPageSize,+}: {+ page: number | undefined;+ pageSize: number | undefined;+ maxPageSize: number;+}): Record<string, string | undefined> {+ return {+ page: page === undefined || page === null ? undefined : String(Math.max(1, Math.floor(page))),+ page_size:+ pageSize === undefined || pageSize === null+ ? undefined+ : String(Math.min(maxPageSize, Math.max(1, Math.floor(pageSize)))),+ };+}++function toHref({ resource, id }: { resource: string; id: string }): { href: string } {+ return { href: `${BASE_URL}/${resource}/${encodeURIComponent(id.trim())}` };+}++function toFormPayload({ form }: { form: TypeformRecord }): TypeformRecord {+ const rest = omitKeys({ record: form, keys: READ_ONLY_FORM_KEYS });+ return {+ ...rest,+ ...(isRecord(rest['settings']) ? { settings: withoutReadOnlySettings({ settings: rest['settings'] }) } : {}),+ };+}++function toDuplicatePayload({ form }: { form: TypeformRecord }): TypeformRecord {+ const payload = toFormPayload({ form });+ return Object.fromEntries(+ Object.entries(payload).map(([key, value]) => [+ key,+ DUPLICATE_ID_KEYS.includes(key) ? stripIds({ value }) : value,+ ])+ );+}++function stripIds({ value }: { value: unknown }): unknown {+ if (Array.isArray(value)) {+ return value.map((item) => stripIds({ value: item }));+ }+ if (!isRecord(value)) {+ return value;+ }+ return Object.fromEntries(+ Object.entries(value)+ .filter(([key]) => key !== 'id')+ .map(([key, item]) => [key, stripIds({ value: item })])+ );+}++function withoutReadOnlySettings({ settings }: { settings: TypeformRecord }): TypeformRecord {+ const enrichment = settings['enrichment_in_renderer'];+ if (!isRecord(enrichment)) {+ return settings;+ }+ return { ...settings, enrichment_in_renderer: omitKeys({ record: enrichment, keys: ['active'] }) };+}++function omitKeys({ record, keys }: { record: TypeformRecord; keys: string[] }): TypeformRecord {+ return Object.fromEntries(Object.entries(record).filter(([key]) => !keys.includes(key)));+}++function flattenFields({ fields }: { fields: unknown }): TypeformRecord[] {+ if (!Array.isArray(fields)) {+ return [];+ }+ return fields.filter(isRecord).flatMap((field) => {+ const properties = field['properties'];+ const nested = isRecord(properties) ? flattenFields({ fields: properties['fields'] }) : [];+ return [field, ...nested];+ });+}++function fieldIds({ fields }: { fields: unknown }): string[] {+ return flattenFields({ fields })+ .map((field) => field['id'])+ .filter((id): id is string => typeof id === 'string');+}++function themeBody({ values, current }: { values: ThemeFieldValues; current: TypeformRecord }): TypeformRecord {+ const colors = compactRecord({+ record: {+ question: values.questionColor,+ answer: values.answerColor,+ button: values.buttonColor,+ background: values.backgroundColor,+ },+ });+ const fields = compactRecord({ record: { alignment: values.fieldAlignment, font_size: values.fieldFontSize } });+ const screens = compactRecord({ record: { alignment: values.screenAlignment, font_size: values.screenFontSize } });+ return {+ ...(isProvided(values.name) ? { name: values.name.trim() } : {}),+ ...(isProvided(values.font) ? { font: values.font } : {}),+ ...(Object.keys(colors).length > 0 ? { colors: { ...recordOrEmpty({ value: current['colors'] }), ...colors } } : {}),+ ...(Object.keys(fields).length > 0 ? { fields: { ...recordOrEmpty({ value: current['fields'] }), ...fields } } : {}),+ ...(Object.keys(screens).length > 0 ? { screens: { ...recordOrEmpty({ value: current['screens'] }), ...screens } } : {}),+ };+}++function compactRecord({ record }: { record: Record<string, string | undefined | null> }): Record<string, string> {+ return Object.fromEntries(+ Object.entries(record)+ .filter((entry): entry is [string, string] => isProvided(entry[1]))+ .map(([key, value]) => [key, value.trim()])+ );+}++function recordOrEmpty({ value }: { value: unknown }): TypeformRecord {+ return isRecord(value) ? value : {};+}++function isProvided(value: string | undefined | null): value is string {+ return value !== undefined && value !== null && value.trim().length > 0;+}++function isRecord(value: unknown): value is TypeformRecord {+ return typeof value === 'object' && value !== null && !Array.isArray(value);+}++function toStringList({ values }: { values: unknown[] | undefined | null }): string[] {+ return (values ?? [])+ .filter((value): value is string | number => typeof value === 'string' || typeof value === 'number')+ .map((value) => String(value).trim())+ .filter((value) => value.length > 0);+}++function compactQuery({+ query,+}: {+ query: Record<string, string | undefined>;+}): Record<string, string> {+ return Object.fromEntries(+ Object.entries(query).filter(+ (entry): entry is [string, string] => entry[1] !== undefined && entry[1] !== ''+ )+ );+}++function toTypeformError({ error }: { error: unknown }): unknown {+ if (!(error instanceof HttpError)) {+ return error;+ }+ const { status, body } = error.response;+ if (status === 403) {+ return new Error(+ 'Typeform denied access (403). Reconnect your Typeform account to grant the permissions this action needs, and check that your plan includes this feature.'+ );+ }+ if (!isRecord(body)) {+ return error;+ }+ const code = typeof body['code'] === 'string' ? body['code'] : 'Typeform error';+ const description = typeof body['description'] === 'string' ? body['description'] : '';+ const details = Array.isArray(body['details']) ? ` ${JSON.stringify(body['details'])}` : '';+ return new Error(`${code} (${status}): ${description}${details}`.trim());+}++async function workspaceOptions({ token }: { token: string | undefined }): Promise<DropdownState<string>> {+ if (!token) {+ return { disabled: true, placeholder: 'Connect your Typeform account', options: [] };+ }+ const workspaces = await fetchAllPages<{ id: string; name: string }>({+ token,+ path: '/workspaces',+ });+ return {+ disabled: false,+ options: workspaces.map((workspace) => ({ label: workspace.name, value: workspace.id })),+ };+}++async function themeOptions({ token }: { token: string | undefined }): Promise<DropdownState<string>> {+ if (!token) {+ return { disabled: true, placeholder: 'Connect your Typeform account', options: [] };+ }+ const themes = await fetchAllPages<{ id: string; name: string; visibility: string }>({+ token,+ path: '/themes',+ });+ return {+ disabled: false,+ options: themes.map((theme) => ({+ label: theme.visibility === 'public' ? `${theme.name} (Typeform)` : theme.name,+ value: theme.id,+ })),+ };+}++const BASE_URL = 'https://api.typeform.com';+const MAX_PAGE_SIZE = 200;+const READ_ONLY_FORM_KEYS = ['id', '_links', 'self', 'created_at', 'last_updated_at', 'published_at'];+const DUPLICATE_ID_KEYS = ['fields', 'welcome_screens', 'thankyou_screens', 'logic', 'variables', 'hidden'];+const THEME_FONTS = [+ 'Acme', 'Arial', 'Arvo', 'Avenir Next', 'Bangers', 'Cabin', 'Cabin Condensed', 'Courier', 'Crete Round',+ 'Dancing Script', 'Exo', 'Georgia', 'Handlee', 'Helvetica Neue', 'Karla', 'Lato', 'Lekton', 'Lobster', 'Lora',+ 'McLaren', 'Montserrat', 'Nixie One', 'Old Standard TT', 'Open Sans', 'Oswald', 'Playfair Display', 'Quicksand',+ 'Raleway', 'Signika', 'Sniglet', 'Source Sans Pro', 'Vollkorn',+];+const ALIGNMENTS = [+ { label: 'Left', value: 'left' },+ { label: 'Center', value: 'center' },+];+const FONT_SIZES = [+ { label: 'Small', value: 'small' },+ { label: 'Medium', value: 'medium' },+ { label: 'Large', value: 'large' },+];+const CHOICE_FIELD_TYPES = ['dropdown', 'multiple_choice', 'ranking', 'picture_choice'];export const formsDropdown = Property.Dropdown<string, true, typeof typeformAuth>({auth: typeformAuth,@@ -80,7 +340,7 @@ export const formsDropdown = Property.Dropdown<string, true, typeof typeformAuth});export const typeformCommon = {- baseUrl: 'https://api.typeform.com',+ baseUrl: BASE_URL,subscribeWebhook: async (formId: string,tag: string,@@ -124,4 +384,181 @@ export const typeformCommon = {};return await httpClient.sendRequest(request);},+ form: formsDropdown,+ workspace: Property.Dropdown<string, false, typeof typeformAuth>({+ auth: typeformAuth,+ displayName: 'Workspace',+ description: 'Workspace ID, from List Workspaces.',+ required: false,+ refreshers: [],+ options: async ({ auth }) => workspaceOptions({ token: auth?.access_token }),+ }),+ theme: Property.Dropdown<string, false, typeof typeformAuth>({+ auth: typeformAuth,+ displayName: 'Theme',+ description: 'Theme ID, from List Themes.',+ required: false,+ refreshers: [],+ options: async ({ auth }) => themeOptions({ token: auth?.access_token }),+ }),+ choiceField: Property.Dropdown<string, true, typeof typeformAuth>({+ auth: typeformAuth,+ displayName: 'Question',+ description: 'Dropdown, multiple choice, ranking or picture choice question. Field ID or ref, from Get Form.',+ required: true,+ refreshers: ['form_id'],+ async options({ auth, form_id }) {+ if (!auth || typeof form_id !== 'string' || form_id.length === 0) {+ return { disabled: true, placeholder: 'Select a form first', options: [] };+ }+ const form = await getForm({ token: auth.access_token, formId: form_id });+ return {+ disabled: false,+ options: flattenFields({ fields: form['fields'] })+ .filter((field) => CHOICE_FIELD_TYPES.includes(String(field['type'])))+ .map((field) => ({ label: String(field['title'] ?? field['id']), value: String(field['id']) })),+ };+ },+ }),+ formId: Property.ShortText({+ displayName: 'Form ID',+ description: 'Form ID, from List Forms.',+ required: true,+ }),+ workspaceId: Property.ShortText({+ displayName: 'Workspace ID',+ description: 'Workspace ID, from List Workspaces.',+ required: false,+ }),+ requiredWorkspaceId: Property.ShortText({+ displayName: 'Workspace ID',+ description: 'Workspace ID, from List Workspaces.',+ required: true,+ }),+ themeId: Property.ShortText({+ displayName: 'Theme ID',+ description: 'Theme ID, from List Themes.',+ required: false,+ }),+ requiredThemeId: Property.ShortText({+ displayName: 'Theme ID',+ description: 'Theme ID, from List Themes.',+ required: true,+ }),+ themeFields: {+ name: Property.ShortText({+ displayName: 'Name',+ required: false,+ }),+ font: Property.StaticDropdown({+ displayName: 'Font',+ required: false,+ options: { options: THEME_FONTS.map((font) => ({ label: font, value: font })) },+ }),+ questionColor: Property.ShortText({+ displayName: 'Question Color',+ description: 'Hex color, for example #3D3D3D.',+ required: false,+ }),+ answerColor: Property.ShortText({+ displayName: 'Answer Color',+ description: 'Hex color.',+ required: false,+ }),+ buttonColor: Property.ShortText({+ displayName: 'Button Color',+ description: 'Hex color.',+ required: false,+ }),+ backgroundColor: Property.ShortText({+ displayName: 'Background Color',+ description: 'Hex color.',+ required: false,+ }),+ fieldAlignment: Property.StaticDropdown({+ displayName: 'Question Alignment',+ required: false,+ options: { options: ALIGNMENTS },+ }),+ fieldFontSize: Property.StaticDropdown({+ displayName: 'Question Font Size',+ required: false,+ options: { options: FONT_SIZES },+ }),+ screenAlignment: Property.StaticDropdown({+ displayName: 'Screen Alignment',+ description: 'Alignment of welcome and thank-you screens.',+ required: false,+ options: { options: ALIGNMENTS },+ }),+ screenFontSize: Property.StaticDropdown({+ displayName: 'Screen Font Size',+ required: false,+ options: { options: FONT_SIZES },+ }),+ },+ page: Property.Number({+ displayName: 'Page',+ description: 'Page number, starting at 1.',+ required: false,+ }),+ pageSize: Property.Number({+ displayName: 'Page Size',+ description: 'How many items to return per page, from 1 to 200.',+ required: false,+ }),+ typeformRequest,+ fetchAllPages,+ getForm,+ pageQuery,+ toHref,+ toFormPayload,+ toDuplicatePayload,+ flattenFields,+ fieldIds,+ themeBody,+ isProvided,+ isRecord,+ toStringList,+ maxPageSize: MAX_PAGE_SIZE,+ choiceFieldTypes: CHOICE_FIELD_TYPES,+};++export type TypeformRecord = Record<string, unknown>;++export type TypeformPage<T> = {+ total_items?: number;+ page_count?: number;+ items?: T[];+};++type ThemeFieldValues = {+ name?: string | null;+ font?: string | null;+ questionColor?: string | null;+ answerColor?: string | null;+ buttonColor?: string | null;+ backgroundColor?: string | null;+ fieldAlignment?: string | null;+ fieldFontSize?: string | null;+ screenAlignment?: string | null;+ screenFontSize?: string | null;+};++type FormListResponse = {+ page_count: number;+ total_items: number;+ items: {+ id: string;+ title: string;+ }[];+};++type TypeformRequest = {+ token: string;+ method: HttpMethod;+ path: string;+ queryParams?: Record<string, string | undefined>;+ body?: unknown;+ headers?: Record<string, string>;};diff --git a/packages/pieces/community/typeform/src/lib/output-schemas.ts b/packages/pieces/community/typeform/src/lib/output-schemas.tsnew file mode 100644index 00000000000..c49e718a004--- /dev/null+++ b/packages/pieces/community/typeform/src/lib/output-schemas.ts@@ -0,0 +1,258 @@+import { OutputSchema, OutputSchemaField } from '@activepieces/pieces-framework';++const pageFields: OutputSchemaField[] = [+ { key: 'total_items', label: 'Total Items', format: 'number' },+ { key: 'page_count', label: 'Page Count', format: 'number' },+];++const choiceFields: OutputSchemaField[] = [+ { key: 'id', label: 'Choice ID' },+ { key: 'ref', label: 'Choice Ref' },+ { key: 'label', label: 'Label' },+];++const questionFields: OutputSchemaField[] = [+ { key: 'id', label: 'Field ID' },+ { key: 'ref', label: 'Ref' },+ { key: 'title', label: 'Question' },+ { key: 'type', label: 'Type' },+ { key: 'validations_required', value: 'validations.required', label: 'Required', format: 'boolean' },+ { key: 'properties_choices', value: 'properties.choices', label: 'Choices', labelKey: 'label', listItems: choiceFields },+];++const formFields: OutputSchemaField[] = [+ { key: 'id', label: 'Form ID' },+ { key: 'title', label: 'Title' },+ { key: 'type', label: 'Type' },+ { key: 'links_display', value: '_links.display', label: 'Share Link', format: 'url' },+ { key: 'settings_is_public', value: 'settings.is_public', label: 'Public', format: 'boolean' },+ { key: 'settings_language', value: 'settings.language', label: 'Language' },+ { key: 'workspace_href', value: 'workspace.href', label: 'Workspace', format: 'url' },+ { key: 'theme_href', value: 'theme.href', label: 'Theme', format: 'url' },+ {+ key: 'fields',+ label: 'Questions',+ labelKey: 'title',+ listItems: [+ ...questionFields,+ { key: 'properties_fields', value: 'properties.fields', label: 'Group Questions', labelKey: 'title', listItems: questionFields },+ ],+ },+ { key: 'hidden', label: 'Hidden Fields' },+ {+ key: 'thankyou_screens',+ label: 'Thank-you Screens',+ labelKey: 'title',+ listItems: [+ { key: 'ref', label: 'Ref' },+ { key: 'title', label: 'Title' },+ ],+ },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'last_updated_at', label: 'Last Updated At', format: 'datetime' },+ { key: 'published_at', label: 'Published At', format: 'datetime' },+];++const formSummaryFields: OutputSchemaField[] = [+ { key: 'id', label: 'Form ID' },+ { key: 'title', label: 'Title' },+ { key: 'type', label: 'Type' },+ { key: 'links_display', value: '_links.display', label: 'Share Link', format: 'url' },+ { key: 'settings_is_public', value: 'settings.is_public', label: 'Public', format: 'boolean' },+ { key: 'theme_href', value: 'theme.href', label: 'Theme', format: 'url' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'last_updated_at', label: 'Last Updated At', format: 'datetime' },+];++const answerFields: OutputSchemaField[] = [+ { key: 'field_id', value: 'field.id', label: 'Field ID' },+ { key: 'field_ref', value: 'field.ref', label: 'Field Ref' },+ { key: 'field_type', value: 'field.type', label: 'Question Type' },+ { key: 'type', label: 'Answer Type' },+ { key: 'text', label: 'Text' },+ { key: 'email', label: 'Email', format: 'email' },+ { key: 'number', label: 'Number', format: 'number' },+ { key: 'boolean', label: 'Yes/No', format: 'boolean' },+ { key: 'date', label: 'Date', format: 'date' },+ { key: 'url', label: 'URL', format: 'url' },+ { key: 'phone_number', label: 'Phone Number' },+ { key: 'file_url', label: 'File', format: 'url' },+ { key: 'choice_label', value: 'choice.label', label: 'Choice' },+ { key: 'choices_labels', value: 'choices.labels', label: 'Choices' },+];++const responseFields: OutputSchemaField[] = [+ { key: 'response_id', label: 'Response ID' },+ { key: 'token', label: 'Token' },+ { key: 'response_type', label: 'Response Type' },+ { key: 'submitted_at', label: 'Submitted At', format: 'datetime' },+ { key: 'landed_at', label: 'Landed At', format: 'datetime' },+ { key: 'answers', label: 'Answers', labelKey: 'field.ref', listItems: answerFields },+ { key: 'hidden', label: 'Hidden Fields' },+ { key: 'calculated_score', value: 'calculated.score', label: 'Score', format: 'number' },+ { key: 'metadata_referer', value: 'metadata.referer', label: 'Referrer', format: 'url' },+ { key: 'metadata_platform', value: 'metadata.platform', label: 'Platform' },+ { key: 'thankyou_screen_ref', label: 'Thank-you Screen Ref' },+];++const workspaceFields: OutputSchemaField[] = [+ { key: 'id', label: 'Workspace ID' },+ { key: 'name', label: 'Name' },+ { key: 'account_id', label: 'Account ID' },+ { key: 'default', label: 'Default', format: 'boolean' },+ { key: 'shared', label: 'Shared', format: 'boolean' },+ { key: 'forms_count', value: 'forms.count', label: 'Form Count', format: 'number' },+];++const workspaceDetailFields: OutputSchemaField[] = [+ ...workspaceFields,+ {+ key: 'members',+ label: 'Members',+ labelKey: 'email',+ listItems: [+ { key: 'name', label: 'Name' },+ { key: 'email', label: 'Email', format: 'email' },+ { key: 'role', label: 'Role' },+ ],+ },+];++const themeFields: OutputSchemaField[] = [+ { key: 'id', label: 'Theme ID' },+ { key: 'name', label: 'Name' },+ { key: 'visibility', label: 'Visibility' },+ { key: 'font', label: 'Font' },+ { key: 'colors_question', value: 'colors.question', label: 'Question Color' },+ { key: 'colors_answer', value: 'colors.answer', label: 'Answer Color' },+ { key: 'colors_button', value: 'colors.button', label: 'Button Color' },+ { key: 'colors_background', value: 'colors.background', label: 'Background Color' },+ { key: 'fields_alignment', value: 'fields.alignment', label: 'Question Alignment' },+ { key: 'fields_font_size', value: 'fields.font_size', label: 'Question Font Size' },+ { key: 'screens_alignment', value: 'screens.alignment', label: 'Screen Alignment' },+ { key: 'screens_font_size', value: 'screens.font_size', label: 'Screen Font Size' },+ { key: 'has_transparent_button', label: 'Transparent Button', format: 'boolean' },+ { key: 'rounded_corners', label: 'Rounded Corners' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },+];++const imageFields: OutputSchemaField[] = [+ { key: 'id', label: 'Image ID' },+ { key: 'file_name', label: 'File Name' },+ { key: 'src', label: 'Image', format: 'image' },+ { key: 'media_type', label: 'Media Type' },+ { key: 'width', label: 'Width', format: 'number' },+ { key: 'height', label: 'Height', format: 'number' },+];++export const accountOutputSchema: OutputSchema = {+ fields: [+ { key: 'user_id', label: 'User ID' },+ { key: 'alias', label: 'Name' },+ { key: 'email', label: 'Email', format: 'email' },+ { key: 'language', label: 'Language' },+ ],+};++export const formsOutputSchema: OutputSchema = {+ fields: [{ key: 'items', label: 'Forms', labelKey: 'title', listItems: formSummaryFields }, ...pageFields],+};++export const formOutputSchema: OutputSchema = {+ fields: formFields,+};++export const deleteFormOutputSchema: OutputSchema = {+ fields: [+ { key: 'deleted', label: 'Deleted', format: 'boolean' },+ { key: 'form_id', label: 'Form ID' },+ ],+};++export const responsesOutputSchema: OutputSchema = {+ fields: [{ key: 'items', label: 'Responses', labelKey: 'submitted_at', listItems: responseFields }, ...pageFields],+};++export const deleteResponsesOutputSchema: OutputSchema = {+ fields: [+ { key: 'registered', label: 'Deletion Requested', format: 'boolean' },+ { key: 'form_id', label: 'Form ID' },+ { key: 'response_ids', label: 'Response IDs' },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const workspacesOutputSchema: OutputSchema = {+ fields: [{ key: 'items', label: 'Workspaces', labelKey: 'name', listItems: workspaceFields }, ...pageFields],+};++export const workspaceOutputSchema: OutputSchema = {+ fields: workspaceDetailFields,+};++export const deleteWorkspaceOutputSchema: OutputSchema = {+ fields: [+ { key: 'deleted', label: 'Deleted', format: 'boolean' },+ { key: 'workspace_id', label: 'Workspace ID' },+ ],+};++export const themesOutputSchema: OutputSchema = {+ fields: [{ key: 'items', label: 'Themes', labelKey: 'name', listItems: themeFields }, ...pageFields],+};++export const themeOutputSchema: OutputSchema = {+ fields: themeFields,+};++export const deleteThemeOutputSchema: OutputSchema = {+ fields: [+ { key: 'deleted', label: 'Deleted', format: 'boolean' },+ { key: 'theme_id', label: 'Theme ID' },+ ],+};++export const imagesOutputSchema: OutputSchema = {+ fields: [+ { key: 'items', label: 'Images', labelKey: 'file_name', listItems: imageFields },+ { key: 'count', label: 'Count', format: 'number' },+ { key: 'total_items', label: 'Total Images', format: 'number' },+ ],+};++export const imageOutputSchema: OutputSchema = {+ fields: imageFields,+};++export const deleteImageOutputSchema: OutputSchema = {+ fields: [+ { key: 'deleted', label: 'Deleted', format: 'boolean' },+ { key: 'image_id', label: 'Image ID' },+ ],+};++export const newSubmissionOutputSchema: OutputSchema = {+ fields: [+ { key: 'form_id', label: 'Form ID' },+ { key: 'token', label: 'Response Token' },+ { key: 'submitted_at', label: 'Submitted At', format: 'datetime' },+ { key: 'landed_at', label: 'Landed At', format: 'datetime' },+ { key: 'definition_title', value: 'definition.title', label: 'Form Title' },+ {+ key: 'definition_fields', value: 'definition.fields',+ label: 'Questions',+ labelKey: 'title',+ listItems: [+ { key: 'id', label: 'Field ID' },+ { key: 'ref', label: 'Ref' },+ { key: 'title', label: 'Question' },+ { key: 'type', label: 'Type' },+ ],+ },+ { key: 'answers', label: 'Answers', labelKey: 'field.ref', listItems: answerFields },+ { key: 'hidden', label: 'Hidden Fields' },+ { key: 'calculated_score', value: 'calculated.score', label: 'Score', format: 'number' },+ { key: 'thankyou_screen_ref', label: 'Thank-you Screen Ref' },+ ],+};diff --git a/packages/pieces/community/typeform/src/lib/trigger/new-submission.ts b/packages/pieces/community/typeform/src/lib/trigger/new-submission.tsindex 9adb0a5b137..cf8f2c8e5dc 100644--- a/packages/pieces/community/typeform/src/lib/trigger/new-submission.ts+++ b/packages/pieces/community/typeform/src/lib/trigger/new-submission.ts@@ -2,7 +2,8 @@ import { typeformCommon, formsDropdown } from '../common';import { nanoid } from 'nanoid';import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';import { getAccessTokenOrThrow } from '@activepieces/pieces-common';-import { typeformAuth } from '../..';+import { typeformAuth } from '../auth';+import { newSubmissionOutputSchema } from '../output-schemas';export const typeformNewSubmission = createTrigger({auth: typeformAuth,@@ -13,6 +14,7 @@ export const typeformNewSubmission = createTrigger({description:'Fires when a respondent completes and submits the specified Typeform form. The event represents a single finished submission, delivered via webhook, and provides the form response payload including the submission token, landing/submission timestamps, the form definition, and the respondent\'s answers.',},+ outputSchema: newSubmissionOutputSchema,props: {form_id: formsDropdown,},