Add Activepieces integration for workflow automation

- Add Activepieces fork with SmoothSchedule custom piece
- Create integrations app with Activepieces service layer
- Add embed token endpoint for iframe integration
- Create Automations page with embedded workflow builder
- Add sidebar visibility fix for embed mode
- Add list inactive customers endpoint to Public API
- Include SmoothSchedule triggers: event created/updated/cancelled
- Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
poduck
2025-12-18 22:59:37 -05:00
parent 9848268d34
commit 3aa7199503
16292 changed files with 1284892 additions and 4708 deletions

View File

@@ -0,0 +1,34 @@
{
"Collaborative interface design tool": "Kollaboratives Interface-Design-Werkzeug",
"Get File": "Datei abrufen",
"Get File Comments": "Dateikommentare abrufen",
"Post File Comment": "Kommentar posten",
"Custom API Call": "Eigener API-Aufruf",
"Get file": "Datei abrufen",
"Get file comments": "Dateikommentare erhalten",
"Post file comment": "Kommentar posten",
"Make a custom API call to a specific endpoint": "Einen benutzerdefinierten API-Aufruf an einen bestimmten Endpunkt machen",
"File Key": "Dateischlüssel",
"Comment": "Kommentar",
"Method": "Methode",
"Headers": "Kopfzeilen",
"Query Parameters": "Abfrageparameter",
"Body": "Körper",
"Response is Binary ?": "Antwort ist binär?",
"No Error on Failure": "Kein Fehler bei Fehler",
"Timeout (in seconds)": "Timeout (in Sekunden)",
"The Figma file key (copy from Figma file URL)": "Der Figma-Dateischlüssel (Kopie von Figma-Datei-URL)",
"Your comment": "Ihr Kommentar",
"Authorization headers are injected automatically from your connection.": "Autorisierungs-Header werden automatisch von Ihrer Verbindung injiziert.",
"Enable for files like PDFs, images, etc..": "Aktivieren für Dateien wie PDFs, Bilder, etc..",
"GET": "ERHALTEN",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "LÖSCHEN",
"HEAD": "HEAD",
"New Comment (Figma Professional plan only)": "Neuer Kommentar (Figma Professional Plan)",
"Triggers when a new comment is posted": "Wird ausgelöst, wenn ein neuer Kommentar veröffentlicht wird",
"Team ID": "Team-ID",
"Naviate to team page, copy the Id from the URL after the word team/": "Zur Teamseite nicht wechseln, kopiere die Id von der URL nach dem Wort Team/"
}

View File

@@ -0,0 +1,34 @@
{
"Collaborative interface design tool": "Herramienta de diseño de interfaz colaborativa",
"Get File": "Obtener archivo",
"Get File Comments": "Obtener Comentarios de Archivo",
"Post File Comment": "Publicar Comentario",
"Custom API Call": "Llamada API personalizada",
"Get file": "Obtener archivo",
"Get file comments": "Obtener comentarios de archivo",
"Post file comment": "Publicar comentario",
"Make a custom API call to a specific endpoint": "Hacer una llamada API personalizada a un extremo específico",
"File Key": "Clave de archivo",
"Comment": "Comentario",
"Method": "Método",
"Headers": "Encabezados",
"Query Parameters": "Parámetros de consulta",
"Body": "Cuerpo",
"Response is Binary ?": "¿Respuesta es binaria?",
"No Error on Failure": "No hay ningún error en fallo",
"Timeout (in seconds)": "Tiempo de espera (en segundos)",
"The Figma file key (copy from Figma file URL)": "La clave del archivo Figma (copiar desde la URL del archivo Figma)",
"Your comment": "Tu comentario",
"Authorization headers are injected automatically from your connection.": "Las cabeceras de autorización se inyectan automáticamente desde tu conexión.",
"Enable for files like PDFs, images, etc..": "Activar para archivos como PDFs, imágenes, etc.",
"GET": "RECOGER",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "BORRAR",
"HEAD": "LIMPIO",
"New Comment (Figma Professional plan only)": "Nuevo comentario (solo plan profesional Figma)",
"Triggers when a new comment is posted": "Dispara cuando se publica un nuevo comentario",
"Team ID": "ID de equipo",
"Naviate to team page, copy the Id from the URL after the word team/": "Navegar a la página del equipo, copiar el Id desde la URL después de la palabra equipo/"
}

