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,18 @@
{
"extends": ["../../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}

View File

@@ -0,0 +1,7 @@
# pieces-gitlab
This library was generated with [Nx](https://nx.dev).
## Building
Run `nx build pieces-gitlab` to build the library.

View File

@@ -0,0 +1,4 @@
{
"name": "@activepieces/piece-gitlab",
"version": "0.0.11"
}

View File

@@ -0,0 +1,57 @@
{
"name": "pieces-gitlab",
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/pieces/community/gitlab/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/packages/pieces/community/gitlab",
"tsConfig": "packages/pieces/community/gitlab/tsconfig.lib.json",
"packageJson": "packages/pieces/community/gitlab/package.json",
"main": "packages/pieces/community/gitlab/src/index.ts",
"assets": [
"packages/pieces/community/gitlab/*.md",
{
"input": "packages/pieces/community/gitlab/src/i18n",
"output": "./src/i18n",
"glob": "**/!(i18n.json)"
}
],
"buildableProjectDepsInPackageJsonType": "dependencies",
"updateBuildableProjectDepsInPackageJson": true
},
"dependsOn": [
"^build",
"prebuild"
]
},
"publish": {
"command": "node tools/scripts/publish.mjs pieces-gitlab {args.ver} {args.tag}",
"dependsOn": [
"build"
]
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}"
]
},
"prebuild": {
"executor": "nx:run-commands",
"options": {
"cwd": "packages/pieces/community/gitlab",
"command": "bun install --no-save --silent"
},
"dependsOn": [
"^build"
]
}
},
"tags": []
}

View File

@@ -0,0 +1,33 @@
{
"Collaboration tool for developers": "Kollaborationstool für Entwickler",
"Create Issue": "Ticket erstellen",
"Custom API Call": "Eigener API-Aufruf",
"Create a project issue": "Ein Projektproblem erstellen",
"Make a custom API call to a specific endpoint": "Einen benutzerdefinierten API-Aufruf an einen bestimmten Endpunkt machen",
"Project": "Projekt",
"Issue Title": "Ticket-Titel",
"Issue Description": "Problembeschreibung",
"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)",
"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 Project Issue Event": "Neues Projekt Issue Ereignis",
"Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.": "Löscht Ereignisse bei Projekt-Issue-Ereignissen, wenn ein Problem erstellt wird oder wenn ein bestehendes Problem aktualisiert, geschlossen oder wieder geöffnet wird.",
"Issue Event": "Ticket Ereignis",
"Issue Event type for trigger": "Ticket Event Typ für Auslöser",
"All": "Alle",
"Opened": "Geöffnet",
"Closed": "Geschlossen",
"Updated": "Updated"
}

View File

@@ -0,0 +1,33 @@
{
"Collaboration tool for developers": "Herramienta de colaboración para desarrolladores",
"Create Issue": "Crear asunto",
"Custom API Call": "Llamada API personalizada",
"Create a project issue": "Crear un problema de proyecto",
"Make a custom API call to a specific endpoint": "Hacer una llamada API personalizada a un extremo específico",
"Project": "Projekt",
"Issue Title": "Título del asunto",
"Issue Description": "Descripción del asunto",
"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)",
"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 Project Issue Event": "Nuevo Evento de Proyectos",
"Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.": "Se activa en eventos de incidencias del proyecto cuando se crea una incidencia o cuando se actualiza, cierra o vuelve a abrir una incidencia.",
"Issue Event": "Emitir Evento",
"Issue Event type for trigger": "Tipo de evento de emisión para el disparador",
"All": "Todos",
"Opened": "Abierto",
"Closed": "Cerrado",
"Updated": "Actualizado"
}

View File

