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

View File

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

View File

@@ -0,0 +1,7 @@
{
"name": "@activepieces/piece-google-slides",
"version": "0.0.10",
"dependencies": {
"googleapis": "129.0.0"
}
}

View File

@@ -0,0 +1,65 @@
{
"name": "pieces-google-slides",
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/pieces/community/google-slides/src",
"projectType": "library",
"release": {
"version": {
"currentVersionResolver": "git-tag",
"preserveLocalDependencyProtocols": false,
"manifestRootsToUpdate": [
"dist/{projectRoot}"
]
}
},
"tags": [],
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/packages/pieces/community/google-slides",
"tsConfig": "packages/pieces/community/google-slides/tsconfig.lib.json",
"packageJson": "packages/pieces/community/google-slides/package.json",
"main": "packages/pieces/community/google-slides/src/index.ts",
"assets": [
"packages/pieces/community/google-slides/*.md",
{
"input": "packages/pieces/community/google-slides/src/i18n",
"output": "./src/i18n",
"glob": "**/!(i18n.json)"
}
],
"buildableProjectDepsInPackageJsonType": "dependencies",
"updateBuildableProjectDepsInPackageJson": true
},
"dependsOn": [
"^build",
"prebuild"
]
},
"nx-release-publish": {
"options": {
"packageRoot": "dist/{projectRoot}"
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}"
]
},
"prebuild": {
"executor": "nx:run-commands",
"options": {
"cwd": "packages/pieces/community/google-slides",
"command": "bun install --no-save --silent"
},
"dependsOn": [
"^build"
]
}
}
}

View File