View File

@@ -0,0 +1,34 @@
{
"Collaborative interface design tool": "Outil de conception d'interface collaborative",
"Get File": "Récupérer le fichier",
"Get File Comments": "Récupérer les commentaires du fichier",
"Post File Comment": "Publier un commentaire sur le fichier",
"Custom API Call": "Appel API personnalisé",
"Get file": "Récupérer le fichier",
"Get file comments": "Récupérer les commentaires du fichier",
"Post file comment": "Poster un commentaire sur le fichier",
"Make a custom API call to a specific endpoint": "Passez un appel API personnalisé à un point de terminaison spécifique",
"File Key": "Clé de fichier",
"Comment": "Commenter",
"Method": "Méthode",
"Headers": "En-têtes",
"Query Parameters": "Paramètres de requête",
"Body": "Corps",
"Response is Binary ?": "La réponse est Binaire ?",
"No Error on Failure": "Aucune erreur en cas d'échec",
"Timeout (in seconds)": "Délai d'attente (en secondes)",
"The Figma file key (copy from Figma file URL)": "La clé de fichier Figma (copie depuis l'URL du fichier Figma)",
"Your comment": "Votre commentaire",
"Authorization headers are injected automatically from your connection.": "Les en-têtes d'autorisation sont injectés automatiquement à partir de votre connexion.",
"Enable for files like PDFs, images, etc..": "Activer pour les fichiers comme les PDFs, les images, etc.",
"GET": "OBTENIR",
"POST": "POSTER",
"PATCH": "PATCH",
"PUT": "EFFACER",
"DELETE": "SUPPRIMER",
"HEAD": "TÊTE",
"New Comment (Figma Professional plan only)": "Nouveau commentaire (Figma Professional plan seulement)",
"Triggers when a new comment is posted": "Déclenche lorsqu'un nouveau commentaire est publié",
"Team ID": "ID d'équipe",
"Naviate to team page, copy the Id from the URL after the word team/": "Naviate à la page de l'équipe, copiez l'ID à partir de l'URL après le mot équipe/"
}

View File

@@ -0,0 +1,34 @@
{
"Collaborative interface design tool": "共同作業型インターフェース設計ツール",
"Get File": "ファイルを取得する",
"Get File Comments": "ファイルコメントの取得",
"Post File Comment": "ファイルのコメントを投稿",
"Custom API Call": "カスタムAPI通話",
"Get file": "ファイルを取得する",
"Get file comments": "ファイルのコメントを取得する",
"Post file comment": "ファイルのコメントを投稿",
"Make a custom API call to a specific endpoint": "特定のエンドポイントへのカスタム API コールを実行します。",
"File Key": "File Key",
"Comment": "コメント",
"Method": "方法",
"Headers": "ヘッダー",
"Query Parameters": "クエリパラメータ",
"Body": "本文",
"Response is Binary ?": "応答はバイナリですか?",
"No Error on Failure": "失敗時にエラーはありません",
"Timeout (in seconds)": "タイムアウト(秒)",
"The Figma file key (copy from Figma file URL)": "Figma file key (Figma file URLからコピー)",
"Your comment": "あなたのコメント",
"Authorization headers are injected automatically from your connection.": "認証ヘッダは接続から自動的に注入されます。",
"Enable for files like PDFs, images, etc..": "PDF、画像などのファイルを有効にします。",
"GET": "取得",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "削除",
"HEAD": "頭",
"New Comment (Figma Professional plan only)": "新しいコメント(図1プロフェッショナルプランのみ)",
"Triggers when a new comment is posted": "新しいコメントが投稿されたときにトリガーします",
"Team ID": "チームID",
"Naviate to team page, copy the Id from the URL after the word team/": "Naviate to team page, copy the Id from the URL after the word team/"
}