@@ -0,0 +1,33 @@
{
"Collaboration tool for developers": "Outil de collaboration pour les développeurs",
"Create Issue": "Créer un problème",
"Custom API Call": "Appel API personnalisé",
"Create a project issue": "Créer un ticket de projet",
"Make a custom API call to a specific endpoint": "Passez un appel API personnalisé à un point de terminaison spécifique",
"Project": "Projet",
"Issue Title": "Titre du ticket",
"Issue Description": "Description du problème",
"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)",
"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 Project Issue Event": "Événement de nouveau problème de projet",
"Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.": "Déclenche les événements de tickets du projet lorsqu'une anomalie est créée ou lorsqu'une anomalie existante est mise à jour, fermée ou rouverte.",
"Issue Event": "Événement de ticket",
"Issue Event type for trigger": "Type d'événement de ticket pour le déclencheur",
"All": "Tous",
"Opened": "Ouvert",
"Closed": "Fermé",
"Updated": "Mis à jour"
}

View File

@@ -0,0 +1,33 @@
{
"Collaboration tool for developers": "開発者向けのコラボレーションツール",
"Create Issue": "課題を作成",
"Custom API Call": "カスタムAPI通話",
"Create a project issue": "プロジェクトの課題を作成",
"Make a custom API call to a specific endpoint": "特定のエンドポイントへのカスタム API コールを実行します。",
"Project": "プロジェクト",
"Issue Title": "課題タイトル",
"Issue Description": "Issue の説明",
"Method": "方法",
"Headers": "ヘッダー",
"Query Parameters": "クエリパラメータ",
"Body": "本文",
"Response is Binary ?": "応答はバイナリですか?",
"No Error on Failure": "失敗時にエラーはありません",
"Timeout (in seconds)": "タイムアウト(秒)",
"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 Project Issue Event": "新しいプロジェクト課題イベント",
"Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.": "課題が作成されたとき、または既存の課題が更新、閉じ、または再開されたときに、プロジェクトの課題イベントをトリガーします。",
"Issue Event": "課題イベント",
"Issue Event type for trigger": "トリガーの課題イベントタイプ",
"All": "すべて",
"Opened": "開放済み",
"Closed": "クローズ済み",
"Updated": "更新日時"
}

View File

@@ -0,0 +1,33 @@
{
"Collaboration tool for developers": "Gereedschap voor ontwikkelaars",
"Create Issue": "Probleem aanmaken",
"Custom API Call": "Custom API Call",
"Create a project issue": "Maak een project probleem aan",
"Make a custom API call to a specific endpoint": "Maak een aangepaste API call naar een specifiek eindpunt",
"Project": "Project",
"Issue Title": "Titel van probleem",
"Issue Description": "Beschrijving van probleem",
"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)",
"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 Project Issue Event": "Nieuw Project Probleem Evenement",
"Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.": "Triggert op project-issue gebeurtenissen wanneer een issue is aangemaakt of wanneer een bestaand issue is bijgewerkt, gesloten of heropend.",
"Issue Event": "Issue Evenement",
"Issue Event type for trigger": "Issue gebeurtenis type voor trigger",
"All": "Allemaal",
"Opened": "Geopend",
"Closed": "gesloten",
"Updated": "Gewijzigd"
}

View File

@@ -0,0 +1,33 @@
{
"Collaboration tool for developers": "Ferramenta de colaboração para desenvolvedores",
"Create Issue": "Criar issue",
"Custom API Call": "Chamada de API personalizada",
"Create a project issue": "Criar um projeto de issue",
"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",
"Issue Title": "Título da Solicitação",
"Issue Description": "Descrição do problema",
"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)",
"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 Project Issue Event": "Novo Evento de Issue Projeto",
"Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.": "Aciona em eventos de issue de projeto quando uma issue é criada ou quando uma issue existente é atualizada, fechada ou reaberta.",
"Issue Event": "Evento de issue",
"Issue Event type for trigger": "Tipo de Evento de issue para gatilho",
"All": "TODOS",
"Opened": "Aberto",
"Closed": "Fechado",
"Updated": "Atualizado"
}

View File

