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-box
This library was generated with [Nx](https://nx.dev).
## Building
Run `nx build pieces-box` to build the library.

View File

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

View File

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

View File

@@ -0,0 +1,34 @@
{
"Secure content management and collaboration": "Sicheres Content-Management und Zusammenarbeit",
"Custom API Call": "Eigener API-Aufruf",
"Make a custom API call to a specific endpoint": "Einen benutzerdefinierten API-Aufruf an einen bestimmten Endpunkt machen",
"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 File": "Neue Datei",
"New Folder": "Neuer Ordner",
"New Comment": "Neuer Kommentar",
"Triggers when a file is uploaded": "Wird ausgelöst, wenn eine Datei hochgeladen wird",
"Triggers when a folder is created": "Wird ausgelöst, wenn ein Ordner erstellt wurde",
"Triggers when a comment is created": "Wird ausgelöst, wenn ein Kommentar erstellt wurde",
"Folder ID": "Ordner-ID",
"File/Folder ID": "Datei/Ordner-ID",
"Item Type": "Artikeltyp",
"The ID of the folder in which file uploads will trigger this webhook": "Die ID des Ordners, in dem Datei-Uploads diesen Webhook auslösen werden",
"The ID of the item to trigger a webhook": "Die ID des Artikels, um einen Webhook auszulösen",
"The type of the item to trigger a webhook": "Der Typ des Artikels, um einen Webhook auszulösen",
"File": "Datei",
"Folder": "Ordner"
}

View File

@@ -0,0 +1,34 @@
{
"Secure content management and collaboration": "Gestión de contenido seguro y colaboración",
"Custom API Call": "Llamada API personalizada",
"Make a custom API call to a specific endpoint": "Hacer una llamada API personalizada a un extremo específico",
"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 File": "Nuevo archivo",
"New Folder": "Nueva carpeta",
"New Comment": "Nuevo comentario",
"Triggers when a file is uploaded": "Dispara cuando se carga un archivo",
"Triggers when a folder is created": "Dispara cuando se crea una carpeta",
"Triggers when a comment is created": "Dispara cuando se crea un comentario",
"Folder ID": "ID Carpeta",
"File/Folder ID": "ID de archivo/carpeta",
"Item Type": "Tipo de artículo",
"The ID of the folder in which file uploads will trigger this webhook": "El ID de la carpeta en la que las subidas de archivos activarán este webhook",
"The ID of the item to trigger a webhook": "El ID del elemento para activar un webhook",
"The type of the item to trigger a webhook": "El tipo de elemento para activar un webhook",
"File": "Archivo",
"Folder": "Carpeta"
}

View File

@@ -0,0 +1,34 @@
{
"Secure content management and collaboration": "Gestion sécurisée du contenu et collaboration",
"Custom API Call": "Appel API personnalisé",
"Make a custom API call to a specific endpoint": "Passez un appel API personnalisé à un point de terminaison spécifique",
"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 File": "Nouveau fichier",
"New Folder": "New Folder",
"New Comment": "Nouveau commentaire",
"Triggers when a file is uploaded": "Déclenche lorsqu'un fichier est téléchargé",
"Triggers when a folder is created": "Déclenche lorsqu'un dossier est créé",
"Triggers when a comment is created": "Déclenche lorsqu'un commentaire est créé",
"Folder ID": "ID du dossier",
"File/Folder ID": "ID du fichier/dossier",
"Item Type": "Type d'élément",
"The ID of the folder in which file uploads will trigger this webhook": "L'ID du dossier dans lequel les téléchargements de fichiers déclencheront ce webhook",
"The ID of the item to trigger a webhook": "L'ID de l'élément pour déclencher un webhook",
"The type of the item to trigger a webhook": "Le type de l'élément pour déclencher un webhook",
"File": "Ficher",
"Folder": "Dossier"
}

View File

@@ -0,0 +1,34 @@
{
"Secure content management and collaboration": "セキュアなコンテンツ管理とコラボレーション",
"Custom API Call": "カスタムAPI通話",
"Make a custom API call to a specific endpoint": "特定のエンドポイントへのカスタム API コールを実行します。",
"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 File": "新規ファイル",
"New Folder": "新規フォルダ",
"New Comment": "新しいコメント",
"Triggers when a file is uploaded": "ファイルがアップロードされたときにトリガーします",
"Triggers when a folder is created": "フォルダが作成されたときにトリガーします",
"Triggers when a comment is created": "コメントが作成されたときにトリガー",
"Folder ID": "フォルダID",
"File/Folder ID": "ファイル/フォルダID",
"Item Type": "アイテムタイプ",
"The ID of the folder in which file uploads will trigger this webhook": "ファイルのアップロードがこのWebhookをトリガーするフォルダのID",
"The ID of the item to trigger a webhook": "WebhookをトリガーするアイテムのID",
"The type of the item to trigger a webhook": "Webhookをトリガーするアイテムの種類",
"File": "ファイル",
"Folder": "フォルダ"
}

View File

@@ -0,0 +1,34 @@
{
"Secure content management and collaboration": "Beveiligd contentbeheer en samenwerking",
"Custom API Call": "Custom API Call",
"Make a custom API call to a specific endpoint": "Maak een aangepaste API call naar een specifiek eindpunt",
"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 File": "Nieuw bestand",
"New Folder": "Nieuwe map",
"New Comment": "Nieuwe reactie",
"Triggers when a file is uploaded": "Activeert wanneer een bestand is geüpload",
"Triggers when a folder is created": "Triggert wanneer een map wordt aangemaakt",
"Triggers when a comment is created": "Triggert wanneer een reactie wordt aangemaakt",
"Folder ID": "Map ID",
"File/Folder ID": "Bestand/map ID",
"Item Type": "Artikel type",
"The ID of the folder in which file uploads will trigger this webhook": "De ID van de map waarin de bestandsuploads deze webhook aanzet",
"The ID of the item to trigger a webhook": "De ID van het item om een webhook te activeren",
"The type of the item to trigger a webhook": "Het type van het item om een webhook te activeren",
"File": "Bestand",
"Folder": "Map"
}

View File

@@ -0,0 +1,34 @@
{
"Secure content management and collaboration": "Gerenciamento seguro de conteúdo e colaboração",
"Custom API Call": "Chamada de API personalizada",
"Make a custom API call to a specific endpoint": "Faça uma chamada de API personalizada para um ponto de extremidade específico",
"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 File": "Novo arquivo",
"New Folder": "Nova Pasta",
"New Comment": "Novo Comentário",
"Triggers when a file is uploaded": "Dispara quando um arquivo é carregado",
"Triggers when a folder is created": "Dispara quando uma pasta é criada",
"Triggers when a comment is created": "Dispara quando um comentário é criado",
"Folder ID": "ID da pasta",
"File/Folder ID": "ID do Arquivo/Pasta",
"Item Type": "Tipo de Item",
"The ID of the folder in which file uploads will trigger this webhook": "A ID da pasta na qual o upload de arquivos irá acionar este webhook",
"The ID of the item to trigger a webhook": "A ID do item para acionar um webhook",
"The type of the item to trigger a webhook": "O tipo do item para acionar um webhook",
"File": "Arquivo",
"Folder": "Pasta"
}

View File

@@ -0,0 +1,33 @@
{
"Box": "Блок",
"Secure content management and collaboration": "Безопасное управление контентом и сотрудничество",
"Custom API Call": "Пользовательский вызов API",
"Make a custom API call to a specific endpoint": "Сделать пользовательский API вызов к определенной конечной точке",
"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 File": "Новый файл",
"New Folder": "Новая папка",
"New Comment": "Новый комментарий",
"Triggers when a file is uploaded": "Триггеры при загрузке файла",
"Triggers when a folder is created": "Включает при создании папки",
"Triggers when a comment is created": "Триггеры при создании комментария",
"Folder ID": "ID папки",
"File/Folder ID": "ID файла/папки",
"Item Type": "Тип предмета",
"The ID of the folder in which file uploads will trigger this webhook": "ID папки, в которой загружается файл, будет срабатывать этот вебхук",
"The ID of the item to trigger a webhook": "ID элемента для запуска webhook",
"The type of the item to trigger a webhook": "Тип элемента для запуска webhook",
"File": "Файл",
"Folder": "Папка"
}

View File

@@ -0,0 +1,34 @@
{
"Secure content management and collaboration": "Secure content management and collaboration",
"Custom API Call": "Custom API Call",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"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 File": "New File",
"New Folder": "New Folder",
"New Comment": "New Comment",
"Triggers when a file is uploaded": "Triggers when a file is uploaded",
"Triggers when a folder is created": "Triggers when a folder is created",
"Triggers when a comment is created": "Triggers when a comment is created",
"Folder ID": "Folder ID",
"File/Folder ID": "File/Folder ID",
"Item Type": "Item Type",
"The ID of the folder in which file uploads will trigger this webhook": "The ID of the folder in which file uploads will trigger this webhook",
"The ID of the item to trigger a webhook": "The ID of the item to trigger a webhook",
"The type of the item to trigger a webhook": "The type of the item to trigger a webhook",
"File": "File",
"Folder": "Folder"
}

View File

@@ -0,0 +1,33 @@
{
"Box": "Box",
"Secure content management and collaboration": "Secure content management and collaboration",
"Custom API Call": "Custom API Call",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"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 File": "New File",
"New Folder": "New Folder",
"New Comment": "New Comment",
"Triggers when a file is uploaded": "Triggers when a file is uploaded",
"Triggers when a folder is created": "Triggers when a folder is created",
"Triggers when a comment is created": "Triggers when a comment is created",
"Folder ID": "Folder ID",
"File/Folder ID": "File/Folder ID",
"Item Type": "Item Type",
"The ID of the folder in which file uploads will trigger this webhook": "The ID of the folder in which file uploads will trigger this webhook",
"The ID of the item to trigger a webhook": "The ID of the item to trigger a webhook",
"The type of the item to trigger a webhook": "The type of the item to trigger a webhook",
"File": "File",
"Folder": "Folder"
}

View File

@@ -0,0 +1,34 @@
{
"Secure content management and collaboration": "Secure content management and collaboration",
"Custom API Call": "自定义 API 呼叫",
"Make a custom API call to a specific endpoint": "将一个自定义 API 调用到一个特定的终点",
"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 File": "New File",
"New Folder": "新建文件夹",
"New Comment": "New Comment",
"Triggers when a file is uploaded": "Triggers when a file is uploaded",
"Triggers when a folder is created": "Triggers when a folder is created",
"Triggers when a comment is created": "Triggers when a comment is created",
"Folder ID": "Folder ID",
"File/Folder ID": "File/Folder ID",
"Item Type": "Item Type",
"The ID of the folder in which file uploads will trigger this webhook": "The ID of the folder in which file uploads will trigger this webhook",
"The ID of the item to trigger a webhook": "The ID of the item to trigger a webhook",
"The type of the item to trigger a webhook": "The type of the item to trigger a webhook",
"File": "文件",
"Folder": "文件夹"
}

View File

@@ -0,0 +1,40 @@
import {
createPiece,
OAuth2PropertyValue,
PieceAuth,
} from '@activepieces/pieces-framework';
import { createCustomApiCallAction } from '@activepieces/pieces-common';
import { PieceCategory } from '@activepieces/shared';
import { common } from './lib/common';
import { newComment } from './lib/triggers/new-comment';
import { newFile } from './lib/triggers/new-file';
import { newFolder } from './lib/triggers/new-folder';
export const boxAuth = PieceAuth.OAuth2({
required: true,
authUrl: 'https://account.box.com/api/oauth2/authorize',
tokenUrl: 'https://api.box.com/oauth2/token',
scope: ['manage_webhook', 'root_readonly', 'root_readwrite'],
});
export const box = createPiece({
displayName: 'Box',
description: 'Secure content management and collaboration',
auth: boxAuth,
minimumSupportedRelease: '0.30.0',
logoUrl: 'https://cdn.activepieces.com/pieces/box.png',
categories: [PieceCategory.CONTENT_AND_FILES],
authors: ["kishanprmr","MoShizzle","abuaboud"],
actions: [
createCustomApiCallAction({
baseUrl: () => common.baseUrl,
auth: boxAuth,
authMapping: async (auth) => ({
Authorization: `Bearer ${auth.access_token}`,
}),
}),
],
triggers: [newFile, newFolder, newComment],
});

View File

@@ -0,0 +1,64 @@
import {
AuthenticationType,
HttpMethod,
HttpRequest,
httpClient,
} from '@activepieces/pieces-common';
import { OAuth2PropertyValue } from '@activepieces/pieces-framework';
export interface WebhookInformation {
id: string;
target: string;
type: string;
address: string;
created_at: string;
created_by: string;
triggers: string[];
}
export const common = {
baseUrl: 'https://api.box.com/2.0',
async subscribeWebhook(
auth: OAuth2PropertyValue,
data: {
event: string;
target: {
id: number | string;
type: string;
};
webhookUrl: string;
}
) {
const request: HttpRequest = {
method: HttpMethod.POST,
url: `${common.baseUrl}/webhooks`,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: auth.access_token,
},
body: {
address: data.webhookUrl,
triggers: [data.event],
target: data.target,
},
};
const response = await httpClient.sendRequest<WebhookInformation>(request);
return response.body;
},
async unsubscribeWebhook(auth: OAuth2PropertyValue, webhookId: string) {
const request: HttpRequest = {
method: HttpMethod.DELETE,
url: `${common.baseUrl}/webhooks/${webhookId}`,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: auth.access_token,
},
};
const response = await httpClient.sendRequest(request);
return response;
},
};