View File

@@ -0,0 +1,34 @@
{
"Collaborative interface design tool": "Hulpmiddel voor gezamenlijke interface",
"Get File": "Bestand ophalen",
"Get File Comments": "Ophalen Bestand Opmerkingen",
"Post File Comment": "Plaats bestand opmerking",
"Custom API Call": "Custom API Call",
"Get file": "Bestand ophalen",
"Get file comments": "Haal bestand commentaren op",
"Post file comment": "Plaats bestand commentaar",
"Make a custom API call to a specific endpoint": "Maak een aangepaste API call naar een specifiek eindpunt",
"File Key": "Bestand Sleutel",
"Comment": "Opmerking",
"Method": "Methode",
"Headers": "Kopteksten",
"Query Parameters": "Query parameters",
"Body": "Lichaam",
"Response is Binary ?": "Antwoord is binair?",
"No Error on Failure": "Geen fout bij fout",
"Timeout (in seconds)": "Time-out (in seconden)",
"The Figma file key (copy from Figma file URL)": "De Figma-bestandssleutel (kopie van Figma bestand URL)",
"Your comment": "Uw commentaar",
"Authorization headers are injected automatically from your connection.": "Autorisatie headers worden automatisch geïnjecteerd vanuit uw verbinding.",
"Enable for files like PDFs, images, etc..": "Inschakelen voor bestanden zoals PDF's, afbeeldingen etc..",
"GET": "KRIJG",
"POST": "POSTE",
"PATCH": "BEKIJK",
"PUT": "PUT",
"DELETE": "VERWIJDEREN",
"HEAD": "HOOFD",
"New Comment (Figma Professional plan only)": "Nieuwe Reactie (uitsluitend professioneel abonnement)",
"Triggers when a new comment is posted": "Triggert wanneer een nieuwe reactie is geplaatst",
"Team ID": "Team ID",
"Naviate to team page, copy the Id from the URL after the word team/": "Navigeer naar de teampagina, kopieer de Id van de URL na het woord team/"
}

View File

@@ -0,0 +1,34 @@
{
"Collaborative interface design tool": "Ferramenta de design de interface colaborativa",
"Get File": "Obter arquivo",
"Get File Comments": "Obter Comentários do Arquivo",
"Post File Comment": "Postar comentário no arquivo",
"Custom API Call": "Chamada de API personalizada",
"Get file": "Obter arquivo",
"Get file comments": "Obter comentários do arquivo",
"Post file comment": "Publicar comentário do arquivo",
"Make a custom API call to a specific endpoint": "Faça uma chamada de API personalizada para um ponto de extremidade específico",
"File Key": "Chave do arquivo",
"Comment": "Comentar",
"Method": "Método",
"Headers": "Cabeçalhos",
"Query Parameters": "Parâmetros da consulta",
"Body": "Conteúdo",
"Response is Binary ?": "A resposta é binária ?",
"No Error on Failure": "Nenhum erro no Failure",
"Timeout (in seconds)": "Tempo limite (em segundos)",
"The Figma file key (copy from Figma file URL)": "A chave de arquivo Figma (cópia do arquivo Figma URL)",
"Your comment": "Seu comentário",
"Authorization headers are injected automatically from your connection.": "Os cabeçalhos de autorização são inseridos automaticamente a partir da sua conexão.",
"Enable for files like PDFs, images, etc..": "Habilitar para arquivos como PDFs, imagens, etc..",
"GET": "OBTER",
"POST": "POSTAR",
"PATCH": "COMPRAR",
"PUT": "COLOCAR",
"DELETE": "EXCLUIR",
"HEAD": "CABEÇA",
"New Comment (Figma Professional plan only)": "Novo Comentário (apenas o plano Figma Profissional)",
"Triggers when a new comment is posted": "Dispara quando um novo comentário é publicado",
"Team ID": "ID da Equipe",
"Naviate to team page, copy the Id from the URL after the word team/": "Naviar para a página de equipe, copie o Id a partir da URL após a palavra equipe /"
}