@@ -0,0 +1,32 @@
{
"GitLab": "GitLab",
"Collaboration tool for developers": "Инструмент сотрудничества для разработчиков",
"Create Issue": "Создать запрос",
"Custom API Call": "Пользовательский вызов API",
"Create a project issue": "Создать проект задачи",
"Make a custom API call to a specific endpoint": "Сделать пользовательский API вызов к определенной конечной точке",
"Project": "Проект",
"Issue Title": "Название задачи",
"Issue Description": "Описание проблемы",
"Method": "Метод",
"Headers": "Заголовки",
"Query Parameters": "Параметры запроса",
"Body": "Тело",
"No Error on Failure": "Нет ошибок при ошибке",
"Timeout (in seconds)": "Таймаут (в секундах)",
"Authorization headers are injected automatically from your connection.": "Заголовки авторизации включаются автоматически из вашего соединения.",
"GET": "ПОЛУЧИТЬ",
"POST": "ПОСТ",
"PATCH": "ПАТЧ",
"PUT": "ПОКУПИТЬ",
"DELETE": "УДАЛИТЬ",
"HEAD": "HEAD",
"New Project Issue Event": "Новое событие Проблемы Проекта",
"Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.": "Запускает события при создании задачи или при обновлении существующей задачи, закрытии или повторном открытии.",
"Issue Event": "Событие Задачи",
"Issue Event type for trigger": "Тип события для триггера",
"All": "Все",
"Opened": "Открыт",
"Closed": "Закрыто",
"Updated": "Updated"
}

View File

@@ -0,0 +1,33 @@
{
"Collaboration tool for developers": "Collaboration tool for developers",
"Create Issue": "Create Issue",
"Custom API Call": "Custom API Call",
"Create a project issue": "Create a project issue",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Project": "Project",
"Issue Title": "Issue Title",
"Issue Description": "Issue Description",
"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)",
"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 Project Issue Event": "New Project Issue Event",
"Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.": "Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.",
"Issue Event": "Issue Event",
"Issue Event type for trigger": "Issue Event type for trigger",
"All": "All",
"Opened": "Opened",
"Closed": "Closed",
"Updated": "Updated"
}

View File

@@ -0,0 +1,32 @@
{
"GitLab": "GitLab",
"Collaboration tool for developers": "Collaboration tool for developers",
"Create Issue": "Create Issue",
"Custom API Call": "Custom API Call",
"Create a project issue": "Create a project issue",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Project": "Project",
"Issue Title": "Issue Title",
"Issue Description": "Issue Description",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
"Body": "Body",
"No Error on Failure": "No Error on Failure",
"Timeout (in seconds)": "Timeout (in seconds)",
"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 Project Issue Event": "New Project Issue Event",
"Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.": "Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.",
"Issue Event": "Issue Event",
"Issue Event type for trigger": "Issue Event type for trigger",
"All": "Tất cả",
"Opened": "Opened",
"Closed": "Closed",
"Updated": "Updated"
}

View File

@@ -0,0 +1,33 @@
{
"Collaboration tool for developers": "Collaboration tool for developers",
"Create Issue": "Create Issue",
"Custom API Call": "自定义 API 呼叫",
"Create a project issue": "Create a project issue",
"Make a custom API call to a specific endpoint": "将一个自定义 API 调用到一个特定的终点",
"Project": "项目",
"Issue Title": "Issue Title",
"Issue Description": "Issue Description",
"Method": "方法",
"Headers": "信头",
"Query Parameters": "查询参数",
"Body": "正文内容",
"Response is Binary ?": "Response is Binary ?",
"No Error on Failure": "失败时没有错误",
"Timeout (in seconds)": "超时(秒)",
"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 Project Issue Event": "New Project Issue Event",
"Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.": "Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.",
"Issue Event": "Issue Event",
"Issue Event type for trigger": "Issue Event type for trigger",
"All": "所有的",
"Opened": "Opened",
"Closed": "Closed",
"Updated": "Updated"
}

View File