@@ -0,0 +1,35 @@
{
"Get Presentation": "Präsentation erhalten",
"Refresh Sheets Charts": "Tabellen aktualisieren",
"Generate from template": "Aus Vorlage generieren",
"Custom API Call": "Eigener API-Aufruf",
"Get all slides from a presentation": "Alle Folien einer Präsentation abrufen",
"Refresh all Google Sheets charts in the presentation": "Alle Google Sheets Diagramme in der Präsentation aktualisieren",
"Generate a new slide from a template": "Eine neue Folie aus einer Vorlage erstellen",
"Make a custom API call to a specific endpoint": "Einen benutzerdefinierten API-Aufruf an einen bestimmten Endpunkt machen",
"Presentation ID": "Präsentations-ID",
"Template presentation ID": "Template presentation ID",
"Placeholder Format": "Platzhalterformat",
"Table Data": "Tabellendaten",
"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 ID of the presentation": "Die ID der Präsentation",
"The ID of the presentation, between /d and /edit": "Die ID der Präsentation, zwischen /d und /edit",
"The ID of the templated presentation": "Die ID der vorgegebenen Präsentation",
"Choose the format of placeholders in your template": "Wählen Sie das Format der Platzhalter in Ihrer Vorlage",
"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..",
"Curly Braces {{}}": "Geschwommene Klammern {{}}",
"Square Brackets [[]]": "Quadratische Klammern [[]]",
"GET": "ERHALTEN",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "LÖSCHEN",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,35 @@
{
"Get Presentation": "Obtener presentación",
"Refresh Sheets Charts": "Actualizar Gráficos de Hojas",
"Generate from template": "Generar desde plantilla",
"Custom API Call": "Llamada API personalizada",
"Get all slides from a presentation": "Obtener todas las diapositivas de una presentación",
"Refresh all Google Sheets charts in the presentation": "Actualizar todas las partituras de Google Sheets en la presentación",
"Generate a new slide from a template": "Generar una nueva diapositiva a partir de una plantilla",
"Make a custom API call to a specific endpoint": "Hacer una llamada API personalizada a un extremo específico",
"Presentation ID": "ID de presentación",
"Template presentation ID": "Template presentation ID",
"Placeholder Format": "Formato de marcador",
"Table Data": "Datos de tabla",
"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 ID of the presentation": "El ID de la presentación",
"The ID of the presentation, between /d and /edit": "El ID de la presentación, entre /d y /edit",
"The ID of the templated presentation": "El ID de la presentación plantillada",
"Choose the format of placeholders in your template": "Elija el formato de marcadores de posición en su plantilla",
"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.",
"Curly Braces {{}}": "Brazados rizados {{}}",
"Square Brackets [[]]": "Corchetes cuadrados [[]]",
"GET": "RECOGER",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "BORRAR",
"HEAD": "LIMPIO"
}

View File

@@ -0,0 +1,35 @@
{
"Get Presentation": "Obtenir la présentation",
"Refresh Sheets Charts": "Rafraîchir les tableaux des feuilles",
"Generate from template": "Générer à partir du modèle",
"Custom API Call": "Appel API personnalisé",
"Get all slides from a presentation": "Obtenir toutes les diapositives d'une présentation",
"Refresh all Google Sheets charts in the presentation": "Rafraîchir tous les tableaux Google Sheets de la présentation",
"Generate a new slide from a template": "Générer une nouvelle diapositive à partir d'un modèle",
"Make a custom API call to a specific endpoint": "Passez un appel API personnalisé à un point de terminaison spécifique",
"Presentation ID": "ID de présentation",
"Template presentation ID": "Template presentation ID",
"Placeholder Format": "Format des espaces réservés",
"Table Data": "Données du tableau",
"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 ID of the presentation": "L'ID de la présentation",
"The ID of the presentation, between /d and /edit": "L'ID de la présentation, entre /d et /edit",
"The ID of the templated presentation": "L'ID de la présentation du modèle",
"Choose the format of placeholders in your template": "Choisissez le format des espaces réservés dans votre modèle",
"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.",
"Curly Braces {{}}": "Bretelles amplitudes {{}}",
"Square Brackets [[]]": "Crochets [[]]",
"GET": "OBTENIR",
"POST": "POSTER",
"PATCH": "PATCH",
"PUT": "EFFACER",
"DELETE": "SUPPRIMER",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,35 @@
{
"Get Presentation": "プレゼンテーションを取得",
"Refresh Sheets Charts": "シートグラフを更新",
"Generate from template": "テンプレートから生成",
"Custom API Call": "カスタムAPI通話",
"Get all slides from a presentation": "プレゼンテーションからすべてのスライドを取得",
"Refresh all Google Sheets charts in the presentation": "プレゼンテーション内のすべての Google スプレッドシートのグラフを更新",
"Generate a new slide from a template": "テンプレートから新しいスライドを生成する",
"Make a custom API call to a specific endpoint": "特定のエンドポイントへのカスタム API コールを実行します。",
"Presentation ID": "プレゼンテーション ID",
"Template presentation ID": "Template presentation ID",
"Placeholder Format": "プレースホルダフォーマット",
"Table Data": "テーブルデータ",
"Method": "方法",
"Headers": "ヘッダー",
"Query Parameters": "クエリパラメータ",
"Body": "本文",
"Response is Binary ?": "応答はバイナリですか?",
"No Error on Failure": "失敗時にエラーはありません",
"Timeout (in seconds)": "タイムアウト(秒)",
"The ID of the presentation": "プレゼンテーションの ID",
"The ID of the presentation, between /d and /edit": "/d から /edit の間のプレゼンテーションの ID",
"The ID of the templated presentation": "テンプレート付きプレゼンテーションのID",
"Choose the format of placeholders in your template": "テンプレートのプレースホルダの形式を選択してください",
"Authorization headers are injected automatically from your connection.": "認証ヘッダは接続から自動的に注入されます。",
"Enable for files like PDFs, images, etc..": "PDF、画像などのファイルを有効にします。",
"Curly Braces {{}}": "Curly Braces {{}}",
"Square Brackets [[]]": "平方ブラケット[[]]",
"GET": "取得",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "削除",
"HEAD": "頭"
}

View File

@@ -0,0 +1,35 @@
{
"Get Presentation": "Ontvang Presentatie",
"Refresh Sheets Charts": "Ververs platen Grafieken",
"Generate from template": "Genereer van template",
"Custom API Call": "Custom API Call",
"Get all slides from a presentation": "Krijg alle dia's van een presentatie",
"Refresh all Google Sheets charts in the presentation": "Vernieuw alle Google Sheets grafieken in de presentatie",
"Generate a new slide from a template": "Een nieuwe slide van een sjabloon genereren",
"Make a custom API call to a specific endpoint": "Maak een aangepaste API call naar een specifiek eindpunt",
"Presentation ID": "Presentatie ID",
"Template presentation ID": "Template presentation ID",
"Placeholder Format": "Placeholder formaat",
"Table Data": "Tabel gegevens",
"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 ID of the presentation": "Het ID van de presentatie",
"The ID of the presentation, between /d and /edit": "Het ID van de presentatie, tussen /d en /edit",
"The ID of the templated presentation": "De ID van de getemplated presentatie",
"Choose the format of placeholders in your template": "Kies het formaat van tijdelijke aanduidingen in je template",
"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..",
"Curly Braces {{}}": "Krullende races {{}}",
"Square Brackets [[]]": "Haakjes [[]]",
"GET": "KRIJG",
"POST": "POSTE",
"PATCH": "BEKIJK",
"PUT": "PUT",
"DELETE": "VERWIJDEREN",
"HEAD": "HOOFD"
}

View File

@@ -0,0 +1,35 @@
{
"Get Presentation": "Obter apresentação",
"Refresh Sheets Charts": "Atualizar gráficos das Chapas",
"Generate from template": "Gerar a partir do modelo",
"Custom API Call": "Chamada de API personalizada",
"Get all slides from a presentation": "Obter todos os slides de uma apresentação",
"Refresh all Google Sheets charts in the presentation": "Atualizar todos os gráficos do Google na apresentação",
"Generate a new slide from a template": "Gerar um novo slide a partir de um modelo",
"Make a custom API call to a specific endpoint": "Faça uma chamada de API personalizada para um ponto de extremidade específico",
"Presentation ID": "ID de apresentação",
"Template presentation ID": "Template presentation ID",
"Placeholder Format": "Formato do Marcador",
"Table Data": "Dados da tabela",
"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 ID of the presentation": "O ID da apresentação",
"The ID of the presentation, between /d and /edit": "O ID da apresentação, entre /d e /edit",
"The ID of the templated presentation": "A ID da apresentação modelo",
"Choose the format of placeholders in your template": "Escolha o formato dos espaços reservados no seu modelo",
"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..",
"Curly Braces {{}}": "Chaves Curly {{}}",
"Square Brackets [[]]": "Braçadeiras quadradas [[]]",
"GET": "OBTER",
"POST": "POSTAR",
"PATCH": "COMPRAR",
"PUT": "COLOCAR",
"DELETE": "EXCLUIR",
"HEAD": "CABEÇA"
}

View File

@@ -0,0 +1,34 @@
{
"Google Slides": "Google слайды",
"Get Presentation": "Получить презентацию",
"Refresh Sheets Charts": "Обновить диаграммы листов",
"Generate from template": "Сгенерировать из шаблона",
"Custom API Call": "Пользовательский вызов API",
"Get all slides from a presentation": "Получить все слайды из презентации",
"Refresh all Google Sheets charts in the presentation": "Обновить все графики Google Sheets в презентации",
"Generate a new slide from a template": "Создать новый слайд из шаблона",
"Make a custom API call to a specific endpoint": "Сделать пользовательский API вызов к определенной конечной точке",
"Presentation ID": "ID презентации",
"Template presentation ID": "Template presentation ID",
"Placeholder Format": "Формат заполнителя",
"Table Data": "Данные таблицы",
"Method": "Метод",
"Headers": "Заголовки",
"Query Parameters": "Параметры запроса",
"Body": "Тело",
"No Error on Failure": "Нет ошибок при ошибке",
"Timeout (in seconds)": "Таймаут (в секундах)",
"The ID of the presentation": "ID презентации",
"The ID of the presentation, between /d and /edit": "Идентификатор презентации между /d и /edit",
"The ID of the templated presentation": "ID шаблона презентации",
"Choose the format of placeholders in your template": "Выберите формат заполнителей в вашем шаблоне",
"Authorization headers are injected automatically from your connection.": "Заголовки авторизации включаются автоматически из вашего соединения.",
"Curly Braces {{}}": "Изогнутые Наручи {{}}",
"Square Brackets [[]]": "Квадратные скобки [[]]",
"GET": "ПОЛУЧИТЬ",
"POST": "ПОСТ",
"PATCH": "ПАТЧ",
"PUT": "ПОКУПИТЬ",
"DELETE": "УДАЛИТЬ",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,35 @@
{
"Get Presentation": "Get Presentation",
"Refresh Sheets Charts": "Refresh Sheets Charts",
"Generate from template": "Generate from template",
"Custom API Call": "Custom API Call",
"Get all slides from a presentation": "Get all slides from a presentation",
"Refresh all Google Sheets charts in the presentation": "Refresh all Google Sheets charts in the presentation",
"Generate a new slide from a template": "Generate a new slide from a template",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Presentation ID": "Presentation ID",
"Template presentation ID": "Template presentation ID",
"Placeholder Format": "Placeholder Format",
"Table Data": "Table Data",
"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 ID of the presentation": "The ID of the presentation",
"The ID of the presentation, between /d and /edit": "The ID of the presentation, between /d and /edit",
"The ID of the templated presentation": "The ID of the templated presentation",
"Choose the format of placeholders in your template": "Choose the format of placeholders in your template",
"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..",
"Curly Braces {{}}": "Curly Braces {{}}",
"Square Brackets [[]]": "Square Brackets [[]]",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,34 @@
{
"Google Slides": "Google Slides",
"Get Presentation": "Get Presentation",
"Refresh Sheets Charts": "Refresh Sheets Charts",
"Generate from template": "Generate from template",
"Custom API Call": "Custom API Call",
"Get all slides from a presentation": "Get all slides from a presentation",
"Refresh all Google Sheets charts in the presentation": "Refresh all Google Sheets charts in the presentation",
"Generate a new slide from a template": "Generate a new slide from a template",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Presentation ID": "Presentation ID",
"Template presentation ID": "Template presentation ID",
"Placeholder Format": "Placeholder Format",
"Table Data": "Table Data",
"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 ID of the presentation": "The ID of the presentation",
"The ID of the presentation, between /d and /edit": "The ID of the presentation, between /d and /edit",
"The ID of the templated presentation": "The ID of the templated presentation",
"Choose the format of placeholders in your template": "Choose the format of placeholders in your template",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"Curly Braces {{}}": "Curly Braces {{}}",
"Square Brackets [[]]": "Square Brackets [[]]",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,35 @@
{
"Get Presentation": "Get Presentation",
"Refresh Sheets Charts": "Refresh Sheets Charts",
"Generate from template": "Generate from template",
"Custom API Call": "自定义 API 呼叫",
"Get all slides from a presentation": "Get all slides from a presentation",
"Refresh all Google Sheets charts in the presentation": "Refresh all Google Sheets charts in the presentation",
"Generate a new slide from a template": "Generate a new slide from a template",
"Make a custom API call to a specific endpoint": "将一个自定义 API 调用到一个特定的终点",
"Presentation ID": "Presentation ID",
"Template presentation ID": "Template presentation ID",
"Placeholder Format": "Placeholder Format",
"Table Data": "Table Data",
"Method": "方法",
"Headers": "信头",
"Query Parameters": "查询参数",
"Body": "正文内容",
"Response is Binary ?": "Response is Binary ?",
"No Error on Failure": "失败时没有错误",
"Timeout (in seconds)": "超时(秒)",
"The ID of the presentation": "The ID of the presentation",
"The ID of the presentation, between /d and /edit": "The ID of the presentation, between /d and /edit",
"The ID of the templated presentation": "The ID of the templated presentation",
"Choose the format of placeholders in your template": "Choose the format of placeholders in your template",
"Authorization headers are injected automatically from your connection.": "授权头自动从您的连接中注入。",
"Enable for files like PDFs, images, etc..": "Enable for files like PDFs, images, etc..",
"Curly Braces {{}}": "Curly Braces {{}}",
"Square Brackets [[]]": "Square Brackets [[]]",
"GET": "获取",
"POST": "帖子",
"PATCH": "PATCH",
"PUT": "弹出",
"DELETE": "删除",
"HEAD": "黑色"
}

View File

@@ -0,0 +1,39 @@
import { createPiece, PieceAuth, OAuth2PropertyValue } from "@activepieces/pieces-framework";
import { createCustomApiCallAction } from '@activepieces/pieces-common';
import { refreshSheetsCharts } from "./lib/actions/refresh-charts";
import { generateFromTemplate } from "./lib/actions/generate-from-template";
import { getPresentation } from "./lib/actions/get-presentation";
export const googleSlidesAuth = PieceAuth.OAuth2({
description: '',
authUrl: 'https://accounts.google.com/o/oauth2/auth',
tokenUrl: 'https://oauth2.googleapis.com/token',
required: true,
scope: [
'https://www.googleapis.com/auth/presentations',
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/spreadsheets',
],
});
export const googleSlide = createPiece({
displayName: "Google Slides",
auth: googleSlidesAuth,
minimumSupportedRelease: '0.36.1',
logoUrl: "https://cdn.activepieces.com/pieces/google-slides.png",
authors: ["Kevinyu-alan"],
actions: [
getPresentation,
refreshSheetsCharts,
generateFromTemplate,
createCustomApiCallAction({
baseUrl: () => 'https://slides.googleapis.com/v1/presentations/',
auth: googleSlidesAuth,
authMapping: async (auth) => ({
Authorization: `Bearer ${(auth).access_token}`,
}),
}),
],
triggers: [],
});

View File

@@ -0,0 +1,164 @@
import { googleSlidesAuth } from '../../index';
import { createAction, DynamicPropsValue, Property } from "@activepieces/pieces-framework";
import { getSlide, PageElement, batchUpdate, TableCell, TextElement } from '../commons/common';
import { google } from 'googleapis';
import { OAuth2Client } from 'googleapis-common';
function extractPlaceholders(content: string, fields: Record<string, any>, placeholder_format: string) {
const regex = placeholder_format === '[[]]'
? /\[\[([^\]]+)\]\]/g
: /\{\{([^}]+)\}\}/g;
const matches = content.match(regex);
if (matches) {
matches.forEach((match: string) => {
const matchValue = placeholder_format === '[[]]'
? match.replace(/[[\]]/g, '')
: match.replace(/[{}]/g, '');
const varName = matchValue.trim();
fields[matchValue] = Property.ShortText({
displayName: varName.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase()),
description: `Value for "${placeholder_format === '[[]]' ? `[[${varName}]]` : `{{${varName}}}`}"`,
required: false,
});
});
}
}
export const generateFromTemplate = createAction({
name: 'generate_from_template',
displayName: 'Generate from template',
description: 'Generate a new slide from a template',
auth: googleSlidesAuth,
props: {
template_presentation_id: Property.ShortText({
displayName: 'Template presentation ID',
description: 'The ID of the templated presentation',
required: true,
}),
placeholder_format: Property.StaticDropdown({
displayName: 'Placeholder Format',
description: 'Choose the format of placeholders in your template',
required: true,
defaultValue: '{{}}',
options: {
disabled: false,
options: [
{ label: 'Curly Braces {{}}', value: '{{}}' },
{ label: 'Square Brackets [[]]', value: '[[]]' }
],
},
}),
table_data: Property.DynamicProperties({
auth: googleSlidesAuth,
displayName: 'Table Data',
required: true,
refreshers: ['template_presentation_id', 'placeholder_format'],
props: async ({auth, template_presentation_id, placeholder_format}) => {
if (!template_presentation_id || !auth)
return {};
const presentation = await getSlide(auth["access_token"] as unknown as string, template_presentation_id as unknown as string);
if (!presentation)
return {}
const fields = {
title: Property.ShortText({
displayName: 'Presentation Title',
description: 'Title of the new presentation',
defaultValue: `Copy of: ${presentation.title}`,
required: true,
})
} as DynamicPropsValue;
presentation.slides?.forEach(slide => {
slide.pageElements?.forEach((element: PageElement) => {
if (element.shape?.text?.textElements) {
element.shape.text.textElements.forEach(textElement => {
const content = textElement?.textRun?.content;
if (content) {
extractPlaceholders(content, fields, placeholder_format as unknown as string);
}
});
}
if (element.table) {
element.table.tableRows?.forEach(row => {
row.tableCells?.forEach((cell: TableCell) => {
if (cell.text?.textElements) {
cell.text.textElements.forEach((textElement: TextElement) => {
const content = textElement?.textRun?.content;
if (content) {
extractPlaceholders(content, fields, placeholder_format as unknown as string);
}
});
}
});
});
}
});
});
return fields;
}
})
},
async run(context) {
const { access_token } = context.auth;
const { template_presentation_id, placeholder_format, table_data } = context.propsValue;
try {
const authClient = new OAuth2Client();
authClient.setCredentials(context.auth);
const drive = google.drive({ version: 'v3', auth: authClient });
const copyResponse = await drive.files.copy({
fileId: template_presentation_id as string,
requestBody: {
name: table_data["title"] || "New Presentation"
},
supportsAllDrives: true
});
const newPresentationId = copyResponse.data.id;
if (!newPresentationId)
return
const requests = Object.entries(table_data)
.map(([key, value]): { replaceAllText: unknown } => {
const placeholder = placeholder_format === '[[]]'
? `[[${key}]]`
: `{{${key}}}`;
return {
replaceAllText: {
containsText: {
text: placeholder,
matchCase: true
},
replaceText: value as string
}
};
});
if (requests.length > 0) {
await batchUpdate(
access_token,
newPresentationId,
requests
);
}
return {
presentationId: newPresentationId,
presentationUrl: `https://docs.google.com/presentation/d/${newPresentationId}/edit`
};
} catch (error) {
console.error('Error creating presentation:', error);
throw error;
}
}
});

View File

@@ -0,0 +1,22 @@
import { googleSlidesAuth } from '../../index';
import { createAction, Property } from "@activepieces/pieces-framework";
import { getSlide } from "../commons/common";
export const getPresentation = createAction({
name: 'get_presentation',
displayName: 'Get Presentation',
description: 'Get all slides from a presentation',
auth: googleSlidesAuth,
props: {
presentation_id: Property.ShortText({
displayName: 'Presentation ID',
description: 'The ID of the presentation',
required: true,
})
},
async run(context) {
const { presentation_id } = context.propsValue;
const { access_token } = context.auth;
return await getSlide(access_token, presentation_id);
},
});

View File

@@ -0,0 +1,51 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { batchUpdate, getSlide, PageElement } from '../commons/common';
import { googleSlidesAuth } from '../..';
export const refreshSheetsCharts = createAction({
name: 'refresh_sheets_charts',
displayName: 'Refresh Sheets Charts',
description: 'Refresh all Google Sheets charts in the presentation',
auth: googleSlidesAuth,
props: {
presentation_id: Property.ShortText({
displayName: 'Presentation ID',
description: 'The ID of the presentation, between /d and /edit',
required: true,
}),
},
async run(context) {
const { presentation_id } = context.propsValue;
const { access_token } = context.auth;
const presentation = await getSlide(access_token, presentation_id);
const requests: { refreshSheetsChart: { objectId: string; }; }[] = [];
presentation.slides?.forEach((slide) => {
slide.pageElements?.forEach((element: PageElement) => {
if (element.sheetsChart) {
const refreshRequest = {
refreshSheetsChart: {
objectId: element.objectId
}
};
requests.push(refreshRequest);
}
});
});
if (requests.length > 0) {
const result = await batchUpdate(access_token, presentation_id, requests);
return {
success: true,
message: `Successfully refreshed ${requests.length} Google Sheets charts`,
result: result
};
} else {
return {
success: false,
message: 'No Google Sheets charts found in the presentation'
};
}
}
});

View File

@@ -0,0 +1,113 @@
import { AuthenticationType, httpClient, HttpMethod } from "@activepieces/pieces-common";
export interface PageElement {
objectId: string;
table?: Table
sheetsChart?: {
spreadsheetId: string;
chartId: number;
};
shape?: Shape
}
interface Presentation {
slides?: Slide[];
}
interface Slide {
pageElements?: PageElement[];
}
interface Shape {
text?: Text;
}
interface Text {
textElements?: TextElement[];
}
export interface TextElement {
textRun?: TextRun;
}
interface TextRun {
content?: string;
}
interface Table {
tableRows?: TableRow[];
}
interface TableRow {
tableCells?: TableCell[];
}
export interface TableCell {
text?: Text;
}
export const googleSheetsCommon = {
baseUrl: 'https://slides.googleapis.com/v1/presentations/',
batchUpdate,
getSlide,
createSlide
};
export async function batchUpdate(access_token: string, slide_id: string, requests: any) {
return (
await httpClient.sendRequest<{
spreadsheetId: string;
}>({
method: HttpMethod.POST,
url: `https://slides.googleapis.com/v1/presentations/${slide_id}:batchUpdate`,
body: {
requests: requests
},
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: access_token,
},
})
).body;
}
export async function getSlide(access_token: string, slide_id: string) {
return (
await httpClient.sendRequest<{
presentationId: string;
title: string;
slides: {
pageElements: any; objectId: object;
}[];
}>({
method: HttpMethod.GET,
url: `https://slides.googleapis.com/v1/presentations/${slide_id}`,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: access_token,
},
})
).body;
}
export async function createSlide(access_token: string, requests: any) {
return (
await httpClient.sendRequest<{
presentationId: string;
title: string;
spreadsheetId: string;
replies: any[];
}>({
method: HttpMethod.POST,
url: `https://slides.googleapis.com/v1/presentations`,
body: {
requests: requests
},
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: access_token,
},
})
).body;
}

View File

@@ -0,0 +1,19 @@
{
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noPropertyAccessFromIndexSignature": 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"]
}