View File

@@ -0,0 +1,33 @@
{
"Figma": "Figma",
"Collaborative interface design tool": "Инструмент совместного дизайна интерфейса",
"Get File": "Получить файл",
"Get File Comments": "Получить комментарии к файлу",
"Post File Comment": "Комментарий к файлу",
"Custom API Call": "Пользовательский вызов API",
"Get file": "Получить файл",
"Get file comments": "Получить комментарии к файлам",
"Post file comment": "Отправить комментарий к файлу",
"Make a custom API call to a specific endpoint": "Сделать пользовательский API вызов к определенной конечной точке",
"File Key": "Ключ файла",
"Comment": "Комментарий",
"Method": "Метод",
"Headers": "Заголовки",
"Query Parameters": "Параметры запроса",
"Body": "Тело",
"No Error on Failure": "Нет ошибок при ошибке",
"Timeout (in seconds)": "Таймаут (в секундах)",
"The Figma file key (copy from Figma file URL)": "Фигура ключа (скопируйте из URL файла Figma)",
"Your comment": "Ваш комментарий",
"Authorization headers are injected automatically from your connection.": "Заголовки авторизации включаются автоматически из вашего соединения.",
"GET": "ПОЛУЧИТЬ",
"POST": "ПОСТ",
"PATCH": "ПАТЧ",
"PUT": "ПОКУПИТЬ",
"DELETE": "УДАЛИТЬ",
"HEAD": "HEAD",
"New Comment (Figma Professional plan only)": "Новый комментарий (только план профессионалов)",
"Triggers when a new comment is posted": "Включает при появлении нового комментария",
"Team ID": "ID команды",
"Naviate to team page, copy the Id from the URL after the word team/": "Naviate to team page copy the Id from the URL after the word team/"
}

View File

@@ -0,0 +1,34 @@
{
"Collaborative interface design tool": "Collaborative interface design tool",
"Get File": "Get File",
"Get File Comments": "Get File Comments",
"Post File Comment": "Post File Comment",
"Custom API Call": "Custom API Call",
"Get file": "Get file",
"Get file comments": "Get file comments",
"Post file comment": "Post file comment",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"File Key": "File Key",
"Comment": "Comment",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
"Body": "Body",
"Response is Binary ?": "Response is Binary ?",
"No Error on Failure": "No Error on Failure",
"Timeout (in seconds)": "Timeout (in seconds)",
"The Figma file key (copy from Figma file URL)": "The Figma file key (copy from Figma file URL)",
"Your comment": "Your comment",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"Enable for files like PDFs, images, etc..": "Enable for files like PDFs, images, etc..",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD",
"New Comment (Figma Professional plan only)": "New Comment (Figma Professional plan only)",
"Triggers when a new comment is posted": "Triggers when a new comment is posted",
"Team ID": "Team ID",
"Naviate to team page, copy the Id from the URL after the word team/": "Naviate to team page, copy the Id from the URL after the word team/"
}

View File

@@ -0,0 +1,33 @@
{
"Figma": "Figma",
"Collaborative interface design tool": "Collaborative interface design tool",
"Get File": "Get File",
"Get File Comments": "Get File Comments",
"Post File Comment": "Post File Comment",
"Custom API Call": "Custom API Call",
"Get file": "Get file",
"Get file comments": "Get file comments",
"Post file comment": "Post file comment",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"File Key": "File Key",
"Comment": "Comment",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
"Body": "Body",
"No Error on Failure": "No Error on Failure",
"Timeout (in seconds)": "Timeout (in seconds)",
"The Figma file key (copy from Figma file URL)": "The Figma file key (copy from Figma file URL)",
"Your comment": "Your comment",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD",
"New Comment (Figma Professional plan only)": "New Comment (Figma Professional plan only)",
"Triggers when a new comment is posted": "Triggers when a new comment is posted",
"Team ID": "Team ID",
"Naviate to team page, copy the Id from the URL after the word team/": "Naviate to team page, copy the Id from the URL after the word team/"
}