View File

@@ -0,0 +1,92 @@
import {
createTrigger,
TriggerStrategy,
Property,
} from '@activepieces/pieces-framework';
import { boxAuth } from '../..';
import { WebhookInformation, common } from '../common';
export const newComment = createTrigger({
auth: boxAuth,
name: 'new_comment',
displayName: 'New Comment',
description: 'Triggers when a comment is created',
type: TriggerStrategy.WEBHOOK,
props: {
id: Property.ShortText({
displayName: 'File/Folder ID',
description: 'The ID of the item to trigger a webhook',
required: true,
}),
type: Property.StaticDropdown({
displayName: 'Item Type',
description: 'The type of the item to trigger a webhook',
required: true,
options: {
options: [
{ label: 'File', value: 'file' },
{ label: 'Folder', value: 'folder' },
],
},
}),
},
async onEnable(context) {
const target: any = {
id: context.propsValue.id,
type: context.propsValue.type,
};
const webhook = await common.subscribeWebhook(context.auth, {
event: 'COMMENT.CREATED',
target: target,
webhookUrl: context.webhookUrl,
});
await context.store.put(`_new_comment_trigger`, webhook);
},
async onDisable(context) {
const webhook = await context.store.get<WebhookInformation>(
`_new_comment_trigger`
);
if (webhook) {
await common.unsubscribeWebhook(context.auth, webhook.id);
}
},
async run(context) {
return [context.payload.body];
},
sampleData: {
type: 'webhook_event',
id: '9a30442d-f681-4d25-8815-aa46f0515387',
created_at: '2023-04-19T13:25:07-07:00',
trigger: 'COMMENT.CREATED',
webhook: { id: '1396363668', type: 'webhook' },
created_by: {
type: 'user',
id: '24316851337',
name: 'Bonobo',
login: 'email@gmail.com',
},
source: {
id: '538146815',
type: 'comment',
is_reply_comment: false,
message: 'Simple times...',
created_by: {
type: 'user',
id: '24316851337',
name: 'Bonobo',
login: 'email@gmail.com',
},
created_at: '2023-04-19T13:25:07-07:00',
item: { id: '1194590019402', type: 'file' },
modified_at: '2023-04-19T13:25:07-07:00',
},
additional_info: [],
},
});