@@ -0,0 +1,38 @@
import { createCustomApiCallAction } from '@activepieces/pieces-common';
import {
createPiece,
OAuth2PropertyValue,
PieceAuth,
} from '@activepieces/pieces-framework';
import { PieceCategory } from '@activepieces/shared';
import { createIssueAction } from './lib/actions/create-issue-action';
import { issuesEventTrigger } from './lib/trigger/issue-event';
export const gitlabAuth = PieceAuth.OAuth2({
required: true,
authUrl: 'https://gitlab.com/oauth/authorize',
tokenUrl: 'https://gitlab.com/oauth/token',
scope: ['api', 'read_user'],
});
export const gitlab = createPiece({
displayName: 'GitLab',
description: 'Collaboration tool for developers',
auth: gitlabAuth,
minimumSupportedRelease: '0.30.0',
logoUrl: 'https://cdn.activepieces.com/pieces/gitlab.png',
categories: [PieceCategory.DEVELOPER_TOOLS],
authors: ["kishanprmr","MoShizzle","khaledmashaly","abuaboud"],
actions: [
createIssueAction,
createCustomApiCallAction({
baseUrl: () => 'https://gitlab.com/api/v4',
auth: gitlabAuth,
authMapping: async (auth) => ({
Authorization: `Bearer ${(auth).access_token}`,
}),
}),
],
triggers: [issuesEventTrigger],
});

View File

@@ -0,0 +1,29 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { gitlabAuth } from '../../';
import { gitlabCommon, makeClient } from '../common';
export const createIssueAction = createAction({
auth: gitlabAuth,
name: 'create_issue',
description: 'Create a project issue',
displayName: 'Create Issue',
props: {
projectId: gitlabCommon.projectId(),
title: Property.ShortText({
displayName: 'Issue Title',
required: true,
}),
description: Property.LongText({
displayName: 'Issue Description',
required: false,
}),
},
async run({ propsValue, auth }) {
const { projectId, title, description } = propsValue;
const client = makeClient({ auth });
return await client.createProjectIssue(projectId as string, {
title: title,
description: description,
});
},
});

View File

@@ -0,0 +1,96 @@
import {
AuthenticationType,
HttpMessageBody,
HttpMethod,
QueryParams,
httpClient,
} from '@activepieces/pieces-common';
import {
ListProjectsRequest,
CreateProjectIssueRequest,
GitlabProject,
ProjectWebhookRequest,
ProjectWebhook,
} from './models';
export class GitlabApi {
constructor(private accessToken: string) {}
async makeRequest<T extends HttpMessageBody>(
method: HttpMethod,
url: string,
query?: QueryParams,
body?: object
): Promise<T> {
const res = await httpClient.sendRequest<T>({
method,
url: 'https://gitlab.com/api/v4' + url,
queryParams: query,
body,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: this.accessToken,
},
});
return res.body;
}
async listProjects(request: ListProjectsRequest) {
return this.makeRequest<GitlabProject[]>(
HttpMethod.GET,
'/projects',
prepareQuery(request)
);
}
async createProjectIssue(
projectId: string,
request: CreateProjectIssueRequest
) {
return this.makeRequest(
HttpMethod.POST,
`/projects/${projectId}/issues`,
undefined,
request
);
}
async subscribeProjectWebhook(
projectId: string,
request: ProjectWebhookRequest
) {
return this.makeRequest<ProjectWebhook>(
HttpMethod.POST,
`/projects/${projectId}/hooks`,
undefined,
request
);
}
async unsubscribeProjectWebhook(projectId: string, webhookId: string) {
return this.makeRequest(
HttpMethod.DELETE,
`/projects/${projectId}/hooks/${webhookId}`,
undefined
);
}
}
function emptyValueFilter(
accessor: (key: string) => any
): (key: string) => boolean {
return (key: string) => {
const val = accessor(key);
return (
val !== null &&
val !== undefined &&
(typeof val != 'string' || val.length > 0)
);
};
}
export function prepareQuery(request?: Record<string, any>): QueryParams {
const params: QueryParams = {};
if (!request) return params;
Object.keys(request)
.filter(emptyValueFilter((k) => request[k]))
.forEach((k: string) => {
params[k] = (request as Record<string, any>)[k].toString();
});
return params;
}