View File

@@ -0,0 +1,34 @@
{
"Collaborative interface design tool": "Collaborative interface design tool",
"Get File": "Get File",
"Get File Comments": "Get File Comments",
"Post File Comment": "Post File Comment",
"Custom API Call": "自定义 API 呼叫",
"Get file": "Get file",
"Get file comments": "Get file comments",
"Post file comment": "Post file comment",
"Make a custom API call to a specific endpoint": "将一个自定义 API 调用到一个特定的终点",
"File Key": "File Key",
"Comment": "Comment",
"Method": "方法",
"Headers": "信头",
"Query Parameters": "查询参数",
"Body": "正文内容",
"Response is Binary ?": "Response is Binary ?",
"No Error on Failure": "失败时没有错误",
"Timeout (in seconds)": "超时(秒)",
"The Figma file key (copy from Figma file URL)": "The Figma file key (copy from Figma file URL)",
"Your comment": "Your comment",
"Authorization headers are injected automatically from your connection.": "授权头自动从您的连接中注入。",
"Enable for files like PDFs, images, etc..": "Enable for files like PDFs, images, etc..",
"GET": "获取",
"POST": "帖子",
"PATCH": "PATCH",
"PUT": "弹出",
"DELETE": "删除",
"HEAD": "黑色",
"New Comment (Figma Professional plan only)": "New Comment (Figma Professional plan only)",
"Triggers when a new comment is posted": "Triggers when a new comment is posted",
"Team ID": "Team ID",
"Naviate to team page, copy the Id from the URL after the word team/": "Naviate to team page, copy the Id from the URL after the word team/"
}

View File

@@ -0,0 +1,41 @@
import { createCustomApiCallAction } from '@activepieces/pieces-common';
import {
OAuth2PropertyValue,
PieceAuth,
createPiece,
} from '@activepieces/pieces-framework';
import { getCommentsAction } from './lib/actions/get-comments-action';
import { getFileAction } from './lib/actions/get-file-action';
import { postCommentAction } from './lib/actions/post-comment-action';
import { newCommentTrigger } from './lib/trigger/new-comment';
export const figmaAuth = PieceAuth.OAuth2({
description: '',
authUrl: 'https://www.figma.com/oauth',
tokenUrl: 'https://www.figma.com/api/oauth/token',
required: true,
scope: ['file_read'],
});
export const figma = createPiece({
displayName: 'Figma',
description: 'Collaborative interface design tool',
minimumSupportedRelease: '0.30.0',
logoUrl: 'https://cdn.activepieces.com/pieces/figma.png',
categories: [],
authors: ["kishanprmr","MoShizzle","khaledmashaly","abuaboud"],
auth: figmaAuth,
actions: [
getFileAction,
getCommentsAction,
postCommentAction,
createCustomApiCallAction({
baseUrl: () => 'https://api.figma.com',
auth: figmaAuth,
authMapping: async (auth) => ({
Authorization: `Bearer ${(auth as OAuth2PropertyValue).access_token}`,
}),
}),
],
triggers: [newCommentTrigger],
});

View File

@@ -0,0 +1,33 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { assertNotNullOrUndefined } from '@activepieces/shared';
import { figmaCommon } from '../common';
import { figmaGetRequest } from '../common/utils';
import { figmaAuth } from '../../';
export const getCommentsAction = createAction({
auth: figmaAuth,
name: 'get_comments',
displayName: 'Get File Comments',
description: 'Get file comments',
props: {
file_key: Property.ShortText({
displayName: 'File Key',
description: 'The Figma file key (copy from Figma file URL)',
required: true,
}),
},
async run(context) {
const token = context.auth.access_token;
const fileKey = context.propsValue.file_key;
assertNotNullOrUndefined(token, 'token');
assertNotNullOrUndefined(fileKey, 'file_key');
const url = `${figmaCommon.baseUrl}/${figmaCommon.comments}`.replace(
':file_key',
fileKey
);
return figmaGetRequest({ token, url });
},
});

