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,36 @@
{
"You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.": "Du kannst deinen API-Schlüssel erhalten, indem du im Menü [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) navigierst.",
"Capture Screenshot": "Screenshot aufnehmen",
"Custom API Call": "Eigener API-Aufruf",
"Captures Screenshot of a URL.": "Erfasst Screenshot einer URL.",
"Make a custom API call to a specific endpoint": "Einen benutzerdefinierten API-Aufruf an einen bestimmten Endpunkt machen",
"Project": "Projekt",
"Target URL": "Target URL",
"Custom Screenshot Width": "Benutzerdefinierte Screenshot-Breite",
"Custom Screenshot Height": "Eigene Bildschirmfoto Höhe",
"Image Format": "Bildformat",
"Custom CSS": "Custom CSS",
"Custom JavaScript": "Eigenes JavaScript",
"Full Page?": "Vollseite?",
"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)",
"Output format for the screenshot.": "Ausgabeformat für den Screenshot.",
"Custom CSS to apply.": "Angepasstes CSS.",
"Custom JavaScript to apply.": "Benutzerdefiniertes JavaScript zum Anwenden.",
"To capture the entire page.": "Zur Aufnahme der gesamten Seite.",
"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..",
"PNG": "PNG",
"JPEG": "JPEG",
"GET": "ERHALTEN",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "LÖSCHEN",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,36 @@
{
"You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.": "Puedes obtener tu clave API navegando a [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menú.",
"Capture Screenshot": "Captura de pantalla",
"Custom API Call": "Llamada API personalizada",
"Captures Screenshot of a URL.": "Captura de pantalla de una URL.",
"Make a custom API call to a specific endpoint": "Hacer una llamada API personalizada a un extremo específico",
"Project": "Projekt",
"Target URL": "Target URL",
"Custom Screenshot Width": "Ancho de captura de pantalla personalizada",
"Custom Screenshot Height": "Altura de captura de pantalla personalizada",
"Image Format": "Formato de imagen",
"Custom CSS": "Custom CSS",
"Custom JavaScript": "JavaScript personalizado",
"Full Page?": "¿Página completa?",
"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)",
"Output format for the screenshot.": "Formato de salida para la captura de pantalla.",
"Custom CSS to apply.": "CSS personalizado para aplicar.",
"Custom JavaScript to apply.": "JavaScript personalizado para aplicar.",
"To capture the entire page.": "Para capturar toda la página.",
"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.",
"PNG": "PNG",
"JPEG": "JPEG",
"GET": "RECOGER",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "BORRAR",
"HEAD": "LIMPIO"
}

View File

@@ -0,0 +1,36 @@
{
"You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.": "Vous pouvez obtenir votre clé API en accédant au menu [API Keys](https://dashboard.peekshot.com/dashboard/api-keys).",
"Capture Screenshot": "Capture d'écran",
"Custom API Call": "Appel API personnalisé",
"Captures Screenshot of a URL.": "Capture d'écran d'une URL.",
"Make a custom API call to a specific endpoint": "Passez un appel API personnalisé à un point de terminaison spécifique",
"Project": "Projet",
"Target URL": "Target URL",
"Custom Screenshot Width": "Largeur de la capture d'écran personnalisée",
"Custom Screenshot Height": "Hauteur de la capture d'écran personnalisée",
"Image Format": "Format de l'image",
"Custom CSS": "Custom CSS",
"Custom JavaScript": "JavaScript personnalisé",
"Full Page?": "Page complète ?",
"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)",
"Output format for the screenshot.": "Format de sortie pour la capture d'écran.",
"Custom CSS to apply.": "CSS personnalisé à appliquer.",
"Custom JavaScript to apply.": "JavaScript personnalisé à appliquer.",
"To capture the entire page.": "Pour capturer toute la page.",
"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.",
"PNG": "PNG",
"JPEG": "JPEG",
"GET": "OBTENIR",
"POST": "POSTER",
"PATCH": "PATCH",
"PUT": "EFFACER",
"DELETE": "SUPPRIMER",
"HEAD": "TÊTE"
}

View File

@@ -0,0 +1,36 @@
{
"You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.": "API キーは [API キー](https://dashboard.peekshot.com/dashboard/api-keys) メニューに移動することで取得できます。",
"Capture Screenshot": "スクリーンショットを撮影",
"Custom API Call": "カスタムAPI通話",
"Captures Screenshot of a URL.": "URL のスクリーンショットを取得します。",
"Make a custom API call to a specific endpoint": "特定のエンドポイントへのカスタム API コールを実行します。",
"Project": "プロジェクト",
"Target URL": "Target URL",
"Custom Screenshot Width": "カスタムスクリーンショットの幅",
"Custom Screenshot Height": "カスタムスクリーンショットの高さ",
"Image Format": "画像フォーマット",
"Custom CSS": "Custom CSS",
"Custom JavaScript": "カスタム JavaScript",
"Full Page?": "フルページですか?",
"Method": "方法",
"Headers": "ヘッダー",
"Query Parameters": "クエリパラメータ",
"Body": "本文",
"Response is Binary ?": "応答はバイナリですか?",
"No Error on Failure": "失敗時にエラーはありません",
"Timeout (in seconds)": "タイムアウト(秒)",
"Output format for the screenshot.": "スクリーンショットの出力形式。",
"Custom CSS to apply.": "適用するカスタム CSS",
"Custom JavaScript to apply.": "適用するカスタムJavaScript。",
"To capture the entire page.": "ページ全体をキャプチャします。",
"Authorization headers are injected automatically from your connection.": "認証ヘッダは接続から自動的に注入されます。",
"Enable for files like PDFs, images, etc..": "PDF、画像などのファイルを有効にします。",
"PNG": "PNG",
"JPEG": "JPEG",
"GET": "取得",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "削除",
"HEAD": "頭"
}

View File

@@ -0,0 +1,36 @@
{
"You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.": "U kunt uw API-sleutel verkrijgen door te navigeren naar [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.",
"Capture Screenshot": "Schermafbeelding maken",
"Custom API Call": "Custom API Call",
"Captures Screenshot of a URL.": "Maakt Screenshot van een URL.",
"Make a custom API call to a specific endpoint": "Maak een aangepaste API call naar een specifiek eindpunt",
"Project": "Project",
"Target URL": "Target URL",
"Custom Screenshot Width": "Aangepaste Schermafbeelding Breedte",
"Custom Screenshot Height": "Aangepaste schermafbeelding hoogte",
"Image Format": "Afbeelding formaat",
"Custom CSS": "Custom CSS",
"Custom JavaScript": "Aangepaste JavaScript",
"Full Page?": "Volledige pagina?",
"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)",
"Output format for the screenshot.": "Uitvoerformaat voor de schermafbeelding.",
"Custom CSS to apply.": "Aangepaste CSS om toe te passen.",
"Custom JavaScript to apply.": "Aangepaste JavaScript om toe te passen.",
"To capture the entire page.": "Het maken van de hele pagina.",
"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..",
"PNG": "PNG",
"JPEG": "JPEG",
"GET": "KRIJG",
"POST": "POSTE",
"PATCH": "BEKIJK",
"PUT": "PUT",
"DELETE": "VERWIJDEREN",
"HEAD": "HOOFD"
}

View File

@@ -0,0 +1,36 @@
{
"You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.": "Você pode obter sua chave de API navegando para o menu [Chaves API](https://dashboard.peekshot.com/dashboard/api-keys).",
"Capture Screenshot": "Capturar tela",
"Custom API Call": "Chamada de API personalizada",
"Captures Screenshot of a URL.": "Captura a Captura de tela de uma URL.",
"Make a custom API call to a specific endpoint": "Faça uma chamada de API personalizada para um ponto de extremidade específico",
"Project": "Projecto",
"Target URL": "Target URL",
"Custom Screenshot Width": "Largura da Captura de Tela Personalizada",
"Custom Screenshot Height": "Altura da Captura de Tela Personalizada",
"Image Format": "Formato de Imagem",
"Custom CSS": "Custom CSS",
"Custom JavaScript": "JavaScript Personalizado",
"Full Page?": "Página completa?",
"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)",
"Output format for the screenshot.": "Formato de saída para a captura de tela.",
"Custom CSS to apply.": "O CSS personalizado para se aplicar.",
"Custom JavaScript to apply.": "JavaScript personalizado para aplicar.",
"To capture the entire page.": "Para capturar a página inteira.",
"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..",
"PNG": "PNG",
"JPEG": "JPEG",
"GET": "OBTER",
"POST": "POSTAR",
"PATCH": "COMPRAR",
"PUT": "COLOCAR",
"DELETE": "EXCLUIR",
"HEAD": "CABEÇA"
}

View File

@@ -0,0 +1,35 @@
{
"PeekShot": "PeekShot",
"You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.": "Вы можете получить ключ API, выбрав меню [API Keys](https://dashboard.peekshot.com/dashboard/api-keys).",
"Capture Screenshot": "Скриншот",
"Custom API Call": "Пользовательский вызов API",
"Captures Screenshot of a URL.": "Записывает скриншот URL.",
"Make a custom API call to a specific endpoint": "Сделать пользовательский API вызов к определенной конечной точке",
"Project": "Проект",
"Target URL": "Target URL",
"Custom Screenshot Width": "Пользовательская ширина скриншота",
"Custom Screenshot Height": "Высота снимка экрана",
"Image Format": "Формат изображения",
"Custom CSS": "Custom CSS",
"Custom JavaScript": "Пользовательский JavaScript",
"Full Page?": "Полная страница?",
"Method": "Метод",
"Headers": "Заголовки",
"Query Parameters": "Параметры запроса",
"Body": "Тело",
"No Error on Failure": "Нет ошибок при ошибке",
"Timeout (in seconds)": "Таймаут (в секундах)",
"Output format for the screenshot.": "Выходной формат для снимка экрана.",
"Custom CSS to apply.": "Пользовательский CSS для применения.",
"Custom JavaScript to apply.": "Пользовательский JavaScript для применения.",
"To capture the entire page.": "Захват всей страницы.",
"Authorization headers are injected automatically from your connection.": "Заголовки авторизации включаются автоматически из вашего соединения.",
"PNG": "PNG",
"JPEG": "JPEG",
"GET": "ПОЛУЧИТЬ",
"POST": "ПОСТ",
"PATCH": "ПАТЧ",
"PUT": "ПОКУПИТЬ",
"DELETE": "УДАЛИТЬ",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,36 @@
{
"You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.": "You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.",
"Capture Screenshot": "Capture Screenshot",
"Custom API Call": "Custom API Call",
"Captures Screenshot of a URL.": "Captures Screenshot of a URL.",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Project": "Project",
"Target URL": "Target URL",
"Custom Screenshot Width": "Custom Screenshot Width",
"Custom Screenshot Height": "Custom Screenshot Height",
"Image Format": "Image Format",
"Custom CSS": "Custom CSS",
"Custom JavaScript": "Custom JavaScript",
"Full Page?": "Full Page?",
"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)",
"Output format for the screenshot.": "Output format for the screenshot.",
"Custom CSS to apply.": "Custom CSS to apply.",
"Custom JavaScript to apply.": "Custom JavaScript to apply.",
"To capture the entire page.": "To capture the entire page.",
"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..",
"PNG": "PNG",
"JPEG": "JPEG",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,35 @@
{
"PeekShot": "PeekShot",
"You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.": "You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.",
"Capture Screenshot": "Capture Screenshot",
"Custom API Call": "Custom API Call",
"Captures Screenshot of a URL.": "Captures Screenshot of a URL.",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Project": "Project",
"Target URL": "Target URL",
"Custom Screenshot Width": "Custom Screenshot Width",
"Custom Screenshot Height": "Custom Screenshot Height",
"Image Format": "Image Format",
"Custom CSS": "Custom CSS",
"Custom JavaScript": "Custom JavaScript",
"Full Page?": "Full Page?",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
"Body": "Body",
"No Error on Failure": "No Error on Failure",
"Timeout (in seconds)": "Timeout (in seconds)",
"Output format for the screenshot.": "Output format for the screenshot.",
"Custom CSS to apply.": "Custom CSS to apply.",
"Custom JavaScript to apply.": "Custom JavaScript to apply.",
"To capture the entire page.": "To capture the entire page.",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"PNG": "PNG",
"JPEG": "JPEG",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,36 @@
{
"You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.": "You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.",
"Capture Screenshot": "Capture Screenshot",
"Custom API Call": "自定义 API 呼叫",
"Captures Screenshot of a URL.": "Captures Screenshot of a URL.",
"Make a custom API call to a specific endpoint": "将一个自定义 API 调用到一个特定的终点",
"Project": "项目",
"Target URL": "Target URL",
"Custom Screenshot Width": "Custom Screenshot Width",
"Custom Screenshot Height": "Custom Screenshot Height",
"Image Format": "Image Format",
"Custom CSS": "Custom CSS",
"Custom JavaScript": "Custom JavaScript",
"Full Page?": "Full Page?",
"Method": "方法",
"Headers": "信头",
"Query Parameters": "查询参数",
"Body": "正文内容",
"Response is Binary ?": "Response is Binary ?",
"No Error on Failure": "失败时没有错误",
"Timeout (in seconds)": "超时(秒)",
"Output format for the screenshot.": "Output format for the screenshot.",
"Custom CSS to apply.": "Custom CSS to apply.",
"Custom JavaScript to apply.": "Custom JavaScript to apply.",
"To capture the entire page.": "To capture the entire page.",
"Authorization headers are injected automatically from your connection.": "授权头自动从您的连接中注入。",
"Enable for files like PDFs, images, etc..": "Enable for files like PDFs, images, etc..",
"PNG": "PNG",
"JPEG": "JPEG",
"GET": "获取",
"POST": "帖子",
"PATCH": "PATCH",
"PUT": "弹出",
"DELETE": "删除",
"HEAD": "黑色"
}

View File

@@ -0,0 +1,51 @@
import { createPiece, PieceAuth } from '@activepieces/pieces-framework';
import { captureScreenshot } from './lib/actions/capture-screenshot';
import { PieceCategory } from '@activepieces/shared';
import {
createCustomApiCallAction,
httpClient,
HttpMethod,
} from '@activepieces/pieces-common';
export const peekshotAuth = PieceAuth.SecretText({
displayName: 'API Key',
required: true,
description: `You can obtain your API key by navigating to [API Keys](https://dashboard.peekshot.com/dashboard/api-keys) menu.`,
validate: async ({ auth }) => {
try {
await httpClient.sendRequest({
method: HttpMethod.GET,
url: 'https://api.peekshot.com/api/v1/projects',
headers: {
'x-api-key': auth,
'Content-Type': 'application/json',
},
});
return { valid: true };
} catch {
return { valid: false, error: 'Invalid API Key.' };
}
},
});
export const peekshot = createPiece({
displayName: 'PeekShot',
auth: peekshotAuth,
minimumSupportedRelease: '0.36.1',
logoUrl: 'https://cdn.activepieces.com/pieces/peekshot.png',
categories: [PieceCategory.PRODUCTIVITY],
authors: ['balwant1707'],
actions: [
captureScreenshot,
createCustomApiCallAction({
auth: peekshotAuth,
baseUrl: () => 'https://api.peekshot.com/api/v1',
authMapping: async (auth) => {
return {
'x-api-key': auth.secret_text,
};
},
}),
],
triggers: [],
});

View File

@@ -0,0 +1,115 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { peekshotAuth } from '../../index';
import { projectId } from '../common/props';
import {
CreateScreenshotResponse,
GetScreenshotResponse,
} from '../common/types';
export const captureScreenshot = createAction({
auth: peekshotAuth,
name: 'captureScreenshot',
displayName: 'Capture Screenshot',
description: 'Captures Screenshot of a URL.',
props: {
projectId: projectId,
url: Property.ShortText({ displayName: 'Target URL', required: true }),
width: Property.ShortText({
displayName: 'Custom Screenshot Width',
required: false,
}),
height: Property.ShortText({
displayName: 'Custom Screenshot Height',
required: false,
}),
file_type: Property.StaticDropdown({
displayName: 'Image Format',
description: 'Output format for the screenshot.',
required: false,
options: {
disabled: false,
options: [
{ label: 'PNG', value: 'png' },
{ label: 'JPEG', value: 'jpeg' },
],
},
}),
inject_css: Property.LongText({
displayName: 'Custom CSS',
description: 'Custom CSS to apply.',
required: false,
}),
inject_js: Property.LongText({
displayName: 'Custom JavaScript',
description: 'Custom JavaScript to apply.',
required: false,
}),
full_page: Property.Checkbox({
displayName: 'Full Page?',
description: 'To capture the entire page.',
required: false,
}),
},
async run({ propsValue, auth }) {
const {
projectId,
url,
width,
height,
file_type,
full_page,
inject_css,
inject_js,
} = propsValue;
const res = await httpClient.sendRequest<CreateScreenshotResponse>({
method: HttpMethod.POST,
url: 'https://api.peekshot.com/api/v1/screenshots',
headers: {
'x-api-key': auth.secret_text as string,
'Content-Type': 'application/json',
},
body: {
project_id: projectId.toString(),
url,
width,
height,
inject_css,
inject_js,
file_type,
full_page: full_page ? 'true' : 'false',
},
});
// Handle error in initial response
if (!res.body || !res.body.data || !res.body.data.requestId) {
throw new Error('Failed to initiate screenshot request');
}
const requestId = res.body.data.requestId;
let status = res.body.status;
const timeoutAt = Date.now() + 5 * 60 * 1000;
while (status !== 'COMPLETE' && Date.now() < timeoutAt) {
await new Promise((resolve) => setTimeout(resolve, 5000)); // wait 5 seconds
const pollRes = await httpClient.sendRequest<GetScreenshotResponse>({
method: HttpMethod.GET,
url: `https://api.peekshot.com/api/v1/screenshots/${requestId}`,
headers: {
'x-api-key': auth.secret_text,
'Content-Type': 'application/json',
},
});
status = pollRes.body?.data?.status;
if (status === 'COMPLETE') {
return pollRes.body; // Screenshot is ready
}
}
throw new Error('Screenshot generation timed out or failed.');
},
});

View File

@@ -0,0 +1,53 @@
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { Property } from '@activepieces/pieces-framework';
import { ListProjectsResponse } from './types';
import { peekshotAuth } from '../..';
export const projectId = Property.Dropdown({
displayName: 'Project',
required: true,
refreshers: [],
auth: peekshotAuth,
options: async ({ auth }) => {
if (!auth) {
return {
disabled: true,
placeholder: 'Please connect your account first.',
options: [],
};
}
try {
const response = await httpClient.sendRequest<ListProjectsResponse>({
method: HttpMethod.GET,
url: 'https://api.peekshot.com/api/v1/projects',
headers: {
'x-api-key': auth.secret_text,
'Content-Type': 'application/json',
},
});
// Handle the specific API response format
const responseData = response.body;
if (responseData?.status === 'success' && responseData?.data?.projects) {
const projects = responseData.data.projects;
const projectOptions = projects.map((project) => ({
label: project.name,
value: project.id,
}));
return {
options: projectOptions,
};
}
return {
options: [],
};
} catch (error) {
return {
options: [],
};
}
},
});

View File

@@ -0,0 +1,27 @@
export interface ListProjectsResponse {
status: string;
message: string;
data: {
projects: Array<{ id: number; name: string }>;
};
}
export interface CreateScreenshotResponse {
status: string;
message: string;
data: {
url: string;
requestId: number;
};
}
export interface GetScreenshotResponse {
status: string;
message: string;
data: {
url: string;
id: number;
status:string
};
}