View File

@@ -0,0 +1,116 @@
import {
createTrigger,
TriggerStrategy,
Property,
} from '@activepieces/pieces-framework';
import { boxAuth } from '../..';
import { WebhookInformation, common } from '../common';
export const newFile = createTrigger({
auth: boxAuth,
name: 'new_file',
displayName: 'New File',
description: 'Triggers when a file is uploaded',
type: TriggerStrategy.WEBHOOK,
props: {
folder: Property.ShortText({
displayName: 'Folder ID',
description:
'The ID of the folder in which file uploads will trigger this webhook',
required: true,
}),
},
async onEnable(context) {
const target: any = {
id: context.propsValue.folder,
type: 'folder',
};
const webhook = await common.subscribeWebhook(context.auth, {
event: 'FILE.UPLOADED',
target: target,
webhookUrl: context.webhookUrl,
});
await context.store.put(`_new_file_trigger`, webhook);
},
async onDisable(context) {
const webhook = await context.store.get<WebhookInformation>(
`_new_file_trigger`
);
if (webhook) {
await common.unsubscribeWebhook(context.auth, webhook.id);
}
},
async run(context) {
return [context.payload.body];
},
sampleData: {
type: 'webhook_event',
id: 'fb0bd323-33b9-4f71-9dbc-fbcc3fe109ad',
created_at: '2023-04-19T12:06:52-07:00',
trigger: 'FILE.UPLOADED',
webhook: { id: '1396340122', type: 'webhook' },
created_by: {
type: 'user',
id: '24316851337',
name: 'Bonobo',
login: 'email@gmail.com',
},
source: {
id: '1194585432265',
type: 'file',
file_version: {
type: 'file_version',
id: '1302595111465',
sha1: '63da452d845b91ccb638510d046b902e96275359',
},
sequence_id: '0',
etag: '0',
sha1: '63da452d845b91ccb638510d046b902e96275359',
name: 'ap-logo.svg',
description: '',
size: 877,
path_collection: { total_count: 2, entries: [Array] },
created_at: '2023-04-19T12:06:52-07:00',
modified_at: '2023-04-19T12:06:52-07:00',
trashed_at: null,
purged_at: null,
content_created_at: '2023-02-02T06:54:17-08:00',
content_modified_at: '2023-02-02T06:54:17-08:00',
created_by: {
type: 'user',
id: '24316851337',
name: 'Bonobo',
login: 'email@gmail.com',
},
modified_by: {
type: 'user',
id: '24316851332',
name: 'Bonobo',
login: 'email@gmail.com',
},
owned_by: {
type: 'user',
id: '24316851332',
name: 'Bonobo',
login: 'email@gmail.com',
},
shared_link: null,
parent: {
type: 'folder',
id: '198605434359',
sequence_id: '0',
etag: '0',
name: 'Kinembe',
},
item_status: 'active',
},
additional_info: [],
},
});