View File

@@ -0,0 +1,33 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { assertNotNullOrUndefined } from '@activepieces/shared';
import { figmaCommon } from '../common';
import { figmaGetRequest } from '../common/utils';
import { figmaAuth } from '../../';
export const getFileAction = createAction({
auth: figmaAuth,
name: 'get_file',
displayName: 'Get File',
description: 'Get file',
props: {
file_key: Property.ShortText({
displayName: 'File Key',
description: 'The Figma file key (copy from Figma file URL)',
required: true,
}),
},
async run(context) {
const token = context.auth.access_token;
const fileKey = context.propsValue.file_key;
assertNotNullOrUndefined(token, 'token');
assertNotNullOrUndefined(fileKey, 'file_key');
const url = `${figmaCommon.baseUrl}/${figmaCommon.files}`.replace(
':file_key',
fileKey
);
return figmaGetRequest({ token, url });
},
});

View File

@@ -0,0 +1,39 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { assertNotNullOrUndefined } from '@activepieces/shared';
import { figmaCommon } from '../common';
import { figmaPostRequestWithMessage } from '../common/utils';
import { figmaAuth } from '../../';
export const postCommentAction = createAction({
auth: figmaAuth,
name: 'post_comment',
displayName: 'Post File Comment',
description: 'Post file comment',
props: {
file_key: Property.ShortText({
displayName: 'File Key',
description: 'The Figma file key (copy from Figma file URL)',
required: true,
}),
message: Property.LongText({
displayName: 'Comment',
description: 'Your comment',
required: true,
}),
},
async run(context) {
const token = context.auth.access_token;
const { file_key, message } = context.propsValue;
assertNotNullOrUndefined(token, 'token');
assertNotNullOrUndefined(file_key, 'file_key');
assertNotNullOrUndefined(message, 'comment');
const url = `${figmaCommon.baseUrl}/${figmaCommon.comments}`.replace(
':file_key',
file_key
);
return figmaPostRequestWithMessage({ token, url, message });
},
});

View File

@@ -0,0 +1,7 @@
export const figmaCommon = {
baseUrl: 'https://api.figma.com',
files: 'v1/files/:file_key',
comments: 'v1/files/:file_key/comments',
webhooks: 'v2/webhooks',
webhook: 'v2/webhooks/:webhook_id',
};

View File

@@ -0,0 +1,24 @@
type User = {
handle: string;
img_url: string;
id: string;
};
type Pos = {
x: number;
y: number;
};
export type Comment = {
id: string;
uuid: string;
file_key: string;
parent_id: string;
user: User;
created_at: string;
resolved_at: string;
message: string;
reactions: unknown;
client_meta: Pos;
order_id: number;
};

View File