View File

@@ -0,0 +1,46 @@
import { getAccessTokenOrThrow } from '@activepieces/pieces-common';
import { OAuth2PropertyValue, Property } from '@activepieces/pieces-framework';
import { GitlabApi } from './client';
import { gitlabAuth } from '../..';
export const gitlabCommon = {
projectId: (required = true) =>
Property.Dropdown({
auth: gitlabAuth,
displayName: 'Project',
required,
refreshers: [],
options: async ({ auth }) => {
if (!auth) {
return {
disabled: true,
placeholder: 'Setup authentication first',
options: [],
};
}
const client = makeClient({
auth: auth,
});
const res = await client.listProjects({
simple: true,
membership: true,
});
return {
disabled: false,
options: res.map((project) => {
return {
label: project.name,
value: project.id,
};
}),
};
},
}),
};
export function makeClient(propsValue: {
auth: OAuth2PropertyValue;
}): GitlabApi {
const token = getAccessTokenOrThrow(propsValue.auth);
return new GitlabApi(token);
}

View File

@@ -0,0 +1,57 @@
export interface ListProjectsRequest {
membership?: boolean;
simple?: boolean;
}
export interface ProjectWebhookRequest {
url: string;
confidential_issues_events?: boolean;
confidential_note_events?: boolean;
deployment_events?: boolean;
enable_ssl_verification?: boolean;
issues_events?: boolean;
job_events?: boolean;
merge_requests_events?: boolean;
note_events?: boolean;
pipeline_events?: boolean;
push_events_branch_filter?: string;
push_events?: boolean;
releases_events?: boolean;
tag_push_events?: boolean;
wiki_page_events?: boolean;
token?: boolean;
}
export interface CreateProjectIssueRequest {
title: string;
description?: string;
}
export interface ProjectWebhook {
id: string;
}
export interface GitlabProject {
id: string;
description?: string;
name: string;
name_with_namespace: string;
path: string;
path_with_namespace: string;
created_at: string;
default_branch: string;
tag_list?: string[];
topics?: string[];
ssh_url_to_repo: string;
http_url_to_repo: string;
web_url: string;
avatar_url?: string;
star_count: number;
last_activity_at: string;
namespace: {
id: number;
name: string;
path: string;
kind: string;
full_path: string;
parent_id?: string;
avatar_url?: string;
web_url: string;
};
}

View File