View File

@@ -0,0 +1,108 @@
import {
createTrigger,
TriggerStrategy,
Property,
} from '@activepieces/pieces-framework';
import { boxAuth } from '../..';
import { WebhookInformation, common } from '../common';
export const newFolder = createTrigger({
auth: boxAuth,
name: 'new_folder',
displayName: 'New Folder',
description: 'Triggers when a folder is created',
type: TriggerStrategy.WEBHOOK,
props: {
folder: Property.ShortText({
displayName: 'Folder ID',
description:
'The ID of the folder in which file uploads will trigger this webhook',
required: true,
}),
},
async onEnable(context) {
const target: any = {
id: context.propsValue.folder,
type: 'folder',
};
const webhook = await common.subscribeWebhook(context.auth, {
event: 'FOLDER.CREATED',
target: target,
webhookUrl: context.webhookUrl,
});
await context.store.put(`_new_folder_trigger`, webhook);
},
async onDisable(context) {
const webhook = await context.store.get<WebhookInformation>(
`_new_folder_trigger`
);
if (webhook) {
await common.unsubscribeWebhook(context.auth, webhook.id);
}
},
async run(context) {
return [context.payload.body];
},
sampleData: {
id: '3f08aca1-aa0b-49a5-8e5a-5d8980bfbdef',
type: 'webhook_event',
source: {
id: '218634717358',
etag: '0',
name: 'test folder',
size: 0,
type: 'folder',
parent: {
id: '218635125044',
etag: '0',
name: 'Desktop',
type: 'folder',
sequence_id: '0',
},
purged_at: null,
created_at: '2023-07-25T05:55:08-07:00',
trashed_at: null,
description: '',
item_status: 'active',
modified_at: '2023-07-25T05:55:08-07:00',
sequence_id: '0',
shared_link: null,
path_collection: {
entries: [
{
id: '0',
etag: null,
name: 'All Files',
type: 'folder',
sequence_id: null,
},
{
id: '218635125044',
etag: '0',
name: 'Desktop',
type: 'folder',
sequence_id: '0',
},
],
total_count: 2,
},
content_created_at: '2023-07-25T05:55:08-07:00',
content_modified_at: '2023-07-25T05:55:08-07:00',
folder_upload_email: null,
},
trigger: 'FOLDER.CREATED',
webhook: {
id: '1738566186',
type: 'webhook',
},
created_at: '2023-07-25T05:55:09-07:00',
additional_info: [],
},
});

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"]
}