@@ -0,0 +1,139 @@
import {
httpClient,
HttpMethod,
HttpRequest,
AuthenticationType,
} from '@activepieces/pieces-common';
export const figmaGetRequest = async ({
token,
url,
}: FigmaGetRequestParams) => {
const request: HttpRequest = {
method: HttpMethod.GET,
url: url,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token,
},
};
const response = await httpClient.sendRequest(request);
return {
success: true,
request_body: request.body,
response_body: response.body,
};
};
export const figmaPostRequestWithMessage = async ({
token,
url,
message,
}: FigmaPostRequestWithMessageParams) => {
const request: HttpRequest<FigmaPostRequestWithMessageBody> = {
method: HttpMethod.POST,
url: url,
body: {
message: message,
},
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token,
},
};
const response = await httpClient.sendRequest(request);
return {
success: true,
request_body: request.body,
response_body: response.body,
};
};
export const figmaWebhookPostRequest = async ({
token,
url,
eventType,
teamId,
endpoint,
passcode,
}: FigmaWebhookPostRequestParams) => {
const request: HttpRequest<FigmaWebhookPostRequestBody> = {
method: HttpMethod.POST,
url: url,
body: {
event_type: eventType,
team_id: teamId,
endpoint: endpoint,
passcode: passcode,
},
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token,
},
};
const response = await httpClient.sendRequest(request);
return {
success: true,
request_body: request.body,
response_body: response.body,
};
};
export const figmaDeleteRequest = async ({
token,
url,
}: FigmaGetRequestParams) => {
const request: HttpRequest = {
method: HttpMethod.DELETE,
url: url,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token,
},
};
const response = await httpClient.sendRequest(request);
return {
success: true,
request_body: request.body,
response_body: response.body,
};
};
type FigmaGetRequestParams = {
token: string;
url: string;
};
type FigmaPostRequestWithMessageParams = {
token: string;
url: string;
message: string;
};
type FigmaPostRequestWithMessageBody = {
message: string;
};
type FigmaWebhookPostRequestParams = {
token: string;
url: string;
eventType: string;
teamId: string;
endpoint: string;
passcode: string;
};
type FigmaWebhookPostRequestBody = {
event_type: string;
team_id: string;
endpoint: string;
passcode: string;
};

View File

@@ -0,0 +1,96 @@
import {
createTrigger,
Property,
TriggerStrategy,
} from '@activepieces/pieces-framework';
import { assertNotNullOrUndefined } from '@activepieces/shared';
import { nanoid } from 'nanoid';
import { figmaCommon } from '../common';
import { figmaWebhookPostRequest, figmaDeleteRequest } from '../common/utils';
import { figmaAuth } from '../../';
type TriggerData = {
webhookId: string;
};
const TRIGGER_DATA_STORE_KEY = 'figma_new_comment_trigger_data';
export const newCommentTrigger = createTrigger({
auth: figmaAuth,
name: 'new_comment',
displayName: 'New Comment (Figma Professional plan only)',
description: 'Triggers when a new comment is posted',
type: TriggerStrategy.WEBHOOK,
sampleData: [
{
id: '12345',
team_id: '1234567890',
event_type: 'FILE_COMMENT',
client_id: null,
endpoint: 'http://localhost:1234/webhook',
passcode: 'figma-passcode',
status: 'ACTIVE',
description: null,
protocol_version: '2',
},
],
props: {
team_id: Property.ShortText({
displayName: 'Team ID',
description:
'Naviate to team page, copy the Id from the URL after the word team/',
required: true,
}),
},
async onEnable(context): Promise<void> {
const token = context.auth.access_token;
const teamId = context.propsValue['team_id'];
assertNotNullOrUndefined(token, 'token');
assertNotNullOrUndefined(teamId, 'teamId');
const url = `${figmaCommon.baseUrl}/${figmaCommon.webhooks}`;
const eventType = 'FILE_COMMENT';
const passcode = `figma_passcode_${nanoid()}`;
const endpoint = context.webhookUrl;
const { response_body } = await figmaWebhookPostRequest({
token,
url,
eventType,
teamId,
endpoint,
passcode,
});
await context.store?.put<TriggerData>(TRIGGER_DATA_STORE_KEY, {
webhookId: response_body['id'],
});
},
async onDisable(context): Promise<void> {
const token = context.auth.access_token;
assertNotNullOrUndefined(token, 'token');
const triggerData = await context.store?.get<TriggerData>(
TRIGGER_DATA_STORE_KEY
);
if (triggerData !== null && triggerData !== undefined) {
const url = `${figmaCommon.baseUrl}/${figmaCommon.webhook}`.replace(
':webhook_id',
triggerData.webhookId
);
await figmaDeleteRequest({ token, url });
}
},
async run(context) {
const payloadBody = context.payload.body as Record<string, unknown>;
if ('event_type' in payloadBody && payloadBody['event_type'] === 'PING') {
return [];
}
return [payloadBody];
},
});