@@ -0,0 +1,171 @@
import {
createTrigger,
TriggerStrategy,
Property,
} from '@activepieces/pieces-framework';
import { gitlabCommon, makeClient } from '../common';
import { gitlabAuth } from '../..';
const sampleData = {
object_kind: 'issue',
event_type: 'issue',
user: {
id: 15269532,
name: 'Kishan Parmar',
username: 'kishanprmr',
avatar_url:
'https://secure.gravatar.com/avatar/4eabe7154116891e3ebc205e9754a832?s=80&d=identicon',
email: '[REDACTED]',
},
project: {
id: 48074457,
name: 'basic-project-demo',
description: null,
web_url: 'https://gitlab.com/basic-group-demo/basic-project-demo',
avatar_url: null,
git_ssh_url: 'git@gitlab.com:basic-group-demo/basic-project-demo.git',
git_http_url: 'https://gitlab.com/basic-group-demo/basic-project-demo.git',
namespace: 'basic-group-demo',
visibility_level: 0,
path_with_namespace: 'basic-group-demo/basic-project-demo',
default_branch: 'main',
ci_config_path: '',
homepage: 'https://gitlab.com/basic-group-demo/basic-project-demo',
url: 'git@gitlab.com:basic-group-demo/basic-project-demo.git',
ssh_url: 'git@gitlab.com:basic-group-demo/basic-project-demo.git',
http_url: 'https://gitlab.com/basic-group-demo/basic-project-demo.git',
},
object_attributes: {
author_id: 15269532,
closed_at: null,
confidential: false,
created_at: '2023-09-01 07:03:02 UTC',
description: '',
discussion_locked: null,
due_date: null,
id: 133093523,
iid: 32,
last_edited_at: null,
last_edited_by_id: null,
milestone_id: null,
moved_to_id: null,
duplicated_to_id: null,
project_id: 48074457,
relative_position: null,
state_id: 1,
time_estimate: 0,
title: 'Activepieces Testing',
updated_at: '2023-09-01 07:03:02 UTC',
updated_by_id: null,
weight: null,
health_status: null,
url: 'https://gitlab.com/basic-group-demo/basic-project-demo/-/issues/32',
total_time_spent: 0,
time_change: 0,
human_total_time_spent: null,
human_time_change: null,
human_time_estimate: null,
assignee_ids: [],
assignee_id: null,
labels: [],
state: 'opened',
severity: 'unknown',
customer_relations_contacts: [],
action: 'open',
},
labels: [],
changes: {
author_id: { previous: null, current: 15269532 },
created_at: { previous: null, current: '2023-09-01 07:03:02 UTC' },
description: { previous: null, current: '' },
id: { previous: null, current: 133093523 },
iid: { previous: null, current: 32 },
project_id: { previous: null, current: 48074457 },
time_estimate: { previous: null, current: 0 },
title: { previous: null, current: 'Activepieces Testing' },
updated_at: { previous: null, current: '2023-09-01 07:03:02 UTC' },
},
repository: {
name: 'basic-project-demo',
url: 'git@gitlab.com:basic-group-demo/basic-project-demo.git',
description: null,
homepage: 'https://gitlab.com/basic-group-demo/basic-project-demo',
},
};
export const issuesEventTrigger = createTrigger({
auth: gitlabAuth,
name: 'project_issue_event',
displayName: 'New Project Issue Event',
description:
'Triggers on project issue events when an issue is created or when an existing issue is updated, closed, or reopened.',
props: {
projectId: gitlabCommon.projectId(),
actiontype: Property.StaticDropdown({
displayName: 'Issue Event',
description: 'Issue Event type for trigger',
defaultValue: 'all',
required: true,
options: {
disabled: false,
options: [
{ label: 'All', value: 'all' },
{ label: 'Opened', value: 'open' },
{ label: 'Closed', value: 'close' },
{ label: 'Updated', value: 'update' },
],
},
}),
},
type: TriggerStrategy.WEBHOOK,
sampleData: sampleData,
async onEnable({ store, auth, propsValue, webhookUrl }) {
const projectId = propsValue.projectId!;
const client = makeClient({ auth });
const res = await client.subscribeProjectWebhook(projectId, {
url: webhookUrl,
issues_events: true,
push_events: false,
});
await store.put<WebhookInformation>('gitlab_issue_trigger', {
webhookId: res.id,
projectId: projectId as string,
});
},
async onDisable({ auth, store }) {
const response = await store.get<WebhookInformation>(
'gitlab_issue_trigger'
);
if (response !== null && response !== undefined) {
const client = makeClient({ auth });
client.unsubscribeProjectWebhook(response.projectId, response.webhookId);
}
},
async run(context) {
const { actiontype } = context.propsValue;
if (
isVerificationCall(
context.payload.body as Record<string, unknown>,
actiontype as string
)
) {
return [context.payload.body];
}
return [];
},
});
function isVerificationCall(payload: Record<string, any>, actiontype: string) {
if (actiontype == 'all') {
return true;
}
return payload['object_attributes']['action'] == actiontype;
}
interface WebhookInformation {
webhookId: string;
projectId: string;
}

View File

@@ -0,0 +1,19 @@
{
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
]
}

View File

@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "../../../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}